public class ColorMap
extends java.lang.Object
The method getIndex(double)
performs step (1). For any
double value, that method
(1a) clips to a specified min-max range of values,
(1b) linearly translates and scales to [0.0,255.0], and
(1c) rounds to the nearest integer pixel in [0,255].
Extensions of this class may of course override this method to
implement alternative mappings.
A color map maintains a list of color map listeners, and notifies those listeners whenever its mapping from values to colors has changed.
Modifier and Type | Field and Description |
---|---|
static java.awt.image.IndexColorModel |
BLUE_WHITE_RED
Color model for blue to white to red.
|
static java.awt.image.IndexColorModel |
GMT_JET
Color model for red to blue like GMT's jet color map.
|
static java.awt.image.IndexColorModel |
GRAY
Color model for grays from black to white.
|
static java.awt.image.IndexColorModel |
GRAY_YELLOW_RED
Color model for gray to yellow to red.
|
static java.awt.image.IndexColorModel |
HUE
Color model for hues from red to blue.
|
static java.awt.image.IndexColorModel |
HUE_BLUE_TO_RED
Color model for hues from blue to red.
|
static java.awt.image.IndexColorModel |
HUE_RED_TO_BLUE
Color model for hues from red to blue.
|
static java.awt.image.IndexColorModel |
JET
Color model for red to blue like Matlab's jet color map.
|
static java.awt.image.IndexColorModel |
PRISM
Color model for eight complete cycles of hues.
|
static java.awt.image.IndexColorModel |
RED_WHITE_BLUE
Color model for red to white to blue.
|
Constructor and Description |
---|
ColorMap(java.awt.Color c)
Constructs a color map for a specified solid color.
|
ColorMap(double vmin,
double vmax,
byte[] r,
byte[] g,
byte[] b)
Constructs a color map for specified values and colors.
|
ColorMap(double vmin,
double vmax,
java.awt.Color c)
Constructs a color map for a specified solid color within a given [0,1]
range.
|
ColorMap(double vmin,
double vmax,
java.awt.Color[] c)
Constructs a color map for specified values and colors.
|
ColorMap(double vmin,
double vmax,
float[] r,
float[] g,
float[] b)
Constructs a color map for specified values and colors.
|
ColorMap(double vmin,
double vmax,
java.awt.image.IndexColorModel colorModel)
Constructs a color map for specified values.
|
ColorMap(java.awt.image.IndexColorModel colorModel)
Constructs a color map for values in [0,1].
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(ColorMapListener cml)
Adds the specified color map listener.
|
static java.awt.image.IndexColorModel |
getBlueWhiteRed()
Gets a blue-white-red color model.
|
java.awt.Color |
getColor(double v)
Gets the color corresponding to the specified value.
|
java.awt.image.IndexColorModel |
getColorModel()
Gets the index color model used by this color map.
|
static java.awt.image.IndexColorModel |
getGmtJet()
Gets a red-to-blue color model like GMT's jet color map.
|
static java.awt.image.IndexColorModel |
getGmtJet(double alpha)
Gets a red-to-blue color model like GMT's jet color map.
|
static java.awt.image.IndexColorModel |
getGray()
Gets a linear gray black-to-white color model.
|
static java.awt.image.IndexColorModel |
getGray(double g0,
double g255)
Gets a linear gray color model for the specified gray levels.
|
static java.awt.image.IndexColorModel |
getGray(double g0,
double g255,
double alpha)
Gets a linear gray color model for the specified gray levels.
|
static java.awt.image.IndexColorModel |
getGrayYellowRed()
Gets the gray-yellow-red color model.
|
static java.awt.image.IndexColorModel |
getHue()
Gets a red-to-blue linear hue color model.
|
static java.awt.image.IndexColorModel |
getHue(double h0,
double h255)
Gets a linear hue color model for the specified hues.
|
static java.awt.image.IndexColorModel |
getHue(double h0,
double h255,
double alpha)
Gets a linear hue color model for the specified hues and alpha.
|
static java.awt.image.IndexColorModel |
getHueBlueToRed()
Gets a blue-to-red linear hue color model.
|
static java.awt.image.IndexColorModel |
getHueRedToBlue()
Gets a red-to-blue linear hue color model.
|
int |
getIndex(double v)
Gets the index in the range [0,255] corresponding to the specified value.
|
static java.awt.image.IndexColorModel |
getJet()
Gets a red-to-blue color model like Matlab's jet color map.
|
static java.awt.image.IndexColorModel |
getJet(double alpha)
Gets a red-to-blue color model like Matlab's jet color map.
|
double |
getMaxValue()
Gets the maximum value in the range of mapped values.
|
double |
getMinValue()
Gets the minimum value in the range of mapped values.
|
static java.awt.image.IndexColorModel |
getPrism()
Gets a color model with eight complete cycles of hues.
|
static java.awt.image.IndexColorModel |
getRedWhiteBlue()
Gets a red-white-blue color model.
|
float[] |
getRgbFloats(float[] v)
Maps an array of floats to a packed array of RGB float values in [0,1].
|
static java.awt.image.IndexColorModel |
makeIndexColorModel(java.awt.Color[] c)
Returns an index color model for the specified array of 256 colors.
|
static java.awt.image.IndexColorModel |
makeSolidColors(java.awt.Color c)
Returns an index color model for a single color.
|
void |
removeListener(ColorMapListener cml)
Removes the specified color map listener.
|
static java.awt.image.IndexColorModel |
setAlpha(java.awt.image.IndexColorModel icm,
double alpha)
Returns an index color model with specified opacity (alpha).
|
static java.awt.image.IndexColorModel |
setAlpha(java.awt.image.IndexColorModel icm,
float[] alpha)
Returns an index color model with specified opacities (alphas).
|
void |
setColorModel(java.awt.Color c)
Sets the index color model for this color map to a single color.
|
void |
setColorModel(java.awt.image.IndexColorModel colorModel)
Sets the index color model for this color map.
|
void |
setValueRange(double vmin,
double vmax)
Sets the min-max range of values mapped to colors.
|
public static final java.awt.image.IndexColorModel GRAY
public static final java.awt.image.IndexColorModel JET
public static final java.awt.image.IndexColorModel GMT_JET
public static final java.awt.image.IndexColorModel HUE
public static final java.awt.image.IndexColorModel HUE_RED_TO_BLUE
public static final java.awt.image.IndexColorModel HUE_BLUE_TO_RED
public static final java.awt.image.IndexColorModel PRISM
public static final java.awt.image.IndexColorModel RED_WHITE_BLUE
public static final java.awt.image.IndexColorModel BLUE_WHITE_RED
public static final java.awt.image.IndexColorModel GRAY_YELLOW_RED
public ColorMap(java.awt.image.IndexColorModel colorModel)
colorModel
- the index color model.public ColorMap(double vmin, double vmax, java.awt.image.IndexColorModel colorModel)
vmin
- the minimum value.vmax
- the maximum value.colorModel
- the index color model.public ColorMap(double vmin, double vmax, java.awt.Color[] c)
vmin
- the minimum value.vmax
- the maximum value.c
- array[256] of colors.public ColorMap(double vmin, double vmax, byte[] r, byte[] g, byte[] b)
vmin
- the minimum value.vmax
- the maximum value.r
- array[256] of reds.g
- array[256] of greens.b
- array[256] of blues.public ColorMap(double vmin, double vmax, float[] r, float[] g, float[] b)
vmin
- the minimum value.vmax
- the maximum value.r
- array[256] of reds.g
- array[256] of greens.b
- array[256] of blues.public ColorMap(java.awt.Color c)
c
- a color.public ColorMap(double vmin, double vmax, java.awt.Color c)
vmin
- the minimum value.vmax
- the maximum value.c
- a color.public double getMinValue()
public double getMaxValue()
public java.awt.image.IndexColorModel getColorModel()
public java.awt.Color getColor(double v)
v
- the value to be mapped to a color.public int getIndex(double v)
v
- the value to be mapped to an index.public float[] getRgbFloats(float[] v)
v
- the array of float values to be mapped to colors.public void setValueRange(double vmin, double vmax)
vmin
- the minimum value.vmax
- the maximum value.public void setColorModel(java.awt.image.IndexColorModel colorModel)
colorModel
- the index color model.public void setColorModel(java.awt.Color c)
c
- a color.public void addListener(ColorMapListener cml)
cml
- the listener.public void removeListener(ColorMapListener cml)
cml
- the listener.public static java.awt.image.IndexColorModel getGray()
public static java.awt.image.IndexColorModel getGray(double g0, double g255)
g0
- the gray level corresponding to index value 0.g255
- the gray level corresponding to index value 255.public static java.awt.image.IndexColorModel getGray(double g0, double g255, double alpha)
g0
- the gray level corresponding to index value 0.g255
- the gray level corresponding to index value 255.alpha
- the opacity for all colors in this color model.public static java.awt.image.IndexColorModel getJet()
public static java.awt.image.IndexColorModel getJet(double alpha)
alpha
- the opacity for all colors in this color model.public static java.awt.image.IndexColorModel getGmtJet()
public static java.awt.image.IndexColorModel getGmtJet(double alpha)
alpha
- the opacity for all colors in this color model.public static java.awt.image.IndexColorModel getPrism()
public static java.awt.image.IndexColorModel getHue()
public static java.awt.image.IndexColorModel getHueRedToBlue()
public static java.awt.image.IndexColorModel getHueBlueToRed()
public static java.awt.image.IndexColorModel getHue(double h0, double h255)
h0
- the hue corresponding to index value 0.h255
- the hue corresponding to index value 255.public static java.awt.image.IndexColorModel getHue(double h0, double h255, double alpha)
h0
- the hue corresponding to index value 0.h255
- the hue corresponding to index value 255.alpha
- the opacity for all colors in this color model.public static java.awt.image.IndexColorModel getRedWhiteBlue()
public static java.awt.image.IndexColorModel getBlueWhiteRed()
public static java.awt.image.IndexColorModel getGrayYellowRed()
public static java.awt.image.IndexColorModel makeIndexColorModel(java.awt.Color[] c)
c
- array[256] of colors.public static java.awt.image.IndexColorModel makeSolidColors(java.awt.Color c)
c
- a color.public static java.awt.image.IndexColorModel setAlpha(java.awt.image.IndexColorModel icm, double alpha)
icm
- an index color model from which to copy RGBs.alpha
- opacity in the range [0.0,1.0].public static java.awt.image.IndexColorModel setAlpha(java.awt.image.IndexColorModel icm, float[] alpha)
icm
- an index color model from which to copy RGBs.alpha
- array of opacities in the range [0.0,1.0].