Package sim.util.gui
Class CompositeColorMap
java.lang.Object
sim.util.gui.CompositeColorMap
- All Implemented Interfaces:
ColorMap
CompositeColorMap is a ColorMap which consists of an array of ColorMaps.
In response to a color request, it queries each of the maps in turn until
one of them indicates that the value is a valid level, at which point it
gets the color from that map. If none of them think the value is valid, then
the default value (and color) is used from the final map.
This is a simple way of defining multiple gradients from different colors in the same space (such as red->green->blue->white->black)
-
Constructor Summary
ConstructorsConstructorDescriptionCompositeColorMap(ColorMap[] maps) Builds a CompositeColorMap with an arbitrary number (> 0) of subsidiary mapsCompositeColorMap(ColorMap map1, ColorMap map2) Builds a CompositeColorMap with two subsidiary mapsCompositeColorMap(ColorMap map1, ColorMap map2, ColorMap map3) Builds a CompositeColorMap with three subsidiary mapsCompositeColorMap(ColorMap map1, ColorMap map2, ColorMap map3, ColorMap map4) Builds a CompositeColorMap with four subsidiary maps -
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.getColor(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
-
CompositeColorMap
Builds a CompositeColorMap with two subsidiary maps -
CompositeColorMap
Builds a CompositeColorMap with three subsidiary maps -
CompositeColorMap
Builds a CompositeColorMap with four subsidiary maps -
CompositeColorMap
Builds a CompositeColorMap with an arbitrary number (> 0) of subsidiary maps
-
-
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
-