computational.geometry
Class SimplePolygon

java.lang.Object
  extended by computational.geometry.Polygon
      extended by computational.geometry.SimplePolygon
All Implemented Interfaces:
Shape, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ConvexPolygon

public class SimplePolygon
extends Polygon

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class computational.geometry.Polygon
Polygon.Edge, Polygon.Vertex
 
Field Summary
 
Fields inherited from class computational.geometry.Polygon
vertices
 
Constructor Summary
SimplePolygon()
          CONSTRUCTORS
SimplePolygon(java.util.List vertices)
           
SimplePolygon(Polygon p)
           
SimplePolygon(java.lang.String label)
           
SimplePolygon(java.lang.String label, java.util.List points)
           
 
Method Summary
 boolean addVertex(Point p)
          SET METHODS
 boolean addVertex(Point p, Segment s)
           
 boolean contains(Point p)
          POINT IN POLYGON TEST
 boolean deleteVertex(java.lang.Integer index)
           
 boolean deleteVertex(Point p)
           
 boolean diagonal(int i0, int i1)
           
 boolean diagonal(Polygon.Vertex v0, Polygon.Vertex v1)
           
 boolean ear(Polygon.Vertex clip)
           
 boolean moveVertex(java.lang.Integer index, int dx, int dy)
           
 boolean moveVertex(Point p, int dx, int dy)
           
 
Methods inherited from class computational.geometry.Polygon
area, boundingBox, clear, clone, draw, drawLabels, drawPoints, equals, getBottomVertex, getEdge, getEdges, getFirstVertex, getIndices, getLabel, getLeftVertex, getNext, getPoints, getPrevious, getRightVertex, getTopVertex, getVertex, getVertices, indexOf, isClockwiseOriented, isConvex, isSimple, perimeter, restore, setLabel, size, toString, translate, updateExtremeVertices
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimplePolygon

public SimplePolygon()
CONSTRUCTORS


SimplePolygon

public SimplePolygon(java.util.List vertices)
              throws SimplicityViolatedException
Throws:
SimplicityViolatedException

SimplePolygon

public SimplePolygon(Polygon p)
              throws SimplicityViolatedException
Throws:
SimplicityViolatedException

SimplePolygon

public SimplePolygon(java.lang.String label)

SimplePolygon

public SimplePolygon(java.lang.String label,
                     java.util.List points)
              throws SimplicityViolatedException
Throws:
SimplicityViolatedException
Method Detail

addVertex

public boolean addVertex(Point p)
                  throws SimplicityViolatedException,
                         ConvexityViolatedException
SET METHODS

Overrides:
addVertex in class Polygon
Throws:
SimplicityViolatedException
ConvexityViolatedException

addVertex

public boolean addVertex(Point p,
                         Segment s)
                  throws SimplicityViolatedException,
                         ConvexityViolatedException
Overrides:
addVertex in class Polygon
Throws:
SimplicityViolatedException
ConvexityViolatedException

contains

public boolean contains(Point p)
POINT IN POLYGON TEST

Specified by:
contains in interface Shape
Overrides:
contains in class Polygon
Parameters:
p - the point we test for encloseness.
Returns:
true iff the point is enclosed in the shape.

deleteVertex

public boolean deleteVertex(java.lang.Integer index)
                     throws SimplicityViolatedException,
                            ConvexityViolatedException
Overrides:
deleteVertex in class Polygon
Throws:
SimplicityViolatedException
ConvexityViolatedException

deleteVertex

public boolean deleteVertex(Point p)
                     throws SimplicityViolatedException,
                            ConvexityViolatedException
Overrides:
deleteVertex in class Polygon
Throws:
SimplicityViolatedException
ConvexityViolatedException

diagonal

public boolean diagonal(int i0,
                        int i1)
Parameters:
i0 - the segment's first index.
i1 - the segment's second index.
Returns:
true iff the segment (i0,i1) is a proper internal diagonal of the polygon.

diagonal

public boolean diagonal(Polygon.Vertex v0,
                        Polygon.Vertex v1)

ear

public boolean ear(Polygon.Vertex clip)

moveVertex

public boolean moveVertex(java.lang.Integer index,
                          int dx,
                          int dy)
                   throws SimplicityViolatedException,
                          ConvexityViolatedException
Overrides:
moveVertex in class Polygon
Throws:
SimplicityViolatedException
ConvexityViolatedException

moveVertex

public boolean moveVertex(Point p,
                          int dx,
                          int dy)
                   throws SimplicityViolatedException,
                          ConvexityViolatedException
Overrides:
moveVertex in class Polygon
Throws:
SimplicityViolatedException
ConvexityViolatedException