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
-
Method Summary
Modifier and TypeMethodDescriptiondouble
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 Color
getColor
(double level) Returns a color for the given levelint
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)
-
Constructor Details
-
AbstractColorMap
public AbstractColorMap()
-
-
Method Details
-
getColor
Description copied from interface:ColorMap
Returns a color for the given level -
getRGB
public int getRGB(double level) Description copied from interface:ColorMap
Returns 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:ColorMap
Returns 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:ColorMap
Returns true if a level is "valid" (it provides a meaningful color)- Specified by:
validLevel
in interfaceColorMap
-
defaultValue
public double defaultValue()Description copied from interface:ColorMap
Returns 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:
defaultValue
in interfaceColorMap
-