FSF GCC merge 02/23/03
[official-gcc.git] / libjava / java / awt / geom / PathIterator.java
blobc23eb351306d4e039d2ecef501999b13ad65e272
1 /* PathIterator.java -- describes a shape by iterating over its vertices
2 Copyright (C) 2000, 2002 Free Software Foundation
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package java.awt.geom;
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.
47 * @author Tom Tromey <tromey@cygnus.com>
48 * @author Eric Blake <ebb9@email.byu.edu>
49 * @see Shape
50 * @see Stroke
51 * @see FlatteningPathIterator
52 * @since 1.2
53 * @status updated to 1.4
55 public interface PathIterator
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.
62 static final int WIND_EVEN_ODD = 0;
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.
69 static final int WIND_NON_ZERO = 1;
71 /**
72 * Starts a new subpath. There is no segment from the previous vertex.
74 static final int SEG_MOVETO = 0;
76 /**
77 * The current segment is a line.
79 static final int SEG_LINETO = 1;
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>
94 static final int SEG_QUADTO = 2;
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>
110 static final int SEG_CUBICTO = 3;
113 * The current segment closes a loop by an implicit line to the previous
114 * SEG_MOVETO coordinate.
116 static final int SEG_CLOSE = 4;
119 * Returns the winding rule to determine which points are inside this path.
121 * @return the winding rule
122 * @see #WIND_EVEN_ODD
123 * @see #WIND_NON_ZERO
125 int getWindingRule();
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).
132 * @return true if the iteration is complete
134 boolean isDone();
137 * Advance to the next segment in the iteration. It is not specified what
138 * this does if called when isDone() returns false.
140 * @throws java.util.NoSuchElementException optional when isDone() is true
142 void next();
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.
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
165 int currentSegment(float[] coords);
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.
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
188 int currentSegment(double[] coords);
189 } // interface PathIterator