public abstract class AbstractColorMap extends java.lang.Object implements ColorMap
This class is intended to make it easy to implement a ColorMap which responds to any numerical value to provide a Color: you only need to implement the obvious method, getColor(...). However it's not particularly efficient, since the other methods call getColor(...), then extract the RGBA values out of the
Constructor and Description |
---|
AbstractColorMap() |
Modifier and Type | Method and Description |
---|---|
double |
defaultValue()
Returns some level which is valid (that is, validLevel(defaultValue()) should
always return true).
|
int |
getAlpha(double level)
Returns the alpha value for a color for the given level.
|
abstract java.awt.Color |
getColor(double level)
Returns a color for the given level
|
int |
getRGB(double level)
Returns the RGB values, plus alpha, for a color for the given level.
|
boolean |
validLevel(double level)
Returns true if a level is "valid" (it provides a meaningful color)
|
public abstract java.awt.Color getColor(double level)
ColorMap
public int getRGB(double level)
ColorMap
Why isn't this called getRGBA(...)? Because for some reason the underlying Color
method is likewise getRGB(), even though it ought to be called getRGBA().
... however it's likely that this method could be written more efficiently than this.
public int getAlpha(double level)
ColorMap
return getRGB(level) >>> 24 ;
...or it could be written as:
return getColor(level).getAlpha()
...however it's likely that it this method could be written more efficiently than either of these.
public boolean validLevel(double level)
ColorMap
validLevel
in interface ColorMap
public double defaultValue()
ColorMap
defaultValue
in interface ColorMap