APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing

public Class GrayFilter

extends RGBImageFilter
Class Inheritance
Imports
java.awt.*, java.awt.image.*, sun.awt.image.MultiResolutionCachedImage

An image filter that "disables" an image by turning it into a grayscale image, and brightening the pixels in the image. Used by buttons to create an image for a disabled button.
Authors
Jeff Dinkins, Tom Ball, Jim Graham
Since
1.2

Field Summary

Modifier and TypeField and Description
private boolean
private int
Inherited from java.awt.image.RGBImageFilter:
canFilterIndexColorModelnewmodelorigmodel

Constructor Summary

AccessConstructor and Description
public
GrayFilter(boolean
a boolean -- true if the pixels should be brightened
b
,
int
an int in the range 0..100 that determines the percentage of gray, where 100 is the darkest gray, and 0 is the lightest
p
)

Constructs a GrayFilter object that filters a color image to a grayscale image.

Method Summary

Modifier and TypeMethod and Description
public static Image

Returns:

the new grayscale image created from i
createDisabledImage
(Image
an Image to be created as disabled
i
)

Creates a disabled image

private static Image
public int
filterRGB(int x, int y, int rgb)

Implements abstract java.awt.image.RGBImageFilter.filterRGB.

Overrides RGBImageFilter.filterRGB.

Inherited from java.awt.image.RGBImageFilter:
filterIndexColorModelfilterRGBPixelssetColorModelsetPixelssetPixelssubstituteColorModel

Field Detail

brighterback to summary
private boolean brighter
percentback to summary
private int percent

Constructor Detail

GrayFilterback to summary
public GrayFilter(boolean b, int p)

Constructs a GrayFilter object that filters a color image to a grayscale image. Used by buttons to create disabled ("grayed out") button images.

Parameters
b:boolean

a boolean -- true if the pixels should be brightened

p:int

an int in the range 0..100 that determines the percentage of gray, where 100 is the darkest gray, and 0 is the lightest

Method Detail

createDisabledImageback to summary
public static Image createDisabledImage(Image i)

Creates a disabled image

Parameters
i:Image

an Image to be created as disabled

Returns:Image

the new grayscale image created from i

createDisabledImageImplback to summary
private static Image createDisabledImageImpl(Image i)
filterRGBback to summary
public int filterRGB(int x, int y, int rgb)

Implements abstract java.awt.image.RGBImageFilter.filterRGB.

Overrides RGBImageFilter.filterRGB.