root / branches / Mobile_Compatible_Hito_1 / libFMap / src / es / prodevelop / gvsig / mobile / fmap / core / FGeometryCollection.java @ 21606
History | View | Annotate | Download (11.4 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* http://www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL
|
34 |
* Conde Salvatierra de ?lava , 34-10
|
35 |
* 46004 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963 510 612
|
39 |
* +34 963 510 968
|
40 |
* gis@prodevelop.es
|
41 |
* http://www.prodevelop.es
|
42 |
*
|
43 |
* or
|
44 |
*
|
45 |
* Instituto de Rob?tica
|
46 |
* Apartado de correos 2085
|
47 |
* 46071 Valencia
|
48 |
* (Spain)
|
49 |
*
|
50 |
* +34 963 543 577
|
51 |
* jjordan@robotica.uv.es
|
52 |
* http://robotica.uv.es
|
53 |
*
|
54 |
*/
|
55 |
|
56 |
package es.prodevelop.gvsig.mobile.fmap.core; |
57 |
|
58 |
import java.util.ArrayList; |
59 |
|
60 |
|
61 |
/**
|
62 |
* Colecci?n de Geometr?as.
|
63 |
*
|
64 |
* @author Vicente Caballero Navarro
|
65 |
*/
|
66 |
public class FGeometryCollection { //implements IGeometry { |
67 |
private ArrayList geometries = new ArrayList(); |
68 |
|
69 |
// /**
|
70 |
// * Crea un nuevo FGeometryCollection.
|
71 |
// *
|
72 |
// * @param geoms vector de geometr?as.
|
73 |
// */
|
74 |
// public FGeometryCollection(IGeometry[] geoms) {
|
75 |
// for (int i = 0; i < geoms.length; i++) {
|
76 |
// geometries.add(geoms[i]);
|
77 |
// }
|
78 |
// }
|
79 |
//
|
80 |
// public void addGeometry(IGeometry g){
|
81 |
// geometries.add(g);
|
82 |
// }
|
83 |
//
|
84 |
// /**
|
85 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D,
|
86 |
// * com.iver.cit.gvsig.fmap.ViewPort, FStyle2D)
|
87 |
// */
|
88 |
// public void draw(Graphics2D g, ViewPort vp, FStyle2D symbol) {
|
89 |
// for (int i = 0; i < geometries.size(); i++)
|
90 |
// ((IGeometry)geometries.get(i)).draw(g, vp, symbol);
|
91 |
// }
|
92 |
//
|
93 |
// /**
|
94 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean)
|
95 |
// */
|
96 |
// public FLabel[] createLabels(int position, boolean duplicates) {
|
97 |
// return null;
|
98 |
// }
|
99 |
//
|
100 |
// /**
|
101 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D)
|
102 |
// */
|
103 |
///* public boolean intersects(Rectangle2D r, double flatness) {
|
104 |
// boolean resul = false;
|
105 |
// for (int i = 0; i < geometries.size(); i++)
|
106 |
// {
|
107 |
// resul = ((IGeometry)geometries.get(i)).intersects(r, flatness);
|
108 |
// if (resul) break;
|
109 |
// }
|
110 |
//
|
111 |
// return resul;
|
112 |
// }
|
113 |
//*/
|
114 |
// /**
|
115 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D)
|
116 |
// */
|
117 |
// public boolean intersects(Rectangle2D r) {
|
118 |
// boolean resul = false;
|
119 |
// for (int i = 0; i < geometries.size(); i++)
|
120 |
// {
|
121 |
// resul = ((IGeometry)geometries.get(i)).intersects(r);
|
122 |
// if (resul) break;
|
123 |
// }
|
124 |
//
|
125 |
// return resul;
|
126 |
// }
|
127 |
//
|
128 |
// /**
|
129 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D()
|
130 |
// */
|
131 |
// public Rectangle2D getBounds2D() {
|
132 |
// Rectangle2D rAux = null;
|
133 |
//
|
134 |
// for (int i = 0; i < geometries.size(); i++)
|
135 |
// if (rAux==null){
|
136 |
// rAux=((IGeometry)geometries.get(i)).getBounds2D();
|
137 |
// }else{
|
138 |
// rAux.add(((IGeometry)geometries.get(i)).getBounds2D());
|
139 |
// }
|
140 |
// return rAux;
|
141 |
// }
|
142 |
//
|
143 |
// /**
|
144 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType()
|
145 |
// */
|
146 |
// public int getGeometryType() {
|
147 |
// /*int ret = 0;
|
148 |
//
|
149 |
// for (int i = 0; i < geometries.length; i++) {
|
150 |
// ret = ret | geometries[i].getGeometryType();
|
151 |
// }
|
152 |
//
|
153 |
// return ret;
|
154 |
// */
|
155 |
// return FShape.LINE;
|
156 |
// }
|
157 |
//
|
158 |
// /* (non-Javadoc)
|
159 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol)
|
160 |
// */
|
161 |
// public void draw(Graphics2D g, ViewPort vp, ISymbol symbol) {
|
162 |
// for (int i = 0; i < geometries.size(); i++)
|
163 |
// ((IGeometry)geometries.get(i)).draw(g, vp, symbol);
|
164 |
// }
|
165 |
//
|
166 |
// /* (non-Javadoc)
|
167 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry()
|
168 |
// */
|
169 |
// public IGeometry cloneGeometry() {
|
170 |
// IGeometry[] newGeometries = new IGeometry[geometries.size()];
|
171 |
//
|
172 |
// for (int i = 0; i < geometries.size(); i++)
|
173 |
// newGeometries[i] = ((IGeometry)geometries.get(i)).cloneGeometry();
|
174 |
//
|
175 |
// return new FGeometryCollection(newGeometries);
|
176 |
// }
|
177 |
//
|
178 |
// /* (non-Javadoc)
|
179 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry()
|
180 |
// */
|
181 |
// public Geometry toJTSGeometry() {
|
182 |
// Geometry[] theGeoms = new Geometry[geometries.size()];
|
183 |
// for (int i = 0; i < geometries.size(); i++)
|
184 |
// {
|
185 |
// theGeoms[i] = ((IGeometry)geometries.get(i)).toJTSGeometry();
|
186 |
// }
|
187 |
// GeometryCollection geomCol = new GeometryFactory().createGeometryCollection(theGeoms);
|
188 |
//
|
189 |
//
|
190 |
// return geomCol;
|
191 |
// }
|
192 |
//
|
193 |
// /* (non-Javadoc)
|
194 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans)
|
195 |
// */
|
196 |
// public void reProject(ICoordTrans ct) {
|
197 |
// for (int i = 0; i < geometries.size(); i++)
|
198 |
// ((IGeometry)geometries.get(i)).reProject(ct);
|
199 |
// }
|
200 |
//
|
201 |
// /**
|
202 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#getPathIterator(AffineTransform)
|
203 |
// */
|
204 |
// public PathIterator getPathIterator(AffineTransform at) {
|
205 |
// // Necesitamos convertir todo esto a una GeneralPathX, tarde o temprano.
|
206 |
// // As? que lo intento aqu? por primera vez.
|
207 |
// // Lo necesitamos para la edici?n, porque se est?n
|
208 |
// // a?adiendo las geometr?as como FGeometryCollection
|
209 |
// // para que el explode sea sencillo. No lo veo muy
|
210 |
// // claro eso, pero bueno.
|
211 |
// /* GeneralPathX gp = new GeneralPathX();
|
212 |
// double[] coords = new double[6];
|
213 |
// for (int i=0; i < geometries.size(); i++)
|
214 |
// {
|
215 |
// IGeometry gAux = (IGeometry) geometries.get(i);
|
216 |
// GeneralPathXIterator pi = gAux.getGeneralPathXIterator();
|
217 |
// // Si el primer punto y el ultimo son iguales, conectamos
|
218 |
// // la geometr?a.
|
219 |
// boolean bFirst = true;
|
220 |
// double[] firstCoord = new double[6];
|
221 |
// while (!pi.isDone())
|
222 |
// {
|
223 |
// int type = pi.currentSegment(coords);
|
224 |
// switch (type)
|
225 |
// {
|
226 |
// case GeneralPathXIterator.SEG_MOVETO:
|
227 |
// if ((!bFirst) || (firstCoord != coords))
|
228 |
// gp.moveTo(coords[0], coords[1]);
|
229 |
// break;
|
230 |
// case SEG_LINETO:
|
231 |
// lineTo(coords[0], coords[1]);
|
232 |
// break;
|
233 |
// case SEG_QUADTO:
|
234 |
// quadTo(coords[0], coords[1],
|
235 |
// coords[2], coords[3]);
|
236 |
// break;
|
237 |
// case SEG_CUBICTO:
|
238 |
// // Not implemented
|
239 |
// System.err.println("ERROR. TRAMO CUBICO. SIN IMPLEMENTAR TODAV?A");
|
240 |
// curveTo(coords[0], coords[1],
|
241 |
// coords[2], coords[3],
|
242 |
// coords[4], coords[5]);
|
243 |
// break;
|
244 |
// case SEG_CLOSE:
|
245 |
// closePath();
|
246 |
// break;
|
247 |
// }
|
248 |
// pi.next();
|
249 |
// }
|
250 |
// } */
|
251 |
// GeneralPathX gp = new GeneralPathX();
|
252 |
// for (int i=0; i < geometries.size(); i++)
|
253 |
// {
|
254 |
// IGeometry gAux = (IGeometry) geometries.get(i);
|
255 |
// gp.append(gAux.getPathIterator(null), true);
|
256 |
// }
|
257 |
// return (GeneralPathXIterator) gp.getPathIterator(null);
|
258 |
// }
|
259 |
//
|
260 |
// /* (non-Javadoc)
|
261 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
|
262 |
// */
|
263 |
// public boolean fastIntersects(double x, double y, double w, double h) {
|
264 |
// boolean resul = false;
|
265 |
// for (int i = 0; i < geometries.size(); i++)
|
266 |
// {
|
267 |
// resul = ((IGeometry)geometries.get(i)).fastIntersects(x,y,w,h);
|
268 |
// if (resul) break;
|
269 |
// }
|
270 |
// return resul;
|
271 |
// }
|
272 |
//
|
273 |
// /**
|
274 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#toWKB()
|
275 |
// */
|
276 |
// public byte[] toWKB() throws IOException {
|
277 |
// return WKBEncoder.encodeGeometry(toJTSGeometry());
|
278 |
// }
|
279 |
//
|
280 |
// /* (non-Javadoc)
|
281 |
// * @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)
|
282 |
// */
|
283 |
// public void drawInts(Graphics2D g, ViewPort vp, ISymbol symbol) {
|
284 |
// for (int i = 0; i < geometries.size(); i++)
|
285 |
// ((IGeometry)geometries.get(i)).drawInts(g, vp, symbol);
|
286 |
//
|
287 |
// }
|
288 |
//
|
289 |
// /**
|
290 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#getShapes()
|
291 |
// */
|
292 |
// /*public FShape[] getShapes() {
|
293 |
// ArrayList shapes=new ArrayList();
|
294 |
// for (int i= 0;i<geometries.size();i++){
|
295 |
// FShape[] s=((IGeometry)geometries.get(i)).getShapes();
|
296 |
// for (int j=0;j<s.length;j++){
|
297 |
// shapes.add(s[j]);
|
298 |
// }
|
299 |
// }
|
300 |
// return (FShape[])shapes.toArray(new FShape[0]);
|
301 |
// }*/
|
302 |
// public IGeometry[] getGeometries(){
|
303 |
// return (IGeometry[])geometries.toArray(new IGeometry[0]).clone();
|
304 |
// }
|
305 |
//
|
306 |
// /* (non-Javadoc)
|
307 |
// * @see com.iver.cit.gvsig.fmap.core.IGeometry#getHandlers(int)
|
308 |
// */
|
309 |
// public Handler[] getHandlers(int type) {
|
310 |
// ArrayList handlers=new ArrayList();
|
311 |
// for (int i = 0; i < geometries.size(); i++){
|
312 |
// Handler[] handAux=((IGeometry)geometries.get(i)).getHandlers(type);
|
313 |
// for (int j=0;j<handAux.length;j++){
|
314 |
// handlers.add(handAux[j]);
|
315 |
// }
|
316 |
// }
|
317 |
// return (Handler[])handlers.toArray(new Handler[0]);
|
318 |
// }
|
319 |
//
|
320 |
//
|
321 |
// public void transform(AffineTransform at) {
|
322 |
// for (int i = 0; i < geometries.size(); i++){
|
323 |
// ((IGeometry)geometries.get(i)).transform(at);
|
324 |
// }
|
325 |
// }
|
326 |
//
|
327 |
// public PathIterator getPathIterator(AffineTransform at, double flatness) {
|
328 |
// GeneralPathX gp = new GeneralPathX();
|
329 |
// for (int i=0; i < geometries.size(); i++)
|
330 |
// {
|
331 |
// IGeometry gAux = (IGeometry) geometries.get(i);
|
332 |
// gp.append(gAux.getPathIterator(null), true);
|
333 |
// }
|
334 |
// return gp.getPathIterator(at, flatness);
|
335 |
// }
|
336 |
//
|
337 |
// public boolean contains(double x, double y) {
|
338 |
// boolean bRes;
|
339 |
// for (int i=0; i < geometries.size(); i++)
|
340 |
// {
|
341 |
// IGeometry gAux = (IGeometry) geometries.get(i);
|
342 |
// bRes = gAux.contains(x,y);
|
343 |
// if (bRes) return bRes;
|
344 |
// }
|
345 |
//
|
346 |
// return false;
|
347 |
// }
|
348 |
//
|
349 |
// public boolean contains(double x, double y, double w, double h) {
|
350 |
// boolean bRes;
|
351 |
// for (int i=0; i < geometries.size(); i++)
|
352 |
// {
|
353 |
// IGeometry gAux = (IGeometry) geometries.get(i);
|
354 |
// bRes = gAux.contains(x,y, w, h);
|
355 |
// if (bRes) return bRes;
|
356 |
// }
|
357 |
//
|
358 |
// return false;
|
359 |
// }
|
360 |
//
|
361 |
// public boolean intersects(double x, double y, double w, double h) {
|
362 |
// boolean bRes;
|
363 |
// for (int i=0; i < geometries.size(); i++)
|
364 |
// {
|
365 |
// IGeometry gAux = (IGeometry) geometries.get(i);
|
366 |
// bRes = gAux.intersects(x,y, w, h);
|
367 |
// if (bRes) return bRes;
|
368 |
// }
|
369 |
//
|
370 |
// return false;
|
371 |
// }
|
372 |
//
|
373 |
// public Rectangle getBounds() {
|
374 |
// Rectangle rAux = null;
|
375 |
//
|
376 |
// for (int i = 0; i < geometries.size(); i++)
|
377 |
// if (rAux==null){
|
378 |
// rAux=((IGeometry)geometries.get(i)).getBounds();
|
379 |
// }else{
|
380 |
// rAux.add(((IGeometry)geometries.get(i)).getBounds());
|
381 |
// }
|
382 |
// return rAux;
|
383 |
// }
|
384 |
//
|
385 |
// public boolean contains(Point2D p) {
|
386 |
// boolean bRes;
|
387 |
// for (int i=0; i < geometries.size(); i++)
|
388 |
// {
|
389 |
// IGeometry gAux = (IGeometry) geometries.get(i);
|
390 |
// bRes = gAux.contains(p);
|
391 |
// if (bRes) return bRes;
|
392 |
// }
|
393 |
//
|
394 |
// return false;
|
395 |
// }
|
396 |
//
|
397 |
// public boolean contains(Rectangle2D r) {
|
398 |
// boolean bRes;
|
399 |
// for (int i=0; i < geometries.size(); i++)
|
400 |
// {
|
401 |
// IGeometry gAux = (IGeometry) geometries.get(i);
|
402 |
// bRes = gAux.contains(r);
|
403 |
// if (bRes) return bRes;
|
404 |
// }
|
405 |
//
|
406 |
// return false;
|
407 |
// }
|
408 |
//
|
409 |
// public Shape getInternalShape() {
|
410 |
// return this;
|
411 |
// }
|
412 |
} |