Package noaa.coastwatch.render
Class DataColorScale
java.lang.Object
noaa.coastwatch.render.Legend
noaa.coastwatch.render.DataColorScale
A color scale annotates a data enhancement plot with a scale of
colors from a color palette and tick marks at regular intervals for
the data values. The data variable name and units are also printed
along side the scale.
- Since:
- 3.1.1
- Author:
- Peter Hollemans
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The axis constatn for a horizontal legend.static final int
The axis constatn for a vertical legend.Fields inherited from class noaa.coastwatch.render.Legend
back, DEFAULT_STROKE, font, fore, preferredSize, SPACE_SIZE
-
Constructor Summary
ConstructorDescriptionDataColorScale
(EnhancementFunction function, Palette palette, String name, String units) Creates a data color scale with the specified parameters.DataColorScale
(EnhancementFunction function, Palette palette, String name, String units, Dimension dim, Font font, Color fore, Color back) Creates a data color scale from the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionint
static double
getLinearTickInterval
(double min, double max, int desired) Gets an appropriate tick mark interval given the tick specifications.static String[]
getLinearTickLabels
(double min, double max, int desired) Gets an appropriate set of tick mark labels given the tick specifications.static String[]
getLogTickLabels
(double min, double max) Gets an appropriate set of tick mark labels given the tick specifications.Gets the actual required legend size.void
render
(Graphics2D g, int x, int y) Renders the legend at the specified coordinates in the graphics device.void
setLegendAxis
(int axis) void
setTickLabels
(String[] labels) Sets the tick labels.Methods inherited from class noaa.coastwatch.render.Legend
setBackground, setFont, setForeground, setPreferredSize
-
Field Details
-
HORIZONTAL_AXIS
public static final int HORIZONTAL_AXISThe axis constatn for a horizontal legend.- See Also:
-
VERTICAL_AXIS
public static final int VERTICAL_AXISThe axis constatn for a vertical legend.- See Also:
-
-
Constructor Details
-
DataColorScale
Creates a data color scale with the specified parameters. The font is set to the default font face, plain style, 12 point, the preferred size to none, the foreground color is set to black, and the background color to none.- Parameters:
function
- the enhancement function for translating between data values and normalized values. The scale is drawn for normalized values in the range [0..1].palette
- the palette to use for scale colors.name
- the data variable name.units
- the data variable units.
-
DataColorScale
public DataColorScale(EnhancementFunction function, Palette palette, String name, String units, Dimension dim, Font font, Color fore, Color back) Creates a data color scale from the specified parameters.- Parameters:
function
- the enhancement function for translating between data values and normalized values. The scale is drawn for normalized values in the range [0..1].palette
- the palette to use for scale colors.name
- the data variable name.units
- the data variable units.dim
- the preferred scale dimensions, or null for none.font
- the font for variable name, units, and scale values, or null for the default font face, plain style, 12 point.fore
- the foreground color for legend lines and annotations.back
- the background color, or null for none.
-
-
Method Details
-
setLegendAxis
public void setLegendAxis(int axis) - Since:
- 3.8.1
-
getLegendAxis
public int getLegendAxis()- Since:
- 3.8.1
-
setTickLabels
Sets the tick labels.- Parameters:
labels
- the new tick labels to use. Each label is a number formatted to a string value.
-
render
Description copied from class:Legend
Renders the legend at the specified coordinates in the graphics device. -
getSize
Description copied from class:Legend
Gets the actual required legend size. -
getLogTickLabels
Gets an appropriate set of tick mark labels given the tick specifications. This method works well for log enhancement scales.- Parameters:
min
- the data value minimum.max
- the data value maximum.- Returns:
- an array of formatted numbers as strings for the tick mark labels.
-
getLinearTickInterval
public static double getLinearTickInterval(double min, double max, int desired) Gets an appropriate tick mark interval given the tick specifications. This method works well for linear enhancement scales.- Parameters:
min
- the data value minimum.max
- the data value maximum.desired
- the approximate number of desired ticks.- Returns:
- the tick interval.
-
getLinearTickLabels
Gets an appropriate set of tick mark labels given the tick specifications. This method works well for linear enhancement scales.- Parameters:
min
- the data value minimum.max
- the data value maximum.desired
- the approximate number of desired ticks.- Returns:
- an array of formatted numbers as strings for the tick mark labels.
-