1/*2* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation. Oracle designates this8* particular file as subject to the "Classpath" exception as provided9* by Oracle in the LICENSE file that accompanied this code.10*11* This code is distributed in the hope that it will be useful, but WITHOUT12* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or13* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License14* version 2 for more details (a copy is included in the LICENSE file that15* accompanied this code).16*17* You should have received a copy of the GNU General Public License version18* 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 USA22* or visit www.oracle.com if you need additional information or have any23* questions.24*/25 26packagejava.awt.geom; 27 28importjava.lang.annotation.Native; 29 30/**31* The <code>PathIterator</code> interface provides the mechanism32* for objects that implement the {@link java.awt.Shape Shape}33* interface to return the geometry of their boundary by allowing34* a caller to retrieve the path of that boundary a segment at a35* time. This interface allows these objects to retrieve the path of36* their boundary a segment at a time by using 1st through 3rd order37* Bézier curves, which are lines and quadratic or cubic38* Bézier splines.39* <p>40* Multiple subpaths can be expressed by using a "MOVETO" segment to41* create a discontinuity in the geometry to move from the end of42* one subpath to the beginning of the next.43* <p>44* Each subpath can be closed manually by ending the last segment in45* the subpath on the same coordinate as the beginning "MOVETO" segment46* for that subpath or by using a "CLOSE" segment to append a line47* segment from the last point back to the first.48* Be aware that manually closing an outline as opposed to using a49* "CLOSE" segment to close the path might result in different line50* style decorations being used at the end points of the subpath.51* For example, the {@link java.awt.BasicStroke BasicStroke} object52* uses a line "JOIN" decoration to connect the first and last points53* if a "CLOSE" segment is encountered, whereas simply ending the path54* on the same coordinate as the beginning coordinate results in line55* "CAP" decorations being used at the ends.56*57* @see java.awt.Shape58* @see java.awt.BasicStroke59*60* @author Jim Graham61*/62publicinterfacePathIterator { 63/**64* The winding rule constant for specifying an even-odd rule65* for determining the interior of a path.66* The even-odd rule specifies that a point lies inside the67* path if a ray drawn in any direction from that point to68* infinity is crossed by path segments an odd number of times.69*/70 @NativepublicstaticfinalintWIND_EVEN_ODD = 0; 71 72/**73* The winding rule constant for specifying a non-zero rule74* for determining the interior of a path.75* The non-zero rule specifies that a point lies inside the76* path if a ray drawn in any direction from that point to77* infinity is crossed by path segments a different number78* of times in the counter-clockwise direction than the79* clockwise direction.80*/81 @NativepublicstaticfinalintWIND_NON_ZERO = 1; 82 83/**84* The segment type constant for a point that specifies the85* starting location for a new subpath.86*/87 @NativepublicstaticfinalintSEG_MOVETO = 0; 88 89/**90* The segment type constant for a point that specifies the91* end point of a line to be drawn from the most recently92* specified point.93*/94 @NativepublicstaticfinalintSEG_LINETO = 1; 95 96/**97* The segment type constant for the pair of points that specify98* a quadratic parametric curve to be drawn from the most recently99* specified point.100* The curve is interpolated by solving the parametric control101* equation in the range <code>(t=[0..1])</code> using102* 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)*P2108* 0 <= t <= 1109*110* B(n,m) = mth coefficient of nth degree Bernstein polynomial111* = C(n,m) * t^(m) * (1 - t)^(n-m)112* C(n,m) = Combinations of n things, taken m at a time113* = n! / (m! * (n-m)!)114* </pre>115*/116 @NativepublicstaticfinalintSEG_QUADTO = 2; 117 118/**119* The segment type constant for the set of 3 points that specify120* a cubic parametric curve to be drawn from the most recently121* specified point.122* The curve is interpolated by solving the parametric control123* equation in the range <code>(t=[0..1])</code> using124* 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)*P3131* 0 <= t <= 1132*133* B(n,m) = mth coefficient of nth degree Bernstein polynomial134* = C(n,m) * t^(m) * (1 - t)^(n-m)135* C(n,m) = Combinations of n things, taken m at a time136* = n! / (m! * (n-m)!)137* </pre>138* This form of curve is commonly known as a Bézier curve.139*/140 @NativepublicstaticfinalintSEG_CUBICTO = 3; 141 142/**143* The segment type constant that specifies that144* the preceding subpath should be closed by appending a line segment145* back to the point corresponding to the most recent SEG_MOVETO.146*/147 @NativepublicstaticfinalintSEG_CLOSE = 4; 148 149/**150* Returns the winding rule for determining the interior of the151* path.152* @return the winding rule.153* @see #WIND_EVEN_ODD154* @see #WIND_NON_ZERO155*/156publicintgetWindingRule(); 157 158/**159* Tests if the iteration is complete.160* @return <code>true</code> if all the segments have161* been read; <code>false</code> otherwise.162*/163publicbooleanisDone(); 164 165/**166* Moves the iterator to the next segment of the path forwards167* along the primary direction of traversal as long as there are168* more points in that direction.169*/170publicvoidnext(); 171 172/**173* Returns the coordinates and type of the current path segment in174* 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 to178* 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,182* SEG_CUBICTO returns 3 points183* and SEG_CLOSE does not return any points.184* @param coords an array that holds the data returned from185* this method186* @return the path-segment type of the current path segment.187* @see #SEG_MOVETO188* @see #SEG_LINETO189* @see #SEG_QUADTO190* @see #SEG_CUBICTO191* @see #SEG_CLOSE192*/193publicintcurrentSegment(float[] coords); 194 195/**196* Returns the coordinates and type of the current path segment in197* the iteration.198* The return value is the path-segment type:199* SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE.200* A double array of length 6 must be passed in and can be used to201* store the coordinates of the point(s).202* Each point is stored as a pair of double x,y coordinates.203* SEG_MOVETO and SEG_LINETO types returns one point,204* SEG_QUADTO returns two points,205* SEG_CUBICTO returns 3 points206* and SEG_CLOSE does not return any points.207* @param coords an array that holds the data returned from208* this method209* @return the path-segment type of the current path segment.210* @see #SEG_MOVETO211* @see #SEG_LINETO212* @see #SEG_QUADTO213* @see #SEG_CUBICTO214* @see #SEG_CLOSE215*/216publicintcurrentSegment(double[] coords); 217 }