summaryrefslogtreecommitdiffstats
path: root/awt/java/awt/geom/PathIterator.java
blob: 2d1c0ffa641b18775bc85dfc1a954e1c11fd0204 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/**
 * @author Denis M. Kishenko
 * @version $Revision$
 */

package java.awt.geom;

/**
 * The Interface PathIterator represents an iterator object that can be used to
 * traverse the outline of a {@link java.awt.Shape}. It returns points along the
 * boundary of the Shape which may be actual vertices (in the case of a shape
 * made of line segments) or may be points on a curved segment with the distance
 * between the points determined by a chosen flattening factor.
 * <p>
 * If the shape is closed, the outline is traversed in the counter-clockwise
 * direction. That means that moving forward along the boundary is to travel in
 * such a way that the interior of the shape is to the left of the outline path
 * and the exterior of the shape is to the right of the outline path. The
 * interior and exterior of the shape are determined by a winding rule.
 * </p>
 * 
 * @since Android 1.0
 */
public interface PathIterator {

    /**
     * The Constant WIND_EVEN_ODD indicates the winding rule that says that a
     * point is outside the shape if any infinite ray from the point crosses the
     * outline of the shape an even number of times, otherwise it is inside.
     */
    public static final int WIND_EVEN_ODD = 0;

    /**
     * The Constant WIND_NON_ZERO indicates the winding rule that says that a
     * point is inside the shape if every infinite ray starting from that point
     * crosses the outline of the shape a non-zero number of times.
     */
    public static final int WIND_NON_ZERO = 1;

    /**
     * The Constant SEG_MOVETO indicates that to follow the shape's outline from
     * the previous point to the current point, the cursor (traversal point)
     * should be placed directly on the current point.
     */
    public static final int SEG_MOVETO = 0;

    /**
     * The Constant SEG_LINETO indicates that to follow the shape's outline from
     * the previous point to the current point, the cursor (traversal point)
     * should follow a straight line.
     */
    public static final int SEG_LINETO = 1;

    /**
     * The Constant SEG_QUADTO indicates that to follow the shape's outline from
     * the previous point to the current point, the cursor (traversal point)
     * should follow a quadratic curve.
     */
    public static final int SEG_QUADTO = 2;

    /**
     * The Constant SEG_CUBICTO indicates that to follow the shape's outline
     * from the previous point to the current point, the cursor (traversal
     * point) should follow a cubic curve.
     */
    public static final int SEG_CUBICTO = 3;

    /**
     * The Constant SEG_CLOSE indicates that the previous point was the end of
     * the shape's outline.
     */
    public static final int SEG_CLOSE = 4;

    /**
     * Gets the winding rule, either {@link PathIterator#WIND_EVEN_ODD} or
     * {@link PathIterator#WIND_NON_ZERO}.
     * 
     * @return the winding rule.
     */
    public int getWindingRule();

    /**
     * Checks if this PathIterator has been completely traversed.
     * 
     * @return true, if this PathIterator has been completely traversed.
     */
    public boolean isDone();

    /**
     * Tells this PathIterator to skip to the next segment.
     */
    public void next();

    /**
     * Gets the coordinates of the next vertex point along the shape's outline
     * and a flag that indicates what kind of segment to use in order to connect
     * the previous vertex point to the current vertex point to form the current
     * segment.
     * 
     * @param coords
     *            the array that the coordinates of the end point of the current
     *            segment are written into.
     * @return the flag that indicates how to follow the shape's outline from
     *         the previous point to the current one, chosen from the following
     *         constants: {@link PathIterator#SEG_MOVETO},
     *         {@link PathIterator#SEG_LINETO}, {@link PathIterator#SEG_QUADTO},
     *         {@link PathIterator#SEG_CUBICTO}, or
     *         {@link PathIterator#SEG_CLOSE}.
     */
    public int currentSegment(float[] coords);

    /**
     * Gets the coordinates of the next vertex point along the shape's outline
     * and a flag that indicates what kind of segment to use in order to connect
     * the previous vertex point to the current vertex point to form the current
     * segment.
     * 
     * @param coords
     *            the array that the coordinates of the end point of the current
     *            segment are written into.
     * @return the flag that indicates how to follow the shape's outline from
     *         the previous point to the current one, chosen from the following
     *         constants: {@link PathIterator#SEG_MOVETO},
     *         {@link PathIterator#SEG_LINETO}, {@link PathIterator#SEG_QUADTO},
     *         {@link PathIterator#SEG_CUBICTO}, or
     *         {@link PathIterator#SEG_CLOSE}.
     */
    public int currentSegment(double[] coords);

}