• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17 /**
18  * @author Denis M. Kishenko
19  * @version $Revision$
20  */
21 
22 package java.awt.geom;
23 
24 /**
25  * The Interface PathIterator represents an iterator object that can be used to
26  * traverse the outline of a {@link java.awt.Shape}. It returns points along the
27  * boundary of the Shape which may be actual vertices (in the case of a shape
28  * made of line segments) or may be points on a curved segment with the distance
29  * between the points determined by a chosen flattening factor.
30  * <p>
31  * If the shape is closed, the outline is traversed in the counter-clockwise
32  * direction. That means that moving forward along the boundary is to travel in
33  * such a way that the interior of the shape is to the left of the outline path
34  * and the exterior of the shape is to the right of the outline path. The
35  * interior and exterior of the shape are determined by a winding rule.
36  * </p>
37  *
38  * @since Android 1.0
39  */
40 public interface PathIterator {
41 
42     /**
43      * The Constant WIND_EVEN_ODD indicates the winding rule that says that a
44      * point is outside the shape if any infinite ray from the point crosses the
45      * outline of the shape an even number of times, otherwise it is inside.
46      */
47     public static final int WIND_EVEN_ODD = 0;
48 
49     /**
50      * The Constant WIND_NON_ZERO indicates the winding rule that says that a
51      * point is inside the shape if every infinite ray starting from that point
52      * crosses the outline of the shape a non-zero number of times.
53      */
54     public static final int WIND_NON_ZERO = 1;
55 
56     /**
57      * The Constant SEG_MOVETO indicates that to follow the shape's outline from
58      * the previous point to the current point, the cursor (traversal point)
59      * should be placed directly on the current point.
60      */
61     public static final int SEG_MOVETO = 0;
62 
63     /**
64      * The Constant SEG_LINETO indicates that to follow the shape's outline from
65      * the previous point to the current point, the cursor (traversal point)
66      * should follow a straight line.
67      */
68     public static final int SEG_LINETO = 1;
69 
70     /**
71      * The Constant SEG_QUADTO indicates that to follow the shape's outline from
72      * the previous point to the current point, the cursor (traversal point)
73      * should follow a quadratic curve.
74      */
75     public static final int SEG_QUADTO = 2;
76 
77     /**
78      * The Constant SEG_CUBICTO indicates that to follow the shape's outline
79      * from the previous point to the current point, the cursor (traversal
80      * point) should follow a cubic curve.
81      */
82     public static final int SEG_CUBICTO = 3;
83 
84     /**
85      * The Constant SEG_CLOSE indicates that the previous point was the end of
86      * the shape's outline.
87      */
88     public static final int SEG_CLOSE = 4;
89 
90     /**
91      * Gets the winding rule, either {@link PathIterator#WIND_EVEN_ODD} or
92      * {@link PathIterator#WIND_NON_ZERO}.
93      *
94      * @return the winding rule.
95      */
getWindingRule()96     public int getWindingRule();
97 
98     /**
99      * Checks if this PathIterator has been completely traversed.
100      *
101      * @return true, if this PathIterator has been completely traversed.
102      */
isDone()103     public boolean isDone();
104 
105     /**
106      * Tells this PathIterator to skip to the next segment.
107      */
next()108     public void next();
109 
110     /**
111      * Gets the coordinates of the next vertex point along the shape's outline
112      * and a flag that indicates what kind of segment to use in order to connect
113      * the previous vertex point to the current vertex point to form the current
114      * segment.
115      *
116      * @param coords
117      *            the array that the coordinates of the end point of the current
118      *            segment are written into.
119      * @return the flag that indicates how to follow the shape's outline from
120      *         the previous point to the current one, chosen from the following
121      *         constants: {@link PathIterator#SEG_MOVETO},
122      *         {@link PathIterator#SEG_LINETO}, {@link PathIterator#SEG_QUADTO},
123      *         {@link PathIterator#SEG_CUBICTO}, or
124      *         {@link PathIterator#SEG_CLOSE}.
125      */
currentSegment(float[] coords)126     public int currentSegment(float[] coords);
127 
128     /**
129      * Gets the coordinates of the next vertex point along the shape's outline
130      * and a flag that indicates what kind of segment to use in order to connect
131      * the previous vertex point to the current vertex point to form the current
132      * segment.
133      *
134      * @param coords
135      *            the array that the coordinates of the end point of the current
136      *            segment are written into.
137      * @return the flag that indicates how to follow the shape's outline from
138      *         the previous point to the current one, chosen from the following
139      *         constants: {@link PathIterator#SEG_MOVETO},
140      *         {@link PathIterator#SEG_LINETO}, {@link PathIterator#SEG_QUADTO},
141      *         {@link PathIterator#SEG_CUBICTO}, or
142      *         {@link PathIterator#SEG_CLOSE}.
143      */
currentSegment(double[] coords)144     public int currentSegment(double[] coords);
145 
146 }
147