< prev index next >

src/java.desktop/share/classes/java/awt/geom/PathIterator.java

Print this page




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.awt.geom;
  27 
  28 import java.lang.annotation.Native;
  29 
  30 /**
  31  * The <code>PathIterator</code> interface provides the mechanism
  32  * for objects that implement the {@link java.awt.Shape Shape}
  33  * interface to return the geometry of their boundary by allowing
  34  * a caller to retrieve the path of that boundary a segment at a
  35  * time.  This interface allows these objects to retrieve the path of
  36  * their boundary a segment at a time by using 1st through 3rd order
  37  * B&eacute;zier curves, which are lines and quadratic or cubic
  38  * B&eacute;zier splines.
  39  * <p>
  40  * Multiple subpaths can be expressed by using a "MOVETO" segment to
  41  * create a discontinuity in the geometry to move from the end of
  42  * one subpath to the beginning of the next.
  43  * <p>
  44  * Each subpath can be closed manually by ending the last segment in
  45  * the subpath on the same coordinate as the beginning "MOVETO" segment
  46  * for that subpath or by using a "CLOSE" segment to append a line
  47  * segment from the last point back to the first.
  48  * Be aware that manually closing an outline as opposed to using a
  49  * "CLOSE" segment to close the path might result in different line
  50  * style decorations being used at the end points of the subpath.
  51  * For example, the {@link java.awt.BasicStroke BasicStroke} object


  81     @Native public static final int WIND_NON_ZERO       = 1;
  82 
  83     /**
  84      * The segment type constant for a point that specifies the
  85      * starting location for a new subpath.
  86      */
  87     @Native public static final int SEG_MOVETO          = 0;
  88 
  89     /**
  90      * The segment type constant for a point that specifies the
  91      * end point of a line to be drawn from the most recently
  92      * specified point.
  93      */
  94     @Native public static final int SEG_LINETO          = 1;
  95 
  96     /**
  97      * The segment type constant for the pair of points that specify
  98      * a quadratic parametric curve to be drawn from the most recently
  99      * specified point.
 100      * The curve is interpolated by solving the parametric control
 101      * equation in the range <code>(t=[0..1])</code> using
 102      * the most recently specified (current) point (CP),
 103      * the first control point (P1),
 104      * and the final interpolated control point (P2).
 105      * The parametric control equation for this curve is:
 106      * <pre>
 107      *          P(t) = B(2,0)*CP + B(2,1)*P1 + B(2,2)*P2
 108      *          0 &lt;= t &lt;= 1
 109      *
 110      *        B(n,m) = mth coefficient of nth degree Bernstein polynomial
 111      *               = C(n,m) * t^(m) * (1 - t)^(n-m)
 112      *        C(n,m) = Combinations of n things, taken m at a time
 113      *               = n! / (m! * (n-m)!)
 114      * </pre>
 115      */
 116     @Native public static final int SEG_QUADTO          = 2;
 117 
 118     /**
 119      * The segment type constant for the set of 3 points that specify
 120      * a cubic parametric curve to be drawn from the most recently
 121      * specified point.
 122      * The curve is interpolated by solving the parametric control
 123      * equation in the range <code>(t=[0..1])</code> using
 124      * the most recently specified (current) point (CP),
 125      * the first control point (P1),
 126      * the second control point (P2),
 127      * and the final interpolated control point (P3).
 128      * The parametric control equation for this curve is:
 129      * <pre>
 130      *          P(t) = B(3,0)*CP + B(3,1)*P1 + B(3,2)*P2 + B(3,3)*P3
 131      *          0 &lt;= t &lt;= 1
 132      *
 133      *        B(n,m) = mth coefficient of nth degree Bernstein polynomial
 134      *               = C(n,m) * t^(m) * (1 - t)^(n-m)
 135      *        C(n,m) = Combinations of n things, taken m at a time
 136      *               = n! / (m! * (n-m)!)
 137      * </pre>
 138      * This form of curve is commonly known as a B&eacute;zier curve.
 139      */
 140     @Native public static final int SEG_CUBICTO         = 3;
 141 
 142     /**
 143      * The segment type constant that specifies that
 144      * the preceding subpath should be closed by appending a line segment
 145      * back to the point corresponding to the most recent SEG_MOVETO.
 146      */
 147     @Native public static final int SEG_CLOSE           = 4;
 148 
 149     /**
 150      * Returns the winding rule for determining the interior of the
 151      * path.
 152      * @return the winding rule.
 153      * @see #WIND_EVEN_ODD
 154      * @see #WIND_NON_ZERO
 155      */
 156     public int getWindingRule();
 157 
 158     /**
 159      * Tests if the iteration is complete.
 160      * @return <code>true</code> if all the segments have
 161      * been read; <code>false</code> otherwise.
 162      */
 163     public boolean isDone();
 164 
 165     /**
 166      * Moves the iterator to the next segment of the path forwards
 167      * along the primary direction of traversal as long as there are
 168      * more points in that direction.
 169      */
 170     public void next();
 171 
 172     /**
 173      * Returns the coordinates and type of the current path segment in
 174      * the iteration.
 175      * The return value is the path-segment type:
 176      * SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE.
 177      * A float array of length 6 must be passed in and can be used to
 178      * store the coordinates of the point(s).
 179      * Each point is stored as a pair of float x,y coordinates.
 180      * SEG_MOVETO and SEG_LINETO types returns one point,
 181      * SEG_QUADTO returns two points,




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.awt.geom;
  27 
  28 import java.lang.annotation.Native;
  29 
  30 /**
  31  * The {@code PathIterator} interface provides the mechanism
  32  * for objects that implement the {@link java.awt.Shape Shape}
  33  * interface to return the geometry of their boundary by allowing
  34  * a caller to retrieve the path of that boundary a segment at a
  35  * time.  This interface allows these objects to retrieve the path of
  36  * their boundary a segment at a time by using 1st through 3rd order
  37  * B&eacute;zier curves, which are lines and quadratic or cubic
  38  * B&eacute;zier splines.
  39  * <p>
  40  * Multiple subpaths can be expressed by using a "MOVETO" segment to
  41  * create a discontinuity in the geometry to move from the end of
  42  * one subpath to the beginning of the next.
  43  * <p>
  44  * Each subpath can be closed manually by ending the last segment in
  45  * the subpath on the same coordinate as the beginning "MOVETO" segment
  46  * for that subpath or by using a "CLOSE" segment to append a line
  47  * segment from the last point back to the first.
  48  * Be aware that manually closing an outline as opposed to using a
  49  * "CLOSE" segment to close the path might result in different line
  50  * style decorations being used at the end points of the subpath.
  51  * For example, the {@link java.awt.BasicStroke BasicStroke} object


  81     @Native public static final int WIND_NON_ZERO       = 1;
  82 
  83     /**
  84      * The segment type constant for a point that specifies the
  85      * starting location for a new subpath.
  86      */
  87     @Native public static final int SEG_MOVETO          = 0;
  88 
  89     /**
  90      * The segment type constant for a point that specifies the
  91      * end point of a line to be drawn from the most recently
  92      * specified point.
  93      */
  94     @Native public static final int SEG_LINETO          = 1;
  95 
  96     /**
  97      * The segment type constant for the pair of points that specify
  98      * a quadratic parametric curve to be drawn from the most recently
  99      * specified point.
 100      * The curve is interpolated by solving the parametric control
 101      * equation in the range {@code (t=[0..1])} using
 102      * the most recently specified (current) point (CP),
 103      * the first control point (P1),
 104      * and the final interpolated control point (P2).
 105      * The parametric control equation for this curve is:
 106      * <pre>
 107      *          P(t) = B(2,0)*CP + B(2,1)*P1 + B(2,2)*P2
 108      *          0 &lt;= t &lt;= 1
 109      *
 110      *        B(n,m) = mth coefficient of nth degree Bernstein polynomial
 111      *               = C(n,m) * t^(m) * (1 - t)^(n-m)
 112      *        C(n,m) = Combinations of n things, taken m at a time
 113      *               = n! / (m! * (n-m)!)
 114      * </pre>
 115      */
 116     @Native public static final int SEG_QUADTO          = 2;
 117 
 118     /**
 119      * The segment type constant for the set of 3 points that specify
 120      * a cubic parametric curve to be drawn from the most recently
 121      * specified point.
 122      * The curve is interpolated by solving the parametric control
 123      * equation in the range {@code (t=[0..1])} using
 124      * the most recently specified (current) point (CP),
 125      * the first control point (P1),
 126      * the second control point (P2),
 127      * and the final interpolated control point (P3).
 128      * The parametric control equation for this curve is:
 129      * <pre>
 130      *          P(t) = B(3,0)*CP + B(3,1)*P1 + B(3,2)*P2 + B(3,3)*P3
 131      *          0 &lt;= t &lt;= 1
 132      *
 133      *        B(n,m) = mth coefficient of nth degree Bernstein polynomial
 134      *               = C(n,m) * t^(m) * (1 - t)^(n-m)
 135      *        C(n,m) = Combinations of n things, taken m at a time
 136      *               = n! / (m! * (n-m)!)
 137      * </pre>
 138      * This form of curve is commonly known as a B&eacute;zier curve.
 139      */
 140     @Native public static final int SEG_CUBICTO         = 3;
 141 
 142     /**
 143      * The segment type constant that specifies that
 144      * the preceding subpath should be closed by appending a line segment
 145      * back to the point corresponding to the most recent SEG_MOVETO.
 146      */
 147     @Native public static final int SEG_CLOSE           = 4;
 148 
 149     /**
 150      * Returns the winding rule for determining the interior of the
 151      * path.
 152      * @return the winding rule.
 153      * @see #WIND_EVEN_ODD
 154      * @see #WIND_NON_ZERO
 155      */
 156     public int getWindingRule();
 157 
 158     /**
 159      * Tests if the iteration is complete.
 160      * @return {@code true} if all the segments have
 161      * been read; {@code false} otherwise.
 162      */
 163     public boolean isDone();
 164 
 165     /**
 166      * Moves the iterator to the next segment of the path forwards
 167      * along the primary direction of traversal as long as there are
 168      * more points in that direction.
 169      */
 170     public void next();
 171 
 172     /**
 173      * Returns the coordinates and type of the current path segment in
 174      * the iteration.
 175      * The return value is the path-segment type:
 176      * SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE.
 177      * A float array of length 6 must be passed in and can be used to
 178      * store the coordinates of the point(s).
 179      * Each point is stored as a pair of float x,y coordinates.
 180      * SEG_MOVETO and SEG_LINETO types returns one point,
 181      * SEG_QUADTO returns two points,


< prev index next >