Class EarthDataOverlay

java.lang.Object
noaa.coastwatch.render.EarthDataOverlay
All Implemented Interfaces:
Serializable, Cloneable, Comparable
Direct Known Subclasses:
LineOverlay, MaskOverlay, MultilayerBitmaskOverlay, MultiPointFeatureOverlay, TextOverlay

public abstract class EarthDataOverlay extends Object implements Comparable, Cloneable, Serializable
An earth data overlay specifies information used for the annotation of an earth data view, for example grid lines, coastlines, symbols, text, and so on. All overlays have a color, transparency, layer number, visibility flag, and name. The layer number may be used by rendering software to determine the order for rendering multiple overlays. A lower layer number indicates that the overlay should be rendered first. The visibility flag may be used to temporarily hide an overlay from the rendered output. The overlay name may be used to reference the overlay in a list. This class implements Cloneable to provide a simple shallow copy of the object. If child classes have any deep mutable data structures such as lists, they should override the clone() method.
Since:
3.1.0
Author:
Peter Hollemans
See Also:
  • Field Details

    • lastTrans

      protected transient EarthImageTransform lastTrans
      The last earth image transform used for rendering.
    • prepared

      protected transient boolean prepared
      The prepared flag, true if this overlay is ready to be drawn. This flag may be used by child classes to indicate that changes have occurred that require the child is be re-prepared for drawing.
    • alpha

      protected int alpha
      The overlay alpha value.
  • Constructor Details

    • EarthDataOverlay

      protected EarthDataOverlay(Color color, int layer)
      Constructs a new data overlay.
      Parameters:
      color - the overlay color.
      layer - the overlay layer number.
    • EarthDataOverlay

      protected EarthDataOverlay(Color color)
      Constructs a new data overlay. The layer number is initialized to 0.
      Parameters:
      color - the overlay color.
  • Method Details

    • setColor

      public void setColor(Color color)
      Sets the overlay color. Only opaque colors are allowed. If the color has an alpha component, the alpha value is set to 255 and the overlay transparency is set using the new alpha value. This behaviour may be changed in the future to ignore the color's alpha value entirely -- overlay transparency should really be set by calling setTransparency(int).
      Parameters:
      color - the new opaque overlay color.
    • getColor

      public Color getColor()
      Gets the overlay color. The overlay color is always opaque, even if a call to setColor(java.awt.Color) specifies a color with an alpha component. The overlay transparency may be accessed through setTransparency(int) or getTransparency().
      Returns:
      the overlay color.
    • getColorWithAlpha

      public Color getColorWithAlpha()
      Gets the overlay color with alpha component.
    • setLayer

      public void setLayer(int layer)
      Sets the overlay layer.
    • getLayer

      public int getLayer()
      Gets the overlay layer.
    • setName

      public void setName(String name)
      Sets the overlay name.
    • getName

      public String getName()
      Gets the overlay name.
    • setVisible

      public void setVisible(boolean flag)
      Sets the overlay visibility flag.
    • getVisible

      public boolean getVisible()
      Gets the overlay visibility flag.
    • compareTo

      public int compareTo(Object o) throws ClassCastException
      Specified by:
      compareTo in interface Comparable
      Throws:
      ClassCastException
    • isPrepared

      public boolean isPrepared(EarthDataView view)
      Gets the status of the overlay preparation. If the overlay is prepared, a render call will return after almost no delay. If not, the render may require time to complete due to loading data from disk or cache, converting earth locations to screen points, and so on.
      Parameters:
      view - the earth data view for the next rendering operation.
    • needsPrepare

      protected boolean needsPrepare()
      Determines if this overlay class needs to be prepared for rendering. This method returns true unless overridden in the child class.
      Returns:
      true if this overlay class needs a preparation stage, or false if not.
    • render

      public void render(Graphics2D g, EarthDataView view)
      Renders the overlay graphics.
      Parameters:
      g - the graphics object for drawing.
      view - the earth data view.
    • prepare

      protected abstract void prepare(Graphics2D g, EarthDataView view)
      Prepares the overlay graphics prior to drawing.
      Parameters:
      g - the graphics object for drawing.
      view - the earth data view.
    • draw

      protected abstract void draw(Graphics2D g, EarthDataView view)
      Draws the overlay graphics.
      Parameters:
      g - the graphics object for drawing.
      view - the earth data view.
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • invalidate

      public void invalidate()
      Invalidates the overlay. This causes the overlay data and graphics to be completely reconstructed upon the next call to render(). This method does nothing unless overridden in the child class.
    • setTransparency

      public void setTransparency(int trans)
      Sets the overlay transparency.
      Parameters:
      trans - the transparency level in percent from 0 to 100. A transparency of 0% is completely opaque, and 100% is completely transparent.
    • getTransparency

      public int getTransparency()
      Gets the overlay transparency.
      Returns:
      the transparency in the range 0 to 100 percent.
    • getAlphaVersion

      public Color getAlphaVersion(Color color)
      Gets a version of the color with the overlay transparency applied.
      Parameters:
      color - the color to convert.
      Returns:
      a new version of the color with the alpha component set to the transparency of the overlay.
    • getColors

      public List getColors()
      Gets a list of all the colors used by this overlay.
      Returns:
      the list of colors.
    • hasMetadata

      public boolean hasMetadata()
      Gets the metadata flag, true if the overlay has metadata associated with its rendered graphics, false if not. If true, the getMetadataAtPoint(java.awt.Point) may be used. By default this method returns false unless overridden by the child class.
      Returns:
      the metadata flag, true if supported or false if not.
      See Also:
    • getMetadataAtPoint

      public Map<String,Object> getMetadataAtPoint(Point point)
      Gets the metadata at the specified point.
      Parameters:
      point - the point to get metadata for.
      Returns:
      the metadata at the specified point, or null if none is available.
      Throws:
      UnsupportedOperationException - if this class doesn't support metadata.