ewe.fx
Class Curve

java.lang.Object
  extended byewe.fx.Curve

public class Curve
extends Object

This class provides methods for calculating points and bounds for linear, quadratic and cubic curves.

A Curve object is stateless but the methods are not static so that a better implementation can be created and substituted for the static variable "curve" if necessary.


Field Summary
static Curve curve
           
static int MAX_POINTS
           
 
Constructor Summary
Curve()
           
 
Method Summary
 int calculateCubes(float[] xpoints, float[] ypoints, int pointsOffset, Object destX, Object destY, int offset, int options)
          Calculate the curve points for the curve.
protected  int calculateCubes(float startx, float starty, float control1x, float control1y, float control2x, float control2y, float endx, float endy, Object destx, Object desty, int offset, int options)
           
 int calculateLines(float[] xpoints, float[] ypoints, int pointsOffset, Object destX, Object destY, int offset, int options)
          Calculate the line points for the line.
protected  int calculateLines(float startx, float starty, float endx, float endy, Object destx, Object desty, int offset, int options)
          This calculates the points on a quad curve, for either the x or y co-ordinate.
 int calculateQuads(float[] xpoints, float[] ypoints, int pointsOffset, Object destX, Object destY, int offset, int options)
          Calculate the curve points for the curve.
protected  int calculateQuads(float startx, float starty, float controlx, float controly, float endx, float endy, Object destx, Object desty, int offset, int options)
          This calculates the points on a quad curve, for either the x or y co-ordinate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

curve

public static Curve curve

MAX_POINTS

public static final int MAX_POINTS
See Also:
Constant Field Values
Constructor Detail

Curve

public Curve()
Method Detail

calculateLines

protected int calculateLines(float startx,
                             float starty,
                             float endx,
                             float endy,
                             Object destx,
                             Object desty,
                             int offset,
                             int options)
This calculates the points on a quad curve, for either the x or y co-ordinate. This is called by the other calculateQuads method. If the destination object is null this should return the number of points in the curve.

This method does NOT include the last point on the curve, but DOES include the first one.


calculateQuads

protected int calculateQuads(float startx,
                             float starty,
                             float controlx,
                             float controly,
                             float endx,
                             float endy,
                             Object destx,
                             Object desty,
                             int offset,
                             int options)
This calculates the points on a quad curve, for either the x or y co-ordinate. This is called by the other calculateQuads method. If the destination object is null this should return the number of points in the curve.

This method does NOT include the last point on the curve, but DOES include the first one.


calculateCubes

protected int calculateCubes(float startx,
                             float starty,
                             float control1x,
                             float control1y,
                             float control2x,
                             float control2y,
                             float endx,
                             float endy,
                             Object destx,
                             Object desty,
                             int offset,
                             int options)

calculateLines

public int calculateLines(float[] xpoints,
                          float[] ypoints,
                          int pointsOffset,
                          Object destX,
                          Object destY,
                          int offset,
                          int options)
Calculate the line points for the line. This is trivial, since it is only the first point that is ever stored.

Parameters:
xpoints - The X coordinates for the curve. The first one should be the start point, the second should be the end point.
ypoints - The Y coordinates for the curve. The first one should be the start point, the second should be the end point. one should be the end point.
pointsOffset - The offset of the points in the xpoints and ypoints array.
destX - Either an int[] or float[] object to hold the destination X points. Can be null if you only are interested in the number of points that will be calculated.
destY - Either an int[] or float[] object to hold the destination Y points. Can be null if you only are interested in the number of points that will be calculated.
offset - The offset into the destX and destY arrays for the points to go.
options - No options are currently defined.
Returns:
The number of points that were, or will be put in the destinations.

calculateQuads

public int calculateQuads(float[] xpoints,
                          float[] ypoints,
                          int pointsOffset,
                          Object destX,
                          Object destY,
                          int offset,
                          int options)
Calculate the curve points for the curve.

Parameters:
xpoints - The X coordinates for the curve. The first one should be the start point, the second should be the control point and the third one should be the end point.
ypoints - The Y coordinates for the curve. The first one should be the start point, the second should be the control point and the third one should be the end point.
pointsOffset - The offset of the points in the xpoints and ypoints array.
destX - Either an int[] or float[] object to hold the destination X points. Can be null if you only are interested in the number of points that will be calculated.
destY - Either an int[] or float[] object to hold the destination Y points. Can be null if you only are interested in the number of points that will be calculated.
offset - The offset into the destX and destY arrays for the points to go.
options - No options are currently defined.
Returns:
The number of points that were, or will be put in the destinations.

calculateCubes

public int calculateCubes(float[] xpoints,
                          float[] ypoints,
                          int pointsOffset,
                          Object destX,
                          Object destY,
                          int offset,
                          int options)
Calculate the curve points for the curve.

Parameters:
xpoints - The X coordinates for the curve. The first one should be the start point, the second should be the control point and the third one should be the end point.
ypoints - The Y coordinates for the curve. The first one should be the start point, the second should be the control point and the third one should be the end point.
pointsOffset - The offset of the points in the xpoints and ypoints array.
destX - Either an int[] or float[] object to hold the destination X points. Can be null if you only are interested in the number of points that will be calculated.
destY - Either an int[] or float[] object to hold the destination Y points. Can be null if you only are interested in the number of points that will be calculated.
offset - The offset into the destX and destY arrays for the points to go.
options - No options are currently defined.
Returns:
The number of points that were, or will be put in the destinations.