src/macosx/classes/com/apple/laf/AquaIcon.java

Print this page




 177             }
 178 
 179             g.dispose();
 180         }
 181 
 182         public int getIconWidth() {
 183             return width;
 184         }
 185 
 186         public int getIconHeight() {
 187             return height;
 188         }
 189 
 190     }
 191 
 192     static abstract class CachableJRSUIIcon extends CachingScalingIcon implements UIResource {
 193         public CachableJRSUIIcon(final int width, final int height) {
 194             super(width, height);
 195         }
 196 





















 197         Image createImage() {
 198             final AquaPainter<JRSUIState> painter = AquaPainter.create(JRSUIState.getInstance());
 199             initIconPainter(painter);
 200 
 201             final BufferedImage img = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
 202             final Graphics g = img.getGraphics();
 203             g.setClip(new Rectangle(0, 0, getIconWidth(), getIconHeight()));
 204             painter.paint(g, null, 0, 0, getIconWidth(), getIconHeight());
 205             g.dispose();
 206             return img;
 207         }
 208 
 209         public abstract void initIconPainter(final AquaPainter<JRSUIState> painter);
 210     }
 211 
 212     static class FileIcon extends CachingScalingIcon {
 213         final File file;
 214 
 215         public FileIcon(final File file, final int width, final int height) {
 216             super(width, height);




 177             }
 178 
 179             g.dispose();
 180         }
 181 
 182         public int getIconWidth() {
 183             return width;
 184         }
 185 
 186         public int getIconHeight() {
 187             return height;
 188         }
 189 
 190     }
 191 
 192     static abstract class CachableJRSUIIcon extends CachingScalingIcon implements UIResource {
 193         public CachableJRSUIIcon(final int width, final int height) {
 194             super(width, height);
 195         }
 196 
 197         // paint the icon directly from the AquaPainter
 198         public void paintIcon(final Component c, Graphics g, final int x, final int y) {
 199             if (GraphicsEnvironment.isHeadless()) {
 200                 return;
 201             }
 202 
 203             g = g.create();
 204 
 205             if (g instanceof Graphics2D) {
 206                 // improves icon rendering quality in Quartz
 207                 ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
 208             }
 209 
 210             final AquaPainter<JRSUIState> painter = AquaPainter.create(JRSUIState.getInstance());
 211             initIconPainter(painter);
 212 
 213             g.setClip(new Rectangle(x, y, getIconWidth(), getIconHeight()));
 214             painter.paint(g, c, x, y, getIconWidth(), getIconHeight());
 215             g.dispose();
 216         }
 217 
 218         Image createImage() {
 219             final AquaPainter<JRSUIState> painter = AquaPainter.create(JRSUIState.getInstance());
 220             initIconPainter(painter);
 221 
 222             final BufferedImage img = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
 223             final Graphics g = img.getGraphics();
 224             g.setClip(new Rectangle(0, 0, getIconWidth(), getIconHeight()));
 225             painter.paint(g, null, 0, 0, getIconWidth(), getIconHeight());
 226             g.dispose();
 227             return img;
 228         }
 229 
 230         public abstract void initIconPainter(final AquaPainter<JRSUIState> painter);
 231     }
 232 
 233     static class FileIcon extends CachingScalingIcon {
 234         final File file;
 235 
 236         public FileIcon(final File file, final int width, final int height) {
 237             super(width, height);