use of java.awt.image.FilteredImageSource in project gephi by gephi.
the class WhiteFilter method createDisabledImage.
//~ Methods --------------------------------------------------------------------------------------------------------------
/**
* Creates a disabled image
*/
public static Image createDisabledImage(final Image i) {
final WhiteFilter filter = new WhiteFilter();
final ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
return Toolkit.getDefaultToolkit().createImage(prod);
}
use of java.awt.image.FilteredImageSource in project adempiere by adempiere.
the class PDFViewerBean method createActionButton.
protected JButton createActionButton(Action action, String text, String image, String tooltip) {
final ImageIcon icon = new ImageIcon(getClass().getResource(image));
final double colorFactor = 0.9;
final RGBImageFilter filter = new RGBImageFilter() {
public int filterRGB(int x, int y, int rgb) {
final int alpha = (rgb >> 24) & 0xff;
final int red = (rgb >> 16) & 0xff;
final int green = (rgb >> 8) & 0xff;
final int blue = (rgb) & 0xff;
return ((int) (alpha * colorFactor) << 24) | ((int) (red * colorFactor) << 16) | ((int) (green * colorFactor) << 8) | ((int) (blue * colorFactor));
}
};
final ImageIcon darkerIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(icon.getImage().getSource(), filter)));
final JButton result = new JButton();
result.setAction(action);
result.setText(text);
result.setIcon(darkerIcon);
result.setBorderPainted(false);
result.setHorizontalTextPosition(SwingConstants.CENTER);
result.setVerticalTextPosition(SwingConstants.BOTTOM);
result.setMnemonic(0);
result.setToolTipText(tooltip);
final Dimension dim = result.getPreferredSize();
result.setMaximumSize(new Dimension(32, dim.height));
result.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent me) {
result.setBorderPainted(true);
result.setIcon(icon);
}
public void mouseExited(MouseEvent me) {
result.setBorderPainted(false);
result.setIcon(darkerIcon);
}
});
result.setBorderPainted(false);
result.setFocusPainted(false);
return result;
}
use of java.awt.image.FilteredImageSource in project jdk8u_jdk by JetBrains.
the class Image method getScaledInstance.
/**
* Creates a scaled version of this image.
* A new <code>Image</code> object is returned which will render
* the image at the specified <code>width</code> and
* <code>height</code> by default. The new <code>Image</code> object
* may be loaded asynchronously even if the original source image
* has already been loaded completely.
*
* <p>
*
* If either <code>width</code>
* or <code>height</code> is a negative number then a value is
* substituted to maintain the aspect ratio of the original image
* dimensions. If both <code>width</code> and <code>height</code>
* are negative, then the original image dimensions are used.
*
* @param width the width to which to scale the image.
* @param height the height to which to scale the image.
* @param hints flags to indicate the type of algorithm to use
* for image resampling.
* @return a scaled version of the image.
* @exception IllegalArgumentException if <code>width</code>
* or <code>height</code> is zero.
* @see java.awt.Image#SCALE_DEFAULT
* @see java.awt.Image#SCALE_FAST
* @see java.awt.Image#SCALE_SMOOTH
* @see java.awt.Image#SCALE_REPLICATE
* @see java.awt.Image#SCALE_AREA_AVERAGING
* @since JDK1.1
*/
public Image getScaledInstance(int width, int height, int hints) {
ImageFilter filter;
if ((hints & (SCALE_SMOOTH | SCALE_AREA_AVERAGING)) != 0) {
filter = new AreaAveragingScaleFilter(width, height);
} else {
filter = new ReplicateScaleFilter(width, height);
}
ImageProducer prod;
prod = new FilteredImageSource(getSource(), filter);
return Toolkit.getDefaultToolkit().createImage(prod);
}
use of java.awt.image.FilteredImageSource in project processdash by dtuma.
the class BufferedIcon method applyFilter.
public void applyFilter(RGBImageFilter filter) {
ImageProducer prod = new FilteredImageSource(getImage().getSource(), filter);
setImage(Toolkit.getDefaultToolkit().createImage(prod));
}
use of java.awt.image.FilteredImageSource in project jdk8u_jdk by JetBrains.
the class WindowsLookAndFeel method getDisabledIcon.
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// in particular by the WindowsFileChooserUI class)
if (icon != null && component != null && Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY)) && icon.getIconWidth() > 0 && icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
Aggregations