Class palette.PaletteServer
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class palette.PaletteServer

java.lang.Object
   |
   +----palette.PaletteServer

public class PaletteServer
extends Object
This class exists only to initialize instances of the IndexColorModel. The idea is that most of the "palettes" (this is the name for the analogous object in NCSA Heirarchical Data Format files) we would want to use are rather cumbersome to generate on the fly, especially for an arbitrary number of values. So, we gather such code here where a palette of arbitrary size can be retrieved easily. Use of this class is pretty simple:
  1. To examine the list of available palettes, do:
    String[] list = PaletteServer.getPaletteList();
    
  2. To define a "hotMetal" palette of length n:
    IndexColorModel hm = PaletteServer.getPalette("hotMetal",n);
    
  3. Other types of palettes can be added to the list by modifying or extending this class. In either case, the variable paletteList__ must be updated, a corresponding entry must be made in the scanPaletteList method, and a method analogous to getHotMetalColors must be established to define the new palette.
Version:
1.0 02-12-97
Author:
Daren Stotler
See Also:
PaletteTest

Variable Index

 o paletteList__

Method Index

 o getPalette(String, int)
These are the main public methods for this class.
 o getPalette(String, int, byte[])
These are the main public methods for this class.
 o getPalette(String, int, int)
These are the main public methods for this class.
 o getPaletteList()
Gives the caller a list of the palettes which can be generated.
 o scanPaletteList(String, byte[], byte[], byte[], int)

Variables

 o paletteList__
  protected final static String paletteList__[]

Methods

 o getPaletteList
  public static String[] getPaletteList()
Gives the caller a list of the palettes which can be generated.
Returns:
string array of the available palette names
 o scanPaletteList
  protected static void scanPaletteList(String pal,
                                        byte r[],
                                        byte g[],
                                        byte b[],
                                        int s)
 o getPalette
  public static IndexColorModel getPalette(String pal,
                                           int s)
These are the main public methods for this class. The name of a palette and its size is requested. An IndexColorModel is instantiated and returned. This version has no transparency.
Parameters:
pal - String containing the palette name
s - number of colors in the palette
Returns:
corresponding instance of IndexColorModel
 o getPalette
  public static IndexColorModel getPalette(String pal,
                                           int s,
                                           int trans)
These are the main public methods for this class. The name of a palette and its size is requested. An IndexColorModel is instantiated and returned. Just as in the IndexColorModel class, offer some options with regard to transparency. Here, use just a single pixel.
Parameters:
pal - String containing the palette name
s - number of colors in the palette
trans - the transparent pixel
Returns:
corresponding instance of IndexColorModel
 o getPalette
  public static IndexColorModel getPalette(String pal,
                                           int s,
                                           byte a[])
These are the main public methods for this class. The name of a palette and its size is requested. An IndexColorModel is instantiated and returned. Just as in the IndexColorModel class, offer some options with regard to transparency. In this case, the caller can select a different transparency for every pixel.
Parameters:
pal - String containing the palette name
s - number of colors in the palette
trans - the transparent pixel
a - array of transparency (alpha) values
Returns:
corresponding instance of IndexColorModel

All Packages  Class Hierarchy  This Package  Previous  Next  Index