Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / gt2 / PointIterator.java @ 9284

History | View | Annotate | Download (2.92 KB)

1 2943 fjp
/*
2
 * Created on 12-may-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.cit.gvsig.fmap.core.gt2;
45
46
import java.awt.geom.AffineTransform;
47
48
import com.vividsolutions.jts.geom.Point;
49
50
51
/**
52
 * A path iterator for the LiteShape class, specialized to iterate over Point objects.
53
 *
54
 * @author Andrea Aime
55
 */
56
public class PointIterator extends AbstractLiteIterator {
57
    /** Transform applied on the coordinates during iteration */
58
    private AffineTransform at;
59
60
    /** The point we are going to provide when asked for coordinates */
61
    private Point point;
62
63
    /** True when the point has been read once */
64
    private boolean done;
65
66
67
    /**
68
     * Creates a new PointIterator object.
69
     *
70
     * @param p The polygon
71
     * @param at The affine transform applied to coordinates during iteration
72
     */
73
    public PointIterator(Point point, AffineTransform at) {
74
        if (at == null) {
75
            at = new AffineTransform();
76
        }
77
78
        this.at = at;
79
        this.point = point;
80
        done = false;
81
    }
82
83
    /**
84
     * Return the winding rule for determining the interior of the path.
85
     *
86
     * @return <code>WIND_EVEN_ODD</code> by default.
87
     */
88
    public int getWindingRule() {
89
        return WIND_EVEN_ODD;
90
    }
91
92
    /**
93
     * @see java.awt.geom.PathIterator#next()
94
     */
95
    public void next() {
96
        done = true;
97
    }
98
99
    /**
100
     * @see java.awt.geom.PathIterator#isDone()
101
     */
102
    public boolean isDone() {
103
        return done;
104
    }
105
106
    /**
107
     * @see java.awt.geom.PathIterator#currentSegment(double[])
108
     */
109
    public int currentSegment(double[] coords) {
110
        coords[0] = point.getX();
111
        coords[1] = point.getY();
112
        at.transform(coords, 0, coords, 0, 1);
113
114
        return SEG_MOVETO;
115
    }
116
117
}