Package org.ka2ddo.yaac.gui.drawlayer
Class Polyline
java.lang.Object
org.ka2ddo.yaac.gui.drawlayer.AbstractDrawable
org.ka2ddo.yaac.gui.drawlayer.Polyline
- All Implemented Interfaces:
Serializable
This class defines a drawable polyline.
- Author:
- Andrew Pavlin, KA2DDO
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addVertex
(double lat, double lon) Add another vertex to this polyline.void
Add another vertex to this polylinefloat
distance
(int x, int y, com.bbn.openmap.proj.Projection proj) This computes the nearest distance from this drawable to the specified pixel coordinates.double
getVertexLat
(int index) Gets the latitude of the index-specified vertex in the polyline.double
getVertexLon
(int index) Gets the longitude of the index-specified vertex in the polyline.void
paintDrawable
(Graphics2D g, com.bbn.openmap.proj.Projection proj) Render this drawable upon a canvas using the specified Graphics and Projection.void
removeVertex
(int index) Remove the specified vertex from the ordered list of vertices.int
size()
Get the number of vertices in this polyline.toString()
Returns a string representation of the object.Methods inherited from class org.ka2ddo.yaac.gui.drawlayer.AbstractDrawable
getLineColor, getName, getStroke, getStrokeType, paramString, setLineColor, setName, setStroke
-
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 Northlon
- longitude of this vertex in degrees East
-
addVertex
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
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
Render this drawable upon a canvas using the specified Graphics and Projection.- Specified by:
paintDrawable
in classAbstractDrawable
- Parameters:
g
- Graphics2D object for rendering the drawableproj
- 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 classAbstractDrawable
- Parameters:
x
- int pixel X-coordinatey
- int pixel Y-coordinateproj
- Projection to translate drawable into screen space- Returns:
- distance in pixels
-
toString
Returns a string representation of the object.
-