Class MaskOverlay

java.lang.Object
noaa.coastwatch.render.EarthDataOverlay
noaa.coastwatch.render.MaskOverlay
All Implemented Interfaces:
Serializable, Cloneable, Comparable, TransparentOverlay
Direct Known Subclasses:
BitmaskOverlay, ExpressionMaskOverlay, JavaExpressionMaskOverlay

public abstract class MaskOverlay extends EarthDataOverlay implements TransparentOverlay
A MaskOverlay annotates a data view using some extra information to form a mask of opaque and transparent pixels at each data location. A MaskOverlay would most often be used to mask certain parts of the data view, such as land or cloud.
Since:
3.2.1
Author:
Peter Hollemans
See Also:
  • Constructor Details

    • MaskOverlay

      public MaskOverlay(Color color)
      Constructs a new mask overlay. The layer number is initialized to 0.
      Parameters:
      color - the overlay color.
  • Method Details

    • getInverse

      public boolean getInverse()
      Gets the inverse flag.
    • setInverse

      public void setInverse(boolean flag)
      Sets the inverse flag. When true, the sense of the mask is inverted and pixels that would normally be masked are not masked and vice-versa. By default the inverse flag is set to false; this is the normal mask behaviour.
      Parameters:
      flag - the inverse flag value.
    • setColor

      public void setColor(Color color)
      Overrides the parent method to set the mask color by updating the index color model as well.
      Overrides:
      setColor in class EarthDataOverlay
      Parameters:
      color - the new opaque overlay color.
    • setTransparency

      public void setTransparency(int percent)
      Overrides the parent method to set the mask transparency by updating the index color model as well.
      Overrides:
      setTransparency in class EarthDataOverlay
      Parameters:
      percent - the transparency level in percent from 0 to 100. A transparency of 0% is completely opaque, and 100% is completely transparent.
    • createColorModel

      public static IndexColorModel createColorModel(Color color, boolean inverse)
      Creates a new two-color indexed color model with one color as the transparent color and the other color as the specified color. Which is which depends on the inverse flag. If inverse is false, the color mapping is 0 = transparent and 1 = color, otherwise it is 0 = color and 1 = transparent.
      Parameters:
      color - the color to use for the non-transparent color.
      inverse - the inverse flag, true to invert the transparent and non-transparent colors.
    • prepareData

      protected void prepareData()
      Prepares any data structures that may be necessary for computing the mask values prior to running prepare(java.awt.Graphics2D, noaa.coastwatch.render.EarthDataView). This should be overrideen in the child class if anything needs to be done.
    • isMasked

      public abstract boolean isMasked(DataLocation loc, boolean isNavigated)
      Determines if the data location should be masked.
      Parameters:
      loc - the data location in question.
      isNavigated - the navigated flag, true if the data location is pre-navigated
      Returns:
      true if the data should be masked at the location or false if not.
    • isCompatible

      protected abstract boolean isCompatible(EarthDataView view)
      Determines if the data view is compatible with this overlay. If so, then the precomputed view coordinate cache tables will be used to determine data locations for each view point. If not, then each view point is transformed individually using the view's image transform.
      Parameters:
      view - the data view in question.
      Returns:
      true if the view has compatible data coordinate caches for the data used to create the mask values in the isMasked(noaa.coastwatch.util.DataLocation, boolean) method, or false if not.
    • prepare

      protected void prepare(Graphics2D g, EarthDataView view)
      Description copied from class: EarthDataOverlay
      Prepares the overlay graphics prior to drawing.
      Specified by:
      prepare in class EarthDataOverlay
      Parameters:
      g - the graphics object for drawing.
      view - the earth data view.
    • draw

      protected void draw(Graphics2D g, EarthDataView view)
      Description copied from class: EarthDataOverlay
      Draws the overlay graphics.
      Specified by:
      draw in class EarthDataOverlay
      Parameters:
      g - the graphics object for drawing.
      view - the earth data view.
    • invalidate

      public void invalidate()
      Invalidates the overlay. This causes the mask graphics to be completely reconstructed upon the next call to EarthDataOverlay.render(java.awt.Graphics2D, noaa.coastwatch.render.EarthDataView).
      Overrides:
      invalidate in class EarthDataOverlay