Class AbstractColorMap
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns some level which is valid (that is, validLevel(defaultValue()) should always return true).intgetAlpha(double level) Returns the alpha value for a color for the given level.abstract ColorgetColor(double level) Returns a color for the given levelintgetRGB(double level) Returns the RGB values, plus alpha, for a color for the given level.booleanvalidLevel(double level) Returns true if a level is "valid" (it provides a meaningful color)
-
Constructor Details
-
AbstractColorMap
public AbstractColorMap()
-
-
Method Details
-
getColor
Description copied from interface:ColorMapReturns a color for the given level -
getRGB
public int getRGB(double level) Description copied from interface:ColorMapReturns the RGB values, plus alpha, for a color for the given level. The byte ordering should be in the same fashion that Color.getRGB() is provided. This could be simply written asinvalid input: '<'code return getColor(level).getRGB() ... however it's likely that this method could be written more efficiently than this.
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().
-
getAlpha
public int getAlpha(double level) Description copied from interface:ColorMapReturns the alpha value for a color for the given level. This could be simply written asreturn 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.
-
validLevel
public boolean validLevel(double level) Description copied from interface:ColorMapReturns true if a level is "valid" (it provides a meaningful color)- Specified by:
validLevelin interfaceColorMap
-
defaultValue
public double defaultValue()Description copied from interface:ColorMapReturns some level which is valid (that is, validLevel(defaultValue()) should always return true). This is commonly provided to give the user a level to replace an "invalid" level he's typed in.- Specified by:
defaultValuein interfaceColorMap
-