com.graphbuilder.curve
Class ControlPath

java.lang.Object
  extended bycom.graphbuilder.curve.ControlPath

public class ControlPath
extends java.lang.Object

A ControlPath is a container of Point objects and Curve objects. The control-path uses arrays to store the points and curves. Methods that accept objects will throw an IllegalArgumentException if those objects are null. Methods that accept index values will throw an IllegalArgumentException if those index values are out of range.


Constructor Summary
ControlPath()
          Creates a control-path.
 
Method Summary
 void addCurve(Curve c)
          Adds a curve to the curve array at index location numCurves.
 void addPoint(Point p)
          Adds a point to the point array at index location numPoints.
 void ensureCurveCapacity(int capacity)
          Checks that the curve array has the specified capacity, otherwise the capacity of the curve array is increased to be the maximum between twice the current capacity or the specified capacity.
 void ensurePointCapacity(int capacity)
          Checks that the point array has the specified capacity, otherwise the capacity of the point array is increased to be the maximum between twice the current capacity or the specified capacity.
 Curve getCurve(int index)
          Returns the curve at the specified index.
 Point getPoint(int index)
          Returns the point at the specified index.
 void insertCurve(Curve c, int index)
          Inserts a curve at the specified index in the curve array.
 void insertPoint(Point p, int index)
          Inserts a point at the specified index in the point array.
 int numCurves()
          Returns the number of curves in the control-path.
 int numPoints()
          Returns the number of points in the control-path.
 void removeCurve(Curve c)
          Removes the first occurrence of the specified curve from the curve array.
 void removeCurve(int index)
          Removes the curve at the specified index location.
 void removePoint(int index)
          Removes the point at the specified index location.
 void removePoint(Point p)
          Removes the first occurrence of the specified point from the point array.
 Curve setCurve(Curve c, int index)
          Sets a curve at the specified index in the curve array, returning the curve that was at that index.
 Point setPoint(Point p, int index)
          Sets a point at the specified index in the point array, returning the point that was at that index.
 void trimCurveArray()
          Creates a new curve array of exact size, copying the curves from the old array into the new one.
 void trimPointArray()
          Creates a new point array of exact size, copying the points from the old array into the new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControlPath

public ControlPath()
Creates a control-path.

Method Detail

addCurve

public void addCurve(Curve c)
Adds a curve to the curve array at index location numCurves.

Throws:
java.lang.IllegalArgumentException - If the specified curve is null.

addPoint

public void addPoint(Point p)
Adds a point to the point array at index location numPoints.

Throws:
java.lang.IllegalArgumentException - If the specified point is null.

insertCurve

public void insertCurve(Curve c,
                        int index)
Inserts a curve at the specified index in the curve array.

Throws:
java.lang.IllegalArgumentException - If the specified curve is null.

insertPoint

public void insertPoint(Point p,
                        int index)
Inserts a point at the specified index in the point array.

Throws:
java.lang.IllegalArgumentException - If the specified point is null.

setCurve

public Curve setCurve(Curve c,
                      int index)
Sets a curve at the specified index in the curve array, returning the curve that was at that index.

Throws:
java.lang.IllegalArgumentException - If the specified curve is null.

setPoint

public Point setPoint(Point p,
                      int index)
Sets a point at the specified index in the point array, returning the point that was at that index.

Throws:
java.lang.IllegalArgumentException - If the specified point is null.

getCurve

public Curve getCurve(int index)
Returns the curve at the specified index.


getPoint

public Point getPoint(int index)
Returns the point at the specified index.


numCurves

public int numCurves()
Returns the number of curves in the control-path.


numPoints

public int numPoints()
Returns the number of points in the control-path.


removeCurve

public void removeCurve(Curve c)
Removes the first occurrence of the specified curve from the curve array.


removePoint

public void removePoint(Point p)
Removes the first occurrence of the specified point from the point array.


removeCurve

public void removeCurve(int index)
Removes the curve at the specified index location.


removePoint

public void removePoint(int index)
Removes the point at the specified index location.


ensureCurveCapacity

public void ensureCurveCapacity(int capacity)
Checks that the curve array has the specified capacity, otherwise the capacity of the curve array is increased to be the maximum between twice the current capacity or the specified capacity.


ensurePointCapacity

public void ensurePointCapacity(int capacity)
Checks that the point array has the specified capacity, otherwise the capacity of the point array is increased to be the maximum between twice the current capacity or the specified capacity.


trimCurveArray

public void trimCurveArray()
Creates a new curve array of exact size, copying the curves from the old array into the new one.


trimPointArray

public void trimPointArray()
Creates a new point array of exact size, copying the points from the old array into the new one.