org.jcae.viewer3d.post
Class DefaultColorMapper

java.lang.Object
  extended by org.jcae.viewer3d.post.DefaultColorMapper
All Implemented Interfaces:
ColorMapper

public class DefaultColorMapper
extends java.lang.Object
implements ColorMapper

Map colors on values. This class properly handle set of values including Float.NEGATIVE_INFINITY, but positive infinity will lead to unexpected behavior.


Constructor Summary
DefaultColorMapper()
          Create a color mapper with the following caracteristics: min=0 max=1 palletteSize=1
DefaultColorMapper(float[] values, int paletteSize)
          Create a mapper for a given set of values
DefaultColorMapper(float min, float max, boolean infinity, int paletteSize)
          Create a mapper for a set of values whose only min and max are known
 
Method Summary
 float getMax()
          Get the greatest value
 float getMin()
          Get the finit smallest value
 byte[] getPalette()
          Return the palette in the RGB format.
 boolean isNegativeInfinity()
          Return true is the set of value contains Float.NEGATIVE_INFINITY
 int map(float value)
          Return the color index in the palette for the given value.
 java.awt.Color mapColor(float value)
          Return the color for the given value.
 void mapColor(float value, int[] dst, int index)
          Set the color associated to the value into the destination array This is a continues mapping (.e. the returned value may not be in the palette).
 void setMax(float max)
          Set the greatest value
 void setMin(float min)
          Set the finit smallest value
 void setNegativeInfinity(boolean b)
          Specifiy that the working set of value contains Float.NEGATIVE_INFINITY.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultColorMapper

public DefaultColorMapper()
Create a color mapper with the following caracteristics:


DefaultColorMapper

public DefaultColorMapper(float[] values,
                          int paletteSize)
Create a mapper for a given set of values

Parameters:
values - Extract the min and max value from this array
paletteSize - The number of color to generate

DefaultColorMapper

public DefaultColorMapper(float min,
                          float max,
                          boolean infinity,
                          int paletteSize)
Create a mapper for a set of values whose only min and max are known

Parameters:
max - greated value
min - smallest finit value
infinity - true if the values include Float.NEGATIVE_INFINITY
Method Detail

getPalette

public byte[] getPalette()
Return the palette in the RGB format. The size of the return array is 3 times the size of the palette. Note that this method do not use min and max values as it always return an HSB palette from red to blue through green.

Specified by:
getPalette in interface ColorMapper

map

public int map(float value)
Return the color index in the palette for the given value. This is a discret mapping.

Specified by:
map in interface ColorMapper

mapColor

public java.awt.Color mapColor(float value)
Return the color for the given value. This is a continues mapping (i.e. the returned value may not be in the palette).

Specified by:
mapColor in interface ColorMapper

mapColor

public void mapColor(float value,
                     int[] dst,
                     int index)
Set the color associated to the value into the destination array This is a continues mapping (.e. the returned value may not be in the palette). This methods aims at being use in loop to fill large destination arrays. Each element of the destination array is a ARGB color encoded on one integer: 0xffRRGGBB.

Specified by:
mapColor in interface ColorMapper

setMin

public void setMin(float min)
Set the finit smallest value


setMax

public void setMax(float max)
Set the greatest value


setNegativeInfinity

public void setNegativeInfinity(boolean b)
Specifiy that the working set of value contains Float.NEGATIVE_INFINITY.


getMin

public float getMin()
Get the finit smallest value


getMax

public float getMax()
Get the greatest value


isNegativeInfinity

public boolean isNegativeInfinity()
Return true is the set of value contains Float.NEGATIVE_INFINITY