|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectPalette
@Immutable public abstract class Palette
A set of RGB colors created by a palette factory from a name. A palette can creates a color model (often indexed) or an image type specifier from the RGB colors.
Sharing IndexColorModel instances
The color model is retained by the palette as a weak reference
(not as a soft reference) because
it may consume up to 256 kilobytes. The purpose of the weak reference is to share existing
instances in order to reduce memory usage; the purpose is not to provide caching.
| coverage/geotk-coverage (download) | View source code for this class |
| Field Summary | |
|---|---|
protected String |
name
The name of this palette. |
protected int |
numBands
The number of bands in the color model. |
protected int |
visibleBand
The band to display, in the range 0 inclusive to numBands exclusive. |
| Constructor Summary | |
|---|---|
protected |
Palette(PaletteFactory factory,
String name,
int numBands,
int visibleBand)
Creates a palette with the specified name. |
| Method Summary | |
|---|---|
protected abstract ImageTypeSpecifier |
createImageTypeSpecifier()
Creates a new image type specifier for this palette. |
boolean |
equals(Object object)
Compares this palette with the specified object for equality. |
ColorModel |
getColorModel()
Returns the color model for this palette. |
RenderedImage |
getImage(Dimension size)
Returns the color palette as an image of the specified size. |
ImageTypeSpecifier |
getImageTypeSpecifier()
Returns the image type specifier for this palette. |
int |
hashCode()
Returns a hash value for this palette. |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final String name
protected final int numBands
protected final int visibleBand
numBands exclusive.
This is used when an image contains more than one band but only one band can
be used for computing the colors to display. For example IndexColorModel
works on only one band.
| Constructor Detail |
|---|
protected Palette(PaletteFactory factory,
String name,
int numBands,
int visibleBand)
factory - The originating factory.name - The palette name.numBands - The number of bands (usually 1) to assign to numBands.visibleBand - The visible band (usually 0) to assign to visibleBand.| Method Detail |
|---|
public ColorModel getColorModel()
throws FileNotFoundException,
IOException
FileNotFoundException - If the RGB values need to be read from a file
and this file (typically inferred from name) is not found.
IOException - If an other kind of I/O error occurred.
public ImageTypeSpecifier getImageTypeSpecifier()
throws FileNotFoundException,
IOException
createImageTypeSpecifier()
method is invoked and its result is stored in the cache for future reuse.
FileNotFoundException - If the RGB values need to be read from a file
and this file (typically inferred from name) is not found.
IOException - If an other kind of I/O error occurred.
protected abstract ImageTypeSpecifier createImageTypeSpecifier()
throws FileNotFoundException,
IOException
getImageTypeSpecifier() when the specifier is not present in the cache.
FileNotFoundException - If the RGB values need to be read from a file
and this file (typically inferred from name) is not found.
IOException - If an other kind of I/O error occurred.
public RenderedImage getImage(Dimension size)
throws IOException
size - The image size. The palette will be vertical if
size.height >
size.width
IOException - if the color values can't be read.public int hashCode()
equals(Object) for information
about which attributes can be used in the computation.
hashCode in class Objectpublic boolean equals(Object object)
ColorModel construction,
because this equals method is used by PaletteFactory.palettes in order to
check if an existing Palette instance can be reused.
equals in class Objectobject - The object to compare with this palette for equality.
true if the given object is equal to this palette.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||