cox.jmatt.java.MathTools.graphing
Interface Polygon

All Superinterfaces:
Renderable
All Known Implementing Classes:
NOPolygon, PolygonXML

public interface Polygon
extends Renderable

This interface provides one special component that may appear on a graph: a polygon. The definition here is used loosely; there is no absolute or implied requirement that the Polygon not intersect itself, nor must it be closed. The Polygon class instead represents a two-dimensional collection of line segments such that each shares at least one endpoint with another line segment and such that it may be drawn (rendered) as a consecutive and finite sequence of points.

The critical components of a Polygon are the points describing its vertices and whether or not it is closed. In a closed Polygon the last point added is automatically considered connected to the very first point; this does not need to be done explicitly. Also, since this concept is very closely tied to the two-dimensional nature of graphs in this package, point values are given as double and not Object.


Method Summary
 Polygon addVertex(double pX, double pY)
          Add a line segment to the Polygon.
 void setClosed(boolean pClosed)
          Determine whether or not the last point added will be 'connected' to the first point entered.
 
Methods inherited from interface cox.jmatt.java.MathTools.graphing.Renderable
render, setParameter, setType, testCondition
 

Method Detail

addVertex

Polygon addVertex(double pX,
                  double pY)
Add a line segment to the Polygon. Due to the nature of polygons, the points added MUST be kept in order! This method should return a reference to itself or a copy (for immutable Polygons) to allow convenient method chaining.

Parameters:
pX - The X-coordinate of the point.
pY - The Y-coordinate of the point.
Returns:
A self-reference to allow multiple vertex adds.

setClosed

void setClosed(boolean pClosed)
Determine whether or not the last point added will be 'connected' to the first point entered. Setting pClosed to 'true' has the same effect as adding the first point again after the last one is added; this method simply makes things easier.

Parameters:
pClosed - true to 'close' the Polygon explicitly, false to leave it 'open'.