Class Polyline

All Implemented Interfaces:
Serializable

public class Polyline extends AbstractDrawable
This class defines a drawable polyline.
Author:
Andrew Pavlin, KA2DDO
See Also:
  • Constructor Details

    • Polyline

      public Polyline()
      Create an empty Polyline.
  • Method Details

    • addVertex

      public void addVertex(double lat, double lon)
      Add another vertex to this polyline.
      Parameters:
      lat - latitude of this vertex in degrees North
      lon - longitude of this vertex in degrees East
    • addVertex

      public void addVertex(Point2D pt)
      Add another vertex to this polyline
      Parameters:
      pt - Point2D containing a position in decimal degrees North and East
    • size

      public int size()
      Get the number of vertices in this polyline.
      Returns:
      vertex count
    • removeVertex

      public void removeVertex(int index) throws ArrayIndexOutOfBoundsException
      Remove the specified vertex from the ordered list of vertices.
      Parameters:
      index - zero-based index of the vertex to remove
      Throws:
      ArrayIndexOutOfBoundsException - if the index is not in range to represent a vertex in ths polyline
    • getVertexLat

      public double getVertexLat(int index)
      Gets the latitude of the index-specified vertex in the polyline.
      Parameters:
      index - zero-based index of the vertex
      Returns:
      degrees North
    • getVertexLon

      public double getVertexLon(int index)
      Gets the longitude of the index-specified vertex in the polyline.
      Parameters:
      index - zero-based index of the vertex
      Returns:
      degrees East
    • paintDrawable

      public void paintDrawable(Graphics2D g, com.bbn.openmap.proj.Projection proj)
      Render this drawable upon a canvas using the specified Graphics and Projection.
      Specified by:
      paintDrawable in class AbstractDrawable
      Parameters:
      g - Graphics2D object for rendering the drawable
      proj - Projection for translating geographic coordinates of the drawable
    • distance

      public float distance(int x, int y, com.bbn.openmap.proj.Projection proj)
      This computes the nearest distance from this drawable to the specified pixel coordinates.
      Specified by:
      distance in class AbstractDrawable
      Parameters:
      x - int pixel X-coordinate
      y - int pixel Y-coordinate
      proj - Projection to translate drawable into screen space
      Returns:
      distance in pixels
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.