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