org.jscience.media.pictures.filters
Class ArrayColormap

java.lang.Object
  extended by org.jscience.media.pictures.filters.ArrayColormap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Colormap
Direct Known Subclasses:
Gradient, SplineColormap

public class ArrayColormap
extends java.lang.Object
implements Colormap, java.lang.Cloneable, java.io.Serializable

A colormap implemented with an array of colors. This corresponds to the IndexColorModel class.

See Also:
Serialized Form

Field Summary
protected  int[] map
          The array of colors.
 
Constructor Summary
ArrayColormap()
          Construct an all-black colormap
ArrayColormap(int[] map)
          Construct a colormap with the given map
 
Method Summary
 java.lang.Object clone()
          DOCUMENT ME!
 int getColor(float v)
          Convert a value in the range 0..1 to an RGB color.
 int[] getMap()
          DOCUMENT ME!
 void setColor(int index, int color)
          DOCUMENT ME!
 void setColorInterpolated(int index, int firstIndex, int lastIndex, int color)
          Set the color at "index" to "color".
 void setColorRange(int firstIndex, int lastIndex, int color)
          DOCUMENT ME!
 void setColorRange(int firstIndex, int lastIndex, int color1, int color2)
          DOCUMENT ME!
 void setMap(int[] map)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected int[] map
The array of colors.

Constructor Detail

ArrayColormap

public ArrayColormap()
Construct an all-black colormap


ArrayColormap

public ArrayColormap(int[] map)
Construct a colormap with the given map

Parameters:
map - the array of ARGB colors
Method Detail

clone

public java.lang.Object clone()
DOCUMENT ME!

Overrides:
clone in class java.lang.Object
Returns:
DOCUMENT ME!

setMap

public void setMap(int[] map)
DOCUMENT ME!

Parameters:
map - DOCUMENT ME!

getMap

public int[] getMap()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getColor

public int getColor(float v)
Convert a value in the range 0..1 to an RGB color.

Specified by:
getColor in interface Colormap
Parameters:
v - a value in the range 0..1
Returns:
an RGB color

setColorInterpolated

public void setColorInterpolated(int index,
                                 int firstIndex,
                                 int lastIndex,
                                 int color)
Set the color at "index" to "color". Entries are interpolated linearly from the existing entries at "firstIndex" and "lastIndex" to the new entry. firstIndex < index < lastIndex must hold.


setColorRange

public void setColorRange(int firstIndex,
                          int lastIndex,
                          int color1,
                          int color2)
DOCUMENT ME!

Parameters:
firstIndex - DOCUMENT ME!
lastIndex - DOCUMENT ME!
color1 - DOCUMENT ME!
color2 - DOCUMENT ME!

setColorRange

public void setColorRange(int firstIndex,
                          int lastIndex,
                          int color)
DOCUMENT ME!

Parameters:
firstIndex - DOCUMENT ME!
lastIndex - DOCUMENT ME!
color - DOCUMENT ME!

setColor

public void setColor(int index,
                     int color)
DOCUMENT ME!

Parameters:
index - DOCUMENT ME!
color - DOCUMENT ME!