100 * or Ductus renderer is specified, it will attempt loading the 101 * sun.dc.DuctusRenderingEngine class using Class.forName as a fastpath; 102 * if not found, use the ServiceLoader. 103 * If no specific {@code RenderingEngine} is specified on the command 104 * line then the last one returned by enumerating all subclasses of 105 * {@code RenderingEngine} known to the ServiceLoader is used. 106 * <p> 107 * Runtime tracing of the actions of the {@code RenderingEngine} 108 * can be enabled by specifying the runtime flag: 109 * <pre> 110 * java -Dsun.java2d.renderer.trace=<any string> 111 * </pre> 112 * @return an instance of {@code RenderingEngine} 113 * @since 1.7 114 */ 115 public static synchronized RenderingEngine getInstance() { 116 if (reImpl != null) { 117 return reImpl; 118 } 119 120 reImpl = (RenderingEngine) 121 AccessController.doPrivileged(new PrivilegedAction() { 122 public Object run() { 123 final String ductusREClass = "sun.dc.DuctusRenderingEngine"; 124 String reClass = 125 System.getProperty("sun.java2d.renderer", ductusREClass); 126 if (reClass.equals(ductusREClass)) { 127 try { 128 Class cls = Class.forName(ductusREClass); 129 return cls.newInstance(); 130 } catch (ReflectiveOperationException ignored) { 131 // not found 132 } 133 } 134 135 ServiceLoader<RenderingEngine> reLoader = 136 ServiceLoader.loadInstalled(RenderingEngine.class); 137 138 RenderingEngine service = null; 139 140 for (RenderingEngine re : reLoader) { 141 service = re; 142 if (re.getClass().getName().equals(reClass)) { 143 break; 144 } 145 } 146 return service; 147 } 148 }); 149 150 if (reImpl == null) { 151 throw new InternalError("No RenderingEngine module found"); 152 } 153 154 GetPropertyAction gpa = 155 new GetPropertyAction("sun.java2d.renderer.trace"); 156 String reTrace = (String) AccessController.doPrivileged(gpa); 157 if (reTrace != null) { 158 reImpl = new Tracer(reImpl); 159 } 160 161 return reImpl; 162 } 163 164 /** 165 * Create a widened path as specified by the parameters. 166 * <p> 167 * The specified {@code src} {@link Shape} is widened according 168 * to the specified attribute parameters as per the 169 * {@link BasicStroke} specification. 170 * 171 * @param src the source path to be widened 172 * @param width the width of the widened path as per {@code BasicStroke} 173 * @param caps the end cap decorations as per {@code BasicStroke} 174 * @param join the segment join decorations as per {@code BasicStroke} 175 * @param miterlimit the miter limit as per {@code BasicStroke} 176 * @param dashes the dash length array as per {@code BasicStroke} | 100 * or Ductus renderer is specified, it will attempt loading the 101 * sun.dc.DuctusRenderingEngine class using Class.forName as a fastpath; 102 * if not found, use the ServiceLoader. 103 * If no specific {@code RenderingEngine} is specified on the command 104 * line then the last one returned by enumerating all subclasses of 105 * {@code RenderingEngine} known to the ServiceLoader is used. 106 * <p> 107 * Runtime tracing of the actions of the {@code RenderingEngine} 108 * can be enabled by specifying the runtime flag: 109 * <pre> 110 * java -Dsun.java2d.renderer.trace=<any string> 111 * </pre> 112 * @return an instance of {@code RenderingEngine} 113 * @since 1.7 114 */ 115 public static synchronized RenderingEngine getInstance() { 116 if (reImpl != null) { 117 return reImpl; 118 } 119 120 reImpl = 121 AccessController.doPrivileged(new PrivilegedAction<RenderingEngine>() { 122 public RenderingEngine run() { 123 final String ductusREClass = "sun.dc.DuctusRenderingEngine"; 124 String reClass = 125 System.getProperty("sun.java2d.renderer", ductusREClass); 126 if (reClass.equals(ductusREClass)) { 127 try { 128 Class<?> cls = Class.forName(ductusREClass); 129 return (RenderingEngine) cls.newInstance(); 130 } catch (ReflectiveOperationException ignored) { 131 // not found 132 } 133 } 134 135 ServiceLoader<RenderingEngine> reLoader = 136 ServiceLoader.loadInstalled(RenderingEngine.class); 137 138 RenderingEngine service = null; 139 140 for (RenderingEngine re : reLoader) { 141 service = re; 142 if (re.getClass().getName().equals(reClass)) { 143 break; 144 } 145 } 146 return service; 147 } 148 }); 149 150 if (reImpl == null) { 151 throw new InternalError("No RenderingEngine module found"); 152 } 153 154 GetPropertyAction gpa = 155 new GetPropertyAction("sun.java2d.renderer.trace"); 156 String reTrace = AccessController.doPrivileged(gpa); 157 if (reTrace != null) { 158 reImpl = new Tracer(reImpl); 159 } 160 161 return reImpl; 162 } 163 164 /** 165 * Create a widened path as specified by the parameters. 166 * <p> 167 * The specified {@code src} {@link Shape} is widened according 168 * to the specified attribute parameters as per the 169 * {@link BasicStroke} specification. 170 * 171 * @param src the source path to be widened 172 * @param width the width of the widened path as per {@code BasicStroke} 173 * @param caps the end cap decorations as per {@code BasicStroke} 174 * @param join the segment join decorations as per {@code BasicStroke} 175 * @param miterlimit the miter limit as per {@code BasicStroke} 176 * @param dashes the dash length array as per {@code BasicStroke} |