Class GrayFilter
java.lang.Object
java.awt.image.ImageFilter
java.awt.image.RGBImageFilter
javax.swing.GrayFilter
- All Implemented Interfaces:
ImageConsumer, Cloneable
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.
- Since:
- 1.2
-
Field Summary
Fields declared in class RGBImageFilter
canFilterIndexColorModel, newmodel, origmodelModifier and TypeFieldDescriptionprotected booleanThis boolean indicates whether or not it is acceptable to apply the color filtering of the filterRGB method to the color table entries of an IndexColorModel object in lieu of pixel by pixel filtering.protected ColorModelTheColorModelwith which to replaceorigmodelwhen the user callssubstituteColorModel.protected ColorModelFields declared in class ImageFilter
consumerModifier and TypeFieldDescriptionprotected ImageConsumerThe consumer of the particular image data stream for which this instance of the ImageFilter is filtering data.Fields declared in interface ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHTModifier and TypeFieldDescriptionstatic final intThe pixels will be delivered in (multiples of) complete scanlines at a time.static final intThe image creation process was deliberately aborted.static final intAn error was encountered while producing the image.static final intThe pixels will be delivered in a random order.static final intThe image contain a single static image.static final intOne frame of the image is complete but there are more frames to be delivered.static final intThe pixels will be delivered in a single pass.static final intThe image is complete and there are no more pixels or frames to be delivered.static final intThe pixels will be delivered in top-down, left-to-right order. -
Constructor Summary
ConstructorsConstructorDescriptionGrayFilter(boolean b, int p) Constructs a GrayFilter object that filters a color image to a grayscale image. -
Method Summary
Methods declared in class RGBImageFilter
filterIndexColorModel, filterRGBPixels, setColorModel, setPixels, setPixels, substituteColorModelModifier and TypeMethodDescriptionFilters an IndexColorModel object by running each entry in its color tables through the filterRGB function that RGBImageFilter subclasses must provide.voidfilterRGBPixels(int x, int y, int w, int h, int[] pixels, int off, int scansize) Filters a buffer of pixels in the default RGB ColorModel by passing them one by one through the filterRGB method.voidsetColorModel(ColorModel model) If the ColorModel is an IndexColorModel and the subclass has set the canFilterIndexColorModel flag to true, we substitute a filtered version of the color model here and wherever that original ColorModel object appears in the setPixels methods.voidsetPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize) If the ColorModel object is the same one that has already been converted, then simply passes the pixels through with the converted ColorModel.voidsetPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize) If the ColorModel object is the same one that has already been converted, then simply passes the pixels through with the converted ColorModel, otherwise converts the buffer of integer pixels to the default RGB ColorModel and passes the converted buffer to the filterRGBPixels method to be converted one by one.voidsubstituteColorModel(ColorModel oldcm, ColorModel newcm) Registers two ColorModel objects for substitution.Methods declared in class ImageFilter
clone, getFilterInstance, imageComplete, resendTopDownLeftRight, setDimensions, setHints, setPropertiesModifier and TypeMethodDescriptionclone()Clones this object.Returns a unique instance of an ImageFilter object which will actually perform the filtering for the specified ImageConsumer.voidimageComplete(int status) Filters the information provided in the imageComplete method of the ImageConsumer interface.voidResponds to a request for a TopDownLeftRight (TDLR) ordered resend of the pixel data from anImageConsumer.voidsetDimensions(int width, int height) Filters the information provided in the setDimensions method of the ImageConsumer interface.voidsetHints(int hints) Filters the information provided in the setHints method of the ImageConsumer interface.voidsetProperties(Hashtable<?, ?> props) Passes the properties from the source object along after adding a property indicating the stream of filters it has been run through.Methods declared in class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionbooleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
GrayFilter
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- a boolean -- true if the pixels should be brightenedp- 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 Details
-
createDisabledImage
-
filterRGB
public int filterRGB(int x, int y, int rgb) OverridesRGBImageFilter.filterRGB.- Specified by:
filterRGBin classRGBImageFilter- Parameters:
x- the X coordinate of the pixely- the Y coordinate of the pixelrgb- the integer pixel representation in the default RGB color model- Returns:
- a filtered pixel in the default RGB color model.
- See Also:
-