Class ColorEnhancement

java.lang.Object
noaa.coastwatch.render.EarthDataView
noaa.coastwatch.render.ColorEnhancement
All Implemented Interfaces:
Cloneable, Renderable

public class ColorEnhancement extends EarthDataView
A color enhancement is an earth data view that creates an image based on a grid variable, color palette, and enhancement function. The variable data is mapped to a normalized range of [0..1] using the enhancement function, then the color palette is applied. For example, if the data is visible surface albedo in percent, the palette is a black-to-white grayscale ramp, and the enhancement is a linear enhancement set to map 0.0 to 0 and 30.0 to 1, then the color enhancement will produce an image that has close to black colors for low albedo values and close to white for albedo values near 30 percent. Values falling below the [0..1] range of the enhancement function are mapped to the missing color, by default black. Values falling above the [0..1] range are mapped to the last palette color.
Since:
3.1.1
Author:
Peter Hollemans
  • Constructor Details

  • Method Details

    • setVarName

      public void setVarName(String varName)
      Sets the variable name to display in the legend for this view.
      Parameters:
      varName - the variable name or null to use the grid variable name.
    • getColors

      public int getColors()
      Gets the number of colors in color model.
      See Also:
    • setColors

      public void setColors(int colors)
      Sets the number of colors in the color model.
      Parameters:
      colors - the number of colors in the model, up to 256 which is the default. The actual number of colors for data will be one less than the number of colors in the model, and the last color will be used for missing data.
    • getColorModel

      public IndexColorModel getColorModel()
      Gets the index color model used for images.
    • getGrid

      public Grid getGrid()
      Gets the data grid variable.
    • getPalette

      public Palette getPalette()
      Gets the enhancement color palette.
    • getFunction

      public EnhancementFunction getFunction()
      Gets the enhancement function.
    • setGrid

      public void setGrid(Grid grid)
      Sets the data grid variable.
    • setPalette

      public void setPalette(Palette pal)
      Sets the enhancement color palette.
    • setMissingColor

      public void setMissingColor(Color missingColor)
      Sets the missing value color.
    • setAdjustingFunction

      public void setAdjustingFunction(EnhancementFunction adjFunc)
      Sets an adjusting function. This may be used when the function is being adjusted interactively, and the view should reflect the new function as well as possible. The view image data is not recomputed, rather the color index model is adjusted to approximate what the view would look like with the new function. The next call to setFunction(noaa.coastwatch.render.EnhancementFunction) will set the view back to normal.
      Parameters:
      adjFunc - the adjusting function.
    • setFunction

      public void setFunction(EnhancementFunction func)
      Sets the enhancement function.
    • prepare

      protected void prepare(Graphics2D g)
      Description copied from class: EarthDataView
      Prepares this view for rendering using the specified graphics object. This method is called when any changes have occurred that require the view to be completely reconstructed, such as a change in view size or data window.
      Specified by:
      prepare in class EarthDataView
    • getLegend

      public Legend getLegend()
      Gets a data color scale legend for annotation of this color enhancement.
      Overrides:
      getLegend in class EarthDataView
      Returns:
      the data color scale legend. The legend is constructed with the default font and colors.
      See Also:
    • normalize

      public void normalize(double units)
      Normalizes the enhancement function for this view using the visible grid value statistics.
      Parameters:
      units - the number of standard deviation units above and below the mean for the data range.
    • saveSettings

      public ColorEnhancementSettings saveSettings()
      Saves and returns the current settings.
    • restoreSettings

      public void restoreSettings(ColorEnhancementSettings settings)
      Restores the previously saved settings.
      Parameters:
      settings - the settings to restore. Only the palette and function are used -- the variable name is igored.
    • clone

      public Object clone()
      Overrides the parent class to null out the cached legend.
      Overrides:
      clone in class EarthDataView