Package noaa.coastwatch.render
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 Summary
Modifier and TypeFieldDescriptionprotected int
The overlay alpha value.protected EarthImageTransform
The last earth image transform used for rendering.protected boolean
The prepared flag, true if this overlay is ready to be drawn. -
Constructor Summary
ModifierConstructorDescriptionprotected
EarthDataOverlay
(Color color) Constructs a new data overlay.protected
EarthDataOverlay
(Color color, int layer) Constructs a new data overlay. -
Method Summary
Modifier and TypeMethodDescriptionclone()
int
protected abstract void
draw
(Graphics2D g, EarthDataView view) Draws the overlay graphics.getAlphaVersion
(Color color) Gets a version of the color with the overlay transparency applied.getColor()
Gets the overlay color.Gets a list of all the colors used by this overlay.Gets the overlay color with alpha component.int
getLayer()
Gets the overlay layer.getMetadataAtPoint
(Point point) Gets the metadata at the specified point.getName()
Gets the overlay name.int
Gets the overlay transparency.boolean
Gets the overlay visibility flag.boolean
Gets the metadata flag, true if the overlay has metadata associated with its rendered graphics, false if not.void
Invalidates the overlay.boolean
isPrepared
(EarthDataView view) Gets the status of the overlay preparation.protected boolean
Determines if this overlay class needs to be prepared for rendering.protected abstract void
prepare
(Graphics2D g, EarthDataView view) Prepares the overlay graphics prior to drawing.void
render
(Graphics2D g, EarthDataView view) Renders the overlay graphics.void
Sets the overlay color.void
setLayer
(int layer) Sets the overlay layer.void
Sets the overlay name.void
setTransparency
(int trans) Sets the overlay transparency.void
setVisible
(boolean flag) Sets the overlay visibility flag.toString()
-
Field Details
-
lastTrans
The last earth image transform used for rendering. -
prepared
protected transient boolean preparedThe 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 alphaThe overlay alpha value.
-
-
Constructor Details
-
EarthDataOverlay
Constructs a new data overlay.- Parameters:
color
- the overlay color.layer
- the overlay layer number.
-
EarthDataOverlay
Constructs a new data overlay. The layer number is initialized to 0.- Parameters:
color
- the overlay color.
-
-
Method Details
-
setColor
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 callingsetTransparency(int)
.- Parameters:
color
- the new opaque overlay color.
-
getColor
Gets the overlay color. The overlay color is always opaque, even if a call tosetColor(java.awt.Color)
specifies a color with an alpha component. The overlay transparency may be accessed throughsetTransparency(int)
orgetTransparency()
.- Returns:
- the overlay 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
Sets the overlay name. -
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
- Specified by:
compareTo
in interfaceComparable
- Throws:
ClassCastException
-
isPrepared
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
Renders the overlay graphics.- Parameters:
g
- the graphics object for drawing.view
- the earth data view.
-
prepare
Prepares the overlay graphics prior to drawing.- Parameters:
g
- the graphics object for drawing.view
- the earth data view.
-
draw
Draws the overlay graphics.- Parameters:
g
- the graphics object for drawing.view
- the earth data view.
-
clone
-
invalidate
public void invalidate()Invalidates the overlay. This causes the overlay data and graphics to be completely reconstructed upon the next call torender()
. 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
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
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, thegetMetadataAtPoint(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
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.
-
toString
-