Package noaa.coastwatch.render
Class LineOverlay
java.lang.Object
noaa.coastwatch.render.EarthDataOverlay
noaa.coastwatch.render.LineOverlay
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable
- Direct Known Subclasses:
LabeledLineOverlay
,LineFeatureOverlay
,PoliticalOverlay
,PolygonOverlay
,ShapeOverlay
,SurveyOverlay
,TopographyOverlay
A vector overlay annotes a data view with vector-specified lines and shapes. The vector overlay adds the concept of a stroke to the parent class.
An implementation note: The normal BasicStroke
object
that would be used to define a stroke for vector overlays is not
serializable. So we add some special serialization methods here to
handle saving and restoring stroke objects. The alternative is to
create a new serializable stroke class, which may be required if
there are other classes that use a stroke and need serialization.
For now, we keep it simple.
- Since:
- 3.1.1
- Author:
- Peter Hollemans
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
The shadow rendering flag, true if we are rendering a shadow.Fields inherited from class noaa.coastwatch.render.EarthDataOverlay
alpha, lastTrans, prepared
-
Constructor Summary
ModifierConstructorDescriptionprotected
LineOverlay
(Color color) Constructs a new vector overlay.protected
LineOverlay
(Color color, int layer, Stroke stroke) Constructs a new vector overlay. -
Method Summary
Modifier and TypeMethodDescriptionstatic Line2D
clip
(Line2D line, Rectangle2D rect) Clips the line segment to the specified rectangle.protected void
drawShadow
(Graphics2D g, EarthDataView view) Draws a drop shadow version of this overlay.boolean
Gets the drop shadow flag.static Color
getShadowColor
(Color foreground) Gets the shadow color that will have the greatest contrast to the specified foreground color.Gets the vector path stroke.void
render
(Graphics2D g, EarthDataView view) Renders the overlay graphics.void
setDropShadow
(boolean flag) Sets the drop shadow flag.void
Sets the vector path stroke.Methods inherited from class noaa.coastwatch.render.EarthDataOverlay
clone, compareTo, draw, getAlphaVersion, getColor, getColors, getColorWithAlpha, getLayer, getMetadataAtPoint, getName, getTransparency, getVisible, hasMetadata, invalidate, isPrepared, needsPrepare, prepare, setColor, setLayer, setName, setTransparency, setVisible, toString
-
Field Details
-
drawingShadow
protected boolean drawingShadowThe shadow rendering flag, true if we are rendering a shadow.
-
-
Constructor Details
-
LineOverlay
Constructs a new vector overlay.- Parameters:
color
- the overlay color.layer
- the overlay layer number.stroke
- the stroke to use for vector paths.
-
LineOverlay
Constructs a new vector overlay. The layer number is initialized to 0, and the stroke to the defaultBasicStroke
with beveled joins.- Parameters:
color
- the overlay color.
-
-
Method Details
-
getDropShadow
public boolean getDropShadow()Gets the drop shadow flag. -
setDropShadow
public void setDropShadow(boolean flag) Sets the drop shadow flag. When drop shadow mode is on, a shadow is drawn behind the lines. By default, drop shadow mode is off. -
drawShadow
Draws a drop shadow version of this overlay.- Parameters:
g
- the graphics device to draw to.view
- the data for drawing.
-
render
Description copied from class:EarthDataOverlay
Renders the overlay graphics.- Overrides:
render
in classEarthDataOverlay
- Parameters:
g
- the graphics object for drawing.view
- the earth data view.
-
getShadowColor
Gets the shadow color that will have the greatest contrast to the specified foreground color.- Parameters:
foreground
- the foreground color in question.- Returns:
- the shadow color, white if the foreground is dark or black if the foreground is light.
-
setStroke
Sets the vector path stroke. -
getStroke
Gets the vector path stroke. -
clip
Clips the line segment to the specified rectangle. This method implements the Cohen-Sutherland line clipping algorithm as specified in:Foley, J.D., A. van Dam, S.K. Feiner, and J.F. Hughes, "Computer Graphics: Principles and Practice, Second edition in C", Addison-Wesley, July 1997, pp 117-124, 274.
- Parameters:
line
- the line for clipping.rect
- the clipping rectangle.- Returns:
- the clipped line, or null if the line is entirely outside the rectangle. The same set of points is returned if no modifications to the points were performed, or a new set of points otherwise.
-