sim.util.gui
Interface ColorMap

All Known Implementing Classes:
SimpleColorMap

public interface ColorMap

ColorMap is a interface for mapping numerical values to colors. The easiest way to implement getRGB(level) is simply with getColor(level).getRGB(). validLevel indicates whether the numerical value is within a range that seems "reasonable" for coding into colors -- however ColorMap should provide *some* feasible color for *any* given value, including NaN. defaultValue() provides a default numerical value within the "reasonable" range -- often the minimum value. It must be the case that validLevel(defaultValue()) == true.


Method Summary
 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.
 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)
 

Method Detail

getColor

public java.awt.Color getColor(double level)
Returns a color for the given level


getRGB

public int getRGB(double level)
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.


getAlpha

public int getAlpha(double level)
Returns the alpha value for a color for the given level. This could be simply written as

return getRGB(level) >>> 24 ;

...or it could be written as:

return getColor(level).getAlpha()

...however it's likely that it thie method could be written more efficiently than either of these.


validLevel

public boolean validLevel(double level)
Returns true if a level is "valid" (it provides a meaningful color)


defaultValue

public double defaultValue()
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.