public abstract class MaskOverlay extends EarthDataOverlay implements TransparentOverlay
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.alpha, lastTrans, prepared
Constructor and Description |
---|
MaskOverlay(java.awt.Color color)
Constructs a new mask overlay.
|
Modifier and Type | Method and Description |
---|---|
static java.awt.image.IndexColorModel |
createColorModel(java.awt.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(java.awt.Graphics2D g,
EarthDataView view)
Draws the overlay graphics.
|
boolean |
getInverse()
Gets the inverse flag.
|
void |
invalidate()
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(java.awt.Graphics2D g,
EarthDataView view)
Prepares the overlay graphics prior to drawing.
|
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) . |
void |
setColor(java.awt.Color color)
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.
|
clone, compareTo, getAlphaVersion, getColor, getColors, getColorWithAlpha, getLayer, getMetadataAtPoint, getName, getTransparency, getVisible, hasMetadata, isPrepared, needsPrepare, render, setLayer, setName, setVisible
public MaskOverlay(java.awt.Color color)
color
- the overlay color.public boolean getInverse()
public void setInverse(boolean flag)
flag
- the inverse flag value.public void setColor(java.awt.Color color)
setColor
in class EarthDataOverlay
color
- the new opaque overlay color.public void setTransparency(int percent)
setTransparency
in class EarthDataOverlay
percent
- the transparency level in percent from 0 to 100. A
transparency of 0% is completely opaque, and 100% is completely
transparent.public static java.awt.image.IndexColorModel createColorModel(java.awt.Color color, boolean inverse)
color
- the color to use for the non-transparent color.inverse
- the inverse flag, true to invert the transparent
and non-transparent colors.protected void prepareData()
prepare(java.awt.Graphics2D, noaa.coastwatch.render.EarthDataView)
.
This should be overrideen in the child class if anything
needs to be done.public abstract boolean isMasked(DataLocation loc, boolean isNavigated)
loc
- the data location in question.isNavigated
- the navigated flag, true if the data
location is pre-navigatedprotected abstract boolean isCompatible(EarthDataView view)
view
- the data view in question.isMasked(noaa.coastwatch.util.DataLocation, boolean)
method, or false if not.protected void prepare(java.awt.Graphics2D g, EarthDataView view)
EarthDataOverlay
prepare
in class EarthDataOverlay
g
- the graphics object for drawing.view
- the earth data view.protected void draw(java.awt.Graphics2D g, EarthDataView view)
EarthDataOverlay
draw
in class EarthDataOverlay
g
- the graphics object for drawing.view
- the earth data view.public void invalidate()
EarthDataOverlay.render(java.awt.Graphics2D, noaa.coastwatch.render.EarthDataView)
.invalidate
in class EarthDataOverlay