public class TLcdColorMap extends Object implements Cloneable
If the number of levels equals the number of colors, the color map is said to be gradient. An example with 3 levels and 3 colors:
retrieveColor
. This method
returns the color at a given level. In case of a gradient color map, it will
interpolate the colors (including alpha). These levels could be anything. For example, an altitude in meters, or a pressure in Pascal.
The object also has a level interval, which is the minimum and maximum allowed level.
For non-gradient color maps, you can specify whether or not to include the end point of each color level.
Changing the default TLcdColorMap.LevelInclusion.EXCLUDES_END_POINT
to TLcdColorMap.LevelInclusion.INCLUDES_END_POINT
would alter the piece-wise constant example above to:
Furthermore the user of this class is responsible to maintain the correct color count and level count. So getLevelCount() == getColorCount() or getLevelCount() == (getColorCount() - 1)
This object fires property changes about all changes made to it.
If trace is enabled (e.g. setClassTraceOn(true)
), this object
will print a warning when retrieveColor
is used and the object
is in an inconsistent state. E.g. levels not ordered, a color is null, ...
Modifier and Type | Class and Description |
---|---|
static class |
TLcdColorMap.LevelInclusion
The LevelInclusion determines how the levels are interpreted when retrieving values
using
retrieveColor(double) . |
Constructor and Description |
---|
TLcdColorMap()
Creates a new
TLcdColorMap . |
TLcdColorMap(ILcdInterval aLevelInterval,
double[] aLevels,
Color[] aColors)
Constructs a new
TLcdColorMap with the given levels and
colors. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Add the given
PropertyChangeListener . |
Object |
clone() |
boolean |
equals(Object o) |
Color |
getColor(int aIndex)
Returns the color at the given index.
|
int |
getColorCount()
Returns the amount of colors.
|
double |
getLevel(int aIndex)
Returns the level at the given index.
|
int |
getLevelCount()
Returns the amount of levels.
|
TLcdColorMap.LevelInclusion |
getLevelInclusion()
Gets how the levels are interpreted when retrieving values using
retrieveColor(double) . |
ILcdInterval |
getLevelInterval()
Returns the level interval.
|
int |
getMasterOpacity()
Returns the master opacity.
|
int |
hashCode() |
void |
insertColor(int aIndex,
Color aColor)
Inserts the color at the given index.
|
void |
insertLevel(int aIndex,
double aLevel)
Inserts the level at the given index.
|
boolean |
isGradient()
Returns true if the level count and color count are equal, false otherwise.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
removeAll()
Removes all colors and levels.
|
void |
removeColor(int aIndex)
Removes the color at the given index.
|
void |
removeLevel(int aIndex)
Removes the level at the given index.
|
void |
removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Removes the given
PropertyChangeListener . |
Color |
retrieveColor(double aLevel)
Retrieves the color at the given level.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setColor(int aIndex,
Color aColor)
Sets the color at the given index.
|
void |
setLevel(int aIndex,
double aLevel)
Sets the level at the given index.
|
void |
setLevelInclusion(TLcdColorMap.LevelInclusion aLevelInclusion)
Sets how the levels are interpreted when retrieving values using
retrieveColor(double) . |
void |
setLevelInterval(ILcdInterval aLevelInterval)
Sets the new level interval: the minimum and maximum values for the
levels.
|
void |
setMasterOpacity(int aMasterOpacity)
Sets the master opacity.
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
String |
toString() |
public TLcdColorMap()
TLcdColorMap
. The color map is initialized
with an interval [0, 10000], one level and two colors.public TLcdColorMap(ILcdInterval aLevelInterval, double[] aLevels, Color[] aColors)
TLcdColorMap
with the given levels and
colors.aLevelInterval
- The minimum and maximum allowed level value. The
aLevelInterval must not be modified after it is passed to this
constructor.aLevels
- The ordered levels. aLevels[i] <= aLevels[i+1] and
aLevelInterval.getMin() <= aLevels[i] <= aLevelInterval.getMax()aColors
- The associated colors for the levels. aLevels.length ==
aColors.length or aLevels.length == (aColors.length - 1)NullPointerException
- If any of the arguments is nullIllegalArgumentException
- If any or the arguments is invalid.public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.aTraceOn
- if true then all log messages are recorded for this
instance. If false, then only the informative, warning and
error log messages are recorded.public boolean isTraceOn()
true
if tracing is enabled for this class.public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
PropertyChangeListener
.aPropertyChangeListener
- The listener to be added.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
PropertyChangeListener
. Does nothing if the
listener was never added (or already removed).aPropertyChangeListener
- The listener to remove.addPropertyChangeListener(java.beans.PropertyChangeListener)
public int getMasterOpacity()
setMasterOpacity(int)
.public void setMasterOpacity(int aMasterOpacity)
aMasterOpacity
- The master opacity, between 0 (fully transparent) and 255 (fully opaque).retrieveColor(double)
public TLcdColorMap.LevelInclusion getLevelInclusion()
Gets how the levels are interpreted when retrieving values using retrieveColor(double)
.
TLcdColorMap.LevelInclusion.EXCLUDES_END_POINT
- [100, 200[
TLcdColorMap.LevelInclusion.INCLUDES_END_POINT
- ]100, 200]
public void setLevelInclusion(TLcdColorMap.LevelInclusion aLevelInclusion)
Sets how the levels are interpreted when retrieving values using retrieveColor(double)
.
TLcdColorMap.LevelInclusion.EXCLUDES_END_POINT
- [100, 200[
TLcdColorMap.LevelInclusion.INCLUDES_END_POINT
- ]100, 200]
aLevelInclusion
- the level inclusion.public ILcdInterval getLevelInterval()
setLevelInterval(com.luciad.util.ILcdInterval)
public void setLevelInterval(ILcdInterval aLevelInterval)
This method will fire a property change.
aLevelInterval
- The new level interval. aLevelInterval.getMin() <=
aLevels[i] <= aLevelInterval.getMax() for every i. The aLevelInterval
must not be modified after it is passed to this method.getLevelInterval()
public int getLevelCount()
public double getLevel(int aIndex)
aIndex
- The index for which to retrieve the level.setLevel(int, double)
public void setLevel(int aIndex, double aLevel)
getLevelInterval()
.This method will fire a "level" property change.
aIndex
- The index at which to set the level.aLevel
- The new level. getLevel( aIndex - 1 ) <= aLevel <=
getLevel( aIndex + 1 )Furthermore getLevelInterval().getMin() <= aLevel <= getLevelInterval().getMax()
getLevel(int)
public void insertLevel(int aIndex, double aLevel)
This method will fire a "levelCount" property change.
aIndex
- The index at which to insert the level. 0 <= aIndex <=
getLevelCount(). If aIndex == getLevelCount() the level is inserted at
the end.aLevel
- The level to insert. getLevel( aIndex - 1 ) <= aLevel <=
getLevel( aIndex )removeLevel(int)
public void removeLevel(int aIndex)
This method will fire a "levelCount" property change.
aIndex
- The index at which to remove the level.insertLevel(int, double)
public void insertColor(int aIndex, Color aColor)
This method will fire a "colorCount" property change.
aIndex
- The index at which to insert the color. 0 <= aIndex <=
getLevelCount(). If aIndex == getLevelCount() the color is inserted at
the end.aColor
- The color to insert.removeColor(int)
public void removeColor(int aIndex)
This method will fire a "colorCount" property change.
aIndex
- The index at which to remove the level.insertColor(int, java.awt.Color)
public void removeAll()
public int getColorCount()
public Color getColor(int aIndex)
aIndex
- The index to retrieve the color for.setColor(int, java.awt.Color)
public void setColor(int aIndex, Color aColor)
This method will fire a "color" property change.
aIndex
- The index to set the color at.aColor
- The color to set.getColor(int)
public boolean isGradient()
getColorCount()
,
getLevelCount()
public Color retrieveColor(double aLevel)
master opacity
and
level inclusion
settings are also respected.Also refer to the class comment.
aLevel
- The level to retrieve the color for.
getLevelInterval.getMin() <= aLevel <= getLevelInterval.getMax()isGradient()
,
setMasterOpacity(int)