Package ucar.nc2.ui.grid
Class ColorScale
- java.lang.Object
-
- ucar.nc2.ui.grid.ColorScale
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class ColorScale extends Object implements Cloneable, Serializable
A ColorScale is used for false-color data mapping. It contains an array of java.awt.Color, along with an assignment of a data interval to each Color. ColorScale.Panel handles the displaying of a ColorScale. It also works with ColorScaleManager to allow editing and defining new ColorScales.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ColorScale.MinMaxType
static class
ColorScale.Panel
-
Constructor Summary
Constructors Constructor Description ColorScale()
ColorScale(String name)
ColorScale(String name, Color[] c)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(PropertyChangeListener l)
add action event listenerObject
clone()
Color
getColor(int i)
double
getEdge(int index)
Get the edge of the ith interval.int
getHistMax()
This is an optimization for counting the number of colors in each interval.int
getIndexFromValue(double value)
Get which color interval this value lies in.int
getIndexFromValueLog(double value)
Color
getMissingDataColor()
String
getName()
Get the colorscale name.int
getNumColors()
Get the number of colors in the colorscale.void
removePropertyChangeListener(PropertyChangeListener l)
remove action event listenervoid
resetHist()
reset the histogram.void
setGeoGrid(IsMissingEvaluator gg)
void
setMinMax(double min, double max)
Set the data min/max interval.void
setName(String name)
Set the colorscale name.void
setNumColors(int n)
Set the number of colors in the colorscale.String
toString()
-
-
-
Field Detail
-
VERTICAL
public static final int VERTICAL
- See Also:
- Constant Field Values
-
HORIZONTAL
public static final int HORIZONTAL
- See Also:
- Constant Field Values
-
redHot
public static final Color[] redHot
-
redBlue
public static final Color[] redBlue
-
hueBands
public static final Color[] hueBands
-
spectrum2
public static final Color[] spectrum2
-
-
Method Detail
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l)
add action event listener
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l)
remove action event listener
-
getName
public String getName()
Get the colorscale name.
-
setName
public void setName(String name)
Set the colorscale name.
-
getNumColors
public int getNumColors()
Get the number of colors in the colorscale.
-
setNumColors
public void setNumColors(int n)
Set the number of colors in the colorscale.
-
getColor
public Color getColor(int i)
-
getEdge
public double getEdge(int index)
Get the edge of the ith interval. see @link setMinMax
-
setGeoGrid
public void setGeoGrid(IsMissingEvaluator gg)
-
getMissingDataColor
public Color getMissingDataColor()
-
getIndexFromValue
public int getIndexFromValue(double value)
Get which color interval this value lies in.- Parameters:
value
- minimum data value.- Returns:
- the color index.
-
getIndexFromValueLog
public int getIndexFromValueLog(double value)
-
setMinMax
public void setMinMax(double min, double max)
Set the data min/max interval. The color intervals are set based on this. A PropertyChangeEvent is sent when this is called. Currently the intervals are calculated in the following way (where incr = (max-min)/(n-2)) :edge data interval 0 min value <= min 1 min+incr min <= value < min + incr 2 min+2*incr min+incr <= value < min+2*incr ith min+i*incr min+(i-1)*incr <= value < min+i*incr n-2 max min+(n-3)*incr <= value < max n-1 max max < value n value = missingDataValue
- Parameters:
min
- minimum data valuemax
- maximum data value
-
getHistMax
public int getHistMax()
This is an optimization for counting the number of colors in each interval. the histpogram is populated by calls to getIndexFromValue().- Returns:
- the index with the maximum histogram count.
-
resetHist
public void resetHist()
reset the histogram.
-
-