APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.javafx.geom

public Class CubicCurve2D

extends Shape
Class Inheritance
Imports
java.util.Arrays, com.sun.javafx.geom.transform.BaseTransform

The CubicCurve2D class defines a cubic parametric curve segment in (x,y) coordinate space.

This class is only the abstract superclass for all objects which store a 2D cubic curve segment. The actual storage representation of the coordinates is left to the subclass.

Version
1.42, 05/05/07

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
public float
ctrlx1

The X coordinate of the first control point of the cubic curve segment.

public float
ctrlx2

The X coordinate of the second control point of the cubic curve segment.

public float
ctrly1

The Y coordinate of the first control point of the cubic curve segment.

public float
ctrly2

The Y coordinate of the second control point of the cubic curve segment.

private static final int
private static final int
private static final int
public float
x1

The X coordinate of the start point of the cubic curve segment.

public float
x2

The X coordinate of the end point of the cubic curve segment.

public float
y1

The Y coordinate of the start point of the cubic curve segment.

public float
y2

The Y coordinate of the end point of the cubic curve segment.

Inherited from com.sun.javafx.geom.Shape:
OUT_BOTTOMOUT_LEFTOUT_RIGHTOUT_TOPRECT_INTERSECTS

Constructor Summary

AccessConstructor and Description
public
CubicCurve2D()

Constructs and initializes a CubicCurve with coordinates (0, 0, 0, 0, 0, 0, 0, 0).

public
CubicCurve2D(float
the X coordinate for the start point of the resulting CubicCurve2D
x1
,
float
the Y coordinate for the start point of the resulting CubicCurve2D
y1
,
float
the X coordinate for the first control point of the resulting CubicCurve2D
ctrlx1
,
float
the Y coordinate for the first control point of the resulting CubicCurve2D
ctrly1
,
float
the X coordinate for the second control point of the resulting CubicCurve2D
ctrlx2
,
float
the Y coordinate for the second control point of the resulting CubicCurve2D
ctrly2
,
float
the X coordinate for the end point of the resulting CubicCurve2D
x2
,
float
the Y coordinate for the end point of the resulting CubicCurve2D
y2
)

Constructs and initializes a CubicCurve2D from the specified float coordinates.

Method Summary

Modifier and TypeMethod and Description
private float
calcX(final float t)

private float
calcY(final float t)

public boolean
contains(float x, float y)

Implements abstract com.sun.javafx.geom.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape.

public boolean
contains(Point2D p)

Overrides com.sun.javafx.geom.Shape.contains.

Tests if a specified Point2D is inside the boundary of the Shape.

public boolean
contains(float x, float y, float w, float h)

Implements abstract com.sun.javafx.geom.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area.

public CubicCurve2D
copy()

Implements abstract com.sun.javafx.geom.Shape.copy.

Returns a new copy of this Shape instance.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Point2D

Returns:

a newly allocated Point2D containing the evaluation of the curve at that parameter value
eval
(float
parameter value at which to evaluate the curve
t
)

Evaluates this cubic curve at the given parameter value, where it is expected, but not required, that the parameter will be between 0 and 1.

public void
eval(float
parameter value at which to evaluate the curve
td
,
Point2D
Point2D in to which to store the evaluation of the curve at that parameter value
result
)

Evaluates this cubic curve at the given parameter value, where it is expected, but not required, that the parameter will be between 0 and 1.

private static int
evalCubic(float[] vals, int num, boolean include0, boolean include1, float[] inflect, float c1, float cp1, float cp2, float c2)

public Point2D

Returns:

a newly allocated Point2D containing the derivative of the curve at that parameter value
evalDt
(float
parameter value at which to compute the derivative of the curve
t
)

Evaluates the derivative of this cubic curve at the given parameter value, where it is expected, but not required, that the parameter will be between 0 and 1.

public void
evalDt(float td, Point2D
Point2D in to which to store the derivative of the curve at that parameter value
result
)

Evaluates the derivative of this cubic curve at the given parameter value, where it is expected, but not required, that the parameter will be between 0 and 1.

private static void
fillEqn(float[] eqn, float val, float c1, float cp1, float cp2, float c2)

private static float
findZero(float t, float target, float[] eqn)

private static void
fixRoots(float[] res, float[] eqn)

public RectBounds
getBounds()

Implements abstract com.sun.javafx.geom.Shape.getBounds.

Note that there is no guarantee that the returned RectBounds is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated RectBounds.

public static float

Returns:

the flatness of the CubicCurve2D represented by the specified coordinates.
getFlatness
(float
the X coordinate that specifies the start point of a CubicCurve2D
x1
,
float
the Y coordinate that specifies the start point of a CubicCurve2D
y1
,
float
the X coordinate that specifies the first control point of a CubicCurve2D
ctrlx1
,
float
the Y coordinate that specifies the first control point of a CubicCurve2D
ctrly1
,
float
the X coordinate that specifies the second control point of a CubicCurve2D
ctrlx2
,
float
the Y coordinate that specifies the second control point of a CubicCurve2D
ctrly2
,
float
the X coordinate that specifies the end point of a CubicCurve2D
x2
,
float
the Y coordinate that specifies the end point of a CubicCurve2D
y2
)

Returns the flatness of the cubic curve specified by the indicated control points.

public static float

Returns:

the flatness of the CubicCurve2D specified by the coordinates in coords at the specified offset.
getFlatness
(float[]
an array containing coordinates
coords
,
int
the index of coords from which to begin getting the end points and control points of the curve
offset
)

Returns the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index.

public float

Returns:

the flatness of this curve.
getFlatness
()

Returns the flatness of this curve.

public static float

Returns:

the square of the flatness of the CubicCurve2D represented by the specified coordinates.
getFlatnessSq
(float
the X coordinate that specifies the start point of a CubicCurve2D
x1
,
float
the Y coordinate that specifies the start point of a CubicCurve2D
y1
,
float
the X coordinate that specifies the first control point of a CubicCurve2D
ctrlx1
,
float
the Y coordinate that specifies the first control point of a CubicCurve2D
ctrly1
,
float
the X coordinate that specifies the second control point of a CubicCurve2D
ctrlx2
,
float
the Y coordinate that specifies the second control point of a CubicCurve2D
ctrly2
,
float
the X coordinate that specifies the end point of a CubicCurve2D
x2
,
float
the Y coordinate that specifies the end point of a CubicCurve2D
y2
)

Returns the square of the flatness of the cubic curve specified by the indicated control points.

public static float

Returns:

the square of the flatness of the CubicCurve2D specified by the coordinates in coords at the specified offset.
getFlatnessSq
(float[]
an array containing coordinates
coords
,
int
the index of coords from which to begin getting the end points and control points of the curve
offset
)

Returns the square of the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index.

public float

Returns:

the square of the flatness of this curve.
getFlatnessSq
()

Returns the square of the flatness of this curve.

public PathIterator

Returns:

the PathIterator object that returns the geometry of the outline of this CubicCurve2D, one segment at a time.
getPathIterator
(BaseTransform
an optional BaseTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
tx
)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Returns an iteration object that defines the boundary of the shape.

public PathIterator

Returns:

the PathIterator object that returns the geometry of the outline of this CubicCurve2D, one segment at a time.
getPathIterator
(BaseTransform
an optional BaseTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
tx
,
float
the maximum amount that the control points for a given curve can vary from colinear before a subdivided curve is replaced by a straight line connecting the end points
flatness
)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Return an iteration object that defines the boundary of the flattened shape.

private static int
getTag(float coord, float low, float high)

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
intersects(float x, float y, float w, float h)

Implements abstract com.sun.javafx.geom.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area.

private static boolean
inwards(int pttag, int opt1tag, int opt2tag)

public void
setCurve(float
the X coordinate used to set the start point of this CubicCurve2D
x1
,
float
the Y coordinate used to set the start point of this CubicCurve2D
y1
,
float
the X coordinate used to set the first control point of this CubicCurve2D
ctrlx1
,
float
the Y coordinate used to set the first control point of this CubicCurve2D
ctrly1
,
float
the X coordinate used to set the second control point of this CubicCurve2D
ctrlx2
,
float
the Y coordinate used to set the second control point of this CubicCurve2D
ctrly2
,
float
the X coordinate used to set the end point of this CubicCurve2D
x2
,
float
the Y coordinate used to set the end point of this CubicCurve2D
y2
)

Sets the location of the end points and control points of this curve to the specified float coordinates.

public void
setCurve(float[]
a double array containing coordinates
coords
,
int
the index of coords from which to begin setting the end points and control points of this curve to the coordinates contained in coords
offset
)

Sets the location of the end points and control points of this curve to the double coordinates at the specified offset in the specified array.

public void
setCurve(Point2D
the first specified Point2D used to set the start point of this curve
p1
,
Point2D
the second specified Point2D used to set the first control point of this curve
cp1
,
Point2D
the third specified Point2D used to set the second control point of this curve
cp2
,
Point2D
the fourth specified Point2D used to set the end point of this curve
p2
)

Sets the location of the end points and control points of this curve to the specified Point2D coordinates.

public void
setCurve(Point2D[]
an array of Point2D objects
pts
,
int
the index of pts from which to begin setting the end points and control points of this curve to the points contained in pts
offset
)

Sets the location of the end points and control points of this curve to the coordinates of the Point2D objects at the specified offset in the specified array.

public void
setCurve(CubicCurve2D
the specified CubicCurve2D
c
)

Sets the location of the end points and control points of this curve to the same as those in the specified CubicCurve2D.

public static int

Returns:

the number of roots, or -1 if the equation is a constant.
solveCubic
(float[]
an array containing coefficients for a cubic
eqn
)

Solves the cubic whose coefficients are in the eqn array and places the non-complex roots back into the same array, returning the number of roots.

public static int

Returns:

the number of roots, or -1 if the equation is a constant
solveCubic
(float[]
the specified array of coefficients to use to solve the cubic equation
eqn
,
float[]
the array that contains the non-complex roots resulting from the solution of the cubic equation
res
)

Solve the cubic whose coefficients are in the eqn array and place the non-complex roots into the res array, returning the number of roots.

private static float
solveEqn(float[] eqn, int order, float t)

public void
subdivide(float
the parameter value at which to subdivide the curve
t
,
CubicCurve2D
the cubic curve object for storing for the left or first portion of the subdivided curve
left
,
CubicCurve2D
the cubic curve object for storing for the right or second portion of the subdivided curve
right
)

Subdivides this cubic curve at the given parameter value (expected to be between 0 and 1) and stores the resulting two subdivided curves into the left and right curve parameters.

public void
subdivide(CubicCurve2D
the cubic curve object for storing for the left or first half of the subdivided curve
left
,
CubicCurve2D
the cubic curve object for storing for the right or second half of the subdivided curve
right
)

Subdivides this cubic curve and stores the resulting two subdivided curves into the left and right curve parameters.

public static void
subdivide(CubicCurve2D
the cubic curve to be subdivided
src
,
CubicCurve2D
the cubic curve object for storing the left or first half of the subdivided curve
left
,
CubicCurve2D
the cubic curve object for storing the right or second half of the subdivided curve
right
)

Subdivides the cubic curve specified by the src parameter and stores the resulting two subdivided curves into the left and right curve parameters.

public static void
subdivide(float[]
the array holding the coordinates for the source curve
src
,
int
the offset into the array of the beginning of the the 6 source coordinates
srcoff
,
float[]
the array for storing the coordinates for the first half of the subdivided curve
left
,
int
the offset into the array of the beginning of the the 6 left coordinates
leftoff
,
float[]
the array for storing the coordinates for the second half of the subdivided curve
right
,
int
the offset into the array of the beginning of the the 6 right coordinates
rightoff
)

Subdivides the cubic curve specified by the coordinates stored in the src array at indices srcoff through (srcoff + 7) and stores the resulting two subdivided curves into the two result arrays at the corresponding indices.

Inherited from com.sun.javafx.geom.Shape:
accumulateaccumulateCubicaccumulateCubicaccumulateQuadcontainsintersectsintersectsLineoutcodepointCrossingsForCubicpointCrossingsForLinepointCrossingsForPathpointCrossingsForQuadrectCrossingsForCubicrectCrossingsForLinerectCrossingsForPathrectCrossingsForQuad

Field Detail

ABOVEback to summary
private static final int ABOVE
BELOWback to summary
private static final int BELOW
ctrlx1back to summary
public float ctrlx1

The X coordinate of the first control point of the cubic curve segment.

ctrlx2back to summary
public float ctrlx2

The X coordinate of the second control point of the cubic curve segment.

ctrly1back to summary
public float ctrly1

The Y coordinate of the first control point of the cubic curve segment.

ctrly2back to summary
public float ctrly2

The Y coordinate of the second control point of the cubic curve segment.

HIGHEDGEback to summary
private static final int HIGHEDGE
INSIDEback to summary
private static final int INSIDE
LOWEDGEback to summary
private static final int LOWEDGE
x1back to summary
public float x1

The X coordinate of the start point of the cubic curve segment.

x2back to summary
public float x2

The X coordinate of the end point of the cubic curve segment.

y1back to summary
public float y1

The Y coordinate of the start point of the cubic curve segment.

y2back to summary
public float y2

The Y coordinate of the end point of the cubic curve segment.

Constructor Detail

CubicCurve2Dback to summary
public CubicCurve2D()

Constructs and initializes a CubicCurve with coordinates (0, 0, 0, 0, 0, 0, 0, 0).

CubicCurve2Dback to summary
public CubicCurve2D(float x1, float y1, float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x2, float y2)

Constructs and initializes a CubicCurve2D from the specified float coordinates.

Parameters
x1:float

the X coordinate for the start point of the resulting CubicCurve2D

y1:float

the Y coordinate for the start point of the resulting CubicCurve2D

ctrlx1:float

the X coordinate for the first control point of the resulting CubicCurve2D

ctrly1:float

the Y coordinate for the first control point of the resulting CubicCurve2D

ctrlx2:float

the X coordinate for the second control point of the resulting CubicCurve2D

ctrly2:float

the Y coordinate for the second control point of the resulting CubicCurve2D

x2:float

the X coordinate for the end point of the resulting CubicCurve2D

y2:float

the Y coordinate for the end point of the resulting CubicCurve2D

Method Detail

calcXback to summary
private float calcX(final float t)
calcYback to summary
private float calcY(final float t)
containsback to summary
public boolean contains(float x, float y)

Implements abstract com.sun.javafx.geom.Shape.contains.

Doc from com.sun.javafx.geom.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape.

Annotations
@Override
containsback to summary
public boolean contains(Point2D p)

Overrides com.sun.javafx.geom.Shape.contains.

Doc from com.sun.javafx.geom.Shape.contains.

Tests if a specified Point2D is inside the boundary of the Shape.

Annotations
@Override
containsback to summary
public boolean contains(float x, float y, float w, float h)

Implements abstract com.sun.javafx.geom.Shape.contains.

Doc from com.sun.javafx.geom.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectanglar area to be considered contained within the Shape.

The Shape.contains() method allows a Shape implementation to conservatively return false when:

  • the intersect method returns true and
  • the calculations to determine whether or not the Shape entirely contains the rectangular area are prohibitively expensive.
This means that for some Shapes this method might return false even though the Shape contains the rectangular area. The Area class performs more accurate geometric computations than most Shape objects and therefore can be used if a more precise answer is required.
Annotations
@Override
copyback to summary
public CubicCurve2D copy()

Implements abstract com.sun.javafx.geom.Shape.copy.

Doc from com.sun.javafx.geom.Shape.copy.

Returns a new copy of this Shape instance.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
evalback to summary
public Point2D eval(float t)

Evaluates this cubic curve at the given parameter value, where it is expected, but not required, that the parameter will be between 0 and 1. 0 corresponds to the start point of the curve and 1 corresponds to the end point of the curve.

Parameters
t:float

parameter value at which to evaluate the curve

Returns:Point2D

a newly allocated Point2D containing the evaluation of the curve at that parameter value

evalback to summary
public void eval(float td, Point2D result)

Evaluates this cubic curve at the given parameter value, where it is expected, but not required, that the parameter will be between 0 and 1. 0 corresponds to the start point of the curve and 1 corresponds to the end point of the curve.

Parameters
td:float

parameter value at which to evaluate the curve

result:Point2D

Point2D in to which to store the evaluation of the curve at that parameter value

evalCubicback to summary
private static int evalCubic(float[] vals, int num, boolean include0, boolean include1, float[] inflect, float c1, float cp1, float cp2, float c2)
evalDtback to summary
public Point2D evalDt(float t)

Evaluates the derivative of this cubic curve at the given parameter value, where it is expected, but not required, that the parameter will be between 0 and 1. 0 corresponds to the derivative at the start point of the curve and 1 corresponds to the derivative at the end point of the curve.

Parameters
t:float

parameter value at which to compute the derivative of the curve

Returns:Point2D

a newly allocated Point2D containing the derivative of the curve at that parameter value

evalDtback to summary
public void evalDt(float td, Point2D result)

Evaluates the derivative of this cubic curve at the given parameter value, where it is expected, but not required, that the parameter will be between 0 and 1. 0 corresponds to the derivative at the start point of the curve and 1 corresponds to the derivative at the end point of the curve.

Parameters
result:Point2D

Point2D in to which to store the derivative of the curve at that parameter value

fillEqnback to summary
private static void fillEqn(float[] eqn, float val, float c1, float cp1, float cp2, float c2)
findZeroback to summary
private static float findZero(float t, float target, float[] eqn)
fixRootsback to summary
private static void fixRoots(float[] res, float[] eqn)
getBoundsback to summary
public RectBounds getBounds()

Implements abstract com.sun.javafx.geom.Shape.getBounds.

Doc from com.sun.javafx.geom.Shape.getBounds.

Note that there is no guarantee that the returned RectBounds is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated RectBounds.

Annotations
@Override
getFlatnessback to summary
public static float getFlatness(float x1, float y1, float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x2, float y2)

Returns the flatness of the cubic curve specified by the indicated control points. The flatness is the maximum distance of a control point from the line connecting the end points.

Parameters
x1:float

the X coordinate that specifies the start point of a CubicCurve2D

y1:float

the Y coordinate that specifies the start point of a CubicCurve2D

ctrlx1:float

the X coordinate that specifies the first control point of a CubicCurve2D

ctrly1:float

the Y coordinate that specifies the first control point of a CubicCurve2D

ctrlx2:float

the X coordinate that specifies the second control point of a CubicCurve2D

ctrly2:float

the Y coordinate that specifies the second control point of a CubicCurve2D

x2:float

the X coordinate that specifies the end point of a CubicCurve2D

y2:float

the Y coordinate that specifies the end point of a CubicCurve2D

Returns:float

the flatness of the CubicCurve2D represented by the specified coordinates.

getFlatnessback to summary
public static float getFlatness(float[] coords, int offset)

Returns the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index. The flatness is the maximum distance of a control point from the line connecting the end points.

Parameters
coords:float[]

an array containing coordinates

offset:int

the index of coords from which to begin getting the end points and control points of the curve

Returns:float

the flatness of the CubicCurve2D specified by the coordinates in coords at the specified offset.

getFlatnessback to summary
public float getFlatness()

Returns the flatness of this curve. The flatness is the maximum distance of a control point from the line connecting the end points.

Returns:float

the flatness of this curve.

getFlatnessSqback to summary
public static float getFlatnessSq(float x1, float y1, float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x2, float y2)

Returns the square of the flatness of the cubic curve specified by the indicated control points. The flatness is the maximum distance of a control point from the line connecting the end points.

Parameters
x1:float

the X coordinate that specifies the start point of a CubicCurve2D

y1:float

the Y coordinate that specifies the start point of a CubicCurve2D

ctrlx1:float

the X coordinate that specifies the first control point of a CubicCurve2D

ctrly1:float

the Y coordinate that specifies the first control point of a CubicCurve2D

ctrlx2:float

the X coordinate that specifies the second control point of a CubicCurve2D

ctrly2:float

the Y coordinate that specifies the second control point of a CubicCurve2D

x2:float

the X coordinate that specifies the end point of a CubicCurve2D

y2:float

the Y coordinate that specifies the end point of a CubicCurve2D

Returns:float

the square of the flatness of the CubicCurve2D represented by the specified coordinates.

getFlatnessSqback to summary
public static float getFlatnessSq(float[] coords, int offset)

Returns the square of the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index. The flatness is the maximum distance of a control point from the line connecting the end points.

Parameters
coords:float[]

an array containing coordinates

offset:int

the index of coords from which to begin getting the end points and control points of the curve

Returns:float

the square of the flatness of the CubicCurve2D specified by the coordinates in coords at the specified offset.

getFlatnessSqback to summary
public float getFlatnessSq()

Returns the square of the flatness of this curve. The flatness is the maximum distance of a control point from the line connecting the end points.

Returns:float

the square of the flatness of this curve.

getPathIteratorback to summary
public PathIterator getPathIterator(BaseTransform tx)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Returns an iteration object that defines the boundary of the shape. The iterator for this class is not multi-threaded safe, which means that this CubicCurve2D class does not guarantee that modifications to the geometry of this CubicCurve2D object do not affect any iterations of that geometry that are already in process.

Parameters
tx:BaseTransform

an optional BaseTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired

Returns:PathIterator

the PathIterator object that returns the geometry of the outline of this CubicCurve2D, one segment at a time.

Annotations
@Override
getPathIteratorback to summary
public PathIterator getPathIterator(BaseTransform tx, float flatness)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Return an iteration object that defines the boundary of the flattened shape. The iterator for this class is not multi-threaded safe, which means that this CubicCurve2D class does not guarantee that modifications to the geometry of this CubicCurve2D object do not affect any iterations of that geometry that are already in process.

Parameters
tx:BaseTransform

an optional BaseTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired

flatness:float

the maximum amount that the control points for a given curve can vary from colinear before a subdivided curve is replaced by a straight line connecting the end points

Returns:PathIterator

the PathIterator object that returns the geometry of the outline of this CubicCurve2D, one segment at a time.

Annotations
@Override
getTagback to summary
private static int getTag(float coord, float low, float high)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
intersectsback to summary
public boolean intersects(float x, float y, float w, float h)

Implements abstract com.sun.javafx.geom.Shape.intersects.

Doc from com.sun.javafx.geom.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area. The rectangular area is considered to intersect the Shape if any point is contained in both the interior of the Shape and the specified rectangular area.

The Shape.intersects() method allows a Shape implementation to conservatively return true when:

  • there is a high probability that the rectangular area and the Shape intersect, but
  • the calculations to accurately determine this intersection are prohibitively expensive.
This means that for some Shapes this method might return true even though the rectangular area does not intersect the Shape. The Area class performs more accurate computations of geometric intersection than most Shape objects and therefore can be used if a more precise answer is required.
Annotations
@Override
inwardsback to summary
private static boolean inwards(int pttag, int opt1tag, int opt2tag)
setCurveback to summary
public void setCurve(float x1, float y1, float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x2, float y2)

Sets the location of the end points and control points of this curve to the specified float coordinates.

Parameters
x1:float

the X coordinate used to set the start point of this CubicCurve2D

y1:float

the Y coordinate used to set the start point of this CubicCurve2D

ctrlx1:float

the X coordinate used to set the first control point of this CubicCurve2D

ctrly1:float

the Y coordinate used to set the first control point of this CubicCurve2D

ctrlx2:float

the X coordinate used to set the second control point of this CubicCurve2D

ctrly2:float

the Y coordinate used to set the second control point of this CubicCurve2D

x2:float

the X coordinate used to set the end point of this CubicCurve2D

y2:float

the Y coordinate used to set the end point of this CubicCurve2D

setCurveback to summary
public void setCurve(float[] coords, int offset)

Sets the location of the end points and control points of this curve to the double coordinates at the specified offset in the specified array.

Parameters
coords:float[]

a double array containing coordinates

offset:int

the index of coords from which to begin setting the end points and control points of this curve to the coordinates contained in coords

setCurveback to summary
public void setCurve(Point2D p1, Point2D cp1, Point2D cp2, Point2D p2)

Sets the location of the end points and control points of this curve to the specified Point2D coordinates.

Parameters
p1:Point2D

the first specified Point2D used to set the start point of this curve

cp1:Point2D

the second specified Point2D used to set the first control point of this curve

cp2:Point2D

the third specified Point2D used to set the second control point of this curve

p2:Point2D

the fourth specified Point2D used to set the end point of this curve

setCurveback to summary
public void setCurve(Point2D[] pts, int offset)

Sets the location of the end points and control points of this curve to the coordinates of the Point2D objects at the specified offset in the specified array.

Parameters
pts:Point2D[]

an array of Point2D objects

offset:int

the index of pts from which to begin setting the end points and control points of this curve to the points contained in pts

setCurveback to summary
public void setCurve(CubicCurve2D c)

Sets the location of the end points and control points of this curve to the same as those in the specified CubicCurve2D.

Parameters
c:CubicCurve2D

the specified CubicCurve2D

solveCubicback to summary
public static int solveCubic(float[] eqn)

Solves the cubic whose coefficients are in the eqn array and places the non-complex roots back into the same array, returning the number of roots. The solved cubic is represented by the equation:

    eqn = {c, b, a, d}
    dx^3 + ax^2 + bx + c = 0
A return value of -1 is used to distinguish a constant equation that might be always 0 or never 0 from an equation that has no zeroes.
Parameters
eqn:float[]

an array containing coefficients for a cubic

Returns:int

the number of roots, or -1 if the equation is a constant.

solveCubicback to summary
public static int solveCubic(float[] eqn, float[] res)

Solve the cubic whose coefficients are in the eqn array and place the non-complex roots into the res array, returning the number of roots. The cubic solved is represented by the equation: eqn = {c, b, a, d} dx^3 + ax^2 + bx + c = 0 A return value of -1 is used to distinguish a constant equation, which may be always 0 or never 0, from an equation which has no zeroes.

Parameters
eqn:float[]

the specified array of coefficients to use to solve the cubic equation

res:float[]

the array that contains the non-complex roots resulting from the solution of the cubic equation

Returns:int

the number of roots, or -1 if the equation is a constant

solveEqnback to summary
private static float solveEqn(float[] eqn, int order, float t)
subdivideback to summary
public void subdivide(float t, CubicCurve2D left, CubicCurve2D right)

Subdivides this cubic curve at the given parameter value (expected to be between 0 and 1) and stores the resulting two subdivided curves into the left and right curve parameters. Either or both of the left and right objects may be the same as this object or null.

Parameters
t:float

the parameter value at which to subdivide the curve

left:CubicCurve2D

the cubic curve object for storing for the left or first portion of the subdivided curve

right:CubicCurve2D

the cubic curve object for storing for the right or second portion of the subdivided curve

subdivideback to summary
public void subdivide(CubicCurve2D left, CubicCurve2D right)

Subdivides this cubic curve and stores the resulting two subdivided curves into the left and right curve parameters. Either or both of the left and right objects may be the same as this object or null.

Parameters
left:CubicCurve2D

the cubic curve object for storing for the left or first half of the subdivided curve

right:CubicCurve2D

the cubic curve object for storing for the right or second half of the subdivided curve

subdivideback to summary
public static void subdivide(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right)

Subdivides the cubic curve specified by the src parameter and stores the resulting two subdivided curves into the left and right curve parameters. Either or both of the left and right objects may be the same as the src object or null.

Parameters
src:CubicCurve2D

the cubic curve to be subdivided

left:CubicCurve2D

the cubic curve object for storing the left or first half of the subdivided curve

right:CubicCurve2D

the cubic curve object for storing the right or second half of the subdivided curve

subdivideback to summary
public static void subdivide(float[] src, int srcoff, float[] left, int leftoff, float[] right, int rightoff)

Subdivides the cubic curve specified by the coordinates stored in the src array at indices srcoff through (srcoff + 7) and stores the resulting two subdivided curves into the two result arrays at the corresponding indices. Either or both of the left and right arrays may be null or a reference to the same array as the src array. Note that the last point in the first subdivided curve is the same as the first point in the second subdivided curve. Thus, it is possible to pass the same array for left and right and to use offsets, such as rightoff equals (leftoff + 6), in order to avoid allocating extra storage for this common point.

Parameters
src:float[]

the array holding the coordinates for the source curve

srcoff:int

the offset into the array of the beginning of the the 6 source coordinates

left:float[]

the array for storing the coordinates for the first half of the subdivided curve

leftoff:int

the offset into the array of the beginning of the the 6 left coordinates

right:float[]

the array for storing the coordinates for the second half of the subdivided curve

rightoff:int

the offset into the array of the beginning of the the 6 right coordinates