svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / FMap.java @ 652
History | View | Annotate | Download (16.8 KB)
1 |
/* Generated by Together */
|
---|---|
2 |
package com.iver.cit.gvsig.fmap; |
3 |
|
4 |
import java.awt.Graphics2D; |
5 |
import java.awt.Toolkit; |
6 |
import java.awt.geom.Point2D; |
7 |
import java.awt.geom.Rectangle2D; |
8 |
import java.awt.image.BufferedImage; |
9 |
import java.io.File; |
10 |
import java.util.ArrayList; |
11 |
import java.util.Iterator; |
12 |
|
13 |
import org.cresques.cts.ICoordTrans; |
14 |
import org.cresques.cts.IProjection; |
15 |
import org.cresques.cts.ProjectionPool; |
16 |
import org.cresques.geo.Projected; |
17 |
|
18 |
import com.hardcode.driverManager.DriverLoadException; |
19 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
20 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
21 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
22 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
23 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
24 |
import com.iver.cit.gvsig.fmap.layers.LayerChangeSupport; |
25 |
import com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent; |
26 |
import com.iver.cit.gvsig.fmap.layers.LayerCollectionListener; |
27 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
28 |
import com.iver.cit.gvsig.fmap.layers.LayerPositionEvent; |
29 |
import com.iver.cit.gvsig.fmap.layers.LegendListener; |
30 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
31 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
32 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable; |
33 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
34 |
import com.iver.cit.gvsig.fmap.operations.QueriedPoint; |
35 |
import com.iver.cit.gvsig.fmap.operations.selection.Record; |
36 |
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor; |
37 |
import com.iver.cit.gvsig.fmap.operations.strategies.QueryByPointVisitor; |
38 |
import com.iver.cit.gvsig.fmap.operations.strategies.SelectByRectVisitor; |
39 |
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent; |
40 |
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
41 |
import com.iver.utiles.XMLEntity; |
42 |
|
43 |
|
44 |
/**
|
45 |
* DOCUMENT ME!
|
46 |
*
|
47 |
* @author Fernando Gonz?lez Cort?s
|
48 |
*/
|
49 |
public class FMap implements Projected { |
50 |
public static final double[] CHANGEM = { |
51 |
1000, 1, 0.01, 0.001, 1609.344, 0.9144, 0.3048, 0.0254 |
52 |
}; |
53 |
|
54 |
/** DOCUMENT ME! */
|
55 |
public static final double[] CHANGE = { |
56 |
100000, 100, 1, 0.1, 160934.4, 91.44, 30.48, 2.54 |
57 |
}; |
58 |
public static final int EQUALS = 0; |
59 |
public static final int DISJOINT = 1; |
60 |
public static final int INTERSECTS = 2; |
61 |
public static final int TOUCHES = 3; |
62 |
public static final int CROSSES = 4; |
63 |
public static final int WITHIN = 5; |
64 |
public static final int CONTAINS = 6; |
65 |
public static final int OVERLAPS = 7; |
66 |
private FLayers layers = new FLayers(); |
67 |
private ViewPort viewPort;
|
68 |
private ArrayList invalidationListeners = new ArrayList(); |
69 |
private LayerChangeSupport layerChangeSupport = new LayerChangeSupport(); |
70 |
private LegendChanges legendChanges = new LegendChanges(); |
71 |
|
72 |
/**
|
73 |
* Crea un nuevo FMap.
|
74 |
*
|
75 |
* @param vp DOCUMENT ME!
|
76 |
*/
|
77 |
public FMap(ViewPort vp) {
|
78 |
this.viewPort = vp;
|
79 |
layers.addLayerCollectionListener(new LayerEventListener());
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* DOCUMENT ME!
|
84 |
*
|
85 |
* @param listener DOCUMENT ME!
|
86 |
*/
|
87 |
public void addLayerListener(LegendListener listener) { |
88 |
layerChangeSupport.addLayerListener(listener); |
89 |
} |
90 |
|
91 |
/**
|
92 |
* DOCUMENT ME!
|
93 |
*
|
94 |
* @param e DOCUMENT ME!
|
95 |
*/
|
96 |
public void callLegendChanged(LegendChangedEvent e) { |
97 |
layerChangeSupport.callLegendChanged(e); |
98 |
} |
99 |
|
100 |
/**
|
101 |
* DOCUMENT ME!
|
102 |
*
|
103 |
* @param listener DOCUMENT ME!
|
104 |
*/
|
105 |
public void removeLayerListener(LegendListener listener) { |
106 |
layerChangeSupport.removeLayerListener(listener); |
107 |
} |
108 |
|
109 |
/**
|
110 |
* DOCUMENT ME!
|
111 |
*
|
112 |
* @return DOCUMENT ME!
|
113 |
*/
|
114 |
public FLayers getLayers() {
|
115 |
return layers;
|
116 |
} |
117 |
|
118 |
/**
|
119 |
* Dibuja en la imagen que se pasa como par?metro el contenido de las capas
|
120 |
* visibles del mapa y teniendo en cuenta los datos del ViewPort contenido
|
121 |
* en este FMap
|
122 |
*
|
123 |
* @param b DOCUMENT ME!
|
124 |
*/
|
125 |
public void drawLabels(BufferedImage b) { |
126 |
} |
127 |
|
128 |
/**
|
129 |
* DOCUMENT ME!
|
130 |
*
|
131 |
* @param g DOCUMENT ME!
|
132 |
*
|
133 |
* @throws DriverIOException
|
134 |
* @throws DriverLoadException
|
135 |
* @throws DriverException
|
136 |
*/
|
137 |
public void print(Graphics2D g) |
138 |
throws DriverException {
|
139 |
///draw(null, g);
|
140 |
layers.print(g, viewPort, |
141 |
new Cancellable() {
|
142 |
/**
|
143 |
* @see com.iver.cit.gvsig.fmap.operations.Cancellable#isCanceled()
|
144 |
*/
|
145 |
public boolean isCanceled() { |
146 |
return false; |
147 |
} |
148 |
}); |
149 |
} |
150 |
|
151 |
/**
|
152 |
* Crea un nuevo FMap con la informaci?n del ViewPort que se pasa como
|
153 |
* par?metro.
|
154 |
*
|
155 |
* @param vp DOCUMENT ME!
|
156 |
*
|
157 |
* @return DOCUMENT ME!
|
158 |
*/
|
159 |
public FMap createNewFMap(ViewPort vp) {
|
160 |
FMap ret = new FMap(vp);
|
161 |
ret.layers = this.layers;
|
162 |
|
163 |
return ret;
|
164 |
} |
165 |
|
166 |
/**
|
167 |
* Crea un nuevo FMap totalmente desligado, se replican las capas y el
|
168 |
* ViewPort
|
169 |
*
|
170 |
* @return DOCUMENT ME!
|
171 |
* @throws DriverException
|
172 |
*/
|
173 |
public FMap cloneFMap() throws DriverException { |
174 |
return createXMLEntity(getXMLEntity());
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* DOCUMENT ME!
|
179 |
*
|
180 |
* @param xe DOCUMENT ME!
|
181 |
*
|
182 |
* @return DOCUMENT ME!
|
183 |
*/
|
184 |
public FMap createXMLEntity(XMLEntity xe) {
|
185 |
// TODO Implementar bien
|
186 |
return new FMap(null); |
187 |
} |
188 |
|
189 |
/**
|
190 |
* A?ade la capa que se pasa como par?metro al nodo que se pasa como
|
191 |
* parametro y lanza ProjectionMismatchException si no est?n todas las
|
192 |
* capas de este FMap en la misma proyecci?n. Lanza un
|
193 |
* ChildNotAllowedException si la capa no es un FLayers y no permite hijos
|
194 |
*
|
195 |
* @param vectorial DOCUMENT ME!
|
196 |
*/
|
197 |
|
198 |
/* public void addLayer(LayerPath parent, FLayer layer)
|
199 |
throws ProjectionMismatchException, ChildrenNotAllowedException {
|
200 |
layers.addLayer(parent, layer);
|
201 |
}
|
202 |
public void removeLayer(LayerPath parent)throws ChildrenNotAllowedException{
|
203 |
layers.removeLayer(parent);
|
204 |
}
|
205 |
*/
|
206 |
|
207 |
/**
|
208 |
* A?ade una capa al grupo de capas que se sit?a por encima de todas las
|
209 |
* otras capas
|
210 |
*
|
211 |
* @param vectorial DOCUMENT ME!
|
212 |
*/
|
213 |
public void addToTrackLayer(FLayer vectorial) { |
214 |
} |
215 |
|
216 |
/**
|
217 |
* DOCUMENT ME!
|
218 |
*
|
219 |
* @return DOCUMENT ME!
|
220 |
*/
|
221 |
public long getScaleView() { |
222 |
Toolkit kit = Toolkit.getDefaultToolkit(); |
223 |
double dpi = kit.getScreenResolution();
|
224 |
IProjection proj = viewPort.getProjection(); |
225 |
|
226 |
double w = ((viewPort.getImageSize().getWidth() / dpi) * 2.54); |
227 |
|
228 |
if (viewPort.getAdjustedExtent() == null) { |
229 |
return 0; |
230 |
} |
231 |
|
232 |
if (proj == null) { |
233 |
return (long) (viewPort.getAdjustedExtent().getWidth() / w * CHANGE[getViewPort() |
234 |
.getMapUnits()]); |
235 |
} |
236 |
|
237 |
return (long) proj.getScale(viewPort.getAdjustedExtent().getMinX(), |
238 |
viewPort.getAdjustedExtent().getMaxX(), |
239 |
viewPort.getImageSize().getWidth(), dpi); |
240 |
} |
241 |
|
242 |
/**
|
243 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#setVectorial(com.iver.cit.gvsig.fmap.VectorialAdapter)
|
244 |
*/
|
245 |
public void setVectorial(VectorialAdapter v) { |
246 |
} |
247 |
|
248 |
/**
|
249 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#process(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor,
|
250 |
* VectorialSubSet)
|
251 |
*/
|
252 |
public void process(FeatureVisitor visitor) { |
253 |
} |
254 |
|
255 |
/**
|
256 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#processSelected(com.iver.cit.gvsig.fmap.FeatureVisitor)
|
257 |
*/
|
258 |
public void processSelected(FeatureVisitor visitor) { |
259 |
} |
260 |
|
261 |
/**
|
262 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#select(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor,
|
263 |
* VectorialSubSet)
|
264 |
*/
|
265 |
public void select(FeatureVisitor visitor) { |
266 |
} |
267 |
|
268 |
/**
|
269 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectFromSelection()
|
270 |
*/
|
271 |
public void selectFromSelection() { |
272 |
} |
273 |
|
274 |
/**
|
275 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#createIndex()
|
276 |
*/
|
277 |
public void createIndex() { |
278 |
} |
279 |
|
280 |
/**
|
281 |
* @see org.cresques.geo.Projected#getProjection()
|
282 |
*/
|
283 |
public IProjection getProjection() {
|
284 |
return null; |
285 |
} |
286 |
|
287 |
/**
|
288 |
* @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
|
289 |
*/
|
290 |
public void reProject(ICoordTrans arg0) { |
291 |
} |
292 |
|
293 |
/**
|
294 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByPoint(java.awt.geom.Point2D,
|
295 |
* double)
|
296 |
*/
|
297 |
public void selectByPoint(Point2D p, double tolerance) |
298 |
throws DriverException {
|
299 |
QueriedPoint qp = new QueriedPoint(p.getX(), p.getY());
|
300 |
Point2D mapPoint = viewPort.toMapPoint((int) p.getX(), (int) p.getY()); |
301 |
qp.setRealCoords(mapPoint.getX(), mapPoint.getY()); |
302 |
QueryByPointVisitor visitor = new QueryByPointVisitor();
|
303 |
visitor.setQueriedPoint(qp); |
304 |
layers.process(visitor); |
305 |
fireInvalidEvent(); |
306 |
} |
307 |
|
308 |
/**
|
309 |
* DOCUMENT ME!
|
310 |
*
|
311 |
* @param rect DOCUMENT ME!
|
312 |
*
|
313 |
* @throws DriverIOException
|
314 |
*
|
315 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByRect(java.awt.geom.Rectangle2D)
|
316 |
*/
|
317 |
public void selectByRect(Rectangle2D rect) throws DriverException { |
318 |
SelectByRectVisitor visitor = new SelectByRectVisitor();
|
319 |
visitor.setRect(rect); |
320 |
layers.process(visitor); |
321 |
fireInvalidEvent(); |
322 |
} |
323 |
|
324 |
/**
|
325 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByShape(com.iver.cit.gvsig.fmap.fshape.IGeometry,
|
326 |
* int)
|
327 |
*/
|
328 |
public void selectByShape(IGeometry g, int relationship) { |
329 |
} |
330 |
|
331 |
/**
|
332 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByPoint(java.awt.geom.Point2D,
|
333 |
* double)
|
334 |
*/
|
335 |
public Record[] queryByPoint(Point2D p, double tolerance) { |
336 |
return null; |
337 |
} |
338 |
|
339 |
/**
|
340 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByRect(java.awt.geom.Rectangle2D)
|
341 |
*/
|
342 |
public Record[] queryByRect(Rectangle2D rect) { |
343 |
return null; |
344 |
} |
345 |
|
346 |
/**
|
347 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByShape(com.iver.cit.gvsig.fmap.fshape.IGeometry,
|
348 |
* int)
|
349 |
*/
|
350 |
public Record[] queryByShape(IGeometry g, int relationship) { |
351 |
return null; |
352 |
} |
353 |
|
354 |
/**
|
355 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#getSelectionBounds()
|
356 |
*/
|
357 |
public Rectangle2D getSelectionBounds() { |
358 |
return null; |
359 |
} |
360 |
|
361 |
/**
|
362 |
* DOCUMENT ME!
|
363 |
*
|
364 |
* @param image DOCUMENT ME!
|
365 |
* @param g DOCUMENT ME!
|
366 |
* @param cancel DOCUMENT ME!
|
367 |
*
|
368 |
* @throws DriverIOException
|
369 |
* @throws DriverLoadException
|
370 |
* @throws DriverException
|
371 |
*
|
372 |
* @see com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage,
|
373 |
* java.awt.Graphics2D, FStyle2D)
|
374 |
*/
|
375 |
public void draw(BufferedImage image, Graphics2D g, Cancellable cancel) |
376 |
throws DriverException {
|
377 |
if (viewPort.getExtent() == null) { |
378 |
return;
|
379 |
} |
380 |
|
381 |
layers.draw(image, g, viewPort, cancel); |
382 |
} |
383 |
|
384 |
/**
|
385 |
* DOCUMENT ME!
|
386 |
*
|
387 |
* @param image DOCUMENT ME!
|
388 |
* @param g DOCUMENT ME!
|
389 |
*
|
390 |
* @throws DriverIOException
|
391 |
* @throws DriverLoadException
|
392 |
* @throws DriverException
|
393 |
*
|
394 |
* @see com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage,
|
395 |
* java.awt.Graphics2D, FStyle2D)
|
396 |
*/
|
397 |
public void draw(BufferedImage image, Graphics2D g) |
398 |
throws DriverException {
|
399 |
layers.draw(image, g, viewPort, |
400 |
new Cancellable() {
|
401 |
/**
|
402 |
* @see com.iver.cit.gvsig.fmap.operations.Cancellable#isCanceled()
|
403 |
*/
|
404 |
public boolean isCanceled() { |
405 |
return false; |
406 |
} |
407 |
}); |
408 |
} |
409 |
|
410 |
/**
|
411 |
* DOCUMENT ME!
|
412 |
*
|
413 |
* @return Returns the viewPort.
|
414 |
*/
|
415 |
public ViewPort getViewPort() {
|
416 |
return viewPort;
|
417 |
} |
418 |
|
419 |
/**
|
420 |
* DOCUMENT ME!
|
421 |
*
|
422 |
* @param viewPort The viewPort to set.
|
423 |
*/
|
424 |
public void setViewPort(ViewPort viewPort) { |
425 |
this.viewPort = viewPort;
|
426 |
} |
427 |
|
428 |
/**
|
429 |
* M?todo de conveniencia. Recorre las capas y te da el fullExtent
|
430 |
*
|
431 |
* @return fullExtent de todas las capas.
|
432 |
*
|
433 |
* @throws DriverIOException
|
434 |
*/
|
435 |
public Rectangle2D getFullExtent() throws DriverException { |
436 |
return layers.getFullExtent();
|
437 |
} |
438 |
|
439 |
/**
|
440 |
* DOCUMENT ME!
|
441 |
*
|
442 |
* @return DOCUMENT ME!
|
443 |
* @throws DriverException
|
444 |
*/
|
445 |
public XMLEntity getXMLEntity() {
|
446 |
XMLEntity xml = new XMLEntity();
|
447 |
xml.addChild(viewPort.getXMLEntity()); |
448 |
xml.putProperty("numLayers", layers.getLayersCount());
|
449 |
String[] s=new String[layers.getLayersCount()]; |
450 |
for (int i=0;i<layers.getLayersCount();i++){ |
451 |
s[i]=layers.getLayer(i).getName(); |
452 |
} |
453 |
xml.putProperty("LayerNames",s);
|
454 |
xml.addChild(layers.getXMLEntity()); |
455 |
|
456 |
return xml;
|
457 |
} |
458 |
|
459 |
/**
|
460 |
* DOCUMENT ME!
|
461 |
*
|
462 |
* @param xml DOCUMENT ME!
|
463 |
*
|
464 |
* @return DOCUMENT ME!
|
465 |
*
|
466 |
* @throws XMLException DOCUMENT ME!
|
467 |
*/
|
468 |
public static FMap createFromXML(XMLEntity xml) |
469 |
throws XMLException, DriverException {
|
470 |
ViewPort vp = ViewPort.createFromXML(xml.getChild(0));
|
471 |
FMap fmap = new FMap(vp);
|
472 |
|
473 |
///fmap.layers=(FLayers)FLayers.createFromXML(xml.getChild(1));
|
474 |
int numLayers = xml.getIntProperty("numLayers"); |
475 |
|
476 |
for (int i = 0; i < numLayers; i++) { |
477 |
IProjection proj = null;
|
478 |
|
479 |
if (xml.getChild(0).getStringProperty("proj") != null) { |
480 |
proj = ProjectionPool.get(xml.getChild(0).getStringProperty("proj")); |
481 |
} |
482 |
|
483 |
FLayer layer = null;
|
484 |
String[] s=xml.getStringArrayProperty("LayerNames"); |
485 |
if (xml.getChild(1).getChild(i).getStringProperty("file") != null) { |
486 |
// TODO cambiar el "nombre" por el nombre de la capa
|
487 |
layer = LayerFactory.createLayer(s[i], xml.getChild(1).getChild(i)
|
488 |
.getStringProperty("driverName"),
|
489 |
new File(xml.getChild(1).getChild(i) |
490 |
.getStringProperty("file")), proj);
|
491 |
} else if (true) { |
492 |
} else if (true) { |
493 |
} |
494 |
|
495 |
layer.setXMLEntity(xml.getChild(1).getChild(i));
|
496 |
|
497 |
fmap.getLayers().addLayer(layer); |
498 |
} |
499 |
|
500 |
return fmap;
|
501 |
} |
502 |
|
503 |
/**
|
504 |
* DOCUMENT ME!
|
505 |
*/
|
506 |
public void fireLegendEvent() { |
507 |
LegendChangedEvent e = legendChanges.getEvent(); |
508 |
|
509 |
if (e.getEvents().length == 0) { |
510 |
return;
|
511 |
} |
512 |
|
513 |
layerChangeSupport.callLegendChanged(e); |
514 |
legendChanges.clear(); |
515 |
} |
516 |
|
517 |
/**
|
518 |
* Invoca el evento invalid de todos los listeners de este FMap
|
519 |
*/
|
520 |
public void fireInvalidEvent() { |
521 |
for (Iterator iter = invalidationListeners.iterator(); iter.hasNext();) { |
522 |
InvalidationListener listener = (InvalidationListener) iter.next(); |
523 |
|
524 |
listener.invalid(); |
525 |
} |
526 |
} |
527 |
|
528 |
/**
|
529 |
* DOCUMENT ME!
|
530 |
*
|
531 |
* @param listener DOCUMENT ME!
|
532 |
*
|
533 |
* @return DOCUMENT ME!
|
534 |
*/
|
535 |
public boolean addInvalidationListener(InvalidationListener listener) { |
536 |
return invalidationListeners.add(listener);
|
537 |
} |
538 |
|
539 |
/**
|
540 |
* DOCUMENT ME!
|
541 |
*
|
542 |
* @param listener DOCUMENT ME!
|
543 |
*
|
544 |
* @return DOCUMENT ME!
|
545 |
*/
|
546 |
public boolean removeInvalidationListener(InvalidationListener listener) { |
547 |
return invalidationListeners.remove(listener);
|
548 |
} |
549 |
|
550 |
/**
|
551 |
* DOCUMENT ME!
|
552 |
*
|
553 |
* @author Fernando Gonz?lez Cort?s
|
554 |
*/
|
555 |
public class LegendChanges implements LegendListener { |
556 |
private ArrayList events = new ArrayList(); |
557 |
|
558 |
/**
|
559 |
* DOCUMENT ME!
|
560 |
*
|
561 |
* @return DOCUMENT ME!
|
562 |
*/
|
563 |
public LegendChangedEvent getEvent() {
|
564 |
LegendChangedEvent e = new LegendChangedEvent();
|
565 |
e.setEvents((LegendChangedEvent[]) events.toArray(
|
566 |
new LegendChangedEvent[0])); |
567 |
|
568 |
return e;
|
569 |
} |
570 |
|
571 |
/**
|
572 |
* @see com.iver.cit.gvsig.fmap.layers.LegendListener#legendChanged(com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent)
|
573 |
*/
|
574 |
public void legendChanged(LegendChangedEvent e) { |
575 |
events.add(e); |
576 |
} |
577 |
|
578 |
/**
|
579 |
* DOCUMENT ME!
|
580 |
*/
|
581 |
public void clear() { |
582 |
events.clear(); |
583 |
} |
584 |
} |
585 |
|
586 |
/**
|
587 |
* DOCUMENT ME!
|
588 |
*
|
589 |
* @author Fernando Gonz?lez Cort?s
|
590 |
*/
|
591 |
public class LayerEventListener implements LayerCollectionListener { |
592 |
/**
|
593 |
* @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdded(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
594 |
*/
|
595 |
public void layerAdded(LayerCollectionEvent e) { |
596 |
// Si es la primera capa, fijamos su extent al ViewPort
|
597 |
if (getLayers().getLayersCount() == 1) { |
598 |
FLayer lyr = e.getAffectedLayer(); |
599 |
|
600 |
try {
|
601 |
getViewPort().setExtent(lyr.getFullExtent()); |
602 |
} catch (DriverException e1) {
|
603 |
} |
604 |
} |
605 |
|
606 |
//Registramos al FMap como listener del legend de las capas
|
607 |
FLayer lyr = e.getAffectedLayer(); |
608 |
|
609 |
if (lyr instanceof Classifiable) { |
610 |
Classifiable c = (Classifiable) lyr; |
611 |
c.addLegendListener(legendChanges); |
612 |
} |
613 |
} |
614 |
|
615 |
/**
|
616 |
* @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerMoved(com.iver.cit.gvsig.fmap.layers.LayerPositionEvent)
|
617 |
*/
|
618 |
public void layerMoved(LayerPositionEvent e) { |
619 |
} |
620 |
|
621 |
/**
|
622 |
* @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerRemoved(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
623 |
*/
|
624 |
public void layerRemoved(LayerCollectionEvent e) { |
625 |
FLayer lyr = e.getAffectedLayer(); |
626 |
|
627 |
if (lyr instanceof Classifiable) { |
628 |
Classifiable c = (Classifiable) lyr; |
629 |
c.removeLegendListener(legendChanges); |
630 |
} |
631 |
} |
632 |
|
633 |
/**
|
634 |
* @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdding(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
635 |
*/
|
636 |
public void layerAdding(LayerCollectionEvent e) |
637 |
throws CancelationException {
|
638 |
} |
639 |
|
640 |
/**
|
641 |
* @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerMoving(com.iver.cit.gvsig.fmap.layers.LayerPositionEvent)
|
642 |
*/
|
643 |
public void layerMoving(LayerPositionEvent e) |
644 |
throws CancelationException {
|
645 |
} |
646 |
|
647 |
/**
|
648 |
* @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerRemoving(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
649 |
*/
|
650 |
public void layerRemoving(LayerCollectionEvent e) |
651 |
throws CancelationException {
|
652 |
} |
653 |
|
654 |
/**
|
655 |
* @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#activationChanged(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
656 |
*/
|
657 |
public void activationChanged(LayerCollectionEvent e) |
658 |
throws CancelationException {
|
659 |
} |
660 |
|
661 |
/**
|
662 |
* @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#visibilityChanged(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
|
663 |
*/
|
664 |
public void visibilityChanged(LayerCollectionEvent e) |
665 |
throws CancelationException {
|
666 |
} |
667 |
} |
668 |
} |