org.gcube.indexmanagement.geo.shape
Class Polygon

java.lang.Object
  extended by org.gcube.indexmanagement.geo.shape.Polygon

public class Polygon
extends Object

A java representation of a Polygon


Constructor Summary
Polygon()
          Constructor
Polygon(Collection<Point> vertices)
          Constructor which creates a polygon from a collection of points representing the vertices
Polygon(Point[] vertices)
          Constructor which creates a polygon from an array of points representing the vertices
 
Method Summary
 void addVertex(Point vertex)
          A method to add a vertex to the polygon
 void addVertices(Collection<Point> vertices)
          A method to add a collection of vertices to the polygon
 void addVertices(Point[] vertices)
          A method to add an array of vertices to the polygon
 Rectangle getBoundingBox()
          A method to get the Minimum Bounding Rectanngle of the polygon
 Point[] getVertexArray()
          A method to get an array of the vertices of the polygon
 ArrayList<Point> getVertices()
          A method to get an ArrayList of the vertices of the polygon
 boolean isValid()
          A method to check the validity of the polygon.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Polygon

public Polygon()
Constructor


Polygon

public Polygon(Collection<Point> vertices)
Constructor which creates a polygon from a collection of points representing the vertices

Parameters:
vertices - - collection of points representing the vertices of the polygon to be created

Polygon

public Polygon(Point[] vertices)
Constructor which creates a polygon from an array of points representing the vertices

Parameters:
vertices - - an array of points representing the vertices of the polygon to be created
Method Detail

addVertex

public void addVertex(Point vertex)
A method to add a vertex to the polygon

Parameters:
vertex - - The vertex to be added to the polygon

addVertices

public void addVertices(Collection<Point> vertices)
A method to add a collection of vertices to the polygon

Parameters:
vertices - - a collection of vertices to be added to the polygon

addVertices

public void addVertices(Point[] vertices)
A method to add an array of vertices to the polygon

Parameters:
vertices - - an array of vertices to be added to the polygon

getVertices

public ArrayList<Point> getVertices()
A method to get an ArrayList of the vertices of the polygon

Returns:
The vertices of the polygon

getVertexArray

public Point[] getVertexArray()
A method to get an array of the vertices of the polygon

Returns:
The vertices of the polygon

getBoundingBox

public Rectangle getBoundingBox()
A method to get the Minimum Bounding Rectanngle of the polygon

Returns:
The Minimum Bounding Rectanngle of the polygon

isValid

public boolean isValid()
A method to check the validity of the polygon. A valid polygon has three or more vertices, and no crossing lines.

Returns:
TRUE if the the polygon is valid.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.