1 |
/* Copyright (C) 2000, 2002 Free Software Foundation |
/* PathIterator.java -- describes a shape by iterating over its vertices |
2 |
|
Copyright (C) 2000, 2002 Free Software Foundation |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
38 |
package java.awt.geom; |
package 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 <tromey@cygnus.com> |
* @author Tom Tromey <tromey@cygnus.com> |
48 |
* @date April 16, 2000 |
* @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 |
54 |
*/ |
*/ |
|
|
|
55 |
public interface PathIterator |
public interface PathIterator |
56 |
{ |
{ |
57 |
public static final int SEG_CLOSE = 4; |
/** |
58 |
public static final int SEG_CUBICTO = 3; |
* The even-odd winding mode: a point is internal to the shape if a ray |
59 |
public static final int SEG_LINETO = 1; |
* from the point to infinity (in any direction) crosses an odd number of |
60 |
public static final int SEG_MOVETO = 0; |
* segments. |
61 |
public static final int SEG_QUADTO = 2; |
*/ |
62 |
public static final int WIND_EVEN_ODD = 0; |
int WIND_EVEN_ODD = 0; |
63 |
public static final int WIND_NON_ZERO = 1; |
|
64 |
|
/** |
65 |
public int currentSegment (double[] coords); |
* The non-zero winding mode: a point is internal to the shape if a ray |
66 |
public int currentSegment (float[] coords); |
* from the point to infinity (in any direction) crosses a different number |
67 |
public int getWindingRule (); |
* of segments headed clockwise than those headed counterclockwise. |
68 |
public boolean isDone (); |
*/ |
69 |
public void next (); |
int WIND_NON_ZERO = 1; |
70 |
} |
|
71 |
|
/** |
72 |
|
* Starts a new subpath. There is no segment from the previous vertex. |
73 |
|
*/ |
74 |
|
int SEG_MOVETO = 0; |
75 |
|
|
76 |
|
/** |
77 |
|
* The current segment is a line. |
78 |
|
*/ |
79 |
|
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 <= t <= 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 |
|
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 <= t <= 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 |
|
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 |
|
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 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 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 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 |