Class PaletteFactory

java.lang.Object
noaa.coastwatch.render.PaletteFactory

public class PaletteFactory extends Object

The PaletteFactory class handles written tables of predefined index color models. Each model has a number of color entries and is associated with a descriptive name. The number of entries can vary from 1 up to 65536, although in practice the palette will be remapped to 256 colors for use with 8-bit images. 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
   56 Ocean-algae
   57 Ocean-amp
   58 Ocean-balance
   59 Ocean-curl
   60 Ocean-deep
   61 Ocean-delta
   62 Ocean-dense
   63 Ocean-gray
   64 Ocean-haline
   65 Ocean-ice
   66 Ocean-matter
   67 Ocean-oxy
   68 Ocean-phase
   69 Ocean-solar
   70 Ocean-speed
   71 Ocean-tempo
   72 Ocean-thermal
   73 Ocean-turbid
 
Since:
3.1.7
Author:
Peter Hollemans
  • Constructor Details

    • PaletteFactory

      public PaletteFactory()
  • Method Details

    • getPredefined

      public static List getPredefined()
      Gets the list of predefined palette names.
    • addPredefined

      public static void addPredefined(Palette palette)
      Adds the specified palette to the list of predefined palettes.
      Parameters:
      palette - the palette to add to the list.
    • addPredefined

      public static void addPredefined(File paletteDir) throws IOException
      Adds the palettes in the specified directory to the list of predefined palettes. Palettes are identified as any file ending in '.xml'. Thus, palettes should be kept in a directory by themselves to use this method.
      Parameters:
      paletteDir - the palette directory to list.
      Throws:
      IOException - if an error occurred reading the directory or parsing palette file contents.
    • create

      public static Palette create(File file) throws FileNotFoundException, IOException
      Creates a new palette from the specified file.
      Parameters:
      file - the file to read.
      Returns:
      the new palette.
      Throws:
      FileNotFoundException - if the file is not valid.
      IOException - if the file had input format errors.
    • create

      public static Palette create(InputStream stream) throws IOException
      Constructs a new palette from an input stream.
      Parameters:
      stream - the input stream to read palette data from.
      Returns:
      the new palette.
      Throws:
      IOException - if the file had input format errors.
    • create

      public static Palette create(String name)
      Constructs a new palette from a predefined palette name. This method returns the same instance of the predefined palette when called multiple times with the same name. A hash map is kept of predefined palettes, and reading of palette data only occurs when required.
      Parameters:
      name - the predefined palette name.
      Returns:
      the new palette.
      Throws:
      RuntimeException - if the predefined palette had input format errors or the predefined palette is invalid.