Top Description Inners Fields Constructors Methods
java.awt.geom

public abstract Class QuadCurve2D

extends Object
implements Shape, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.awt.Shape
Known Direct Subclasses
java.awt.geom.QuadCurve2D.Float, java.awt.geom.QuadCurve2D.Double
Imports
java.awt.Rectangle, .Shape, java.io.Serial, .Serializable

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

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

Author
Jim Graham
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
QuadCurve2D.Double

A quadratic parametric curve segment specified with double coordinates.

public static class
QuadCurve2D.Float

A quadratic parametric curve segment specified with float coordinates.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
protected
QuadCurve2D()

This is an abstract class that cannot be instantiated directly.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

a clone of this instance.
clone
()

Overrides java.lang.Object.clone.

Creates a new object of the same class and with the same contents as this object.
public boolean
contains(double
the specified X coordinate to be tested
x
,
double
the specified Y coordinate to be tested
y
)

Implements java.awt.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape, as described by the definition of insideness.
public boolean
contains(Point2D
the specified Point2D to be tested
p
)

Implements java.awt.Shape.contains.

Tests if a specified Point2D is inside the boundary of the Shape, as described by the definition of insideness.
public boolean
contains(double
the X coordinate of the upper-left corner of the specified rectangular area
x
,
double
the Y coordinate of the upper-left corner of the specified rectangular area
y
,
double
the width of the specified rectangular area
w
,
double
the height of the specified rectangular area
h
)

Implements java.awt.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area.
public boolean
contains(Rectangle2D
The specified Rectangle2D
r
)

Implements java.awt.Shape.contains.

Tests if the interior of the Shape entirely contains the specified Rectangle2D.
private static int
evalQuadratic(double[] vals, int num, boolean include0, boolean include1, double[] inflect, double c1, double ctrl, double c2)

Evaluate the t values in the first num slots of the vals[] array and place the evaluated values back into the same array.

private static void
fillEqn(double[] eqn, double val, double c1, double cp, double c2)

Fill an array with the coefficients of the parametric equation in t, ready for solving against val with solveQuadratic.

public Rectangle
getBounds()

Implements java.awt.Shape.getBounds.

Returns an integer Rectangle that completely encloses the Shape.
public Rectangle2D
getBounds2D()

Implements java.awt.Shape.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method.
public abstract Point2D

Returns:

a Point2D that is the control point of this Point2D.
getCtrlPt
()

Returns the control point.

public abstract double

Returns:

X coordinate the control point
getCtrlX
()

Returns the X coordinate of the control point in double precision.

public abstract double

Returns:

the Y coordinate of the control point.
getCtrlY
()

Returns the Y coordinate of the control point in double precision.

public static double

Returns:

the flatness of the quadratic curve defined by the specified coordinates.
getFlatness
(double
the X coordinate of the start point
x1
,
double
the Y coordinate of the start point
y1
,
double
the X coordinate of the control point
ctrlx
,
double
the Y coordinate of the control point
ctrly
,
double
the X coordinate of the end point
x2
,
double
the Y coordinate of the end point
y2
)

Returns the flatness, or maximum distance of a control point from the line connecting the end points, of the quadratic curve specified by the indicated control points.

public static double

Returns:

the flatness of a quadratic curve defined by the specified array at the specified offset.
getFlatness
(double[]
an array containing coordinate values
coords
,
int
the index into coords from which to start getting the coordinate values
offset
)

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

public double

Returns:

the flatness of this QuadCurve2D.
getFlatness
()

Returns the flatness, or maximum distance of a control point from the line connecting the end points, of this QuadCurve2D.

public static double

Returns:

the square of the flatness of the quadratic curve defined by the specified coordinates.
getFlatnessSq
(double
the X coordinate of the start point
x1
,
double
the Y coordinate of the start point
y1
,
double
the X coordinate of the control point
ctrlx
,
double
the Y coordinate of the control point
ctrly
,
double
the X coordinate of the end point
x2
,
double
the Y coordinate of the end point
y2
)

Returns the square of the flatness, or maximum distance of a control point from the line connecting the end points, of the quadratic curve specified by the indicated control points.

public static double

Returns:

the flatness of the quadratic curve that is defined by the values in the specified array at the specified index.
getFlatnessSq
(double[]
an array containing coordinate values
coords
,
int
the index into coords from which to to start getting the values from the array
offset
)

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

public double

Returns:

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

Returns the square of the flatness, or maximum distance of a control point from the line connecting the end points, of this QuadCurve2D.

public abstract Point2D

Returns:

a Point2D that is the start point of this QuadCurve2D.
getP1
()

Returns the start point.

public abstract Point2D

Returns:

a Point object that is the end point of this Point2D.
getP2
()

Returns the end point.

public PathIterator

Returns:

a PathIterator object that defines the boundary of the shape.
getPathIterator
(AffineTransform
an optional AffineTransform to apply to the shape boundary
at
)

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of the shape of this QuadCurve2D.
public PathIterator

Returns:

a PathIterator object that defines the flattened boundary of the shape.
getPathIterator
(AffineTransform
an optional AffineTransform to apply to the boundary of the shape
at
,
double
the maximum distance that the control points for a subdivided curve can be with respect to a line connecting the end points of this curve before this curve is replaced by a straight line connecting the end points.
flatness
)

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of the flattened shape of this QuadCurve2D.
private static int
getTag(double coord, double low, double high)

Determine where coord lies with respect to the range from low to high.

public abstract double

Returns:

the X coordinate of the start point.
getX1
()

Returns the X coordinate of the start point in double in precision.

public abstract double

Returns:

the x coordinate of the end point.
getX2
()

Returns the X coordinate of the end point in double precision.

public abstract double

Returns:

the Y coordinate of the start point.
getY1
()

Returns the Y coordinate of the start point in double precision.

public abstract double

Returns:

the Y coordinate of the end point.
getY2
()

Returns the Y coordinate of the end point in double precision.

public boolean
intersects(double
the X coordinate of the upper-left corner of the specified rectangular area
x
,
double
the Y coordinate of the upper-left corner of the specified rectangular area
y
,
double
the width of the specified rectangular area
w
,
double
the height of the specified rectangular area
h
)

Implements java.awt.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area.
public boolean
intersects(Rectangle2D
the specified Rectangle2D
r
)

Implements java.awt.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified Rectangle2D.
private static boolean
inwards(int pttag, int opt1tag, int opt2tag)

Determine if the pttag represents a coordinate that is already in its test range, or is on the border with either of the two opttags representing another coordinate that is "towards the inside" of that test range.

public abstract void
setCurve(double
the X coordinate of the start point
x1
,
double
the Y coordinate of the start point
y1
,
double
the X coordinate of the control point
ctrlx
,
double
the Y coordinate of the control point
ctrly
,
double
the X coordinate of the end point
x2
,
double
the Y coordinate of the end point
y2
)

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

public void
setCurve(double[]
the array containing coordinate values
coords
,
int
the index into the array from which to start getting the coordinate values and assigning them to this QuadCurve2D
offset
)

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

public void
setCurve(Point2D
the start point
p1
,
Point2D
the control point
cp
,
Point2D
the end point
p2
)

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

public void
setCurve(Point2D[]
an array containing Point2D that define coordinate values
pts
,
int
the index into pts from which to start getting the coordinate values and assigning them to this QuadCurve2D
offset
)

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

public void
setCurve(QuadCurve2D
the specified QuadCurve2D
c
)

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

public static int

Returns:

the number of roots, or -1 if the equation is a constant
solveQuadratic
(double[]
the array that contains the quadratic coefficients
eqn
)

Solves the quadratic 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.
solveQuadratic
(double[]
the specified array of coefficients to use to solve the quadratic equation
eqn
,
double[]
the array that contains the non-complex roots resulting from the solution of the quadratic equation
res
)

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

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

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

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

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

public static void
subdivide(double[]
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
,
double[]
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
,
double[]
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 quadratic curve specified by the coordinates stored in the src array at indices srcoff through srcoff + 5 and stores the resulting two subdivided curves into the two result arrays at the corresponding indices.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait