cox.jmatt.java.MathTools.graphing.xml
Class PolygonXML

java.lang.Object
  extended by cox.jmatt.java.MathTools.graphing.xml.RenderableXML
      extended by cox.jmatt.java.MathTools.graphing.xml.PolygonXML
All Implemented Interfaces:
Polygon, Renderable

public class PolygonXML
extends RenderableXML
implements Polygon

PolygonXML contains a <Polygon> tag with the usual attributes along with one mandatory child tag. The <Vertices> tag contains the 'closed=' attribute along with the vertices, if any, expressed as a space-separated String. Any parameters added will follow.


Field Summary
 
Fields inherited from class cox.jmatt.java.MathTools.graphing.xml.RenderableXML
myID, myName, myParams, myType
 
Constructor Summary
PolygonXML()
          Constructor for an unnamed Polygon.
PolygonXML(java.lang.String pName)
          Build a named Polygon.
 
Method Summary
 Polygon addVertex(double pX, double pY)
          Add a vertex to the Polygon.
 java.lang.Object render(java.lang.Object pContext)
          Rendering Polygon yields a <Polygon> tag with the usual 'id=', 'name=' and 'type=' attributes.
 void setClosed(boolean pClosed)
          Set the closedness of the Polygon.
 
Methods inherited from class cox.jmatt.java.MathTools.graphing.xml.RenderableXML
setID, setParameter, setType, testCondition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cox.jmatt.java.MathTools.graphing.Renderable
setParameter, setType, testCondition
 

Constructor Detail

PolygonXML

public PolygonXML()
Constructor for an unnamed Polygon.


PolygonXML

public PolygonXML(java.lang.String pName)
Build a named Polygon.

Method Detail

addVertex

public Polygon addVertex(double pX,
                         double pY)
Add a vertex to the Polygon. It is stored and rendered as the content of the <Vertices> tag. Return value is a reference to itself.

Specified by:
addVertex in interface Polygon
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

public void setClosed(boolean pClosed)
Set the closedness of the Polygon. Default value is true.

Specified by:
setClosed in interface Polygon
Parameters:
pClosed - true to 'close' the Polygon explicitly, false to leave it 'open'.

render

public java.lang.Object render(java.lang.Object pContext)
Rendering Polygon yields a <Polygon> tag with the usual 'id=', 'name=' and 'type=' attributes. Vertices are represented as a space-separated String inside a <Vertices> child tag. The closure of the Polygon is a 'closed=' attribute on the Vertices tag. Any parameters will follow.

Specified by:
render in interface Renderable
Overrides:
render in class RenderableXML
Parameters:
pContext - The Context Object to be used for rendering.
Returns:
The graph-ready Object, requiring no further MathTools interaction.