Statistics
| Revision:

svn-gvsig-desktop / tags / Root_FMap_piloto_CAD_Layout_version / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FPointIterator.java @ 1664

History | View | Annotate | Download (3.08 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 extends GeneralPathXIterator {
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
                super(new GeneralPathX());
77
                if (at == null) {
78
                        at = new AffineTransform();
79
                }
80

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

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

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

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

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

    
117
                return PathIterator.SEG_MOVETO;
118
        }
119

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

    
128
                return PathIterator.SEG_MOVETO;
129
        }
130
}