|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.util.gui.SimpleColorMap
public class SimpleColorMap
Maps numerical levels to colors using either a lookup table, color interpolation, or both. A simple implementation of the ColorMap interface.
You can customize the interpolation by overriding the filterLevel(double) method. This method receives a level value converted to between 0.0 and 1.0 inclusive, and is supposed to return a revised value between 0.0 and 1.0. For example, if you'd like to nudge colors up towards the maximum portion of the table, you could return the square root of the value you receive. The default simply returns the value itself.
The user can provide both a color table and an interpolation; in this case, the color table takes precedence over the interpolation in that region where the color table is relevant. You specify a color table with setColorTable(), and you specify an interpolation range with setLevels().
validLevel() is set to return true if the level range is between min-level and max-level, or if it's inside the color table range.
defaultValue() is set to return 0 if the color table exists, else min-level is provided.
Field Summary | |
---|---|
java.awt.Color[] |
colors
User-provided color table |
Constructor Summary | |
---|---|
SimpleColorMap()
Constructs a ColorMap that gradiates from 0.0 -> black to 1.0 -> white. |
|
SimpleColorMap(java.awt.Color[] colorTable)
Given an array of size n, constructs a ColorMap that maps integers from 0 to n-1 to the colors in the array. |
|
SimpleColorMap(java.awt.Color[] colorTable,
double minLevel,
double maxLevel,
java.awt.Color minColor,
java.awt.Color maxColor)
Given an array of size n, constructs a ColorMap that maps integers from 0 to n-1 to the colors in the array, and gradiates from minLevel -> minColor to maxLevel -> maxColor for certain other values. |
|
SimpleColorMap(double minLevel,
double maxLevel,
java.awt.Color minColor,
java.awt.Color maxColor)
Constructs a ColorMap that gradiates from minLevel -> minColor to maxLevel -> maxColor. |
Method Summary | |
---|---|
double |
defaultValue()
Returns some level which is valid (that is, validLevel(defaultValue()) should always return true). |
double |
filterLevel(double level)
|
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. |
java.awt.Color[] |
setColorTable(java.awt.Color[] colorTable)
Specifies that if a value (cast into an int) in the IntGrid2D or DoubleGrid2D falls in the range 0 ... |
void |
setLevels(double minLevel,
double maxLevel,
java.awt.Color minColor,
java.awt.Color maxColor)
Sets the color levels for the ValueGridPortrayal2D values for use by the default getColor(...) method. |
boolean |
validLevel(double value)
Returns true if a level is "valid" (it provides a meaningful color) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.awt.Color[] colors
Constructor Detail |
---|
public SimpleColorMap()
public SimpleColorMap(double minLevel, double maxLevel, java.awt.Color minColor, java.awt.Color maxColor)
public SimpleColorMap(java.awt.Color[] colorTable)
public SimpleColorMap(java.awt.Color[] colorTable, double minLevel, double maxLevel, java.awt.Color minColor, java.awt.Color maxColor)
Method Detail |
---|
public java.awt.Color[] setColorTable(java.awt.Color[] colorTable)
public double filterLevel(double level)
public void setLevels(double minLevel, double maxLevel, java.awt.Color minColor, java.awt.Color maxColor)
public java.awt.Color getColor(double level)
ColorMap
getColor
in interface ColorMap
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.
getAlpha
in interface ColorMap
public int getRGB(double level)
ColorMap
... however it's likely that this method could be written more efficiently than this.
public boolean validLevel(double value)
ColorMap
validLevel
in interface ColorMap
public double defaultValue()
ColorMap
defaultValue
in interface ColorMap
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |