root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / FMap.java @ 350
History | View | Annotate | Download (10.8 KB)
1 | 213 | fernando | /* Generated by Together */
|
---|---|---|---|
2 | package com.iver.cit.gvsig.fmap; |
||
3 | |||
4 | import java.awt.Graphics2D; |
||
5 | 214 | fernando | import java.awt.Toolkit; |
6 | 213 | fernando | import java.awt.geom.Point2D; |
7 | import java.awt.geom.Rectangle2D; |
||
8 | import java.awt.image.BufferedImage; |
||
9 | |||
10 | import org.cresques.cts.ICoordTrans; |
||
11 | import org.cresques.cts.IProjection; |
||
12 | import org.cresques.geo.Projected; |
||
13 | |||
14 | 305 | fjp | import com.iver.cit.gvsig.fmap.core.IGeometry; |
15 | 214 | fernando | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
16 | 346 | fernando | import com.iver.cit.gvsig.fmap.layers.CancelationException; |
17 | 214 | fernando | import com.iver.cit.gvsig.fmap.layers.FLayer; |
18 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
19 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
20 | 342 | fjp | import com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent; |
21 | import com.iver.cit.gvsig.fmap.layers.LayerCollectionListener; |
||
22 | import com.iver.cit.gvsig.fmap.layers.LayerPositionEvent; |
||
23 | 214 | fernando | import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
24 | 244 | fernando | import com.iver.cit.gvsig.fmap.operations.Cancellable; |
25 | 214 | fernando | import com.iver.cit.gvsig.fmap.operations.selection.Record; |
26 | import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor; |
||
27 | 325 | fernando | import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
28 | 213 | fernando | |
29 | |||
30 | /**
|
||
31 | * DOCUMENT ME!
|
||
32 | *
|
||
33 | * @author Fernando Gonz?lez Cort?s
|
||
34 | */
|
||
35 | 350 | fernando | public class FMap implements Projected { |
36 | 230 | fernando | public static final double[] CHANGEM = { |
37 | 214 | fernando | 1000, 1, 0.01, 0.001, 1609.344, 0.9144, 0.3048, 0.0254 |
38 | }; |
||
39 | |||
40 | /** DOCUMENT ME! */
|
||
41 | public static final double[] CHANGE = { |
||
42 | 100000, 100, 1, 0.1, 160934.4, 91.44, 30.48, 2.54 |
||
43 | }; |
||
44 | |||
45 | 213 | fernando | public static final int EQUALS = 0; |
46 | public static final int DISJOINT = 1; |
||
47 | public static final int INTERSECTS = 2; |
||
48 | public static final int TOUCHES = 3; |
||
49 | public static final int CROSSES = 4; |
||
50 | public static final int WITHIN = 5; |
||
51 | public static final int CONTAINS = 6; |
||
52 | public static final int OVERLAPS = 7; |
||
53 | private FLayers layers = new FLayers(); |
||
54 | private ViewPort viewPort;
|
||
55 | |||
56 | 214 | fernando | public FMap(ViewPort vp){
|
57 | this.viewPort = vp;
|
||
58 | 350 | fernando | layers.addLayerCollectionListener(new LayerListener());
|
59 | 214 | fernando | } |
60 | |||
61 | 213 | fernando | /**
|
62 | * DOCUMENT ME!
|
||
63 | *
|
||
64 | * @return DOCUMENT ME!
|
||
65 | */
|
||
66 | public FLayers getLayers() {
|
||
67 | return layers;
|
||
68 | } |
||
69 | |||
70 | /**
|
||
71 | * Dibuja en la imagen que se pasa como par?metro el contenido de las capas
|
||
72 | * visibles del mapa y teniendo en cuenta los datos del ViewPort contenido
|
||
73 | * en este FMap
|
||
74 | *
|
||
75 | * @param b DOCUMENT ME!
|
||
76 | */
|
||
77 | public void drawLabels(BufferedImage b) { |
||
78 | } |
||
79 | |||
80 | /**
|
||
81 | * DOCUMENT ME!
|
||
82 | *
|
||
83 | * @param g DOCUMENT ME!
|
||
84 | */
|
||
85 | public void print(Graphics2D g) { |
||
86 | } |
||
87 | |||
88 | /**
|
||
89 | * Crea un nuevo FMap con la informaci?n del ViewPort que se pasa como
|
||
90 | * par?metro.
|
||
91 | *
|
||
92 | * @param vp DOCUMENT ME!
|
||
93 | *
|
||
94 | * @return DOCUMENT ME!
|
||
95 | */
|
||
96 | public FMap createNewFMap(ViewPort vp) {
|
||
97 | 214 | fernando | FMap ret = new FMap(vp);
|
98 | 213 | fernando | ret.layers = this.layers;
|
99 | |||
100 | return ret;
|
||
101 | } |
||
102 | |||
103 | /**
|
||
104 | * Crea un nuevo FMap totalmente desligado, se replican las capas y el
|
||
105 | * ViewPort
|
||
106 | *
|
||
107 | * @return DOCUMENT ME!
|
||
108 | */
|
||
109 | public FMap cloneFMap() {
|
||
110 | return createXMLEntity(getXMLEntity());
|
||
111 | } |
||
112 | |||
113 | /**
|
||
114 | * DOCUMENT ME!
|
||
115 | *
|
||
116 | * @return DOCUMENT ME!
|
||
117 | */
|
||
118 | public XMLEntity getXMLEntity() {
|
||
119 | return new XMLEntity(); |
||
120 | } |
||
121 | |||
122 | /**
|
||
123 | * DOCUMENT ME!
|
||
124 | *
|
||
125 | * @param xe DOCUMENT ME!
|
||
126 | *
|
||
127 | * @return DOCUMENT ME!
|
||
128 | */
|
||
129 | public FMap createXMLEntity(XMLEntity xe) {
|
||
130 | // TODO Implementar bien
|
||
131 | 214 | fernando | return new FMap(null); |
132 | 213 | fernando | } |
133 | 245 | vcaballero | |
134 | 213 | fernando | /**
|
135 | * A?ade la capa que se pasa como par?metro al nodo que se pasa como
|
||
136 | * parametro y lanza ProjectionMismatchException si no est?n todas las
|
||
137 | * capas de este FMap en la misma proyecci?n. Lanza un
|
||
138 | * ChildNotAllowedException si la capa no es un FLayers y no permite hijos
|
||
139 | *
|
||
140 | * @param parent DOCUMENT ME!
|
||
141 | * @param layer DOCUMENT ME!
|
||
142 | *
|
||
143 | * @throws ProjectionMismatchException DOCUMENT ME!
|
||
144 | * @throws ChildrenNotAllowedException DOCUMENT ME!
|
||
145 | */
|
||
146 | 245 | vcaballero | /* public void addLayer(LayerPath parent, FLayer layer)
|
147 | 213 | fernando | throws ProjectionMismatchException, ChildrenNotAllowedException {
|
148 | layers.addLayer(parent, layer);
|
||
149 | }
|
||
150 | 241 | vcaballero | public void removeLayer(LayerPath parent)throws ChildrenNotAllowedException{
|
151 | layers.removeLayer(parent);
|
||
152 | }
|
||
153 | 245 | vcaballero | */
|
154 | 213 | fernando | /**
|
155 | * A?ade una capa al grupo de capas que se sit?a por encima de todas las
|
||
156 | * otras capas
|
||
157 | *
|
||
158 | * @param vectorial DOCUMENT ME!
|
||
159 | */
|
||
160 | public void addToTrackLayer(FLyrVect vectorial) { |
||
161 | } |
||
162 | 214 | fernando | |
163 | public long getScaleView() { |
||
164 | Toolkit kit = Toolkit.getDefaultToolkit(); |
||
165 | double dpi = kit.getScreenResolution();
|
||
166 | 346 | fernando | IProjection proj = viewPort.getProjection(); |
167 | 213 | fernando | |
168 | 214 | fernando | double w = ((viewPort.getImageSize().getWidth() / dpi) * 2.54); |
169 | |||
170 | if (viewPort.getAdjustedExtent() == null) { |
||
171 | return 0; |
||
172 | } |
||
173 | |||
174 | |||
175 | if (proj == null) |
||
176 | return (long) (viewPort.getAdjustedExtent().getWidth() / w * CHANGE[getViewPort() |
||
177 | .getMapUnits()]); |
||
178 | return (long) proj.getScale(viewPort.getAdjustedExtent().getMinX(), viewPort.getAdjustedExtent().getMaxX(), viewPort.getImageSize().getWidth(), dpi); |
||
179 | } |
||
180 | |||
181 | 213 | fernando | /**
|
182 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#setVectorial(com.iver.cit.gvsig.fmap.VectorialAdapter)
|
183 | 213 | fernando | */
|
184 | public void setVectorial(VectorialAdapter v) { |
||
185 | } |
||
186 | |||
187 | /**
|
||
188 | 217 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#process(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor, VectorialSubSet)
|
189 | 213 | fernando | */
|
190 | 229 | vcaballero | public void process(FeatureVisitor visitor) { |
191 | 213 | fernando | } |
192 | |||
193 | /**
|
||
194 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#processSelected(com.iver.cit.gvsig.fmap.FeatureVisitor)
|
195 | 213 | fernando | */
|
196 | public void processSelected(FeatureVisitor visitor) { |
||
197 | } |
||
198 | |||
199 | /**
|
||
200 | 217 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#select(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor, VectorialSubSet)
|
201 | 213 | fernando | */
|
202 | 229 | vcaballero | public void select(FeatureVisitor visitor) { |
203 | 213 | fernando | } |
204 | |||
205 | /**
|
||
206 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectFromSelection()
|
207 | 213 | fernando | */
|
208 | public void selectFromSelection() { |
||
209 | } |
||
210 | |||
211 | /**
|
||
212 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#createIndex()
|
213 | 213 | fernando | */
|
214 | public void createIndex() { |
||
215 | } |
||
216 | |||
217 | /**
|
||
218 | * @see org.cresques.geo.Projected#getProjection()
|
||
219 | */
|
||
220 | public IProjection getProjection() {
|
||
221 | return null; |
||
222 | } |
||
223 | |||
224 | /**
|
||
225 | * @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
|
||
226 | */
|
||
227 | public void reProject(ICoordTrans arg0) { |
||
228 | } |
||
229 | |||
230 | /**
|
||
231 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByPoint(java.awt.geom.Point2D,
|
232 | 213 | fernando | * double)
|
233 | */
|
||
234 | public void selectByPoint(Point2D p, double tolerance) { |
||
235 | } |
||
236 | |||
237 | /**
|
||
238 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByRect(java.awt.geom.Rectangle2D)
|
239 | 213 | fernando | */
|
240 | public void selectByRect(Rectangle2D rect) { |
||
241 | } |
||
242 | |||
243 | /**
|
||
244 | 305 | fjp | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByShape(com.iver.cit.gvsig.fmap.fshape.IGeometry,
|
245 | 213 | fernando | * int)
|
246 | */
|
||
247 | 305 | fjp | public void selectByShape(IGeometry g, int relationship) { |
248 | 213 | fernando | } |
249 | |||
250 | /**
|
||
251 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByPoint(java.awt.geom.Point2D,
|
252 | 213 | fernando | * double)
|
253 | */
|
||
254 | public Record[] queryByPoint(Point2D p, double tolerance) { |
||
255 | return null; |
||
256 | } |
||
257 | |||
258 | /**
|
||
259 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByRect(java.awt.geom.Rectangle2D)
|
260 | 213 | fernando | */
|
261 | public Record[] queryByRect(Rectangle2D rect) { |
||
262 | return null; |
||
263 | } |
||
264 | |||
265 | /**
|
||
266 | 305 | fjp | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByShape(com.iver.cit.gvsig.fmap.fshape.IGeometry,
|
267 | 213 | fernando | * int)
|
268 | */
|
||
269 | 305 | fjp | public Record[] queryByShape(IGeometry g, int relationship) { |
270 | 213 | fernando | return null; |
271 | } |
||
272 | |||
273 | /**
|
||
274 | 214 | fernando | * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#getSelectionBounds()
|
275 | 213 | fernando | */
|
276 | public Rectangle2D getSelectionBounds() { |
||
277 | return null; |
||
278 | } |
||
279 | |||
280 | /**
|
||
281 | * DOCUMENT ME!
|
||
282 | *
|
||
283 | * @param image DOCUMENT ME!
|
||
284 | * @param g DOCUMENT ME!
|
||
285 | * @param viewPort DOCUMENT ME!
|
||
286 | *
|
||
287 | * @throws DriverIOException
|
||
288 | *
|
||
289 | 228 | fernando | * @see com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage,
|
290 | 325 | fernando | * java.awt.Graphics2D, FStyle2D)
|
291 | 213 | fernando | */
|
292 | 244 | fernando | public void draw(BufferedImage image, Graphics2D g, Cancellable cancel) |
293 | throws DriverIOException {
|
||
294 | 349 | fjp | if (viewPort.getExtent() == null) return; |
295 | |||
296 | 244 | fernando | layers.draw(image, g, viewPort, cancel); |
297 | } |
||
298 | |||
299 | /**
|
||
300 | * DOCUMENT ME!
|
||
301 | *
|
||
302 | * @param image DOCUMENT ME!
|
||
303 | * @param g DOCUMENT ME!
|
||
304 | * @param viewPort DOCUMENT ME!
|
||
305 | *
|
||
306 | * @throws DriverIOException
|
||
307 | *
|
||
308 | * @see com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage,
|
||
309 | 325 | fernando | * java.awt.Graphics2D, FStyle2D)
|
310 | 244 | fernando | */
|
311 | 214 | fernando | public void draw(BufferedImage image, Graphics2D g) |
312 | 213 | fernando | throws DriverIOException {
|
313 | 244 | fernando | layers.draw(image, g, viewPort, new Cancellable() {
|
314 | /**
|
||
315 | * @see com.iver.cit.gvsig.fmap.operations.Cancellable#isCanceled()
|
||
316 | */
|
||
317 | public boolean isCanceled() { |
||
318 | return false; |
||
319 | } |
||
320 | }); |
||
321 | 213 | fernando | } |
322 | 244 | fernando | |
323 | 213 | fernando | /**
|
324 | * @return Returns the viewPort.
|
||
325 | */
|
||
326 | public ViewPort getViewPort() {
|
||
327 | return viewPort;
|
||
328 | } |
||
329 | /**
|
||
330 | * @param viewPort The viewPort to set.
|
||
331 | */
|
||
332 | public void setViewPort(ViewPort viewPort) { |
||
333 | this.viewPort = viewPort;
|
||
334 | } |
||
335 | 342 | fjp | |
336 | 350 | fernando | public class LayerListener implements LayerCollectionListener{ |
337 | |||
338 | /**
|
||
339 | * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdded(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
||
340 | */
|
||
341 | public void layerAdded(LayerCollectionEvent e) { |
||
342 | // Si es la primera capa, fijamos su extent al ViewPort
|
||
343 | if (getLayers().getLayerCount() == 1) |
||
344 | { |
||
345 | FLayer lyr = e.getAffectedLayer(); |
||
346 | try {
|
||
347 | getViewPort().setExtent(lyr.getFullExtent()); |
||
348 | } catch (DriverIOException e1) {
|
||
349 | } |
||
350 | 346 | fernando | } |
351 | 342 | fjp | } |
352 | |||
353 | 350 | fernando | /**
|
354 | * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerMoved(com.iver.cit.gvsig.fmap.layers.LayerPositionEvent)
|
||
355 | */
|
||
356 | public void layerMoved(LayerPositionEvent e) { |
||
357 | } |
||
358 | 342 | fjp | |
359 | 350 | fernando | /**
|
360 | * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerRemoved(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
||
361 | */
|
||
362 | public void layerRemoved(LayerCollectionEvent e) { |
||
363 | } |
||
364 | 342 | fjp | |
365 | 350 | fernando | /**
|
366 | * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdding(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
||
367 | */
|
||
368 | public void layerAdding(LayerCollectionEvent e) throws CancelationException { |
||
369 | } |
||
370 | 342 | fjp | |
371 | 350 | fernando | /**
|
372 | * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerMoving(com.iver.cit.gvsig.fmap.layers.LayerPositionEvent)
|
||
373 | */
|
||
374 | public void layerMoving(LayerPositionEvent e) throws CancelationException { |
||
375 | } |
||
376 | 342 | fjp | |
377 | 350 | fernando | /**
|
378 | * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerRemoving(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
||
379 | */
|
||
380 | public void layerRemoving(LayerCollectionEvent e) throws CancelationException { |
||
381 | } |
||
382 | |||
383 | /**
|
||
384 | * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#activationChanged(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
||
385 | */
|
||
386 | public void activationChanged(LayerCollectionEvent e) throws CancelationException { |
||
387 | } |
||
388 | |||
389 | /**
|
||
390 | * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#visibilityChanged(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
||
391 | */
|
||
392 | public void visibilityChanged(LayerCollectionEvent e) throws CancelationException { |
||
393 | } |
||
394 | 342 | fjp | |
395 | } |
||
396 | 349 | fjp | |
397 | /**
|
||
398 | * M?todo de conveniencia. Recorre las capas y te da el fullExtent
|
||
399 | * @return fullExtent de todas las capas.
|
||
400 | * @throws DriverIOException
|
||
401 | */
|
||
402 | public Rectangle2D getFullExtent() throws DriverIOException |
||
403 | { |
||
404 | return layers.getFullExtent();
|
||
405 | } |
||
406 | 213 | fernando | } |