public class FloatColorMap extends ColorMap
This mapping consists of two parts. Floats are first mapped to bytes, and then those bytes are mapped to colors.
The first mapping from floats to bytes is linear between minimum and maximum clip values. Values below and above these min and max values are clipped. Clips may be computed from percentiles or may be specified explicitly. By default, the clip min and max values are the minimum and maximum values in specified arrays of floats.
The second mapping depends on the number of arrays of floats specified. When only one array is specified, each byte from the float-to-byte mapping is used as an index for an index color model with 256 colors.
When three arrays are specified, a float value from each of the three arrays is first mapped independently (using different float-to-byte maps, possibly with different clips) to obtain three bytes. These three bytes are then interpreted directly as color components in either (red,green,blue) or (hue,saturation,brightness) color models. Because each color component can have 256 values, millions of colors are possible.
When four arrays are specified, the mapping is the same as for three arrays, except that the fourth array corresponds to an alpha (opacity) component.
An index color model may be useful even when three or four arrays are specified, by specifying one of the arrays to serve as a source of of byte indices. This capability enables a single float value to be mapped to a color, even when three or four arrays of floats are specified. For example, if the index color model contained fully saturated and bright colors with different hues, then one might specify the array corresponding to the hue component as the source of byte indices. The indexed colors might then be displayed in a color bar.
By default, direct color components with indices 0, 1, and 2 are red, green, and blue, respectively. If HSB components are enabled, then these same indices instead correspond to components hue, saturation, and brightness. Enabling HSB adds an extra conversion step to the mapping from floats to colors. After three bytes are computed from three floats, these HSB byte values are then mapped to the nearest RGB byte values. The hues corresponding to min/max byte values 0 and 255 are red (0.00) and blue (0.67), but these hues may be specified explicitly. This extra conversion step is never performed for indexed color mappings of single float values.
BLUE_WHITE_RED, GMT_JET, GRAY, GRAY_YELLOW_RED, HUE, HUE_BLUE_TO_RED, HUE_RED_TO_BLUE, JET, PRISM, RED_WHITE_BLUE
Constructor and Description |
---|
FloatColorMap(float[][][] f,
int ic,
java.awt.image.IndexColorModel icm)
Constructs a color map with more than one color components.
|
FloatColorMap(float[][] f,
java.awt.image.IndexColorModel icm)
Constructs a color map with only indexed colors.
|
Modifier and Type | Method and Description |
---|---|
int |
getARGB(float f)
Gets the 32-bit color in 0xAARRGGBB format for the specified value.
|
int |
getARGB(float f0,
float f1,
float f2,
float f3)
Gets the 32-bit color in 0xAARRGGBB format for specified values.
|
int |
getIndex(double v)
Gets the color index corresponding to the specified value.
|
int |
getIndex(float f)
Gets the color index corresponding to the specified value.
|
double |
getMaxValue()
Gets the maximum value in the range of mapped values.
|
double |
getMinValue()
Gets the minimum value in the range of mapped values.
|
int |
getRGB(float f0,
float f1,
float f2)
Gets the 32-bit color in 0xffRRGGBB format for specified values.
|
void |
setHSB(boolean hsb)
Enables or disables HSB components.
|
void |
setHues(double hue000,
double hue255)
Sets hue values corresponding to byte values 0 and 255.
|
void |
setValueRange(double vmin,
double vmax)
Sets the min-max range of values mapped to colors.
|
addListener, getBlueWhiteRed, getColor, getColorModel, getGmtJet, getGmtJet, getGray, getGray, getGray, getGrayYellowRed, getHue, getHue, getHue, getHueBlueToRed, getHueRedToBlue, getJet, getJet, getPrism, getRedWhiteBlue, getRgbFloats, makeIndexColorModel, makeSolidColors, removeListener, setAlpha, setAlpha, setColorModel, setColorModel
public FloatColorMap(float[][] f, java.awt.image.IndexColorModel icm)
f
- an array of floats.icm
- the index color model.public FloatColorMap(float[][][] f, int ic, java.awt.image.IndexColorModel icm)
f
- arrays of floats, one array for each color component.ic
- array index of the component for the index color model.icm
- the index color model corresponding to one component.public void setHSB(boolean hsb)
hsb
- true, to enable HSB components; false, for RGB components.public void setHues(double hue000, double hue255)
hue000
- hue corresponding to byte value 0; default is 0.00 (red).hue255
- hue corresponding to byte value 255; default is 0.67 (blue).public int getIndex(float f)
f
- the value to be mapped to index.public int getARGB(float f)
f
- the value to be mapped to a color.public int getRGB(float f0, float f1, float f2)
f0
- the value for color component 0.f1
- the value for color component 1.f2
- the value for color component 2.public int getARGB(float f0, float f1, float f2, float f3)
f0
- the value for color component 0.f1
- the value for color component 1.f2
- the value for color component 2.f3
- the value for color component 3.public int getIndex(double v)
public double getMinValue()
getMinValue
in class ColorMap
public double getMaxValue()
getMaxValue
in class ColorMap
public void setValueRange(double vmin, double vmax)
setValueRange
in class ColorMap
vmin
- the minimum value.vmax
- the maximum value.