Class Polygon<PointType extends Point>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<PointType>
                  extended by Polygon<PointType>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<PointType>, java.util.Collection<PointType>, java.util.List<PointType>, java.util.Queue<PointType>

public class Polygon<PointType extends Point>
extends java.util.LinkedList<PointType>

A LinkedList of Points

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Polygon()
          The null Polygon
Polygon(java.util.Collection<? extends PointType> poly)
          Construct from a collection of Points.
 
Method Summary
 double areaPoly2()
          Twice the area of the Polygon.
 double areaPolygon2()
          Twice the area of the Polygon (using Green's Theorem).
 boolean diagonal(PointType a, PointType b)
          Is the polygon edge segment ab an internal diagonal.
 PointType getRelative(PointType p, int offset)
          Circular reference relative to a given Point
 java.lang.String toString()
          Format the polygon.
 java.lang.String toString(java.lang.String df)
          Format the polygon using a hint.
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, peek, poll, remove, remove, remove, removeFirst, removeLast, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

Polygon

public Polygon(java.util.Collection<? extends PointType> poly)
Construct from a collection of Points.

Parameters:
poly - collection of Points

Polygon

public Polygon()
The null Polygon

Method Detail

toString

public java.lang.String toString(java.lang.String df)
Format the polygon using a hint.

Parameters:
df - the format to be used for a single coordinate

toString

public java.lang.String toString()
Format the polygon.

Overrides:
toString in class java.util.AbstractCollection<PointType extends Point>

getRelative

public PointType getRelative(PointType p,
                             int offset)
Circular reference relative to a given Point

Parameters:
p - reference Point
offset - index relative to p

areaPoly2

public double areaPoly2()
Twice the area of the Polygon. Construct triangles using a fixed vertex and all edges and accumulate (twice) the areas of these triangles.


areaPolygon2

public double areaPolygon2()
Twice the area of the Polygon (using Green's Theorem). Walk the Polygon and accumulate a contribution from each edge.


diagonal

public boolean diagonal(PointType a,
                        PointType b)
Is the polygon edge segment ab an internal diagonal.