Class FConvexPoly

java.lang.Object
   |
   +----FConvexPoly

class FConvexPoly
extends Object
The FConvexPoly class represents a convex polygon.


Variable Index

 o closed
 o polyColor
 o trigo
Indicates if the polygon has been drawn in counter-clockwise order
 o v
The vector used to store the polygon vertices

Constructor Index

 o FConvexPoly(Color)
Creates a new empty polygon

Method Index

 o addPoint(FPoint)
Takes a point and adds it to the polygon if this point keeps the polygon convex.
 o boundVector()
Returns the vector between the first and last vertices.
 o draw(Graphics)
Draw the outline of the polygon on the given graphics.
 o fill(Graphics)
Draw the filled polygon on the given graphics.
 o firstVector()
Returns the first vector of the polygonal chain.
 o getFPoint(int)
Returns the FPoint indexed by i.
 o getPoint(int)
Returns the Point indexed by i.
 o infiniteRegion(FPoint, FVector, FPoint, FVector)
This method returns a Polygon that will look infinite when drawn by the Graphics methods.
 o isClosed()
Returns true if the polygon is closed.
 o isNextOK(FPoint)
Returns true iff the given point would keep the polygon convex if addded.
 o isTrigo()
Returns true if the polygon has been drawn in counter clockwise order.
 o lastVector()
Returns the last vector of the polygonal chain.

Variables

 o v
 public Vector v
The vector used to store the polygon vertices

 o closed
 boolean closed
 o trigo
 boolean trigo
Indicates if the polygon has been drawn in counter-clockwise order

 o polyColor
 Color polyColor

Constructors

 o FConvexPoly
 public FConvexPoly(Color c)
Creates a new empty polygon

Methods

 o isClosed
 public boolean isClosed()
Returns true if the polygon is closed.

 o isTrigo
 public boolean isTrigo()
Returns true if the polygon has been drawn in counter clockwise order.

 o getPoint
 public Point getPoint(int i)
Returns the Point indexed by i.

 o getFPoint
 public FPoint getFPoint(int i)
Returns the FPoint indexed by i. The actual index for these two functions is computed modulo the number of vertices.

 o addPoint
 public void addPoint(FPoint p)
Takes a point and adds it to the polygon if this point keeps the polygon convex. It also updates the "trigo" and "closed" variables when appropriate.

 o isNextOK
 public boolean isNextOK(FPoint p)
Returns true iff the given point would keep the polygon convex if addded. It checks this by making sure the point is on the right side the three lines that define the possible next-point region.

 o firstVector
 public FVector firstVector()
Returns the first vector of the polygonal chain.

 o lastVector
 public FVector lastVector()
Returns the last vector of the polygonal chain.

 o boundVector
 public FVector boundVector()
Returns the vector between the first and last vertices. These three functions return the three vectors that describe the possible next-point region

 o fill
 public void fill(Graphics g)
Draw the filled polygon on the given graphics.

 o draw
 public void draw(Graphics g)
Draw the outline of the polygon on the given graphics.

 o infiniteRegion
 public static Polygon infiniteRegion(FPoint p1,
                                      FVector v1,
                                      FPoint p2,
                                      FVector v2)
This method returns a Polygon that will look infinite when drawn by the Graphics methods. This should not be in here, it should not be a static method, but it worked so I left it this way...