source: trunk/gcc/libjava/java/awt/geom/PathIterator.java@ 3951

Last change on this file since 3951 was 1392, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.1 KB
Line 
1/* PathIterator.java -- describes a shape by iterating over its vertices
2 Copyright (C) 2000, 2002 Free Software Foundation
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38package java.awt.geom;
39
40/**
41 * This interface provides a directed path over the boundary of a shape. The
42 * path can contain 1st through 3rd order Bezier curves (lines, and quadratic
43 * and cubic splines). A shape can have multiple disjoint paths via the
44 * MOVETO directive, and can close a circular path back to the previos
45 * MOVETO via the CLOSE directive.
46 *
47 * @author Tom Tromey <[email protected]>
48 * @author Eric Blake <[email protected]>
49 * @see Shape
50 * @see Stroke
51 * @see FlatteningPathIterator
52 * @since 1.2
53 * @status updated to 1.4
54 */
55public interface PathIterator
56{
57 /**
58 * The even-odd winding mode: a point is internal to the shape if a ray
59 * from the point to infinity (in any direction) crosses an odd number of
60 * segments.
61 */
62 static final int WIND_EVEN_ODD = 0;
63
64 /**
65 * The non-zero winding mode: a point is internal to the shape if a ray
66 * from the point to infinity (in any direction) crosses a different number
67 * of segments headed clockwise than those headed counterclockwise.
68 */
69 static final int WIND_NON_ZERO = 1;
70
71 /**
72 * Starts a new subpath. There is no segment from the previous vertex.
73 */
74 static final int SEG_MOVETO = 0;
75
76 /**
77 * The current segment is a line.
78 */
79 static final int SEG_LINETO = 1;
80
81 /**
82 * The current segment is a quadratic parametric curve. It is interpolated
83 * as t varies from 0 to 1 over the current point (CP), first control point
84 * (P1), and final interpolated control point (P2):
85 * <pre>
86 * P(t) = B(2,0)*CP + B(2,1)*P1 + B(2,2)*P2
87 * 0 &lt;= t &lt;= 1
88 * B(n,m) = mth coefficient of nth degree Bernstein polynomial
89 * = C(n,m) * t^(m) * (1 - t)^(n-m)
90 * C(n,m) = Combinations of n things, taken m at a time
91 * = n! / (m! * (n-m)!)
92 * </pre>
93 */
94 static final int SEG_QUADTO = 2;
95
96 /**
97 * The current segment is a cubic parametric curve (more commonly known as
98 * a Bezier curve). It is interpolated as t varies from 0 to 1 over the
99 * current point (CP), first control point (P1), the second control point
100 * (P2), and final interpolated control point (P3):
101 * <pre>
102 * P(t) = B(3,0)*CP + B(3,1)*P1 + B(3,2)*P2 + B(3,3)*P3
103 * 0 &lt;= t &lt;= 1
104 * B(n,m) = mth coefficient of nth degree Bernstein polynomial
105 * = C(n,m) * t^(m) * (1 - t)^(n-m)
106 * C(n,m) = Combinations of n things, taken m at a time
107 * = n! / (m! * (n-m)!)
108 * </pre>
109 */
110 static final int SEG_CUBICTO = 3;
111
112 /**
113 * The current segment closes a loop by an implicit line to the previous
114 * SEG_MOVETO coordinate.
115 */
116 static final int SEG_CLOSE = 4;
117
118 /**
119 * Returns the winding rule to determine which points are inside this path.
120 *
121 * @return the winding rule
122 * @see #WIND_EVEN_ODD
123 * @see #WIND_NON_ZERO
124 */
125 int getWindingRule();
126
127 /**
128 * Tests if the iterator is exhausted. If this returns false, currentSegment
129 * and next may throw a NoSuchElementException (although this is not
130 * required).
131 *
132 * @return true if the iteration is complete
133 */
134 boolean isDone();
135
136 /**
137 * Advance to the next segment in the iteration. It is not specified what
138 * this does if called when isDone() returns false.
139 *
140 * @throws java.util.NoSuchElementException optional when isDone() is true
141 */
142 void next();
143
144 /**
145 * Returns the coordinates of the next point(s), as well as the type of
146 * line segment. The input array must be at least a float[6], to accomodate
147 * up to three (x,y) point pairs (although if you know the iterator is
148 * flat, you can probably get by with a float[2]). If the returned type is
149 * SEG_MOVETO or SEG_LINETO, the first point in the array is modified; if
150 * the returned type is SEG_QUADTO, the first two points are modified; if
151 * the returned type is SEG_CUBICTO, all three points are modified; and if
152 * the returned type is SEG_CLOSE, the array is untouched.
153 *
154 * @param coords the array to place the point coordinates in
155 * @return the segment type
156 * @throws NullPointerException if coords is null
157 * @throws ArrayIndexOutOfBoundsException if coords is too small
158 * @throws java.util.NoSuchElementException optional when isDone() is true
159 * @see #SEG_MOVETO
160 * @see #SEG_LINETO
161 * @see #SEG_QUADTO
162 * @see #SEG_CUBICTO
163 * @see #SEG_CLOSE
164 */
165 int currentSegment(float[] coords);
166
167 /**
168 * Returns the coordinates of the next point(s), as well as the type of
169 * line segment. The input array must be at least a double[6], to accomodate
170 * up to three (x,y) point pairs (although if you know the iterator is
171 * flat, you can probably get by with a double[2]). If the returned type is
172 * SEG_MOVETO or SEG_LINETO, the first point in the array is modified; if
173 * the returned type is SEG_QUADTO, the first two points are modified; if
174 * the returned type is SEG_CUBICTO, all three points are modified; and if
175 * the returned type is SEG_CLOSE, the array is untouched.
176 *
177 * @param coords the array to place the point coordinates in
178 * @return the segment type
179 * @throws NullPointerException if coords is null
180 * @throws ArrayIndexOutOfBoundsException if coords is too small
181 * @throws java.util.NoSuchElementException optional when isDone() is true
182 * @see #SEG_MOVETO
183 * @see #SEG_LINETO
184 * @see #SEG_QUADTO
185 * @see #SEG_CUBICTO
186 * @see #SEG_CLOSE
187 */
188 int currentSegment(double[] coords);
189} // interface PathIterator
Note: See TracBrowser for help on using the repository browser.