/** * Creates a new version of the specified icon that is rendered in the * colors of the specified color scheme. * * @param comp * Component. * @param original * The original icon. * @param colorScheme * Color scheme. * @return Scheme-based version of the original icon. */ public static BufferedImage getColorSchemeImage(Component comp, Icon original, SubstanceColorScheme colorScheme, float originalBrightnessFactor) { int w = original.getIconWidth(); int h = original.getIconHeight(); BufferedImage origImage = SubstanceCoreUtilities.getBlankImage(w, h); original.paintIcon(comp, origImage.getGraphics(), 0, 0); return getColorSchemeImage(origImage, colorScheme, originalBrightnessFactor); }
/** * Creates a new version of the specified icon that is rendered in the * colors of the specified color scheme. * * @param comp * Component. * @param original * The original icon. * @param colorScheme * Color scheme. * @return Scheme-based version of the original icon. */ public static BufferedImage getColorSchemeImage(Component comp, Icon original, SubstanceColorScheme colorScheme, float originalBrightnessFactor) { int w = original.getIconWidth(); int h = original.getIconHeight(); BufferedImage origImage = SubstanceCoreUtilities.getBlankImage(w, h); original.paintIcon(comp, origImage.getGraphics(), 0, 0); return getColorSchemeImage(origImage, colorScheme, originalBrightnessFactor); }
/** * Returns an icon that matches the specified watermark. * * @param watermark * Watermark instance. * @return Icon that matches the specified watermark. */ public static Icon getWatermarkIcon(SubstanceWatermark watermark) { int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(iSize, iSize); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); watermark .previewWatermark(graphics, SubstanceColorSchemeUtilities.METALLIC_SKIN, 0, 0, iSize, iSize); graphics.dispose(); return new ImageIcon(result); }
/** * Returns an icon that matches the specified watermark. * * @param watermark * Watermark instance. * @return Icon that matches the specified watermark. */ public static Icon getWatermarkIcon(SubstanceWatermark watermark) { int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(iSize, iSize); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); watermark .previewWatermark(graphics, SubstanceColorSchemeUtilities.METALLIC_SKIN, 0, 0, iSize, iSize); graphics.dispose(); return new ImageIcon(result); }
private static BufferedImage createHighlighterImage(Component c, Rectangle rect, float borderAlpha, Set<Side> openSides, SubstanceColorScheme currScheme, SubstanceColorScheme currBorderScheme, SubstanceHighlightPainter highlightPainter, SubstanceBorderPainter highlightBorderPainter) { BufferedImage result = SubstanceCoreUtilities.getBlankImage(rect.width, rect.height); Graphics2D resGraphics = result.createGraphics(); highlightPainter.paintHighlight(resGraphics, c, rect.width, rect.height, currScheme); paintHighlightBorder(resGraphics, c, rect.width, rect.height, borderAlpha, openSides, highlightBorderPainter, currBorderScheme); resGraphics.dispose(); return result; }
private static BufferedImage createHighlighterImage(Component c, Rectangle rect, float borderAlpha, Set<Side> openSides, SubstanceColorScheme currScheme, SubstanceColorScheme currBorderScheme, SubstanceHighlightPainter highlightPainter, SubstanceBorderPainter highlightBorderPainter) { BufferedImage result = SubstanceCoreUtilities.getBlankImage(rect.width, rect.height); Graphics2D resGraphics = result.createGraphics(); highlightPainter.paintHighlight(resGraphics, c, rect.width, rect.height, currScheme); paintHighlightBorder(resGraphics, c, rect.width, rect.height, borderAlpha, openSides, highlightBorderPainter, currBorderScheme); resGraphics.dispose(); return result; }
/** * Translated the specified icon to grey scale. * * @param icon * Icon. * @return Greyscale version of the specified icon. */ public static Icon toGreyscale(Icon icon) { if (icon == null) { return null; } int width = icon.getIconWidth(); int height = icon.getIconHeight(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); icon.paintIcon(null, result.getGraphics(), 0, 0); return new ImageIcon(new GrayscaleFilter().filter(result, null)); }
/** * Translated the specified icon to grey scale. * * @param icon * Icon. * @return Greyscale version of the specified icon. */ public static Icon toGreyscale(Icon icon) { if (icon == null) { return null; } int width = icon.getIconWidth(); int height = icon.getIconHeight(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); icon.paintIcon(null, result.getGraphics(), 0, 0); return new ImageIcon(new GrayscaleFilter().filter(result, null)); }
/** * Makes the specified icon transparent. * * @param c * Component. * @param icon * Icon. * @param alpha * The alpha of the resulting image. The closer this value is to * 0.0, the more transparent resulting image will be. * @return Transparent version of the specified icon. */ public static Icon makeTransparent(Component c, Icon icon, double alpha) { if (icon == null) { return null; } int width = icon.getIconWidth(); int height = icon.getIconHeight(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); icon.paintIcon(c, result.getGraphics(), 0, 0); return new ImageIcon(new TranslucentFilter(alpha).filter(result, null)); }
public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; SubstanceCrosshatchWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) SubstanceCrosshatchWatermark.watermarkImage .getGraphics().create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; }
@Override public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; SubstanceCrosshatchWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) SubstanceCrosshatchWatermark.watermarkImage .getGraphics().create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; }
@Override public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; TextureWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) TextureWatermark.watermarkImage .getGraphics().create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; }
@Override public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; SubstanceStripeWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) SubstanceStripeWatermark.watermarkImage .getGraphics().create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; }
public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; SubstanceStripeWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) SubstanceStripeWatermark.watermarkImage .getGraphics().create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; }
@Override public Icon getDisabledIcon(JComponent component, Icon icon) { if (icon == null) return null; SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(component, ComponentState.DISABLED_UNSELECTED); BufferedImage result = SubstanceImageCreator.getColorSchemeImage( component, icon, colorScheme, 0.5f); float alpha = SubstanceColorSchemeUtilities.getAlpha(component, ComponentState.DISABLED_UNSELECTED); if (alpha < 1.0f) { BufferedImage intermediate = SubstanceCoreUtilities.getBlankImage( result.getWidth(), result.getHeight()); Graphics2D g2d = intermediate.createGraphics(); g2d.setComposite(AlphaComposite.SrcOver.derive(alpha)); g2d.drawImage(result, 0, 0, null); g2d.dispose(); result = intermediate; } return new IconUIResource(new ImageIcon(result)); } }
@Override public Icon getDisabledIcon(JComponent component, Icon icon) { if (icon == null) return null; SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(component, ComponentState.DISABLED_UNSELECTED); BufferedImage result = SubstanceImageCreator.getColorSchemeImage( component, icon, colorScheme, 0.5f); float alpha = SubstanceColorSchemeUtilities.getAlpha(component, ComponentState.DISABLED_UNSELECTED); if (alpha < 1.0f) { BufferedImage intermediate = SubstanceCoreUtilities.getBlankImage( result.getWidth(), result.getHeight()); Graphics2D g2d = intermediate.createGraphics(); g2d.setComposite(AlphaComposite.SrcOver.derive(alpha)); g2d.drawImage(result, 0, 0, null); g2d.dispose(); result = intermediate; } return new IconUIResource(new ImageIcon(result)); } }
@Override public Icon getIcon(File f) { Icon icon = getCachedIcon(f); if (icon != null) return icon; icon = getDefaultIcon(f); // System.out.println("System : " + f.getAbsolutePath() + " --> " // + icon); if (icon == null) { icon = super.getIcon(f); if (icon == null) { icon = new ImageIcon(SubstanceCoreUtilities.getBlankImage( 8, 8)); } // System.out.println("Super : " + f.getAbsolutePath() + " --> " // + icon); } cacheIcon(f, icon); return icon; }
@Override public Icon getIcon(File f) { Icon icon = getCachedIcon(f); if (icon != null) return icon; icon = getDefaultIcon(f); // System.out.println("System : " + f.getAbsolutePath() + " --> " // + icon); if (icon == null) { icon = super.getIcon(f); if (icon == null) { icon = new ImageIcon(SubstanceCoreUtilities.getBlankImage( 8, 8)); } // System.out.println("Super : " + f.getAbsolutePath() + " --> " // + icon); } cacheIcon(f, icon); return icon; }
public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { SubstanceColorScheme scheme = skin .getBackgroundColorScheme(decorationAreaType); if (width * height < 100000) { HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, scheme.getDisplayName()); BufferedImage result = smallImageCache.get(key); if (result == null) { result = SubstanceCoreUtilities.getBlankImage(width, height); this.internalPaint((Graphics2D) result.getGraphics(), comp, width, height, scheme); smallImageCache.put(key, result); } graphics.drawImage(result, 0, 0, null); return; } this.internalPaint(graphics, comp, width, height, scheme); }
@Override public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { SubstanceColorScheme scheme = skin .getBackgroundColorScheme(decorationAreaType); if (width * height < 100000) { HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, scheme.getDisplayName()); BufferedImage result = smallImageCache.get(key); if (result == null) { result = SubstanceCoreUtilities.getBlankImage(width, height); this.internalPaint((Graphics2D) result.getGraphics(), comp, width, height, scheme); smallImageCache.put(key, result); } graphics.drawImage(result, 0, 0, null); return; } this.internalPaint(graphics, comp, width, height, scheme); }