Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FPointIterator.java @ 1100

History | View | Annotate | Download (3.04 KB)

1
/*
2
 * Created on 25-nov-2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.fmap.core;
48

    
49
import java.awt.geom.AffineTransform;
50
import java.awt.geom.PathIterator;
51
import java.awt.geom.Point2D;
52

    
53

    
54
/**
55
 * (Sacado de GT2)
56
 *
57
 * @author FJP
58
 */
59
public class FPointIterator implements PathIterator {
60
        /** Transform applied on the coordinates during iteration */
61
        private AffineTransform at;
62

    
63
        /** The point we are going to provide when asked for coordinates */
64
        private Point2D p;
65

    
66
        /** True when the point has been read once */
67
        private boolean done;
68

    
69
        /**
70
         * Creates a new PointIterator object.
71
         *
72
         * @param p The polygon
73
         * @param at The affine transform applied to coordinates during iteration
74
         */
75
        public FPointIterator(Point2D p, AffineTransform at) {
76
                if (at == null) {
77
                        at = new AffineTransform();
78
                }
79

    
80
                this.at = at;
81
                this.p = p;
82
                done = false;
83
        }
84

    
85
        /**
86
         * Return the winding rule for determining the interior of the path.
87
         *
88
         * @return <code>WIND_EVEN_ODD</code> by default.
89
         */
90
        public int getWindingRule() {
91
                return PathIterator.WIND_EVEN_ODD;
92
        }
93

    
94
        /**
95
         * @see java.awt.geom.PathIterator#next()
96
         */
97
        public void next() {
98
                done = true;
99
        }
100

    
101
        /**
102
         * @see java.awt.geom.PathIterator#isDone()
103
         */
104
        public boolean isDone() {
105
                return done;
106
        }
107

    
108
        /**
109
         * @see java.awt.geom.PathIterator#currentSegment(double[])
110
         */
111
        public int currentSegment(double[] coords) {
112
                coords[0] = p.getX();
113
                coords[1] = p.getY();
114
                at.transform(coords, 0, coords, 0, 1);
115

    
116
                return PathIterator.SEG_MOVETO;
117
        }
118

    
119
        /* (non-Javadoc)
120
         * @see java.awt.geom.PathIterator#currentSegment(float[])
121
         */
122
        public int currentSegment(float[] coords) {
123
                coords[0] = (float) p.getX();
124
                coords[1] = (float) p.getY();
125
                at.transform(coords, 0, coords, 0, 1);
126

    
127
                return PathIterator.SEG_MOVETO;
128
        }
129
}