Class RGBGrayFilter

  • All Implemented Interfaces:
    java.awt.image.ImageConsumer, java.lang.Cloneable

    public final class RGBGrayFilter
    extends java.awt.image.RGBImageFilter
    An image filter that turns an icon into a grayscale icon. Used by the JGoodies Windows and Plastic L&Fs to create a disabled icon.

    The high-resolution gray filter can be disabled globally using Options.setHiResGrayFilterEnabled(boolean); it is enabled by default. The global setting can be overridden per component by setting the client property key Options.HI_RES_DISABLED_ICON_CLIENT_KEY to Boolean.FALSE.

    Thanks to Andrej Golovnin for suggesting a simpler filter formula.

    Version:
    $Revision: 1.13 $
    • Field Summary

      • Fields inherited from class java.awt.image.RGBImageFilter

        canFilterIndexColorModel, newmodel, origmodel
      • Fields inherited from class java.awt.image.ImageFilter

        consumer
      • Fields inherited from interface java.awt.image.ImageConsumer

        COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private RGBGrayFilter()
      Overrides default constructor; prevents instantiation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int filterRGB​(int x, int y, int rgb)
      Converts a single input pixel in the default RGB ColorModel to a single gray pixel.
      static javax.swing.Icon getDisabledIcon​(javax.swing.JComponent component, javax.swing.Icon icon)
      Returns an icon with a disabled appearance.
      • Methods inherited from class java.awt.image.RGBImageFilter

        filterIndexColorModel, filterRGBPixels, setColorModel, setPixels, setPixels, substituteColorModel
      • Methods inherited from class java.awt.image.ImageFilter

        clone, getFilterInstance, imageComplete, resendTopDownLeftRight, setDimensions, setHints, setProperties
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RGBGrayFilter

        private RGBGrayFilter()
        Overrides default constructor; prevents instantiation.
    • Method Detail

      • getDisabledIcon

        public static javax.swing.Icon getDisabledIcon​(javax.swing.JComponent component,
                                                       javax.swing.Icon icon)
        Returns an icon with a disabled appearance. This method is used to generate a disabled icon when one has not been specified.
        Parameters:
        component - the component that will display the icon, may be null.
        icon - the icon to generate disabled icon from.
        Returns:
        disabled icon, or null if a suitable icon can not be generated.
      • filterRGB

        public int filterRGB​(int x,
                             int y,
                             int rgb)
        Converts a single input pixel in the default RGB ColorModel to a single gray pixel.
        Specified by:
        filterRGB in class java.awt.image.RGBImageFilter
        Parameters:
        x - the horizontal pixel coordinate
        y - the vertical pixel coordinate
        rgb - the integer pixel representation in the default RGB color model
        Returns:
        a gray pixel in the default RGB color model.
        See Also:
        ColorModel.getRGBdefault(), RGBImageFilter.filterRGBPixels(int, int, int, int, int[], int, int)