< prev index next >
src/java.desktop/share/classes/java/awt/geom/QuadCurve2D.java
Print this page
*** 29,39 ****
import java.awt.Rectangle;
import java.io.Serializable;
import sun.awt.geom.Curve;
/**
! * The <code>QuadCurve2D</code> class defines a quadratic parametric curve
* segment in {@code (x,y)} coordinate space.
* <p>
* 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
--- 29,39 ----
import java.awt.Rectangle;
import java.io.Serializable;
import sun.awt.geom.Curve;
/**
! * The {@code QuadCurve2D} class defines a quadratic parametric curve
* segment in {@code (x,y)} coordinate space.
* <p>
* 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
*** 98,116 ****
* @serial
*/
public float y2;
/**
! * Constructs and initializes a <code>QuadCurve2D</code> with
* coordinates (0, 0, 0, 0, 0, 0).
* @since 1.2
*/
public Float() {
}
/**
! * Constructs and initializes a <code>QuadCurve2D</code> from the
* specified {@code float} coordinates.
*
* @param x1 the X coordinate of the start point
* @param y1 the Y coordinate of the start point
* @param ctrlx the X coordinate of the control point
--- 98,116 ----
* @serial
*/
public float y2;
/**
! * Constructs and initializes a {@code QuadCurve2D} with
* coordinates (0, 0, 0, 0, 0, 0).
* @since 1.2
*/
public Float() {
}
/**
! * Constructs and initializes a {@code QuadCurve2D} from the
* specified {@code float} coordinates.
*
* @param x1 the X coordinate of the start point
* @param y1 the Y coordinate of the start point
* @param ctrlx the X coordinate of the control point
*** 311,329 ****
* @serial
*/
public double y2;
/**
! * Constructs and initializes a <code>QuadCurve2D</code> with
* coordinates (0, 0, 0, 0, 0, 0).
* @since 1.2
*/
public Double() {
}
/**
! * Constructs and initializes a <code>QuadCurve2D</code> from the
* specified {@code double} coordinates.
*
* @param x1 the X coordinate of the start point
* @param y1 the Y coordinate of the start point
* @param ctrlx the X coordinate of the control point
--- 311,329 ----
* @serial
*/
public double y2;
/**
! * Constructs and initializes a {@code QuadCurve2D} with
* coordinates (0, 0, 0, 0, 0, 0).
* @since 1.2
*/
public Double() {
}
/**
! * Constructs and initializes a {@code QuadCurve2D} from the
* specified {@code double} coordinates.
*
* @param x1 the X coordinate of the start point
* @param y1 the Y coordinate of the start point
* @param ctrlx the X coordinate of the control point
*** 460,542 ****
protected QuadCurve2D() {
}
/**
* Returns the X coordinate of the start point in
! * <code>double</code> in precision.
* @return the X coordinate of the start point.
* @since 1.2
*/
public abstract double getX1();
/**
* Returns the Y coordinate of the start point in
! * <code>double</code> precision.
* @return the Y coordinate of the start point.
* @since 1.2
*/
public abstract double getY1();
/**
* Returns the start point.
! * @return a <code>Point2D</code> that is the start point of this
! * <code>QuadCurve2D</code>.
* @since 1.2
*/
public abstract Point2D getP1();
/**
* Returns the X coordinate of the control point in
! * <code>double</code> precision.
* @return X coordinate the control point
* @since 1.2
*/
public abstract double getCtrlX();
/**
* Returns the Y coordinate of the control point in
! * <code>double</code> precision.
* @return the Y coordinate of the control point.
* @since 1.2
*/
public abstract double getCtrlY();
/**
* Returns the control point.
! * @return a <code>Point2D</code> that is the control point of this
! * <code>Point2D</code>.
* @since 1.2
*/
public abstract Point2D getCtrlPt();
/**
* Returns the X coordinate of the end point in
! * <code>double</code> precision.
* @return the x coordinate of the end point.
* @since 1.2
*/
public abstract double getX2();
/**
* Returns the Y coordinate of the end point in
! * <code>double</code> precision.
* @return the Y coordinate of the end point.
* @since 1.2
*/
public abstract double getY2();
/**
* Returns the end point.
! * @return a <code>Point</code> object that is the end point
! * of this <code>Point2D</code>.
* @since 1.2
*/
public abstract Point2D getP2();
/**
* Sets the location of the end points and control point of this curve
! * to the specified <code>double</code> coordinates.
*
* @param x1 the X coordinate of the start point
* @param y1 the Y coordinate of the start point
* @param ctrlx the X coordinate of the control point
* @param ctrly the Y coordinate of the control point
--- 460,542 ----
protected QuadCurve2D() {
}
/**
* Returns the X coordinate of the start point in
! * {@code double} in precision.
* @return the X coordinate of the start point.
* @since 1.2
*/
public abstract double getX1();
/**
* Returns the Y coordinate of the start point in
! * {@code double} precision.
* @return the Y coordinate of the start point.
* @since 1.2
*/
public abstract double getY1();
/**
* Returns the start point.
! * @return a {@code Point2D} that is the start point of this
! * {@code QuadCurve2D}.
* @since 1.2
*/
public abstract Point2D getP1();
/**
* Returns the X coordinate of the control point in
! * {@code double} precision.
* @return X coordinate the control point
* @since 1.2
*/
public abstract double getCtrlX();
/**
* Returns the Y coordinate of the control point in
! * {@code double} precision.
* @return the Y coordinate of the control point.
* @since 1.2
*/
public abstract double getCtrlY();
/**
* Returns the control point.
! * @return a {@code Point2D} that is the control point of this
! * {@code Point2D}.
* @since 1.2
*/
public abstract Point2D getCtrlPt();
/**
* Returns the X coordinate of the end point in
! * {@code double} precision.
* @return the x coordinate of the end point.
* @since 1.2
*/
public abstract double getX2();
/**
* Returns the Y coordinate of the end point in
! * {@code double} precision.
* @return the Y coordinate of the end point.
* @since 1.2
*/
public abstract double getY2();
/**
* Returns the end point.
! * @return a {@code Point} object that is the end point
! * of this {@code Point2D}.
* @since 1.2
*/
public abstract Point2D getP2();
/**
* Sets the location of the end points and control point of this curve
! * to the specified {@code double} coordinates.
*
* @param x1 the X coordinate of the start point
* @param y1 the Y coordinate of the start point
* @param ctrlx the X coordinate of the control point
* @param ctrly the Y coordinate of the control point
*** 548,574 ****
double ctrlx, double ctrly,
double x2, double y2);
/**
* Sets the location of the end points and control points of this
! * <code>QuadCurve2D</code> to the <code>double</code> coordinates at
* the specified offset in the specified array.
* @param coords the array containing coordinate values
* @param offset the index into the array from which to start
* getting the coordinate values and assigning them to this
! * <code>QuadCurve2D</code>
* @since 1.2
*/
public void setCurve(double[] coords, int offset) {
setCurve(coords[offset + 0], coords[offset + 1],
coords[offset + 2], coords[offset + 3],
coords[offset + 4], coords[offset + 5]);
}
/**
* Sets the location of the end points and control point of this
! * <code>QuadCurve2D</code> to the specified <code>Point2D</code>
* coordinates.
* @param p1 the start point
* @param cp the control point
* @param p2 the end point
* @since 1.2
--- 548,574 ----
double ctrlx, double ctrly,
double x2, double y2);
/**
* Sets the location of the end points and control points of this
! * {@code QuadCurve2D} to the {@code double} coordinates at
* the specified offset in the specified array.
* @param coords the array containing coordinate values
* @param offset the index into the array from which to start
* getting the coordinate values and assigning them to this
! * {@code QuadCurve2D}
* @since 1.2
*/
public void setCurve(double[] coords, int offset) {
setCurve(coords[offset + 0], coords[offset + 1],
coords[offset + 2], coords[offset + 3],
coords[offset + 4], coords[offset + 5]);
}
/**
* Sets the location of the end points and control point of this
! * {@code QuadCurve2D} to the specified {@code Point2D}
* coordinates.
* @param p1 the start point
* @param cp the control point
* @param p2 the end point
* @since 1.2
*** 579,609 ****
p2.getX(), p2.getY());
}
/**
* Sets the location of the end points and control points of this
! * <code>QuadCurve2D</code> to the coordinates of the
! * <code>Point2D</code> objects at the specified offset in
* the specified array.
! * @param pts an array containing <code>Point2D</code> that define
* coordinate values
! * @param offset the index into <code>pts</code> from which to start
* getting the coordinate values and assigning them to this
! * <code>QuadCurve2D</code>
* @since 1.2
*/
public void setCurve(Point2D[] pts, int offset) {
setCurve(pts[offset + 0].getX(), pts[offset + 0].getY(),
pts[offset + 1].getX(), pts[offset + 1].getY(),
pts[offset + 2].getX(), pts[offset + 2].getY());
}
/**
* Sets the location of the end points and control point of this
! * <code>QuadCurve2D</code> to the same as those in the specified
! * <code>QuadCurve2D</code>.
! * @param c the specified <code>QuadCurve2D</code>
* @since 1.2
*/
public void setCurve(QuadCurve2D c) {
setCurve(c.getX1(), c.getY1(),
c.getCtrlX(), c.getCtrlY(),
--- 579,609 ----
p2.getX(), p2.getY());
}
/**
* Sets the location of the end points and control points of this
! * {@code QuadCurve2D} to the coordinates of the
! * {@code Point2D} objects at the specified offset in
* the specified array.
! * @param pts an array containing {@code Point2D} that define
* coordinate values
! * @param offset the index into {@code pts} from which to start
* getting the coordinate values and assigning them to this
! * {@code QuadCurve2D}
* @since 1.2
*/
public void setCurve(Point2D[] pts, int offset) {
setCurve(pts[offset + 0].getX(), pts[offset + 0].getY(),
pts[offset + 1].getX(), pts[offset + 1].getY(),
pts[offset + 2].getX(), pts[offset + 2].getY());
}
/**
* Sets the location of the end points and control point of this
! * {@code QuadCurve2D} to the same as those in the specified
! * {@code QuadCurve2D}.
! * @param c the specified {@code QuadCurve2D}
* @since 1.2
*/
public void setCurve(QuadCurve2D c) {
setCurve(c.getX1(), c.getY1(),
c.getCtrlX(), c.getCtrlY(),
*** 656,666 ****
* 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.
* @param coords an array containing coordinate values
! * @param offset the index into <code>coords</code> from which to
* to start getting the values from the array
* @return the flatness of the quadratic curve that is defined by the
* values in the specified array at the specified index.
* @since 1.2
*/
--- 656,666 ----
* 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.
* @param coords an array containing coordinate values
! * @param offset the index into {@code coords} from which to
* to start getting the values from the array
* @return the flatness of the quadratic curve that is defined by the
* values in the specified array at the specified index.
* @since 1.2
*/
*** 674,684 ****
* 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.
* @param coords an array containing coordinate values
! * @param offset the index into <code>coords</code> from which to
* start getting the coordinate values
* @return the flatness of a quadratic curve defined by the
* specified array at the specified offset.
* @since 1.2
*/
--- 674,684 ----
* 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.
* @param coords an array containing coordinate values
! * @param offset the index into {@code coords} from which to
* start getting the coordinate values
* @return the flatness of a quadratic curve defined by the
* specified array at the specified offset.
* @since 1.2
*/
*** 689,701 ****
}
/**
* Returns the square of the flatness, or maximum distance of a
* control point from the line connecting the end points, of this
! * <code>QuadCurve2D</code>.
* @return the square of the flatness of this
! * <code>QuadCurve2D</code>.
* @since 1.2
*/
public double getFlatnessSq() {
return Line2D.ptSegDistSq(getX1(), getY1(),
getX2(), getY2(),
--- 689,701 ----
}
/**
* Returns the square of the flatness, or maximum distance of a
* control point from the line connecting the end points, of this
! * {@code QuadCurve2D}.
* @return the square of the flatness of this
! * {@code QuadCurve2D}.
* @since 1.2
*/
public double getFlatnessSq() {
return Line2D.ptSegDistSq(getX1(), getY1(),
getX2(), getY2(),
*** 703,750 ****
}
/**
* Returns the flatness, or maximum distance of a
* control point from the line connecting the end points, of this
! * <code>QuadCurve2D</code>.
! * @return the flatness of this <code>QuadCurve2D</code>.
* @since 1.2
*/
public double getFlatness() {
return Line2D.ptSegDist(getX1(), getY1(),
getX2(), getY2(),
getCtrlX(), getCtrlY());
}
/**
! * Subdivides this <code>QuadCurve2D</code> and stores the resulting
! * two subdivided curves into the <code>left</code> and
! * <code>right</code> curve parameters.
! * Either or both of the <code>left</code> and <code>right</code>
! * objects can be the same as this <code>QuadCurve2D</code> or
! * <code>null</code>.
! * @param left the <code>QuadCurve2D</code> object for storing the
* left or first half of the subdivided curve
! * @param right the <code>QuadCurve2D</code> object for storing the
* right or second half of the subdivided curve
* @since 1.2
*/
public void subdivide(QuadCurve2D left, QuadCurve2D right) {
subdivide(this, left, right);
}
/**
! * Subdivides the quadratic curve specified by the <code>src</code>
* parameter and stores the resulting two subdivided curves into the
! * <code>left</code> and <code>right</code> curve parameters.
! * Either or both of the <code>left</code> and <code>right</code>
! * objects can be the same as the <code>src</code> object or
! * <code>null</code>.
* @param src the quadratic curve to be subdivided
! * @param left the <code>QuadCurve2D</code> object for storing the
* left or first half of the subdivided curve
! * @param right the <code>QuadCurve2D</code> object for storing the
* right or second half of the subdivided curve
* @since 1.2
*/
public static void subdivide(QuadCurve2D src,
QuadCurve2D left,
--- 703,750 ----
}
/**
* Returns the flatness, or maximum distance of a
* control point from the line connecting the end points, of this
! * {@code QuadCurve2D}.
! * @return the flatness of this {@code QuadCurve2D}.
* @since 1.2
*/
public double getFlatness() {
return Line2D.ptSegDist(getX1(), getY1(),
getX2(), getY2(),
getCtrlX(), getCtrlY());
}
/**
! * Subdivides this {@code QuadCurve2D} and stores the resulting
! * two subdivided curves into the {@code left} and
! * {@code right} curve parameters.
! * Either or both of the {@code left} and {@code right}
! * objects can be the same as this {@code QuadCurve2D} or
! * {@code null}.
! * @param left the {@code QuadCurve2D} object for storing the
* left or first half of the subdivided curve
! * @param right the {@code QuadCurve2D} object for storing the
* right or second half of the subdivided curve
* @since 1.2
*/
public void subdivide(QuadCurve2D left, QuadCurve2D right) {
subdivide(this, left, right);
}
/**
! * Subdivides the quadratic curve specified by the {@code src}
* parameter and stores the resulting two subdivided curves into the
! * {@code left} and {@code right} curve parameters.
! * Either or both of the {@code left} and {@code right}
! * objects can be the same as the {@code src} object or
! * {@code null}.
* @param src the quadratic curve to be subdivided
! * @param left the {@code QuadCurve2D} object for storing the
* left or first half of the subdivided curve
! * @param right the {@code QuadCurve2D} object for storing the
* right or second half of the subdivided curve
* @since 1.2
*/
public static void subdivide(QuadCurve2D src,
QuadCurve2D left,
*** 769,790 ****
}
}
/**
* Subdivides the quadratic curve specified by the coordinates
! * stored in the <code>src</code> array at indices
! * <code>srcoff</code> through <code>srcoff</code> + 5
* and stores the resulting two subdivided curves into the two
* result arrays at the corresponding indices.
! * Either or both of the <code>left</code> and <code>right</code>
! * arrays can be <code>null</code> or a reference to the same array
! * and offset as the <code>src</code> 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 <code>left</code> and
! * <code>right</code> and to use offsets such that
! * <code>rightoff</code> equals <code>leftoff</code> + 4 in order
* to avoid allocating extra storage for this common point.
* @param src the array holding the coordinates for the source curve
* @param srcoff the offset into the array of the beginning of the
* the 6 source coordinates
* @param left the array for storing the coordinates for the first
--- 769,790 ----
}
}
/**
* Subdivides the quadratic curve specified by the coordinates
! * stored in the {@code src} array at indices
! * {@code srcoff} through {@code srcoff} + 5
* and stores the resulting two subdivided curves into the two
* result arrays at the corresponding indices.
! * Either or both of the {@code left} and {@code right}
! * arrays can be {@code null} or a reference to the same array
! * and offset as the {@code 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 {@code left} and
! * {@code right} and to use offsets such that
! * {@code rightoff} equals {@code leftoff} + 4 in order
* to avoid allocating extra storage for this common point.
* @param src the array holding the coordinates for the source curve
* @param srcoff the offset into the array of the beginning of the
* the 6 source coordinates
* @param left the array for storing the coordinates for the first
*** 833,879 ****
right[rightoff + 3] = y2;
}
}
/**
! * Solves the quadratic whose coefficients are in the <code>eqn</code>
* 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:
* <pre>
* eqn = {C, B, A};
* ax^2 + bx + c = 0
* </pre>
! * A return value of <code>-1</code> is used to distinguish a constant
* equation, which might be always 0 or never 0, from an equation that
* has no zeroes.
* @param eqn the array that contains the quadratic coefficients
! * @return the number of roots, or <code>-1</code> if the equation is
* a constant
* @since 1.2
*/
public static int solveQuadratic(double eqn[]) {
return solveQuadratic(eqn, eqn);
}
/**
! * Solves the quadratic whose coefficients are in the <code>eqn</code>
! * array and places the non-complex roots into the <code>res</code>
* array, returning the number of roots.
* The quadratic solved is represented by the equation:
* <pre>
* eqn = {C, B, A};
* ax^2 + bx + c = 0
* </pre>
! * A return value of <code>-1</code> is used to distinguish a constant
* equation, which might be always 0 or never 0, from an equation that
* has no zeroes.
* @param eqn the specified array of coefficients to use to solve
* the quadratic equation
* @param res the array that contains the non-complex roots
* resulting from the solution of the quadratic equation
! * @return the number of roots, or <code>-1</code> if the equation is
* a constant.
* @since 1.3
*/
public static int solveQuadratic(double eqn[], double res[]) {
double a = eqn[2];
--- 833,879 ----
right[rightoff + 3] = y2;
}
}
/**
! * Solves the quadratic whose coefficients are in the {@code 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:
* <pre>
* eqn = {C, B, A};
* ax^2 + bx + c = 0
* </pre>
! * A return value of {@code -1} is used to distinguish a constant
* equation, which might be always 0 or never 0, from an equation that
* has no zeroes.
* @param eqn the array that contains the quadratic coefficients
! * @return the number of roots, or {@code -1} if the equation is
* a constant
* @since 1.2
*/
public static int solveQuadratic(double eqn[]) {
return solveQuadratic(eqn, eqn);
}
/**
! * Solves the quadratic whose coefficients are in the {@code eqn}
! * array and places the non-complex roots into the {@code res}
* array, returning the number of roots.
* The quadratic solved is represented by the equation:
* <pre>
* eqn = {C, B, A};
* ax^2 + bx + c = 0
* </pre>
! * A return value of {@code -1} is used to distinguish a constant
* equation, which might be always 0 or never 0, from an equation that
* has no zeroes.
* @param eqn the specified array of coefficients to use to solve
* the quadratic equation
* @param res the array that contains the non-complex roots
* resulting from the solution of the quadratic equation
! * @return the number of roots, or {@code -1} if the equation is
* a constant.
* @since 1.3
*/
public static int solveQuadratic(double eqn[], double res[]) {
double a = eqn[2];
*** 1341,1355 ****
return getBounds2D().getBounds();
}
/**
* Returns an iteration object that defines the boundary of the
! * shape of this <code>QuadCurve2D</code>.
* The iterator for this class is not multi-threaded safe,
! * which means that this <code>QuadCurve2D</code> class does not
* guarantee that modifications to the geometry of this
! * <code>QuadCurve2D</code> object do not affect any iterations of
* that geometry that are already in process.
* @param at an optional {@link AffineTransform} to apply to the
* shape boundary
* @return a {@link PathIterator} object that defines the boundary
* of the shape.
--- 1341,1355 ----
return getBounds2D().getBounds();
}
/**
* Returns an iteration object that defines the boundary of the
! * shape of this {@code QuadCurve2D}.
* The iterator for this class is not multi-threaded safe,
! * which means that this {@code QuadCurve2D} class does not
* guarantee that modifications to the geometry of this
! * {@code QuadCurve2D} object do not affect any iterations of
* that geometry that are already in process.
* @param at an optional {@link AffineTransform} to apply to the
* shape boundary
* @return a {@link PathIterator} object that defines the boundary
* of the shape.
*** 1359,1381 ****
return new QuadIterator(this, at);
}
/**
* Returns an iteration object that defines the boundary of the
! * flattened shape of this <code>QuadCurve2D</code>.
* The iterator for this class is not multi-threaded safe,
! * which means that this <code>QuadCurve2D</code> class does not
* guarantee that modifications to the geometry of this
! * <code>QuadCurve2D</code> object do not affect any iterations of
* that geometry that are already in process.
! * @param at an optional <code>AffineTransform</code> to apply
* to the boundary of the shape
* @param 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.
! * @return a <code>PathIterator</code> object that defines the
* flattened boundary of the shape.
* @since 1.2
*/
public PathIterator getPathIterator(AffineTransform at, double flatness) {
return new FlatteningPathIterator(getPathIterator(at), flatness);
--- 1359,1381 ----
return new QuadIterator(this, at);
}
/**
* Returns an iteration object that defines the boundary of the
! * flattened shape of this {@code QuadCurve2D}.
* The iterator for this class is not multi-threaded safe,
! * which means that this {@code QuadCurve2D} class does not
* guarantee that modifications to the geometry of this
! * {@code QuadCurve2D} object do not affect any iterations of
* that geometry that are already in process.
! * @param at an optional {@code AffineTransform} to apply
* to the boundary of the shape
* @param 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.
! * @return a {@code PathIterator} object that defines the
* flattened boundary of the shape.
* @since 1.2
*/
public PathIterator getPathIterator(AffineTransform at, double flatness) {
return new FlatteningPathIterator(getPathIterator(at), flatness);
< prev index next >