peakml.graphics
Class Colormap

java.lang.Object
  extended by peakml.graphics.Colormap

public class Colormap
extends java.lang.Object

Defines different color models for visualization purposes (like heatmaps and graphs). A specific colormap can be created by using one of the enumerated integers defined in the class. An example of the use:

 // create the colormap
 Colormap colormap = new Colormap(Colormap.JET);
 
 // print all the colors
 for (int i=0; i>16)&0xFF) + ", " + ((color>>8)&0xFF) + ", " + (color&0xFF));
 }
 


Field Summary
static int EXCEL
          A standard excel color model, where each color tries to be as different from the rest as possible.
static int GRAYSCALE
          A greyscale color model.
static int HEAT
          A heat color model used to create heatmaps.
static int HSV
          A Hue-Saturation-Value colormodel.
static int JET
          A JET color model as used in Matlab.
static int RAINBOW
           
static int REDBLACKGREEN
          A color model ranging from red to black to green.
static int REDGREEN
          A color model ranging from red to white to green.
static int WAVE
           
 
Constructor Summary
Colormap(int type)
          Constructor for creating the specified color model.
 
Method Summary
static java.awt.image.BufferedImage createImage(int type, int width, int height)
           
 int getColor(int index)
          Returns an integer representation of the color at the given index.
 int getNrColors()
          Returns the number of colors stored in this color model.
 int getType()
          Returns the type of color model stored in the instance.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JET

public static final int JET
A JET color model as used in Matlab.

See Also:
Constant Field Values

HSV

public static final int HSV
A Hue-Saturation-Value colormodel.

See Also:
Constant Field Values

HEAT

public static final int HEAT
A heat color model used to create heatmaps.

See Also:
Constant Field Values

EXCEL

public static final int EXCEL
A standard excel color model, where each color tries to be as different from the rest as possible.

See Also:
Constant Field Values

GRAYSCALE

public static final int GRAYSCALE
A greyscale color model.

See Also:
Constant Field Values

REDGREEN

public static final int REDGREEN
A color model ranging from red to white to green.

See Also:
Constant Field Values

REDBLACKGREEN

public static final int REDBLACKGREEN
A color model ranging from red to black to green.

See Also:
Constant Field Values

RAINBOW

public static final int RAINBOW
See Also:
Constant Field Values

WAVE

public static final int WAVE
See Also:
Constant Field Values
Constructor Detail

Colormap

public Colormap(int type)
         throws java.lang.RuntimeException
Constructor for creating the specified color model.

Parameters:
type - The type of color-model to be created.
Throws:
java.lang.RuntimeException
Method Detail

getType

public int getType()
Returns the type of color model stored in the instance.

Returns:
The type of the color model.

getNrColors

public int getNrColors()
Returns the number of colors stored in this color model. The number of colors is dependent on the color model chosen, so this value needs to be checked before retrieving colors.

Returns:
The number of colors stored in the color model.

getColor

public int getColor(int index)
             throws java.lang.IndexOutOfBoundsException
Returns an integer representation of the color at the given index. The index should be larger than 0 and smaller than getNrColors()-1.

Parameters:
index - The index where the color is located.
Returns:
The color at the given index represented in integer format.
Throws:
java.lang.IndexOutOfBoundsException - Thrown when the index is out of bounds.

createImage

public static java.awt.image.BufferedImage createImage(int type,
                                                       int width,
                                                       int height)

main

public static void main(java.lang.String[] args)