comirva.visu.colormap
Class ColorMap

java.lang.Object
  extended by comirva.visu.colormap.ColorMap
Direct Known Subclasses:
ColorMap_Colorful, ColorMap_Fire, ColorMap_Gray, ColorMap_Islands, ColorMap_Ocean, ColorMap_Sun

public class ColorMap
extends Object

This class implements a colormap, i.e. a mapping from a normalized range [0,1] to a defined set of colors.


Constructor Summary
ColorMap(Color lowerMargin, Color upperMargin)
          Creates a ColorMap with defined mapping colors for the lower and upper margin of the value range.
ColorMap(Color lowerMargin, Color upperMargin, int granularity)
          Creates a ColorMap with defined mapping colors for the lower and upper margin of the value range and the specified granularity.
 
Method Summary
 void addColor(Color col, int position)
          Defines a new sampling point of the ColorMap.
 Color getColor(double value)
          Returns the color defined in the ColorMap for the specified value, where the argument value must be normalized, i.e. in the range [0,1].
 void invert()
          Inverts each color of the ColorMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorMap

public ColorMap(Color lowerMargin,
                Color upperMargin)
Creates a ColorMap with defined mapping colors for the lower and upper margin of the value range.

Parameters:
lowerMargin - the Color for the value 0
upperMargin - the Color for the value 1

ColorMap

public ColorMap(Color lowerMargin,
                Color upperMargin,
                int granularity)
Creates a ColorMap with defined mapping colors for the lower and upper margin of the value range and the specified granularity.

Parameters:
lowerMargin - the Color for the value 0
upperMargin - the Color for the value 1
granularity - the number of different Colors available in the ColorMap
Method Detail

addColor

public void addColor(Color col,
                     int position)
Defines a new sampling point of the ColorMap. Between each pair of sampling points, the colors are interpolated.

Parameters:
col - the Color to be added
position - the index in the range [0, granularity-1] where the sampling point is to be inserted

getColor

public Color getColor(double value)
Returns the color defined in the ColorMap for the specified value, where the argument value must be normalized, i.e. in the range [0,1].

Parameters:
value - the normalized double value for which the color should be returned
Returns:
the Color for the value passed as argument

invert

public void invert()
Inverts each color of the ColorMap.