Class ControlPath

java.lang.Object
com.graphbuilder.curve.ControlPath

public class ControlPath extends 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

    Constructors
    Constructor
    Description
    Creates a control-path.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a curve to the curve array at index location numCurves.
    void
    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.
    getCurve(int index)
    Returns the curve at the specified index.
    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
    Returns the number of curves in the control-path.
    int
    Returns the number of points in the control-path.
    void
    removeCurve(int index)
    Removes the curve at the specified index location.
    void
    Removes the first occurrence of the specified curve from the curve array.
    void
    removePoint(int index)
    Removes the point at the specified index location.
    void
    Removes the first occurrence of the specified point from the point array.
    setCurve(Curve c, int index)
    Sets a curve at the specified index in the curve array, returning the curve that was at that index.
    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
    Creates a new curve array of exact size, copying the curves from the old array into the new one.
    void
    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 Details

    • ControlPath

      public ControlPath()
      Creates a control-path.
  • Method Details

    • addCurve

      public void addCurve(Curve c)
      Adds a curve to the curve array at index location numCurves.
      Throws:
      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:
      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:
      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:
      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:
      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:
      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.