public class PaletteFactory
extends java.lang.Object
PaletteFactory
class handles written tables of
predefined index color models. Each model has a maximum of 256
colors and is associated with a descriptive name. The palette file
has an XML format, as follows:
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE palette SYSTEM "http://coastwatch.noaa.gov/xml/palette.dtd"> <palette name="BW-Linear" length="256"> <color r="0" g="0" b="0" /> <color r="1" g="1" b="1" /> <color r="2" g="2" b="2" /> ... </palette>
Users may generate files of this form and use them as input to the palette constructor. Alternately, palettes may be created by specifying the name and index color model data. A number of predefined palettes are also available by name or index:
0 BW-Linear 1 HSL256 2 RAMSDIS 3 Blue-Red 4 Blue-White 5 Grn-Red-Blu-Wht 6 Red-Temperature 7 Blue-Green-Red-Yellow 8 Std-Gamma-II 9 Prism 10 Red-Purple 11 Green-White-Linear 12 Grn-Wht-Exponential 13 Green-Pink 14 Blue-Red2 15 16-Level 16 Rainbow 17 Steps 18 Stern-Special 19 Haze 20 Blue-Pastel-Red 21 Pastels 22 Hue-Sat-Lightness-1 23 Hue-Sat-Lightness-2 24 Hue-Sat-Value-1 25 Hue-Sat-Value-2 26 Purple-Red-Stripes 27 Beach 28 Mac-Style 29 Eos-A 30 Eos-B 31 Hardcandy 32 Nature 33 Ocean 34 Peppermint 35 Plasma 36 Rainbow2 37 Blue-Waves 38 Volcano 39 Waves 40 Rainbow18 41 Rainbow-white 42 Rainbow-black 43 NDVI 44 GLERL-Archive 45 GLERL-30-Degrees 46 Chlora-1 47 Chlora-anom 48 Spectrum 49 Wind-0-50 50 CRW_SST 51 CRW_SSTANOMALY 52 CRW_HOTSPOT 53 CRW_DHW 54 StepSeq25 55 HSB-Cycle
Constructor and Description |
---|
PaletteFactory() |
Modifier and Type | Method and Description |
---|---|
static void |
addPredefined(java.io.File paletteDir)
Adds the palettes in the specified directory to the list of
predefined palettes.
|
static void |
addPredefined(Palette palette)
Adds the specified palette to the list of predefined palettes.
|
static Palette |
create(java.io.File file)
Creates a new palette from the specified file.
|
static Palette |
create(java.io.InputStream stream)
Constructs a new palette from an input stream.
|
static Palette |
create(java.lang.String name)
Constructs a new palette from a predefined palette name.
|
static java.util.List |
getPredefined()
Gets the list of predefined palette names.
|
public static java.util.List getPredefined()
public static void addPredefined(Palette palette)
palette
- the palette to add to the list.public static void addPredefined(java.io.File paletteDir) throws java.io.IOException
paletteDir
- the palette directory to list.java.io.IOException
- if an error occurred reading the directory or
parsing palette file contents.public static Palette create(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
file
- the file to read.java.io.FileNotFoundException
- if the file is not valid.java.io.IOException
- if the file had input format errors.public static Palette create(java.io.InputStream stream) throws java.io.IOException
stream
- the input stream to read palette data from.java.io.IOException
- if the file had input format errors.public static Palette create(java.lang.String name)
name
- the predefined palette name.java.lang.RuntimeException
- if the predefined palette had input
format errors or the predefined palette is invalid.