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

public abstract class LineOverlay extends EarthDataOverlay

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 Details

    • drawingShadow

      protected boolean drawingShadow
      The shadow rendering flag, true if we are rendering a shadow.
  • Constructor Details

    • LineOverlay

      protected LineOverlay(Color color, int layer, Stroke stroke)
      Constructs a new vector overlay.
      Parameters:
      color - the overlay color.
      layer - the overlay layer number.
      stroke - the stroke to use for vector paths.
    • LineOverlay

      protected LineOverlay(Color color)
      Constructs a new vector overlay. The layer number is initialized to 0, and the stroke to the default BasicStroke 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

      protected void drawShadow(Graphics2D g, EarthDataView view)
      Draws a drop shadow version of this overlay.
      Parameters:
      g - the graphics device to draw to.
      view - the data for drawing.
    • render

      public void render(Graphics2D g, EarthDataView view)
      Description copied from class: EarthDataOverlay
      Renders the overlay graphics.
      Overrides:
      render in class EarthDataOverlay
      Parameters:
      g - the graphics object for drawing.
      view - the earth data view.
    • getShadowColor

      public static Color getShadowColor(Color foreground)
      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

      public void setStroke(Stroke stroke)
      Sets the vector path stroke.
    • getStroke

      public Stroke getStroke()
      Gets the vector path stroke.
    • clip

      public static Line2D clip(Line2D line, Rectangle2D rect)
      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.