public static ColorFilter getInstance(boolean brighter, int percent) { if (_colorFilter == null) { _colorFilter = new ColorFilter(brighter, percent); } else { _colorFilter.setBrighter(brighter); setPercent(percent); } return _colorFilter; }
/** * Creates a brighter image with a given percentage of brightness * * @param i the original image * @param p percentage of brightness * * @return a brighter image */ public static Image createBrighterImage(Image i, int p) { setPercent(p); return createBrighterImage(i); }
/** * Creates a darker image with a given percentage of darkness * * @param i the original image * @param p percentage of darkness * * @return a darker image. */ public static Image createDarkerImage(Image i, int p) { setPercent(p); return createDarkerImage(i); }
/** * Creates a brighter image from an input image. If input image is null, a blank ImageIcon will be returned. * * @param image image * @return dimmed version of the image */ public static ImageIcon createBrighterImage(Image image) { if (image == null) return EMPTY_ICON; return new ImageIcon(ColorFilter.createBrighterImage(image)); }
paint = new Paint(); paint.setColor(Color.RED); ColorFilter cf = new ColorFilter(); paint.setColorFilter(cf); paint.setStyle(Paint.Style.FILL);
/** * Creates a brighter image * * @param i the original image * * @return a brighter image */ public static Image createBrighterImage(Image i) { ColorFilter filter = ColorFilter.getInstance(true, _percent); ImageProducer prod = new FilteredImageSource(i.getSource(), filter); return Toolkit.getDefaultToolkit().createImage(prod); }
/** * Gets a brighter ImageIcon by passing class and a relative image file path. * * @param clazz the Class<?> * @param fileName relative file name * @return the ImageIcon */ public static ImageIcon getBrighterImageIcon(Class<?> clazz, String fileName) { String id = clazz.getName() + ":" + fileName + ":" + ColorFilter.getPercent(); ImageIcon saved = _brighterIcons.get(id); if (saved != null) return saved; else { ImageIcon icon = createBrighterImage(getImageIcon(clazz, fileName)); _brighterIcons.put(id, icon); return icon; } }
/** * Creates a brighter image from an input image with a given percentage of brightness. If input image is null, a * blank ImageIcon will be returned. * * @param image image * @param percent percentage of brightness * @return dimmed version of the image */ public static ImageIcon createBrighterImage(Image image, int percent) { if (image == null) return EMPTY_ICON; return new ImageIcon(ColorFilter.createBrighterImage(image, percent)); }
/** * Creates a darker image * * @param i the original image * * @return a darker image. */ public static Image createDarkerImage(Image i) { ColorFilter filter = ColorFilter.getInstance(false, _percent); ImageProducer prod = new FilteredImageSource(i.getSource(), filter); return Toolkit.getDefaultToolkit().createImage(prod); }
/** * Creates a brighten version from an input ImageIcon. If input icon is null, a blank ImageIcon will be returned. * * @param icon image * @return dimmed version of the image */ public static ImageIcon createBrighterImage(ImageIcon icon) { if (icon == null) return EMPTY_ICON; return new ImageIcon(ColorFilter.createBrighterImage(icon.getImage())); }
/** * Creates a brighter image from an input image with a given percentage of brightness. If input image is null, a * blank ImageIcon will be returned. * * @param icon image * @param percent percentage of brightness * @return dimmed version of the image */ public static ImageIcon createBrighterImage(ImageIcon icon, int percent) { if (icon == null) return EMPTY_ICON; return new ImageIcon(ColorFilter.createBrighterImage(icon.getImage(), percent)); }
/** * Creates a gray version from an input image. Usually gray icon indicates disabled. If input icon is null, a blank * ImageIcon will be returned. * * @param c The component to get properties useful for painting, e.g. the foreground or background color. * @param icon icon * @return gray version of the image */ public static ImageIcon createBrighterImage(Component c, Icon icon) { if (icon == null) return EMPTY_ICON; BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); icon.paintIcon(c, image.getGraphics(), 0, 0); return new ImageIcon(ColorFilter.createBrighterImage(image)); }
/** * Creates a gray version from an input image with a given percentage of brightness. Usually gray icon indicates * disabled. If input icon is null, a blank ImageIcon will be returned. * * @param c The component to get properties useful for painting, e.g. the foreground or background color. * @param icon icon * @param percent percentage of brightness * @return gray version of the image */ public static ImageIcon createBrighterImage(Component c, Icon icon, int percent) { if (icon == null) return EMPTY_ICON; BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); icon.paintIcon(c, image.getGraphics(), 0, 0); return new ImageIcon(ColorFilter.createBrighterImage(image, percent)); }