< prev index next >
src/java.desktop/share/classes/java/awt/geom/CubicCurve2D.java
Print this page
*** 34,44 ****
import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.ulp;
/**
! * The <code>CubicCurve2D</code> class defines a cubic parametric curve
* segment in {@code (x,y)} coordinate space.
* <p>
* 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
--- 34,44 ----
import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.ulp;
/**
! * The {@code CubicCurve2D} class defines a cubic parametric curve
* segment in {@code (x,y)} coordinate space.
* <p>
* 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
*** 720,732 ****
/**
* 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.
* @param coords a double array containing coordinates
! * @param offset the index of <code>coords</code> from which to begin
* setting the end points and control points of this curve
! * to the coordinates contained in <code>coords</code>
* @since 1.2
*/
public void setCurve(double[] coords, int offset) {
setCurve(coords[offset + 0], coords[offset + 1],
coords[offset + 2], coords[offset + 3],
--- 720,732 ----
/**
* 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.
* @param coords a double array containing coordinates
! * @param offset the index of {@code coords} from which to begin
* setting the end points and control points of this curve
! * to the coordinates contained in {@code coords}
* @since 1.2
*/
public void setCurve(double[] coords, int offset) {
setCurve(coords[offset + 0], coords[offset + 1],
coords[offset + 2], coords[offset + 3],
*** 734,767 ****
coords[offset + 6], coords[offset + 7]);
}
/**
* Sets the location of the end points and control points of this curve
! * to the specified <code>Point2D</code> coordinates.
! * @param p1 the first specified <code>Point2D</code> used to set the
* start point of this curve
! * @param cp1 the second specified <code>Point2D</code> used to set the
* first control point of this curve
! * @param cp2 the third specified <code>Point2D</code> used to set the
* second control point of this curve
! * @param p2 the fourth specified <code>Point2D</code> used to set the
* end point of this curve
* @since 1.2
*/
public void setCurve(Point2D p1, Point2D cp1, Point2D cp2, Point2D p2) {
setCurve(p1.getX(), p1.getY(), cp1.getX(), cp1.getY(),
cp2.getX(), cp2.getY(), p2.getX(), p2.getY());
}
/**
* Sets the location of the end points and control points of this curve
! * to the coordinates of the <code>Point2D</code> objects at the specified
* offset in the specified array.
! * @param pts an array of <code>Point2D</code> objects
! * @param offset the index of <code>pts</code> from which to begin setting
* the end points and control points of this curve to the
! * points contained in <code>pts</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(),
--- 734,767 ----
coords[offset + 6], coords[offset + 7]);
}
/**
* Sets the location of the end points and control points of this curve
! * to the specified {@code Point2D} coordinates.
! * @param p1 the first specified {@code Point2D} used to set the
* start point of this curve
! * @param cp1 the second specified {@code Point2D} used to set the
* first control point of this curve
! * @param cp2 the third specified {@code Point2D} used to set the
* second control point of this curve
! * @param p2 the fourth specified {@code Point2D} used to set the
* end point of this curve
* @since 1.2
*/
public void setCurve(Point2D p1, Point2D cp1, Point2D cp2, Point2D p2) {
setCurve(p1.getX(), p1.getY(), cp1.getX(), cp1.getY(),
cp2.getX(), cp2.getY(), p2.getX(), p2.getY());
}
/**
* Sets the location of the end points and control points of this curve
! * to the coordinates of the {@code Point2D} objects at the specified
* offset in the specified array.
! * @param pts an array of {@code Point2D} objects
! * @param offset the index of {@code pts} from which to begin setting
* the end points and control points of this curve to the
! * points contained in {@code pts}
* @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(),
*** 769,780 ****
pts[offset + 3].getX(), pts[offset + 3].getY());
}
/**
* Sets the location of the end points and control points of this curve
! * to the same as those in the specified <code>CubicCurve2D</code>.
! * @param c the specified <code>CubicCurve2D</code>
* @since 1.2
*/
public void setCurve(CubicCurve2D c) {
setCurve(c.getX1(), c.getY1(), c.getCtrlX1(), c.getCtrlY1(),
c.getCtrlX2(), c.getCtrlY2(), c.getX2(), c.getY2());
--- 769,780 ----
pts[offset + 3].getX(), pts[offset + 3].getY());
}
/**
* Sets the location of the end points and control points of this curve
! * to the same as those in the specified {@code CubicCurve2D}.
! * @param c the specified {@code CubicCurve2D}
* @since 1.2
*/
public void setCurve(CubicCurve2D c) {
setCurve(c.getX1(), c.getY1(), c.getCtrlX1(), c.getCtrlY1(),
c.getCtrlX2(), c.getCtrlY2(), c.getX2(), c.getY2());
*** 851,864 ****
* 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.
* @param coords an array containing coordinates
! * @param offset the index of <code>coords</code> from which to begin
* getting the end points and control points of the curve
! * @return the square of the flatness of the <code>CubicCurve2D</code>
! * specified by the coordinates in <code>coords</code> at
* the specified offset.
* @since 1.2
*/
public static double getFlatnessSq(double coords[], int offset) {
return getFlatnessSq(coords[offset + 0], coords[offset + 1],
--- 851,864 ----
* 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.
* @param coords an array containing coordinates
! * @param offset the index of {@code coords} from which to begin
* getting the end points and control points of the curve
! * @return the square of the flatness of the {@code CubicCurve2D}
! * specified by the coordinates in {@code coords} at
* the specified offset.
* @since 1.2
*/
public static double getFlatnessSq(double coords[], int offset) {
return getFlatnessSq(coords[offset + 0], coords[offset + 1],
*** 871,884 ****
* 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.
* @param coords an array containing coordinates
! * @param offset the index of <code>coords</code> from which to begin
* getting the end points and control points of the curve
! * @return the flatness of the <code>CubicCurve2D</code>
! * specified by the coordinates in <code>coords</code> at
* the specified offset.
* @since 1.2
*/
public static double getFlatness(double coords[], int offset) {
return getFlatness(coords[offset + 0], coords[offset + 1],
--- 871,884 ----
* 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.
* @param coords an array containing coordinates
! * @param offset the index of {@code coords} from which to begin
* getting the end points and control points of the curve
! * @return the flatness of the {@code CubicCurve2D}
! * specified by the coordinates in {@code coords} at
* the specified offset.
* @since 1.2
*/
public static double getFlatness(double coords[], int offset) {
return getFlatness(coords[offset + 0], coords[offset + 1],
*** 925,939 ****
public void subdivide(CubicCurve2D left, CubicCurve2D right) {
subdivide(this, left, right);
}
/**
! * Subdivides the cubic 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
! * may be the same as the <code>src</code> object or <code>null</code>.
* @param src the cubic curve to be subdivided
* @param left the cubic curve object for storing the left or
* first half of the subdivided curve
* @param right the cubic curve object for storing the right or
* second half of the subdivided curve
--- 925,939 ----
public void subdivide(CubicCurve2D left, CubicCurve2D right) {
subdivide(this, left, right);
}
/**
! * Subdivides the cubic 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
! * may be the same as the {@code src} object or {@code null}.
* @param src the cubic curve to be subdivided
* @param left the cubic curve object for storing the left or
* first half of the subdivided curve
* @param right the cubic curve object for storing the right or
* second half of the subdivided curve
*** 972,993 ****
}
}
/**
* Subdivides the cubic curve specified by the coordinates
! * stored in the <code>src</code> array at indices <code>srcoff</code>
! * through (<code>srcoff</code> + 7) 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 may be <code>null</code> or a reference to the same array
! * 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 as <code>rightoff</code>
! * equals (<code>leftoff</code> + 6), 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
--- 972,993 ----
}
}
/**
* Subdivides the cubic curve specified by the coordinates
! * stored in the {@code src} array at indices {@code srcoff}
! * through ({@code srcoff} + 7) 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 may be {@code null} or a reference to the same array
! * 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 as {@code rightoff}
! * equals ({@code leftoff} + 6), 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
*** 1048,1058 ****
right[rightoff + 5] = y2;
}
}
/**
! * Solves the cubic 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 solved cubic is represented
* by the equation:
* <pre>
* eqn = {c, b, a, d}
--- 1048,1058 ----
right[rightoff + 5] = y2;
}
}
/**
! * Solves the cubic 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 solved cubic is represented
* by the equation:
* <pre>
* eqn = {c, b, a, d}
*** 1068,1079 ****
public static int solveCubic(double eqn[]) {
return solveCubic(eqn, eqn);
}
/**
! * Solve the cubic whose coefficients are in the <code>eqn</code>
! * array and place the non-complex roots into the <code>res</code>
* 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,
--- 1068,1079 ----
public static int solveCubic(double eqn[]) {
return solveCubic(eqn, eqn);
}
/**
! * Solve the cubic whose coefficients are in the {@code eqn}
! * array and place the non-complex roots into the {@code 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,
*** 1515,1533 ****
/**
* 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 <code>CubicCurve2D</code> class does not
* guarantee that modifications to the geometry of this
! * <code>CubicCurve2D</code> object do not affect any iterations of
* that geometry that are already in process.
! * @param at an optional <code>AffineTransform</code> to be applied to the
! * coordinates as they are returned in the iteration, or <code>null</code>
* if untransformed coordinates are desired
! * @return the <code>PathIterator</code> object that returns the
! * geometry of the outline of this <code>CubicCurve2D</code>, one
* segment at a time.
* @since 1.2
*/
public PathIterator getPathIterator(AffineTransform at) {
return new CubicIterator(this, at);
--- 1515,1533 ----
/**
* 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 {@code CubicCurve2D} class does not
* guarantee that modifications to the geometry of this
! * {@code CubicCurve2D} object do not affect any iterations of
* that geometry that are already in process.
! * @param at an optional {@code AffineTransform} to be applied to the
! * coordinates as they are returned in the iteration, or {@code null}
* if untransformed coordinates are desired
! * @return the {@code PathIterator} object that returns the
! * geometry of the outline of this {@code CubicCurve2D}, one
* segment at a time.
* @since 1.2
*/
public PathIterator getPathIterator(AffineTransform at) {
return new CubicIterator(this, at);
*** 1535,1556 ****
/**
* 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 <code>CubicCurve2D</code> class does not
* guarantee that modifications to the geometry of this
! * <code>CubicCurve2D</code> object do not affect any iterations of
* that geometry that are already in process.
! * @param at an optional <code>AffineTransform</code> to be applied to the
! * coordinates as they are returned in the iteration, or <code>null</code>
* if untransformed coordinates are desired
* @param flatness 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
! * @return the <code>PathIterator</code> object that returns the
! * geometry of the outline of this <code>CubicCurve2D</code>,
* one segment at a time.
* @since 1.2
*/
public PathIterator getPathIterator(AffineTransform at, double flatness) {
return new FlatteningPathIterator(getPathIterator(at), flatness);
--- 1535,1556 ----
/**
* 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 {@code CubicCurve2D} class does not
* guarantee that modifications to the geometry of this
! * {@code CubicCurve2D} object do not affect any iterations of
* that geometry that are already in process.
! * @param at an optional {@code AffineTransform} to be applied to the
! * coordinates as they are returned in the iteration, or {@code null}
* if untransformed coordinates are desired
* @param flatness 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
! * @return the {@code PathIterator} object that returns the
! * geometry of the outline of this {@code CubicCurve2D},
* one segment at a time.
* @since 1.2
*/
public PathIterator getPathIterator(AffineTransform at, double flatness) {
return new FlatteningPathIterator(getPathIterator(at), flatness);
< prev index next >