79 * setting the sun.java2d.renderer.trace property to any non-null value. 80 * <p> 81 * Parts of the system that need to use any of the above features should 82 * call {@code RenderingEngine.getInstance()} to obtain the properly 83 * registered (and possibly trace-enabled) version of the RenderingEngine. 84 */ 85 public abstract class RenderingEngine { 86 private static RenderingEngine reImpl; 87 88 /** 89 * Returns an instance of {@code RenderingEngine} as determined 90 * by the installation environment and runtime flags. 91 * <p> 92 * A specific instance of the {@code RenderingEngine} can be 93 * chosen by specifying the runtime flag: 94 * <pre> 95 * java -Dsun.java2d.renderer=<classname> 96 * </pre> 97 * 98 * If no specific {@code RenderingEngine} is specified on the command 99 * or Ductus renderer is specified, it will first attempt loading the 100 * sun.dc.DuctusRenderingEngine class using Class.forName, if that 101 * is not found, then it will look for Pisces. 102 * <p> 103 * Runtime tracing of the actions of the {@code RenderingEngine} 104 * can be enabled by specifying the runtime flag: 105 * <pre> 106 * java -Dsun.java2d.renderer.trace=<any string> 107 * </pre> 108 * @return an instance of {@code RenderingEngine} 109 * @since 1.7 110 */ 111 public static synchronized RenderingEngine getInstance() { 112 if (reImpl != null) { 113 return reImpl; 114 } 115 116 /* Look first for ductus or an app-override renderer, 117 * if not specified or present, then look for pisces. 118 */ 119 final String ductusREClass = "sun.dc.DuctusRenderingEngine"; 120 final String piscesREClass = "sun.java2d.pisces.PiscesRenderingEngine"; 121 GetPropertyAction gpa = 122 new GetPropertyAction("sun.java2d.renderer", ductusREClass); 123 String reClass = AccessController.doPrivileged(gpa); 124 try { 125 Class<?> cls = Class.forName(reClass); 126 reImpl = (RenderingEngine) cls.newInstance(); 127 } catch (ReflectiveOperationException ignored0) { 128 try { 129 Class<?> cls = Class.forName(piscesREClass); 130 reImpl = (RenderingEngine) cls.newInstance(); 131 } catch (ReflectiveOperationException ignored1) { 132 } 133 } 134 135 if (reImpl == null) { 136 throw new InternalError("No RenderingEngine module found"); 137 } 138 139 gpa = new GetPropertyAction("sun.java2d.renderer.trace"); 140 String reTrace = AccessController.doPrivileged(gpa); 141 if (reTrace != null) { 142 reImpl = new Tracer(reImpl); 143 } 144 145 return reImpl; 146 } 147 148 /** 149 * Create a widened path as specified by the parameters. 150 * <p> 151 * The specified {@code src} {@link Shape} is widened according 152 * to the specified attribute parameters as per the 153 * {@link BasicStroke} specification. 154 * 155 * @param src the source path to be widened 156 * @param width the width of the widened path as per {@code BasicStroke} 157 * @param caps the end cap decorations as per {@code BasicStroke} 158 * @param join the segment join decorations as per {@code BasicStroke} | 79 * setting the sun.java2d.renderer.trace property to any non-null value. 80 * <p> 81 * Parts of the system that need to use any of the above features should 82 * call {@code RenderingEngine.getInstance()} to obtain the properly 83 * registered (and possibly trace-enabled) version of the RenderingEngine. 84 */ 85 public abstract class RenderingEngine { 86 private static RenderingEngine reImpl; 87 88 /** 89 * Returns an instance of {@code RenderingEngine} as determined 90 * by the installation environment and runtime flags. 91 * <p> 92 * A specific instance of the {@code RenderingEngine} can be 93 * chosen by specifying the runtime flag: 94 * <pre> 95 * java -Dsun.java2d.renderer=<classname> 96 * </pre> 97 * 98 * If no specific {@code RenderingEngine} is specified on the command 99 * line or the requested class fails to load, then the Marlin 100 * renderer will be used as the default. 101 * <p> 102 * A printout of which RenderingEngine is loaded and used can be 103 * enabled by specifying the runtime flag: 104 * <pre> 105 * java -Dsun.java2d.renderer.verbose=true 106 * </pre> 107 * <p> 108 * Runtime tracing of the actions of the {@code RenderingEngine} 109 * can be enabled by specifying the runtime flag: 110 * <pre> 111 * java -Dsun.java2d.renderer.trace=<any string> 112 * </pre> 113 * @return an instance of {@code RenderingEngine} 114 * @since 1.7 115 */ 116 public static synchronized RenderingEngine getInstance() { 117 if (reImpl != null) { 118 return reImpl; 119 } 120 121 /* Look first for an app-override renderer, 122 * if not specified or present, then look for marlin. 123 */ 124 GetPropertyAction gpa = 125 new GetPropertyAction("sun.java2d.renderer"); 126 String reClass = AccessController.doPrivileged(gpa); 127 if (reClass != null) { 128 try { 129 Class<?> cls = Class.forName(reClass); 130 reImpl = (RenderingEngine) cls.newInstance(); 131 } catch (ReflectiveOperationException ignored0) { 132 } 133 } 134 if (reImpl == null) { 135 final String marlinREClass = "sun.java2d.marlin.MarlinRenderingEngine"; 136 try { 137 Class<?> cls = Class.forName(marlinREClass); 138 reImpl = (RenderingEngine) cls.newInstance(); 139 } catch (ReflectiveOperationException ignored1) { 140 } 141 } 142 143 if (reImpl == null) { 144 throw new InternalError("No RenderingEngine module found"); 145 } 146 147 gpa = new GetPropertyAction("sun.java2d.renderer.verbose"); 148 String verbose = AccessController.doPrivileged(gpa); 149 if (verbose != null && verbose.startsWith("t")) { 150 System.out.println("RenderingEngine = "+reImpl); 151 } 152 153 gpa = new GetPropertyAction("sun.java2d.renderer.trace"); 154 String reTrace = AccessController.doPrivileged(gpa); 155 if (reTrace != null) { 156 reImpl = new Tracer(reImpl); 157 } 158 159 return reImpl; 160 } 161 162 /** 163 * Create a widened path as specified by the parameters. 164 * <p> 165 * The specified {@code src} {@link Shape} is widened according 166 * to the specified attribute parameters as per the 167 * {@link BasicStroke} specification. 168 * 169 * @param src the source path to be widened 170 * @param width the width of the widened path as per {@code BasicStroke} 171 * @param caps the end cap decorations as per {@code BasicStroke} 172 * @param join the segment join decorations as per {@code BasicStroke} |