svn-gvsig-desktop / branches / pilotoDWG / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FGeometryCollection.java @ 1532
History | View | Annotate | Download (5.9 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. 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 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.core; |
42 |
|
43 |
import com.iver.cit.gvsig.fmap.ViewPort; |
44 |
import com.iver.cit.gvsig.fmap.core.v02.FLabel; |
45 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
46 |
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
47 |
|
48 |
import com.vividsolutions.jts.geom.Geometry; |
49 |
|
50 |
import org.cresques.cts.ICoordTrans; |
51 |
|
52 |
import java.awt.Graphics2D; |
53 |
import java.awt.geom.Point2D; |
54 |
import java.awt.geom.Rectangle2D; |
55 |
import java.util.ArrayList; |
56 |
|
57 |
|
58 |
/**
|
59 |
* Colecci?n de Geometr?as.
|
60 |
*
|
61 |
* @author Vicente Caballero Navarro
|
62 |
*/
|
63 |
public class FGeometryCollection implements IGeometry { |
64 |
private IGeometry[] geometries; |
65 |
|
66 |
/**
|
67 |
* Crea un nuevo FGeometryCollection.
|
68 |
*
|
69 |
* @param geoms vector de geometr?as.
|
70 |
*/
|
71 |
public FGeometryCollection(IGeometry[] geoms) { |
72 |
geometries = geoms; |
73 |
} |
74 |
|
75 |
/**
|
76 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D,
|
77 |
* com.iver.cit.gvsig.fmap.ViewPort, FStyle2D)
|
78 |
*/
|
79 |
public void draw(Graphics2D g, ViewPort vp, FStyle2D symbol) { |
80 |
for (int i = 0; i < geometries.length; i++) |
81 |
geometries[i].draw(g, vp, symbol); |
82 |
} |
83 |
|
84 |
/**
|
85 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean)
|
86 |
*/
|
87 |
public FLabel[] createLabels(int position, boolean duplicates) { |
88 |
return null; |
89 |
} |
90 |
|
91 |
/**
|
92 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D)
|
93 |
*/
|
94 |
public boolean intersects(Rectangle2D r) { |
95 |
boolean resul = false; |
96 |
for (int i = 0; i < geometries.length; i++) |
97 |
{ |
98 |
resul = geometries[i].intersects(r); |
99 |
if (resul) break; |
100 |
} |
101 |
|
102 |
return resul;
|
103 |
} |
104 |
|
105 |
/**
|
106 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D()
|
107 |
*/
|
108 |
public Rectangle2D getBounds2D() { |
109 |
Rectangle2D rAux = null; |
110 |
|
111 |
for (int i = 0; i < geometries.length; i++) |
112 |
if (rAux==null){ |
113 |
rAux=geometries[i].getBounds2D(); |
114 |
}else{
|
115 |
rAux.add(geometries[i].getBounds2D()); |
116 |
} |
117 |
return rAux;
|
118 |
} |
119 |
|
120 |
/**
|
121 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType()
|
122 |
*/
|
123 |
public int getGeometryType() { |
124 |
int ret = 0; |
125 |
|
126 |
for (int i = 0; i < geometries.length; i++) { |
127 |
ret = ret & geometries[i].getGeometryType(); |
128 |
} |
129 |
|
130 |
return ret;
|
131 |
} |
132 |
|
133 |
/* (non-Javadoc)
|
134 |
* @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)
|
135 |
*/
|
136 |
public void draw(Graphics2D g, ViewPort vp, FSymbol symbol) { |
137 |
for (int i = 0; i < geometries.length; i++) |
138 |
geometries[i].draw(g, vp, symbol); |
139 |
} |
140 |
|
141 |
/* (non-Javadoc)
|
142 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry()
|
143 |
*/
|
144 |
public IGeometry cloneGeometry() {
|
145 |
IGeometry[] newGeometries = new IGeometry[geometries.length]; |
146 |
|
147 |
for (int i = 0; i < geometries.length; i++) |
148 |
newGeometries[i] = geometries[i].cloneGeometry(); |
149 |
|
150 |
return new FGeometryCollection(newGeometries); |
151 |
} |
152 |
|
153 |
/* (non-Javadoc)
|
154 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry()
|
155 |
*/
|
156 |
public Geometry toJTSGeometry() {
|
157 |
// TODO Auto-generated method stub
|
158 |
return null; |
159 |
} |
160 |
|
161 |
/* (non-Javadoc)
|
162 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans)
|
163 |
*/
|
164 |
public void reProject(ICoordTrans ct) { |
165 |
for (int i = 0; i < geometries.length; i++) |
166 |
geometries[i].reProject(ct); |
167 |
} |
168 |
|
169 |
/**
|
170 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeneralPathXIterator()
|
171 |
*/
|
172 |
public GeneralPathXIterator getGeneralPathXIterator() {
|
173 |
//TODO no esta implementado.
|
174 |
return null; |
175 |
} |
176 |
|
177 |
/* (non-Javadoc)
|
178 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
|
179 |
*/
|
180 |
public boolean fastIntersects(double x, double y, double w, double h) { |
181 |
boolean resul = false; |
182 |
for (int i = 0; i < geometries.length; i++) |
183 |
{ |
184 |
resul = geometries[i].fastIntersects(x,y,w,h); |
185 |
if (resul) break; |
186 |
} |
187 |
return resul;
|
188 |
} |
189 |
|
190 |
/**
|
191 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#move(double, double)
|
192 |
*/
|
193 |
public void move(double x, double y) { |
194 |
for (int i = 0; i < geometries.length; i++){ |
195 |
geometries[i].move(x,y); |
196 |
} |
197 |
} |
198 |
|
199 |
/**
|
200 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#rotate(double, double, double)
|
201 |
*/
|
202 |
public void rotate(double r, double x, double y) { |
203 |
for (int i = 0; i < geometries.length; i++){ |
204 |
geometries[i].rotate(r,x,y); |
205 |
} |
206 |
} |
207 |
|
208 |
/**
|
209 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getHandlers()
|
210 |
*/
|
211 |
public Handler[] getHandlers(int type) { |
212 |
ArrayList handlers=new ArrayList(); |
213 |
for (int i = 0; i < geometries.length; i++){ |
214 |
Handler[] handAux=geometries[i].getHandlers(type); |
215 |
for (int j=0;j<handAux.length;j++){ |
216 |
handlers.add(handAux[j]); |
217 |
} |
218 |
} |
219 |
return (Handler[])handlers.toArray(new Handler[0]); |
220 |
|
221 |
} |
222 |
|
223 |
/**
|
224 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#scale(java.awt.geom.Point2D, double, double)
|
225 |
*/
|
226 |
public void scale(Point2D point, double x, double y) { |
227 |
for (int i = 0; i < geometries.length; i++){ |
228 |
geometries[i].scale(point,x,y); |
229 |
} |
230 |
} |
231 |
} |