Package noaa.coastwatch.render
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
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:
-
Field Summary
Fields inherited from class noaa.coastwatch.render.EarthDataOverlay
alpha, lastTrans, prepared
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.protected void
draw
(Graphics2D g, EarthDataView view) Draws the overlay graphics.boolean
Gets the inverse flag.void
Invalidates the overlay.protected abstract boolean
isCompatible
(EarthDataView view) Determines if the data view is compatible with this overlay.abstract boolean
isMasked
(DataLocation loc, boolean isNavigated) Determines if the data location should be masked.protected void
prepare
(Graphics2D g, EarthDataView view) Prepares the overlay graphics prior to drawing.protected void
Prepares any data structures that may be necessary for computing the mask values prior to runningprepare(java.awt.Graphics2D, noaa.coastwatch.render.EarthDataView)
.void
Overrides the parent method to set the mask color by updating the index color model as well.void
setInverse
(boolean flag) Sets the inverse flag.void
setTransparency
(int percent) Overrides the parent method to set the mask transparency by updating the index color model as well.Methods inherited from class noaa.coastwatch.render.EarthDataOverlay
clone, compareTo, getAlphaVersion, getColor, getColors, getColorWithAlpha, getLayer, getMetadataAtPoint, getName, getTransparency, getVisible, hasMetadata, isPrepared, needsPrepare, render, setLayer, setName, setVisible, toString
-
Constructor Details
-
MaskOverlay
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
Overrides the parent method to set the mask color by updating the index color model as well.- Overrides:
setColor
in classEarthDataOverlay
- 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 classEarthDataOverlay
- Parameters:
percent
- the transparency level in percent from 0 to 100. A transparency of 0% is completely opaque, and 100% is completely transparent.
-
createColorModel
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 runningprepare(java.awt.Graphics2D, noaa.coastwatch.render.EarthDataView)
. This should be overrideen in the child class if anything needs to be done. -
isMasked
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
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
Description copied from class:EarthDataOverlay
Prepares the overlay graphics prior to drawing.- Specified by:
prepare
in classEarthDataOverlay
- Parameters:
g
- the graphics object for drawing.view
- the earth data view.
-
draw
Description copied from class:EarthDataOverlay
Draws the overlay graphics.- Specified by:
draw
in classEarthDataOverlay
- 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 toEarthDataOverlay.render(java.awt.Graphics2D, noaa.coastwatch.render.EarthDataView)
.- Overrides:
invalidate
in classEarthDataOverlay
-