List of usage examples for javax.swing GrayFilter GrayFilter
public GrayFilter(boolean b, int p)
From source file:org.mbari.aved.ui.classifier.ClassModelListRenderer.java
/** * Converts and image into gray scale if the color space is grayscale * TODO: convert to whatever color space is required here, not just gray * @param image// w w w . ja va 2s .c o m * @param colorSpace * @return */ public static ImageIcon convertImageIcon(Image image, ColorSpace colorSpace) { // Convert to gray if in that color space. Images // are actually stored in color but converted to gray // in the classifier. Display them as GRAY to avoid // confusion as the classifier can only work in one // color space at a time, e.g. classes in different // color spaces cannot be mixed if (colorSpace != null && colorSpace.equals(ColorSpace.GRAY)) { // This isn't necessarily how the image is rendered in the Matlab // code, but it makes it easier to see the thumbnails ImageFilter filter = new GrayFilter(true, 50); ImageProducer prod; prod = new FilteredImageSource(image.getSource(), filter); Image grayScale = Toolkit.getDefaultToolkit().createImage(prod); return new ImageIcon(grayScale); } else { return new ImageIcon(image); } }
From source file:util.ui.PictureAreaIcon.java
public void paintIcon(final Component c, Graphics g, int x, int y) { if (mScaledIcon == null) { return;//from www .j a v a 2 s .com } y += 2; Color color = g.getColor(); if (!colorsInEqualRange(c.getBackground(), c.getForeground()) && !mProgram.isExpired()) { g.setColor(c.getBackground()); g.fillRect(x, y, getIconWidth(), getIconHeight() - 2); } g.setColor(color); g.drawRect(x, y, getIconWidth() - 1, getIconHeight() - 3); y += 3; x += 3; if (mIsGrayFilter && !mIsExpired && mProgram.isExpired()) { ImageFilter filter = new GrayFilter(true, 60); mScaledIcon .setImage(c.createImage(new FilteredImageSource(mScaledIcon.getImage().getSource(), filter))); mIsExpired = true; } if (c.getForeground().getAlpha() != 255) { ImageFilter filter = new RGBImageFilter() { public int filterRGB(int x, int y, int rgb) { if ((rgb & 0xff000000) != 0) { return (rgb & 0xffffff) | (c.getForeground().getAlpha() << 24); } return rgb; } }; mScaledIcon .setImage(c.createImage(new FilteredImageSource(mScaledIcon.getImage().getSource(), filter))); } mScaledIcon.paintIcon(c, g, x, y); /* if(!mProgram.isExpired()) { g.setColor(color); } else { g.setColor(color); } */ mCopyrightText.paintIcon(null, g, x, y + mScaledIcon.getIconHeight()); if (mDescriptionLines > 0 && mDescriptionText != null) { mDescriptionText.paintIcon(null, g, x, y + mScaledIcon.getIconHeight() + mCopyrightText.getIconHeight() + 1); } g.setColor(color); }