This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.awt.geom
class QuadCurve2D

java.lang.Object extended by java.awt.geom.QuadCurve2D
All Implemented Interfaces:
Shape, Cloneable
Direct Known Subclasses:
QuadCurve2D.Double, QuadCurve2D.Float

public abstract class QuadCurve2D
extends Object
implements Shape, Cloneable

The QuadCurve2D class defines a quadratic parametric curve segment in {@code (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.


Nested Class Summary
static class

           A quadratic parametric curve segment specified with coordinates.
static class

           A quadratic parametric curve segment specified with coordinates.
 
Constructor Summary
protected

          This is an abstract class that cannot be instantiated directly.
 
Method Summary
 Object

          Creates a new object of the same class and with the same contents as this object.
 boolean
contains(double x, double y)

          
 boolean
contains(double x, double y, double w, double h)

          
 boolean

          
 boolean

          
 Rectangle

          
abstract Point2D

          Returns the control point.
abstract double

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

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

          Returns the flatness, or maximum distance of a control point from the line connecting the end points, of this QuadCurve2D.
static double
getFlatness(double x1, double y1, double ctrlx, double ctrly, double x2, double 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.
static double
getFlatness(double[] coords, int 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.
 double

          Returns the square of the flatness, or maximum distance of a control point from the line connecting the end points, of this QuadCurve2D.
static double
getFlatnessSq(double x1, double y1, double ctrlx, double ctrly, double x2, double 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.
static double
getFlatnessSq(double[] coords, int 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.
abstract Point2D

          Returns the start point.
abstract Point2D

          Returns the end point.
 PathIterator

          Returns an iteration object that defines the boundary of the shape of this QuadCurve2D.
 PathIterator
getPathIterator(AffineTransform at, double flatness)

          Returns an iteration object that defines the boundary of the flattened shape of this QuadCurve2D.
abstract double

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

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

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

          Returns the Y coordinate of the end point in double precision.
 boolean
intersects(double x, double y, double w, double h)

          
 boolean

          
abstract void
setCurve(double x1, double y1, double ctrlx, double ctrly, double x2, double y2)

          Sets the location of the end points and control point of this curve to the specified double coordinates.
 void
setCurve(double[] coords, int 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.
 void

          Sets the location of the end points and control point of this QuadCurve2D to the specified Point2D coordinates.
 void
setCurve(Point2D[] pts, int 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.
 void

          Sets the location of the end points and control point of this QuadCurve2D to the same as those in the specified QuadCurve2D.
static int
solveQuadratic(double[] 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.
static int
solveQuadratic(double[] eqn, double[] 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.
static void
subdivide(double[] src, int srcoff, double[] left, int leftoff, double[] right, int 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.
 void

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

          Subdivides the quadratic curve specified by the src parameter and stores the resulting two subdivided curves into the left and right curve parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuadCurve2D

protected QuadCurve2D()
This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below.

Method Detail

clone

public Object clone()
Creates a new object of the same class and with the same contents as this object.

Overrides:
clone in class Object
Returns:
a clone of this instance.

contains

public boolean contains(double x,
                        double y)
{@inheritDoc}

Parameters:
x
y

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
{@inheritDoc}

Parameters:
x
y
w
h

contains

public boolean contains(Point2D p)
{@inheritDoc}

Parameters:
p

contains

public boolean contains(Rectangle2D r)
{@inheritDoc}

Parameters:
r

getBounds

public Rectangle getBounds()
{@inheritDoc}


getCtrlPt

public abstract Point2D getCtrlPt()
Returns the control point.

Returns:
a Point2D that is the control point of this Point2D.

getCtrlX

public abstract double getCtrlX()
Returns the X coordinate of the control point in double precision.

Returns:
X coordinate the control point

getCtrlY

public abstract double getCtrlY()
Returns the Y coordinate of the control point in double precision.

Returns:
the Y coordinate of the control point.

getFlatness

public double getFlatness()
Returns the flatness, or maximum distance of a control point from the line connecting the end points, of this QuadCurve2D.

Returns:
the flatness of this QuadCurve2D.

getFlatness

public static double getFlatness(double x1,
                                 double y1,
                                 double ctrlx,
                                 double ctrly,
                                 double x2,
                                 double 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.

Parameters:
x1 - the X coordinate of the start point
y1 - the Y coordinate of the start point
ctrlx - the X coordinate of the control point
ctrly - the Y coordinate of the control point
x2 - the X coordinate of the end point
y2 - the Y coordinate of the end point
Returns:
the flatness of the quadratic curve defined by the specified coordinates.

getFlatness

public static double getFlatness(double[] coords,
                                 int 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.

Parameters:
coords - an array containing coordinate values
offset - the index into coords from which to start getting the coordinate values
Returns:
the flatness of a quadratic curve defined by the specified array at the specified offset.

getFlatnessSq

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

Returns:
the square of the flatness of this QuadCurve2D.

getFlatnessSq

public static double getFlatnessSq(double x1,
                                   double y1,
                                   double ctrlx,
                                   double ctrly,
                                   double x2,
                                   double 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.

Parameters:
x1 - the X coordinate of the start point
y1 - the Y coordinate of the start point
ctrlx - the X coordinate of the control point
ctrly - the Y coordinate of the control point
x2 - the X coordinate of the end point
y2 - the Y coordinate of the end point
Returns:
the square of the flatness of the quadratic curve defined by the specified coordinates.

getFlatnessSq

public static double getFlatnessSq(double[] coords,
                                   int 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.

Parameters:
coords - an array containing coordinate values
offset - the index into coords from which to to start getting the values from the array
Returns:
the flatness of the quadratic curve that is defined by the values in the specified array at the specified index.

getP1

public abstract Point2D getP1()
Returns the start point.

Returns:
a Point2D that is the start point of this QuadCurve2D.

getP2

public abstract Point2D getP2()
Returns the end point.

Returns:
a Point object that is the end point of this Point2D.

getPathIterator

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

Parameters:
at - an optional {@link AffineTransform} to apply to the shape boundary
Returns:
a {@link PathIterator} object that defines the boundary of the shape.

getPathIterator

public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Returns an iteration object that defines the boundary of the flattened shape of this QuadCurve2D. The iterator for this class is not multi-threaded safe, which means that this QuadCurve2D class does not guarantee that modifications to the geometry of this QuadCurve2D object do not affect any iterations of that geometry that are already in process.

Parameters:
at - an optional AffineTransform to apply to the boundary of the shape
flatness - 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.
Returns:
a PathIterator object that defines the flattened boundary of the shape.

getX1

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

Returns:
the X coordinate of the start point.

getX2

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

Returns:
the x coordiante of the end point.

getY1

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

Returns:
the Y coordinate of the start point.

getY2

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

Returns:
the Y coordinate of the end point.

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
{@inheritDoc}

Parameters:
x
y
w
h

intersects

public boolean intersects(Rectangle2D r)
{@inheritDoc}

Parameters:
r

setCurve

public abstract void setCurve(double x1,
                              double y1,
                              double ctrlx,
                              double ctrly,
                              double x2,
                              double y2)
Sets the location of the end points and control point of this curve to the specified double coordinates.

Parameters:
x1 - the X coordinate of the start point
y1 - the Y coordinate of the start point
ctrlx - the X coordinate of the control point
ctrly - the Y coordinate of the control point
x2 - the X coordinate of the end point
y2 - the Y coordinate of the end point

setCurve

public void setCurve(double[] coords,
                     int 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.

Parameters:
coords - the array containing coordinate values
offset - the index into the array from which to start getting the coordinate values and assigning them to this QuadCurve2D

setCurve

public void setCurve(Point2D p1,
                     Point2D cp,
                     Point2D p2)
Sets the location of the end points and control point of this QuadCurve2D to the specified Point2D coordinates.

Parameters:
p1 - the start point
cp - the control point
p2 - the end point

setCurve

public void setCurve(Point2D[] pts,
                     int 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.

Parameters:
pts - an array containing Point2D that define coordinate values
offset - the index into pts from which to start getting the coordinate values and assigning them to this QuadCurve2D

setCurve

public void setCurve(QuadCurve2D c)
Sets the location of the end points and control point of this QuadCurve2D to the same as those in the specified QuadCurve2D.

Parameters:
c - the specified QuadCurve2D

solveQuadratic

public static int solveQuadratic(double[] 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. The quadratic solved is represented by the equation:
     eqn = {C, B, A};
     ax^2 + bx + c = 0
 
A return value of -1 is used to distinguish a constant equation, which might be always 0 or never 0, from an equation that has no zeroes.

Parameters:
eqn - the array that contains the quadratic coefficients
Returns:
the number of roots, or -1 if the equation is a constant

solveQuadratic

public static int solveQuadratic(double[] eqn,
                                 double[] 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. The quadratic solved is represented by the equation:
     eqn = {C, B, A};
     ax^2 + bx + c = 0
 
A return value of -1 is used to distinguish a constant equation, which might be always 0 or never 0, from an equation that has no zeroes.

Parameters:
eqn - the specified array of coefficients to use to solve the quadratic equation
res - the array that contains the non-complex roots resulting from the solution of the quadratic equation
Returns:
the number of roots, or -1 if the equation is a constant.

subdivide

public static void subdivide(double[] src,
                             int srcoff,
                             double[] left,
                             int leftoff,
                             double[] right,
                             int 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. Either or both of the left and right arrays can be null or a reference to the same array and offset 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 that rightoff equals leftoff + 4 in order to avoid allocating extra storage for this common point.

Parameters:
src - the array holding the coordinates for the source curve
srcoff - the offset into the array of the beginning of the the 6 source coordinates
left - the array for storing the coordinates for the first half of the subdivided curve
leftoff - the offset into the array of the beginning of the the 6 left coordinates
right - the array for storing the coordinates for the second half of the subdivided curve
rightoff - the offset into the array of the beginning of the the 6 right coordinates

subdivide

public void subdivide(QuadCurve2D left,
                      QuadCurve2D right)
Subdivides this QuadCurve2D and stores the resulting two subdivided curves into the left and right curve parameters. Either or both of the left and right objects can be the same as this QuadCurve2D or null.

Parameters:
left - the QuadCurve2D object for storing the left or first half of the subdivided curve
right - the QuadCurve2D object for storing the right or second half of the subdivided curve

subdivide

public static void subdivide(QuadCurve2D src,
                             QuadCurve2D left,
                             QuadCurve2D right)
Subdivides the quadratic 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 can be the same as the src object or null.

Parameters:
src - the quadratic curve to be subdivided
left - the QuadCurve2D object for storing the left or first half of the subdivided curve
right - the QuadCurve2D object for storing the right or second half of the subdivided curve


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.