Statistics
| Revision:

root / branches / Mobile_Compatible_Hito_1 / libFMap / src / es / prodevelop / gvsig / mobile / fmap / core / FGeometry.java @ 21606

History | View | Annotate | Download (7.31 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
/************************************************
48
 *                                                                                                *
49
 *   Modfied By:                                                                *
50
 *   Prodevelop Integraci?n de Tecnolog?as SL        *
51
 *   Conde Salvatierra de ?lava , 34-10                        *
52
 *   46004 Valencia                                                                *
53
 *   Spain                                                                                *
54
 *                                                                                                *
55
 *   +34 963 510 612                                                        *
56
 *   +34 963 510 968                                                        *
57
 *   gis@prodevelop.es                                                        *
58
 *   http://www.prodevelop.es                                        *
59
 *                                                                                                *
60
 *   gvSIG Mobile Team 2006                                         *
61
 *                                                                                          *         
62
 ************************************************/
63

    
64
package es.prodevelop.gvsig.mobile.fmap.core;
65

    
66
import java.awt.Graphics2D;
67
import java.awt.Rectangle;
68
import java.awt.Shape;
69
import java.awt.geom.AffineTransform;
70
import java.awt.geom.PathIterator;
71
import java.awt.geom.Point2D;
72
import java.awt.geom.Rectangle2D;
73

    
74
import org.apache.log4j.Logger;
75

    
76
import es.prodevelop.gvsig.mobile.fmap.proj.ICoordTrans;
77
import es.prodevelop.gvsig.mobile.fmap.symbol.FSymbol;
78
import es.prodevelop.gvsig.mobile.fmap.util.graph2d.Graph2DUtilities;
79
import es.prodevelop.gvsig.mobile.fmap.viewport.ViewPort;
80

    
81

    
82
/**
83
 * Geometr?a.
84
 *
85
 * @author FJP
86
 */
87
public class FGeometry implements IGeometry3D {
88
        
89
        private static Logger logger = Logger.getLogger(FGeometry.class.getName());
90
        /**
91
         *
92
         */
93
        private static final long serialVersionUID = 5431865770186523337L;
94
        private FShape shp;
95
        private Rectangle2D bounds2D;
96

    
97
        /**
98
         * Crea un nuevo FGeometry.
99
         *
100
         * @param shp 
101
         */
102
        FGeometry(FShape shp) {
103
                this.shp = shp;
104
        }
105

    
106
        /* (non-Javadoc)
107
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, org.geotools.renderer.style.Style2D)
108
         */
109
        /**
110
         * Dibuja la geometria actual en el graphics que se le pasa como par?metro,
111
         * aplicandole las caracter?sticas del s?mbolo.
112
         *
113
         * @param g Graphics2D.
114
         * @param vp ViewPort.
115
         * @param symbol S?mbolo.
116
         */
117
        public void draw(Graphics2D g, ViewPort vp, FSymbol symbol, AffineTransform at) {
118
                // OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
119
                // O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
120
                // SHAPE
121
                // Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
122
                transform(vp.getAffineTransform());
123
                
124
                if (shp instanceof FPolygon2D) {
125
                        
126
                        Graph2DUtilities.drawPathIterator(g,
127
                                        ((FPolygon2D) shp).getPathIterator(at), null);
128
                }
129
        }
130

    
131
    /* (non-Javadoc)
132
     * @see com.iver.cit.gvsig.fmap.core.IGeometry#drawInts(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol)
133
     */
134
    public void drawInts(Graphics2D g, ViewPort vp, FSymbol symbol, AffineTransform at) {
135
            draw(g, vp, symbol, at);    }
136

    
137
        /**
138
         * Aplica la transformaci?n a la geometr?a de la matriz de transformaci?n
139
         * que se pasa como par?metro.
140
         *
141
         * @param at Matriz de transformaci?n.
142
         */
143
        public void transform(AffineTransform at) {
144
                shp.transform(at);
145
        }
146

    
147
        /* (non-Javadoc)
148
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D)
149
         */
150
        public boolean intersects(Rectangle2D r) {
151
                return shp.intersects(r);
152
        }
153

    
154
        /* (non-Javadoc)
155
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D()
156
         */
157
        public Rectangle2D getBounds2D() {
158
                if (bounds2D == null)
159
                {
160
                        bounds2D = new Rectangle2D.Double(
161
                                        shp.getBounds().x,
162
                                        shp.getBounds().y,
163
                                        shp.getBounds().width,
164
                                        shp.getBounds().height);
165
                }
166
                // return shp.getBounds2D();
167
                return bounds2D;
168
        }
169

    
170
        
171

    
172
        /* (non-Javadoc)
173
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry()
174
         */
175
        
176
        /* (non-Javadoc)
177
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean)
178
         */
179
        
180

    
181
        /**
182
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType()
183
         */
184
        public int getGeometryType() {
185
                return shp.getShapeType();
186
        }
187

    
188
        /* (non-Javadoc)
189
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry()
190
         */
191
        public IGeometry cloneGeometry() {
192
                return new FGeometry(shp.cloneFShape());
193
        }
194

    
195
        /* (non-Javadoc)
196
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans)
197
         */
198
        public void reProject(ICoordTrans ct) {
199
                shp.reProject(ct);
200
        }
201

    
202
        /**
203
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#getPathIterator(AffineTransform)
204
         */
205
        public PathIterator getPathIterator(AffineTransform at) {
206
                if (shp instanceof FPolygon2D) {
207
                        return ((FPolygon2D)shp).getPathIterator(null);
208
                }
209
                if (shp instanceof FPolyline2D) {
210
                        return ((FPolyline2D)shp).getPathIterator(null);
211
                }
212
                return null;
213
        }
214
    /**
215
         * Devuelve un array con todos los valores de Z.
216
         *
217
         * @return Array de Zs.
218
         */
219
        public double[] getZs() {
220
                return ((FShape3D) shp).getZs();
221
        }
222
        /**
223
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#getHandlers()
224
         */
225
        public Handler[] getHandlers(int type) {
226
                if (type==STRETCHINGHANDLER){
227
                return shp.getStretchingHandlers();
228
                }else if (type==SELECTHANDLER){
229
                        return shp.getSelectHandlers();
230
                }
231
                return null;
232
        }
233

    
234
        /* (non-Javadoc)
235
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeneralPathXIterator(java.awt.geom.AffineTransform, double)
236
         */
237
        public PathIterator getPathIterator(AffineTransform at, double flatness) {
238
                return getPathIterator(at);
239
        }
240

    
241
        public boolean contains(double x, double y) {
242
                return true;
243
        }
244

    
245
        public boolean contains(double x, double y, double w, double h) {
246
                return true;
247
        }
248

    
249
        public boolean intersects(double x, double y, double w, double h) {
250
                return true;
251
        }
252

    
253
        public Rectangle getBounds() {
254
                return shp.getBounds();
255
        }
256

    
257
        public boolean contains(Point2D p) {
258
                return true;
259
        }
260

    
261
        public boolean contains(Rectangle2D r) {
262
                return true;
263
        }
264

    
265
        public Shape getInternalShape() {
266
                return shp;
267
        }
268

    
269
        /* public void move(double x, double y) {
270
                AffineTransform at = new AffineTransform();
271
                at.translate(x, y);
272
                transform(at);
273
        }
274
        public void rotate(double r, double x, double y) {
275
                AffineTransform at = new AffineTransform();
276
                at.rotate(r, x, y);
277
                transform(at);
278
        }
279
        public void scale(Point2D point,double x, double y) {
280
                AffineTransform at = new AffineTransform();
281
                at.setToTranslation(point.getX(),point.getY());
282
                at.scale(x,y);
283
                at.translate(-point.getX(),-point.getY());
284
                transform(at);
285
        } */
286
}