 Direct Known Subclasses:
CubicCurve2D.Double
,CubicCurve2D.Float
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.
 Since:
 1.2

Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A cubic parametric curve segment specified withdouble
coordinates.static class
A cubic parametric curve segment specified withfloat
coordinates. 
Constructor Summary
ModifierConstructorDescriptionprotected
This is an abstract class that cannot be instantiated directly. 
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates a new object of the same class as this object.boolean
contains
(double x, double y) Tests if the specified coordinates are inside the boundary of theShape
, as described by the definition of insideness.boolean
contains
(double x, double y, double w, double h) Tests if the interior of theShape
entirely contains the specified rectangular area.boolean
Tests if a specifiedPoint2D
is inside the boundary of theShape
, as described by the definition of insideness.boolean
Tests if the interior of theShape
entirely contains the specifiedRectangle2D
.Returns an integerRectangle
that completely encloses theShape
.abstract Point2D
Returns the first control point.abstract Point2D
Returns the second control point.abstract double
Returns the X coordinate of the first control point in double precision.abstract double
Returns the X coordinate of the second control point in double precision.abstract double
Returns the Y coordinate of the first control point in double precision.abstract double
Returns the Y coordinate of the second control point in double precision.double
Returns the flatness of this curve.static double
getFlatness
(double[] coords, int offset) Returns the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index.static double
getFlatness
(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) Returns the flatness of the cubic curve specified by the indicated control points.double
Returns the square of the flatness of this curve.static double
getFlatnessSq
(double[] 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.static double
getFlatnessSq
(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) Returns the square of the flatness of the cubic curve specified by the indicated control points.abstract Point2D
getP1()
Returns the start point.abstract Point2D
getP2()
Returns the end point.Returns an iteration object that defines the boundary of the shape.getPathIterator
(AffineTransform at, double flatness) Return an iteration object that defines the boundary of the flattened shape.abstract double
getX1()
Returns the X coordinate of the start point in double precision.abstract double
getX2()
Returns the X coordinate of the end point in double precision.abstract double
getY1()
Returns the Y coordinate of the start point in double precision.abstract double
getY2()
Returns the Y coordinate of the end point in double precision.boolean
intersects
(double x, double y, double w, double h) Tests if the interior of theShape
intersects the interior of a specified rectangular area.boolean
Tests if the interior of theShape
intersects the interior of a specifiedRectangle2D
.void
setCurve
(double[] 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.abstract void
setCurve
(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) Sets the location of the end points and control points of this curve to the specified double coordinates.void
Sets the location of the end points and control points of this curve to the same as those in the specifiedCubicCurve2D
.void
Sets the location of the end points and control points of this curve to the coordinates of thePoint2D
objects at the specified offset in the specified array.void
Sets the location of the end points and control points of this curve to the specifiedPoint2D
coordinates.static int
solveCubic
(double[] eqn) Solves the cubic whose coefficients are in theeqn
array and places the noncomplex roots back into the same array, returning the number of roots.static int
solveCubic
(double[] eqn, double[] res) Solve the cubic whose coefficients are in theeqn
array and place the noncomplex roots into theres
array, returning the number of roots.static void
subdivide
(double[] src, int srcoff, double[] left, int leftoff, double[] right, int rightoff) Subdivides the cubic curve specified by the coordinates stored in thesrc
array at indicessrcoff
through (srcoff
+ 7) and stores the resulting two subdivided curves into the two result arrays at the corresponding indices.void
subdivide
(CubicCurve2D left, CubicCurve2D right) Subdivides this cubic curve and stores the resulting two subdivided curves into the left and right curve parameters.static void
subdivide
(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right) Subdivides the cubic curve specified by thesrc
parameter and stores the resulting two subdivided curves into theleft
andright
curve parameters.Methods declared in class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods declared in interface java.awt.Shape
getBounds2D

Constructor Details

CubicCurve2D
protected CubicCurve2D()This is an abstract class that cannot be instantiated directly. Typespecific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below. Since:
 1.2
 See Also:


Method Details

getX1
public abstract double getX1()Returns the X coordinate of the start point in double precision. Returns:
 the X coordinate of the start point of the
CubicCurve2D
.  Since:
 1.2

getY1
public abstract double getY1()Returns the Y coordinate of the start point in double precision. Returns:
 the Y coordinate of the start point of the
CubicCurve2D
.  Since:
 1.2

getP1
Returns the start point. Returns:
 a
Point2D
that is the start point of theCubicCurve2D
.  Since:
 1.2

getCtrlX1
public abstract double getCtrlX1()Returns the X coordinate of the first control point in double precision. Returns:
 the X coordinate of the first control point of the
CubicCurve2D
.  Since:
 1.2

getCtrlY1
public abstract double getCtrlY1()Returns the Y coordinate of the first control point in double precision. Returns:
 the Y coordinate of the first control point of the
CubicCurve2D
.  Since:
 1.2

getCtrlP1
Returns the first control point. Returns:
 a
Point2D
that is the first control point of theCubicCurve2D
.  Since:
 1.2

getCtrlX2
public abstract double getCtrlX2()Returns the X coordinate of the second control point in double precision. Returns:
 the X coordinate of the second control point of the
CubicCurve2D
.  Since:
 1.2

getCtrlY2
public abstract double getCtrlY2()Returns the Y coordinate of the second control point in double precision. Returns:
 the Y coordinate of the second control point of the
CubicCurve2D
.  Since:
 1.2

getCtrlP2
Returns the second control point. Returns:
 a
Point2D
that is the second control point of theCubicCurve2D
.  Since:
 1.2

getX2
public abstract double getX2()Returns the X coordinate of the end point in double precision. Returns:
 the X coordinate of the end point of the
CubicCurve2D
.  Since:
 1.2

getY2
public abstract double getY2()Returns the Y coordinate of the end point in double precision. Returns:
 the Y coordinate of the end point of the
CubicCurve2D
.  Since:
 1.2

getP2
Returns the end point. Returns:
 a
Point2D
that is the end point of theCubicCurve2D
.  Since:
 1.2

setCurve
public abstract void setCurve(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) Sets the location of the end points and control points of this curve to the specified double coordinates. Parameters:
x1
 the X coordinate used to set the start point of thisCubicCurve2D
y1
 the Y coordinate used to set the start point of thisCubicCurve2D
ctrlx1
 the X coordinate used to set the first control point of thisCubicCurve2D
ctrly1
 the Y coordinate used to set the first control point of thisCubicCurve2D
ctrlx2
 the X coordinate used to set the second control point of thisCubicCurve2D
ctrly2
 the Y coordinate used to set the second control point of thisCubicCurve2D
x2
 the X coordinate used to set the end point of thisCubicCurve2D
y2
 the Y coordinate used to set the end point of thisCubicCurve2D
 Since:
 1.2

setCurve
public void setCurve(double[] 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
 a double array containing coordinatesoffset
 the index ofcoords
from which to begin setting the end points and control points of this curve to the coordinates contained incoords
 Since:
 1.2

setCurve
Sets the location of the end points and control points of this curve to the specifiedPoint2D
coordinates. Parameters:
p1
 the first specifiedPoint2D
used to set the start point of this curvecp1
 the second specifiedPoint2D
used to set the first control point of this curvecp2
 the third specifiedPoint2D
used to set the second control point of this curvep2
 the fourth specifiedPoint2D
used to set the end point of this curve Since:
 1.2

setCurve
Sets the location of the end points and control points of this curve to the coordinates of thePoint2D
objects at the specified offset in the specified array. Parameters:
pts
 an array ofPoint2D
objectsoffset
 the index ofpts
from which to begin setting the end points and control points of this curve to the points contained inpts
 Since:
 1.2

setCurve
Sets the location of the end points and control points of this curve to the same as those in the specifiedCubicCurve2D
. Parameters:
c
 the specifiedCubicCurve2D
 Since:
 1.2

getFlatnessSq
public static double getFlatnessSq(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double 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
 the X coordinate that specifies the start point of aCubicCurve2D
y1
 the Y coordinate that specifies the start point of aCubicCurve2D
ctrlx1
 the X coordinate that specifies the first control point of aCubicCurve2D
ctrly1
 the Y coordinate that specifies the first control point of aCubicCurve2D
ctrlx2
 the X coordinate that specifies the second control point of aCubicCurve2D
ctrly2
 the Y coordinate that specifies the second control point of aCubicCurve2D
x2
 the X coordinate that specifies the end point of aCubicCurve2D
y2
 the Y coordinate that specifies the end point of aCubicCurve2D
 Returns:
 the square of the flatness of the
CubicCurve2D
represented by the specified coordinates.  Since:
 1.2

getFlatness
public static double getFlatness(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double 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
 the X coordinate that specifies the start point of aCubicCurve2D
y1
 the Y coordinate that specifies the start point of aCubicCurve2D
ctrlx1
 the X coordinate that specifies the first control point of aCubicCurve2D
ctrly1
 the Y coordinate that specifies the first control point of aCubicCurve2D
ctrlx2
 the X coordinate that specifies the second control point of aCubicCurve2D
ctrly2
 the Y coordinate that specifies the second control point of aCubicCurve2D
x2
 the X coordinate that specifies the end point of aCubicCurve2D
y2
 the Y coordinate that specifies the end point of aCubicCurve2D
 Returns:
 the flatness of the
CubicCurve2D
represented by the specified coordinates.  Since:
 1.2

getFlatnessSq
public static double getFlatnessSq(double[] 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
 an array containing coordinatesoffset
 the index ofcoords
from which to begin getting the end points and control points of the curve Returns:
 the square of the flatness of the
CubicCurve2D
specified by the coordinates incoords
at the specified offset.  Since:
 1.2

getFlatness
public static double getFlatness(double[] 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
 an array containing coordinatesoffset
 the index ofcoords
from which to begin getting the end points and control points of the curve Returns:
 the flatness of the
CubicCurve2D
specified by the coordinates incoords
at the specified offset.  Since:
 1.2

getFlatnessSq
public double 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:
 the square of the flatness of this curve.
 Since:
 1.2

getFlatness
public double 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:
 the flatness of this curve.
 Since:
 1.2

subdivide
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
 the cubic curve object for storing for the left or first half of the subdivided curveright
 the cubic curve object for storing for the right or second half of the subdivided curve Since:
 1.2

subdivide
Subdivides the cubic curve specified by thesrc
parameter and stores the resulting two subdivided curves into theleft
andright
curve parameters. Either or both of theleft
andright
objects may be the same as thesrc
object ornull
. Parameters:
src
 the cubic curve to be subdividedleft
 the cubic curve object for storing the left or first half of the subdivided curveright
 the cubic curve object for storing the right or second half of the subdivided curve Since:
 1.2

subdivide
public static void subdivide(double[] src, int srcoff, double[] left, int leftoff, double[] right, int rightoff) Subdivides the cubic curve specified by the coordinates stored in thesrc
array at indicessrcoff
through (srcoff
+ 7) and stores the resulting two subdivided curves into the two result arrays at the corresponding indices. Either or both of theleft
andright
arrays may benull
or a reference to the same array as thesrc
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 forleft
andright
and to use offsets, such asrightoff
equals (leftoff
+ 6), in order to avoid allocating extra storage for this common point. Parameters:
src
 the array holding the coordinates for the source curvesrcoff
 the offset into the array of the beginning of the the 6 source coordinatesleft
 the array for storing the coordinates for the first half of the subdivided curveleftoff
 the offset into the array of the beginning of the the 6 left coordinatesright
 the array for storing the coordinates for the second half of the subdivided curverightoff
 the offset into the array of the beginning of the the 6 right coordinates Since:
 1.2

solveCubic
public static int solveCubic(double[] eqn) Solves the cubic whose coefficients are in theeqn
array and places the noncomplex 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
 an array containing coefficients for a cubic Returns:
 the number of roots, or 1 if the equation is a constant.
 Since:
 1.2

solveCubic
public static int solveCubic(double[] eqn, double[] res) Solve the cubic whose coefficients are in theeqn
array and place the noncomplex roots into theres
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
 the specified array of coefficients to use to solve the cubic equationres
 the array that contains the noncomplex roots resulting from the solution of the cubic equation Returns:
 the number of roots, or 1 if the equation is a constant
 Since:
 1.3

contains
public boolean contains(double x, double y) Tests if the specified coordinates are inside the boundary of theShape
, as described by the definition of insideness. 
contains
Tests if a specifiedPoint2D
is inside the boundary of theShape
, as described by the definition of insideness. 
intersects
public boolean intersects(double x, double y, double w, double h) Tests if the interior of theShape
intersects the interior of a specified rectangular area. The rectangular area is considered to intersect theShape
if any point is contained in both the interior of theShape
and the specified rectangular area.The
Shape.intersects()
method allows aShape
implementation to conservatively returntrue
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.
Shapes
this method might returntrue
even though the rectangular area does not intersect theShape
. TheArea
class performs more accurate computations of geometric intersection than mostShape
objects and therefore can be used if a more precise answer is required. Specified by:
intersects
in interfaceShape
 Parameters:
x
 the X coordinate of the upperleft corner of the specified rectangular areay
 the Y coordinate of the upperleft corner of the specified rectangular areaw
 the width of the specified rectangular areah
 the height of the specified rectangular area Returns:
true
if the interior of theShape
and the interior of the rectangular area intersect, or are both highly likely to intersect and intersection calculations would be too expensive to perform;false
otherwise. Since:
 1.2
 See Also:

there is a high probability that the rectangular area and the

intersects
Tests if the interior of theShape
intersects the interior of a specifiedRectangle2D
. TheShape.intersects()
method allows aShape
implementation to conservatively returntrue
when:
there is a high probability that the
Rectangle2D
and theShape
intersect, but  the calculations to accurately determine this intersection are prohibitively expensive.
Shapes
this method might returntrue
even though theRectangle2D
does not intersect theShape
. TheArea
class performs more accurate computations of geometric intersection than mostShape
objects and therefore can be used if a more precise answer is required. Specified by:
intersects
in interfaceShape
 Parameters:
r
 the specifiedRectangle2D
 Returns:
true
if the interior of theShape
and the interior of the specifiedRectangle2D
intersect, or are both highly likely to intersect and intersection calculations would be too expensive to perform;false
otherwise. Since:
 1.2
 See Also:

there is a high probability that the

contains
public boolean contains(double x, double y, double w, double h) Tests if the interior of theShape
entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within theShape
for the entire rectangular area to be considered contained within theShape
.The
Shape.contains()
method allows aShape
implementation to conservatively returnfalse
when:
the
intersect
method returnstrue
and 
the calculations to determine whether or not the
Shape
entirely contains the rectangular area are prohibitively expensive.
Shapes
this method might returnfalse
even though theShape
contains the rectangular area. TheArea
class performs more accurate geometric computations than mostShape
objects and therefore can be used if a more precise answer is required. Specified by:
contains
in interfaceShape
 Parameters:
x
 the X coordinate of the upperleft corner of the specified rectangular areay
 the Y coordinate of the upperleft corner of the specified rectangular areaw
 the width of the specified rectangular areah
 the height of the specified rectangular area Returns:
true
if the interior of theShape
entirely contains the specified rectangular area;false
otherwise or, if theShape
contains the rectangular area and theintersects
method returnstrue
and the containment calculations would be too expensive to perform. Since:
 1.2
 See Also:

the

contains
Tests if the interior of theShape
entirely contains the specifiedRectangle2D
. TheShape.contains()
method allows aShape
implementation to conservatively returnfalse
when:
the
intersect
method returnstrue
and 
the calculations to determine whether or not the
Shape
entirely contains theRectangle2D
are prohibitively expensive.
Shapes
this method might returnfalse
even though theShape
contains theRectangle2D
. TheArea
class performs more accurate geometric computations than mostShape
objects and therefore can be used if a more precise answer is required. Specified by:
contains
in interfaceShape
 Parameters:
r
 The specifiedRectangle2D
 Returns:
true
if the interior of theShape
entirely contains theRectangle2D
;false
otherwise or, if theShape
contains theRectangle2D
and theintersects
method returnstrue
and the containment calculations would be too expensive to perform. Since:
 1.2
 See Also:

the

getBounds
Returns an integerRectangle
that completely encloses theShape
. Note that there is no guarantee that the returnedRectangle
is the smallest bounding box that encloses theShape
, only that theShape
lies entirely within the indicatedRectangle
. The returnedRectangle
might also fail to completely enclose theShape
if theShape
overflows the limited range of the integer data type. ThegetBounds2D
method generally returns a tighter bounding box due to its greater flexibility in representation.Note that the definition of insideness can lead to situations where points on the defining outline of the
shape
may not be considered contained in the returnedbounds
object, but only in cases where those points are also not considered contained in the originalshape
.If a
point
is inside theshape
according to thecontains(point)
method, then it must be inside the returnedRectangle
bounds object according to thecontains(point)
method of thebounds
. Specifically:shape.contains(x,y)
requiresbounds.contains(x,y)
If a
point
is not inside theshape
, then it might still be contained in thebounds
object:bounds.contains(x,y)
does not implyshape.contains(x,y)

getPathIterator
Returns an iteration object that defines the boundary of the shape. The iterator for this class is not multithreaded safe, which means that thisCubicCurve2D
class does not guarantee that modifications to the geometry of thisCubicCurve2D
object do not affect any iterations of that geometry that are already in process. Specified by:
getPathIterator
in interfaceShape
 Parameters:
at
 an optionalAffineTransform
to be applied to the coordinates as they are returned in the iteration, ornull
if untransformed coordinates are desired Returns:
 the
PathIterator
object that returns the geometry of the outline of thisCubicCurve2D
, one segment at a time.  Since:
 1.2

getPathIterator
Return an iteration object that defines the boundary of the flattened shape. The iterator for this class is not multithreaded safe, which means that thisCubicCurve2D
class does not guarantee that modifications to the geometry of thisCubicCurve2D
object do not affect any iterations of that geometry that are already in process. Specified by:
getPathIterator
in interfaceShape
 Parameters:
at
 an optionalAffineTransform
to be applied to the coordinates as they are returned in the iteration, ornull
if untransformed coordinates are desiredflatness
 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:
 the
PathIterator
object that returns the geometry of the outline of thisCubicCurve2D
, one segment at a time.  Since:
 1.2

clone
Creates a new object of the same class as this object. Overrides:
clone
in classObject
 Returns:
 a clone of this instance.
 Throws:
OutOfMemoryError
 if there is not enough memory. Since:
 1.2
 See Also:
