Palette Class Reference

The Palette class manages the list of colors that are used to generate thematic maps and decision surface outputs, as well as legends, which explicitly show the colors that make up the Palette. More...

#include <Palette.h>

Collaboration diagram for Palette:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void writeLegend (ofstream &ost, NameList &classNames, bool vertical=true)
 Writes a legend based on the colors in the Palette to the passed output file stream.
void save (ofstream &ost)
 Saves the color definitions to the passed output file stream.
void load (ifstream &ist)
 Loads new color definitions into the system Palette.
int getRGB (int classIdx, int idx)
 Returns the color value (R, G, or B) associated with a specified class.
int getMaxColor ()
 Accessor method.

Static Public Member Functions

static PaletteInstance ()
 Returns a reference to the Palette singleton.

Protected Member Functions

 Palette ()
 Initializes the default Palette with thirty colors, with RGB values ranging from 0 to 3.

Detailed Description

The Palette class manages the list of colors that are used to generate thematic maps and decision surface outputs, as well as legends, which explicitly show the colors that make up the Palette.

It is implemented as a singleton pattern, ensuring that there is only a single, global instance of the Palette in Classer.


Constructor & Destructor Documentation

Palette::Palette  )  [protected]
 

Initializes the default Palette with thirty colors, with RGB values ranging from 0 to 3.


Member Function Documentation

int Palette::getMaxColor  )  [inline]
 

Accessor method.

Returns:
The maximum color component value

int Palette::getRGB int  classIdx,
int  idx
 

Returns the color value (R, G, or B) associated with a specified class.

Parameters:
classIdx The class index for which to retrieve a color component.
idx The component index: 0 - Red, 1 - Green, 2 - Blue
Returns:
The color value for the requested component.

Palette * Palette::Instance  )  [static]
 

Returns a reference to the Palette singleton.

This is the method to use to get access to the Classer Palette.

void Palette::load ifstream &  ist  ) 
 

Loads new color definitions into the system Palette.

The format is identical to that generated by the Palette::save() method. The easiest approach to modifying the color values is to write them out using the save() method, modify the file, and then load them back in with this method.

Parameters:
ist The file input stream from which to load the color values.

void Palette::save ofstream &  ost  ) 
 

Saves the color definitions to the passed output file stream.

The format consists of:

  • An integer specifying the number of color values stored.
  • An integer specifying the maximum color value (color component values can range from 0 to this)
  • For each color value defined:
    • Three whitespace-separated integers on the same line, specifying the R, G, and B color components.
Parameters:
ost The output file stream to which to write the color definitions.

void Palette::writeLegend ofstream &  ost,
NameList classNames,
bool  vertical = true
 

Writes a legend based on the colors in the Palette to the passed output file stream.

The file is written as a portable pixmap, and so should have the extension '.ppm'. The number of colors that are written is based on the number of string in the classNames NameList. The legend consists of a set of colored rectangles, i.e., adding the class name strings must be done separately.

Parameters:
ost The output stream to direct the legend to.
classNames Specifies how many colors to write.
vertical If true, the legend is oriented vertically, else horizontally.


The documentation for this class was generated from the following files:
Generated on Tue Dec 13 11:00:27 2005 for Classer by  doxygen 1.4.3