Class DataColorScale

java.lang.Object
noaa.coastwatch.render.Legend
noaa.coastwatch.render.DataColorScale

public class DataColorScale extends Legend
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 Details

    • HORIZONTAL_AXIS

      public static final int HORIZONTAL_AXIS
      The axis constatn for a horizontal legend.
      See Also:
    • VERTICAL_AXIS

      public static final int VERTICAL_AXIS
      The axis constatn for a vertical legend.
      See Also:
  • Constructor Details

    • DataColorScale

      public DataColorScale(EnhancementFunction function, Palette palette, String name, String units)
      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

      public void setTickLabels(String[] labels)
      Sets the tick labels.
      Parameters:
      labels - the new tick labels to use. Each label is a number formatted to a string value.
    • render

      public void render(Graphics2D g, int x, int y)
      Description copied from class: Legend
      Renders the legend at the specified coordinates in the graphics device.
      Specified by:
      render in class Legend
      Parameters:
      g - the graphics device for rendering.
      x - the x coordinate of the top-left corner.
      y - the y coordinate of the top-left corner.
    • getSize

      public Dimension getSize(Graphics2D g)
      Description copied from class: Legend
      Gets the actual required legend size.
      Specified by:
      getSize in class Legend
      Parameters:
      g - the graphics device that the legend will be rendered on.
    • getLogTickLabels

      public static String[] getLogTickLabels(double min, double max)
      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

      public static String[] getLinearTickLabels(double min, double max, int desired)
      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.