root / tags / v1_0_2_Build_903+3D / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayers.java @ 10722
History | View | Annotate | Download (42.5 KB)
1 | 1100 | fjp | /* 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 | 214 | fernando | package com.iver.cit.gvsig.fmap.layers; |
42 | |||
43 | 2608 | caballero | import java.awt.Graphics2D; |
44 | 4928 | ldiaz | import java.awt.Point; |
45 | 2608 | caballero | import java.awt.geom.Rectangle2D; |
46 | import java.awt.image.BufferedImage; |
||
47 | 5923 | fjp | import java.awt.image.WritableRaster; |
48 | 2608 | caballero | import java.io.File; |
49 | import java.util.ArrayList; |
||
50 | 2857 | jaume | import java.util.Collections; |
51 | 2608 | caballero | import java.util.Iterator; |
52 | 2981 | fjp | import java.util.List; |
53 | 5057 | ldiaz | import java.util.Vector; |
54 | 2608 | caballero | |
55 | 9013 | caballero | import javax.print.attribute.PrintRequestAttributeSet; |
56 | 5761 | jmvivo | import javax.swing.ImageIcon; |
57 | |||
58 | 3481 | caballero | import org.apache.log4j.Logger; |
59 | 2608 | caballero | import org.cresques.cts.ICoordTrans; |
60 | import org.cresques.cts.IProjection; |
||
61 | |||
62 | 1828 | fernando | import com.hardcode.driverManager.Driver; |
63 | import com.hardcode.driverManager.DriverLoadException; |
||
64 | 651 | fernando | import com.iver.cit.gvsig.fmap.DriverException; |
65 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
66 | 5761 | jmvivo | import com.iver.cit.gvsig.fmap.MapControl; |
67 | 562 | fernando | import com.iver.cit.gvsig.fmap.ViewPort; |
68 | 6164 | luisw2 | import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
69 | 3462 | caballero | import com.iver.cit.gvsig.fmap.drivers.DefaultDBDriver; |
70 | 1453 | luisw | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
71 | 2778 | fjp | import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
72 | 3301 | fjp | import com.iver.cit.gvsig.fmap.drivers.VectorialDriver; |
73 | 1828 | fernando | import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
74 | 4928 | ldiaz | import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint; |
75 | 562 | fernando | import com.iver.cit.gvsig.fmap.layers.layerOperations.LayerCollection; |
76 | import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData; |
||
77 | 5200 | ldiaz | import com.iver.cit.gvsig.fmap.layers.layerOperations.XMLItem; |
78 | 562 | fernando | import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor; |
79 | 926 | fernando | import com.iver.cit.gvsig.fmap.operations.strategies.VisitException; |
80 | 2659 | fjp | import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
81 | 3301 | fjp | import com.iver.utiles.IPersistance; |
82 | 562 | fernando | import com.iver.utiles.XMLEntity; |
83 | 6762 | jmvivo | import com.iver.utiles.extensionPoints.ExtensionPoint; |
84 | import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
||
85 | 5317 | fjp | import com.iver.utiles.swing.threads.Cancellable; |
86 | 541 | vcaballero | |
87 | 214 | fernando | /**
|
88 | * Representa un nodo interno en el ?rbol de capas
|
||
89 | */
|
||
90 | 4928 | ldiaz | public class FLayers extends FLyrDefault implements VectorialData, LayerCollection, InfoByPoint |
91 | { |
||
92 | 524 | vcaballero | //ArrayList de Listener registrados.
|
93 | 8765 | jjdelcerro | protected ArrayList layerCollectionListeners = new ArrayList(); |
94 | 3963 | caballero | |
95 | |||
96 | 8765 | jjdelcerro | protected List layers = Collections.synchronizedList(new ArrayList()); |
97 | protected MapContext fmap;
|
||
98 | protected static Logger logger = Logger.getLogger(FLayers.class.getName()); |
||
99 | 524 | vcaballero | /**
|
100 | * Crea un nuevo FLayers.
|
||
101 | 1005 | vcaballero | *
|
102 | * @param fmap
|
||
103 | * @param parent
|
||
104 | 524 | vcaballero | */
|
105 | 6878 | cesar | public FLayers(MapContext fmap, FLayers parent) {
|
106 | 694 | fernando | setParentLayer(parent); |
107 | this.fmap = fmap;
|
||
108 | 524 | vcaballero | } |
109 | 257 | vcaballero | |
110 | 524 | vcaballero | /**
|
111 | * A?ade un listener de los eventos de la colecci?n de capas
|
||
112 | *
|
||
113 | 1005 | vcaballero | * @param listener
|
114 | 524 | vcaballero | */
|
115 | public void addLayerCollectionListener(LayerCollectionListener listener) { |
||
116 | 5228 | caballero | if (!layerCollectionListeners.contains(listener))
|
117 | layerCollectionListeners.add(listener); |
||
118 | 524 | vcaballero | } |
119 | 1005 | vcaballero | |
120 | 3772 | fjp | |
121 | 1005 | vcaballero | /**
|
122 | * @see com.iver.cit.gvsig.fmap.layers.layerOperations.LayerCollection#setAllVisibles(boolean)
|
||
123 | */
|
||
124 | public void setAllVisibles(boolean visible) { |
||
125 | 708 | fernando | FLayer lyr; |
126 | 214 | fernando | |
127 | 524 | vcaballero | for (int i = 0; i < layers.size(); i++) { |
128 | lyr = ((FLayer) layers.get(i)); |
||
129 | 708 | fernando | lyr.setVisible(visible); |
130 | 1005 | vcaballero | |
131 | if (lyr instanceof LayerCollection) { |
||
132 | 708 | fernando | ((LayerCollection) lyr).setAllVisibles(visible); |
133 | } |
||
134 | 524 | vcaballero | } |
135 | } |
||
136 | 346 | fernando | |
137 | 524 | vcaballero | /**
|
138 | 1005 | vcaballero | * Elimina un listener de los eventos de la colecci?n de capas
|
139 | 524 | vcaballero | *
|
140 | 1005 | vcaballero | * @param listener
|
141 | 524 | vcaballero | */
|
142 | public void removeLayerCollectionListener(LayerCollectionListener listener) { |
||
143 | 3772 | fjp | layerCollectionListeners.remove(listener); |
144 | 524 | vcaballero | } |
145 | 214 | fernando | |
146 | 524 | vcaballero | /**
|
147 | 1005 | vcaballero | * A?ade una capa.
|
148 | 524 | vcaballero | *
|
149 | 1005 | vcaballero | * @param layer
|
150 | 524 | vcaballero | */
|
151 | 6556 | caballero | // private void doAddLayer(FLayer layer) {
|
152 | // layers.add(layer);
|
||
153 | // layer.setParentLayer(this);
|
||
154 | // }
|
||
155 | private void doAddLayer(int pos,FLayer layer) { |
||
156 | layers.add(pos,layer); |
||
157 | 694 | fernando | layer.setParentLayer(this);
|
158 | 524 | vcaballero | } |
159 | 6556 | caballero | public void addLayer(FLayer layer) { |
160 | addLayer(layers.size(),layer); |
||
161 | } |
||
162 | 524 | vcaballero | /**
|
163 | 10401 | fjp | * A?ade una capa en la posici?n pos de la lista de subcapas
|
164 | 524 | vcaballero | *
|
165 | 1005 | vcaballero | * @param layer
|
166 | 524 | vcaballero | *
|
167 | * @throws CancelationException
|
||
168 | */
|
||
169 | 6556 | caballero | public void addLayer(int pos,FLayer layer) throws CancelationException { |
170 | 4376 | nacho | //Notificamos a la capa que va a ser a?adida
|
171 | 6762 | jmvivo | //FLyrDefault layerDef = (FLyrDefault)layer;
|
172 | 6537 | jmvivo | //if (!layerDef.isUnavailable()) {
|
173 | 6400 | jmvivo | if (layer instanceof FLyrDefault) |
174 | ((FLyrDefault)layer).wakeUp(); |
||
175 | 6480 | jaume | |
176 | 6400 | jmvivo | if (layer instanceof FLayers){ |
177 | FLayers layers=(FLayers)layer; |
||
178 | fmap.addAsCollectionListener(layers); |
||
179 | } |
||
180 | callLayerAdding(LayerCollectionEvent.createLayerAddingEvent(layer)); |
||
181 | 6537 | jmvivo | //}
|
182 | 214 | fernando | |
183 | 6556 | caballero | doAddLayer(pos,layer); |
184 | 404 | fjp | |
185 | 6537 | jmvivo | //if (!layerDef.isUnavailable()) {
|
186 | 6400 | jmvivo | callLayerAdded(LayerCollectionEvent.createLayerAddedEvent(layer)); |
187 | 6537 | jmvivo | //}
|
188 | 524 | vcaballero | } |
189 | 404 | fjp | |
190 | 524 | vcaballero | /**
|
191 | * Mueve una capa de la posici?n from a la posici?n to. (Se supone que
|
||
192 | * est?n dentro del mismo nivel). Para mover entre niveles, usar otro
|
||
193 | * m?todo (por hacer)
|
||
194 | *
|
||
195 | 1005 | vcaballero | * @param from origen.
|
196 | * @param to destino.
|
||
197 | 524 | vcaballero | *
|
198 | * @throws CancelationException
|
||
199 | */
|
||
200 | public void moveTo(int from, int to) throws CancelationException { |
||
201 | 2356 | vcaballero | int newfrom=layers.size()-from-1; |
202 | int newto=layers.size()-to-1; |
||
203 | 6466 | jmvivo | if ( newfrom < 0 || newfrom >=layers.size() || newto < 0 || newto >= layers.size()) return; |
204 | 2356 | vcaballero | FLayer aux = (FLayer) layers.get(newfrom); |
205 | callLayerMoving(LayerPositionEvent.createLayerMovingEvent(aux, newfrom, newto)); |
||
206 | layers.remove(newfrom); |
||
207 | layers.add(newto, aux); |
||
208 | callLayerMoved(LayerPositionEvent.createLayerMovedEvent(aux, newfrom, newto)); |
||
209 | 524 | vcaballero | } |
210 | 257 | vcaballero | |
211 | 524 | vcaballero | /**
|
212 | 1005 | vcaballero | * Borra una capa del ArrayList que contiene a las capas.
|
213 | 524 | vcaballero | *
|
214 | 1005 | vcaballero | * @param lyr FLayer.
|
215 | 524 | vcaballero | */
|
216 | private void doRemoveLayer(FLayer lyr) { |
||
217 | 2198 | vcaballero | layers.remove(lyr); |
218 | 524 | vcaballero | } |
219 | 214 | fernando | |
220 | 524 | vcaballero | /**
|
221 | 1005 | vcaballero | * Borra una capa de la colecci?n de capas.
|
222 | 524 | vcaballero | *
|
223 | 1005 | vcaballero | * @param lyr FLayer
|
224 | 524 | vcaballero | *
|
225 | 1005 | vcaballero | * @throws CancelationException
|
226 | 524 | vcaballero | */
|
227 | public void removeLayer(FLayer lyr) throws CancelationException { |
||
228 | 1081 | fernando | callLayerRemoving(LayerCollectionEvent.createLayerRemovingEvent(lyr)); |
229 | 524 | vcaballero | doRemoveLayer(lyr); |
230 | 1081 | fernando | callLayerRemoved(LayerCollectionEvent.createLayerRemovedEvent(lyr)); |
231 | 524 | vcaballero | } |
232 | 214 | fernando | |
233 | 524 | vcaballero | /**
|
234 | * Borra una FLayer del vector a partir del identificador.
|
||
235 | *
|
||
236 | * @param idLayer
|
||
237 | */
|
||
238 | public void removeLayer(int idLayer) { |
||
239 | 1081 | fernando | FLayer lyr = (FLayer) layers.get(idLayer); |
240 | callLayerRemoving(LayerCollectionEvent.createLayerRemovingEvent(lyr)); |
||
241 | 524 | vcaballero | layers.remove(idLayer); |
242 | 1081 | fernando | callLayerRemoved(LayerCollectionEvent.createLayerRemovedEvent(lyr)); |
243 | 524 | vcaballero | } |
244 | 257 | vcaballero | |
245 | 524 | vcaballero | /**
|
246 | * M?todo de conveniencia para borrar una capa con ese nombre
|
||
247 | *
|
||
248 | * @param layerName
|
||
249 | */
|
||
250 | public void removeLayer(String layerName) { |
||
251 | FLayer lyr; |
||
252 | 214 | fernando | |
253 | 524 | vcaballero | for (int i = 0; i < layers.size(); i++) { |
254 | lyr = ((FLayer) layers.get(i)); |
||
255 | 402 | fjp | |
256 | 524 | vcaballero | if (lyr.getName().compareToIgnoreCase(layerName) == 0) { |
257 | 1081 | fernando | removeLayer(i); |
258 | 214 | fernando | |
259 | 524 | vcaballero | break;
|
260 | } |
||
261 | } |
||
262 | } |
||
263 | 4945 | ldiaz | /**
|
264 | * M?todo de conveniencia para reemplazar una capa con ese nombre
|
||
265 | *
|
||
266 | * @param layerName
|
||
267 | */
|
||
268 | public void replaceLayer(String layerName, FLayer layer) |
||
269 | { |
||
270 | FLayer lyr; |
||
271 | 5021 | ldiaz | FLayer parent; |
272 | 4945 | ldiaz | for (int i = 0; i < layers.size(); i++) { |
273 | lyr = ((FLayer) layers.get(i)); |
||
274 | 214 | fernando | |
275 | 4945 | ldiaz | if (lyr.getName().compareToIgnoreCase(layerName) == 0) { |
276 | 5228 | caballero | parent = lyr.getParentLayer(); |
277 | 4945 | ldiaz | removeLayer(i); |
278 | 5021 | ldiaz | if (parent != null) |
279 | 4968 | ldiaz | //Notificamos a la capa que va a ser a?adida
|
280 | if (layer instanceof FLyrDefault) |
||
281 | ((FLyrDefault)layer).wakeUp(); |
||
282 | 5228 | caballero | |
283 | 4968 | ldiaz | if (layer instanceof FLayers){ |
284 | FLayers layers=(FLayers)layer; |
||
285 | fmap.addAsCollectionListener(layers); |
||
286 | } |
||
287 | callLayerAdding(LayerCollectionEvent.createLayerAddingEvent(layer)); |
||
288 | |||
289 | 4945 | ldiaz | layers.add(i,layer); |
290 | 4968 | ldiaz | layer.setParentLayer(this);
|
291 | |||
292 | callLayerAdded(LayerCollectionEvent.createLayerAddedEvent(layer)); |
||
293 | 4945 | ldiaz | break;
|
294 | } |
||
295 | } |
||
296 | } |
||
297 | |||
298 | 5228 | caballero | |
299 | 524 | vcaballero | /**
|
300 | * Obtiene el array de capas visibles que penden del arbol cuya ra?z es
|
||
301 | * este nodo
|
||
302 | *
|
||
303 | 1005 | vcaballero | * @return Vector de FLayer.
|
304 | 524 | vcaballero | */
|
305 | public FLayer[] getVisibles() { |
||
306 | ArrayList array = new ArrayList(); |
||
307 | 8765 | jjdelcerro | LayersIterator iter = new LayersIterator(this) { |
308 | public boolean evaluate(FLayer layer) { |
||
309 | return layer.isVisible();
|
||
310 | } |
||
311 | 9013 | caballero | |
312 | 8765 | jjdelcerro | }; |
313 | 404 | fjp | |
314 | 8765 | jjdelcerro | while (iter.hasNext()) {
|
315 | 9013 | caballero | array.add(iter.nextLayer()); |
316 | 524 | vcaballero | } |
317 | 404 | fjp | |
318 | 524 | vcaballero | return (FLayer[]) array.toArray(new FLayer[0]); |
319 | } |
||
320 | 404 | fjp | |
321 | 524 | vcaballero | /**
|
322 | 5228 | caballero | * Obtiene el hijo i-?simo (de abajo a arriba) directo de esta colecci?n.
|
323 | 524 | vcaballero | *
|
324 | 1005 | vcaballero | * @param index ?ndice.
|
325 | 524 | vcaballero | *
|
326 | 1005 | vcaballero | * @return capa seleccionada.
|
327 | 524 | vcaballero | */
|
328 | public FLayer getLayer(int index) { |
||
329 | return (FLayer) layers.get(index);
|
||
330 | } |
||
331 | 242 | vcaballero | |
332 | 524 | vcaballero | /**
|
333 | * M?todo de conveniencia para buscar una capa por su nombre Es conveniente
|
||
334 | * usar getLayer(int) siempre que se pueda, es m?s directo.
|
||
335 | *
|
||
336 | 1005 | vcaballero | * @param layerName nombre.
|
337 | 524 | vcaballero | *
|
338 | 1005 | vcaballero | * @return capa seleccionada.
|
339 | 524 | vcaballero | */
|
340 | public FLayer getLayer(String layerName) { |
||
341 | FLayer lyr; |
||
342 | 3038 | ldiaz | FLayer lyr2; |
343 | 3963 | caballero | ArrayList layerList;
|
344 | |||
345 | 524 | vcaballero | for (int i = 0; i < layers.size(); i++) { |
346 | lyr = ((FLayer) layers.get(i)); |
||
347 | 242 | vcaballero | |
348 | 4638 | ldiaz | if (lyr.getName().compareToIgnoreCase(layerName) == 0) { |
349 | return lyr;
|
||
350 | } |
||
351 | 10656 | caballero | |
352 | 3038 | ldiaz | layerList = new ArrayList(); |
353 | 10583 | ldiaz | getLayerFromGroup(lyr,layerList); |
354 | 10656 | caballero | |
355 | 3038 | ldiaz | for(int j = 0; j<layerList.size(); j++ ) |
356 | { |
||
357 | lyr2 = ((FLayer)layerList.get(j)); |
||
358 | if (lyr2.getName().compareToIgnoreCase(layerName) == 0) { |
||
359 | return lyr2;
|
||
360 | } |
||
361 | 524 | vcaballero | } |
362 | 10656 | caballero | |
363 | 524 | vcaballero | } |
364 | 346 | fernando | |
365 | 524 | vcaballero | return null; |
366 | } |
||
367 | 10656 | caballero | // looks in the layertree including FLayers
|
368 | 10583 | ldiaz | private void getLayerFromGroup(FLayer layer, ArrayList result){ |
369 | int i;
|
||
370 | FLayers layerGroup; |
||
371 | if (layer instanceof FLayers) |
||
372 | { |
||
373 | result.add(layer); |
||
374 | layerGroup = (FLayers)layer; |
||
375 | for (i=0; i < layerGroup.getLayersCount(); i++ ) |
||
376 | { |
||
377 | getLayerFromGroup(layerGroup.getLayer(i),result); |
||
378 | } |
||
379 | } |
||
380 | else
|
||
381 | { |
||
382 | result.add(layer); |
||
383 | } |
||
384 | } |
||
385 | 10656 | caballero | |
386 | |||
387 | 3038 | ldiaz | // this is to to split up a layer group in order to get a layer by name
|
388 | // when there are layergroups.
|
||
389 | private void splitLayerGroup(FLayer layer, ArrayList result) |
||
390 | { |
||
391 | int i;
|
||
392 | FLayers layerGroup; |
||
393 | if (layer instanceof FLayers) |
||
394 | { |
||
395 | layerGroup = (FLayers)layer; |
||
396 | for (i=0; i < layerGroup.getLayersCount(); i++ ) |
||
397 | { |
||
398 | splitLayerGroup(layerGroup.getLayer(i),result); |
||
399 | } |
||
400 | } |
||
401 | else
|
||
402 | { |
||
403 | result.add(layer); |
||
404 | } |
||
405 | } |
||
406 | 346 | fernando | |
407 | 524 | vcaballero | /**
|
408 | * Obtiene el n?mero de capas que hay en su mismo nivel Es decir, no cuenta
|
||
409 | * las subcapas de un FLayers
|
||
410 | *
|
||
411 | 1005 | vcaballero | * @return n?mero de capas.
|
412 | 524 | vcaballero | */
|
413 | public int getLayersCount() { |
||
414 | return layers.size();
|
||
415 | } |
||
416 | 346 | fernando | |
417 | 524 | vcaballero | /**
|
418 | 1056 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage,
|
419 | 524 | vcaballero | * java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
|
420 | */
|
||
421 | public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
||
422 | 2531 | caballero | Cancellable cancel,double scale) throws DriverException { |
423 | 2411 | caballero | //double scale = getFMap().getScaleView();
|
424 | 6611 | caballero | // Iterator iter = layers.iterator();
|
425 | // try
|
||
426 | // {
|
||
427 | 5923 | fjp | boolean bNeedRecalculateCache = false; |
428 | 6611 | caballero | // while (iter.hasNext())
|
429 | // {
|
||
430 | for (int i=0; i < layers.size(); i++) { |
||
431 | 3372 | fjp | if (cancel.isCanceled())
|
432 | break; // M?s que nada porque las capas raster no son interrumpibles por ahora. |
||
433 | 6611 | caballero | // FLayer lyr = (FLayer) iter.next();
|
434 | FLayer lyr = (FLayer) layers.get(i); |
||
435 | 3479 | caballero | /* if (lyr instanceof FLyrVect && ((FLyrVect)lyr).isBroken()){
|
436 | 3478 | caballero | continue;
|
437 | }
|
||
438 | 3479 | caballero | */
|
439 | 3772 | fjp | LayerDrawEvent beforeEvent = new LayerDrawEvent(lyr, g, viewPort, LayerDrawEvent.LAYER_BEFORE_DRAW);
|
440 | fmap.fireLayerDrawingEvent(beforeEvent); |
||
441 | 10401 | fjp | if ((lyr.isDirty()) && (lyr.isCachingDrawnLayers() == false)) |
442 | 6002 | fjp | bNeedRecalculateCache = true;
|
443 | |||
444 | 2981 | fjp | if (lyr.isVisible()) {
|
445 | 3963 | caballero | |
446 | 2981 | fjp | long t1 = System.currentTimeMillis(); |
447 | 10656 | caballero | System.err.println("Layer " + lyr.getName() + " dirty=" + lyr.isDirty()+ " isCachingDrawnLayers= "+lyr.isCachingDrawnLayers()); |
448 | 3076 | fjp | // synchronized (this) {
|
449 | 3963 | caballero | //Sincronizaci?n del m?todo dibujar de cada Layer, esto es posible hacerlo de otra forma,
|
450 | 2981 | fjp | //pero de momento se queda as?, para solucionar el refresco de una misma vista que est? a?adida en el Layout.
|
451 | 3492 | jaume | try{
|
452 | 3685 | fjp | /* if (lyr instanceof IComposedDrawing)
|
453 | {
|
||
454 | // Acumulamos las peticiones hasta que sea
|
||
455 | // otro servidor o otro tipo de capa o la ?ltima
|
||
456 | // Si hay que dibujar:
|
||
457 | lyr.draw(image, g, viewPort, cancel,scale);
|
||
458 | // Si hay que acumlar:
|
||
459 | lyr.acumulateDrawing(antLayer);
|
||
460 | 3963 | caballero | |
461 | 3685 | fjp | }
|
462 | else */
|
||
463 | 3963 | caballero | |
464 | 6259 | fjp | if (lyr.isCachingDrawnLayers())
|
465 | 5923 | fjp | { |
466 | 7368 | jmvivo | if ((bNeedRecalculateCache) || (lyr.getCacheImageDrawnLayers()==null)) |
467 | 5923 | fjp | { |
468 | 7368 | jmvivo | //if (bNeedRecalculateCache)
|
469 | 8765 | jjdelcerro | // {
|
470 | 5923 | fjp | // Copiamos la imagen actual
|
471 | BufferedImage buff = new BufferedImage(image.getWidth(), image.getHeight(), image.getType()); |
||
472 | 6480 | jaume | WritableRaster w = buff.getRaster();
|
473 | 5923 | fjp | image.copyData(w); |
474 | lyr.setCacheImageDrawnLayers(buff); |
||
475 | System.err.println("RECALCULO LA CACHE CON LO QUE HABIA ANTES DE " + lyr.getName()); |
||
476 | } |
||
477 | // }
|
||
478 | // else
|
||
479 | // {
|
||
480 | if (lyr.getCacheImageDrawnLayers() != null) |
||
481 | { |
||
482 | // Previo a esto hemos tenido que fijar
|
||
483 | 6480 | jaume | // la imagen que queremos usar, en el
|
484 | 5923 | fjp | // prepareDrawing de FMap.
|
485 | if (lyr.isDirty())
|
||
486 | { |
||
487 | g.drawImage(lyr.getCacheImageDrawnLayers(), 0, 0, null); |
||
488 | System.err.println("Pinto con acelerado lo que hab?a antes de " + lyr.getName()); |
||
489 | } |
||
490 | } |
||
491 | // }
|
||
492 | 6480 | jaume | } |
493 | 5923 | fjp | // Si la capa est? "sucia" o alguna de las de abajo est? sucia
|
494 | // hay que volver a dibujar.
|
||
495 | if (lyr.isDirty() || bNeedRecalculateCache)
|
||
496 | { |
||
497 | 10638 | fjp | if (lyr.getFLayerStatus().isDriverLoaded())
|
498 | { |
||
499 | lyr.draw(image, g, viewPort, cancel,scale); |
||
500 | bNeedRecalculateCache = true;
|
||
501 | 10656 | caballero | System.err.println("Pinto sin acelerado " + lyr.getName()); |
502 | |||
503 | 10638 | fjp | } |
504 | 5923 | fjp | } |
505 | 3492 | jaume | } catch (DriverException e){
|
506 | 3941 | fjp | // fmap.callNewErrorEvent(new ErrorEvent(lyr.getName(), e));
|
507 | 5258 | jmvivo | fmap.addLayerError("La capa " + lyr.getName() + " es err?nea."); |
508 | 4181 | fjp | e.printStackTrace(); |
509 | 6537 | jmvivo | lyr.setAvailable(false);
|
510 | 4181 | fjp | // this.removeLayer(lyr);
|
511 | 6537 | jmvivo | } catch (Exception e) { |
512 | fmap.addLayerError("La capa " + lyr.getName() + " es err?nea."); |
||
513 | e.printStackTrace(); |
||
514 | lyr.setAvailable(false);
|
||
515 | 3492 | jaume | } |
516 | 3076 | fjp | // }
|
517 | 2981 | fjp | long t2 = System.currentTimeMillis(); |
518 | System.out.println("Layer " + lyr.getName() + " " |
||
519 | 3963 | caballero | + (t2-t1) + " milisecs.");
|
520 | 5923 | fjp | lyr.setDirty(false);
|
521 | 2981 | fjp | } |
522 | 3772 | fjp | LayerDrawEvent afterEvent = new LayerDrawEvent(lyr, g, viewPort, LayerDrawEvent.LAYER_AFTER_DRAW);
|
523 | fmap.fireLayerDrawingEvent(afterEvent); |
||
524 | |||
525 | 2981 | fjp | } |
526 | if (getVirtualLayers() != null) { |
||
527 | getVirtualLayers().draw(image, g, viewPort, cancel,scale); |
||
528 | } |
||
529 | 6611 | caballero | // }
|
530 | // catch (ConcurrentModificationException e)
|
||
531 | // {
|
||
532 | // System.err.println(e.getMessage());
|
||
533 | // }
|
||
534 | 524 | vcaballero | } |
535 | |||
536 | /**
|
||
537 | 1005 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D,
|
538 | * com.iver.cit.gvsig.fmap.ViewPort,
|
||
539 | 5317 | fjp | * com.iver.utiles.swing.threads.Cancellable)
|
540 | 524 | vcaballero | */
|
541 | 9013 | caballero | public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) |
542 | 1005 | vcaballero | throws DriverException {
|
543 | 3963 | caballero | |
544 | 2510 | fjp | // TODO: A la hora de imprimir, isWithinScale falla, porque est?
|
545 | // calculando la escala en pantalla, no para el layout.
|
||
546 | // Revisar esto.
|
||
547 | 9361 | fdiaz | for (int i=0; i < layers.size(); i++) { |
548 | FLayer lyr = (FLayer) layers.get(i); |
||
549 | 9013 | caballero | lyr.print(g, viewPort, cancel, scale, properties); |
550 | 3963 | caballero | |
551 | 2531 | caballero | } |
552 | if (getVirtualLayers() != null) { |
||
553 | 9013 | caballero | getVirtualLayers().print( g, viewPort, cancel, scale, properties); |
554 | 3963 | caballero | } |
555 | 524 | vcaballero | } |
556 | |||
557 | /**
|
||
558 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
|
||
559 | */
|
||
560 | 651 | fernando | public Rectangle2D getFullExtent() throws DriverException { |
561 | 524 | vcaballero | Rectangle2D rAux = null; |
562 | 3478 | caballero | boolean first = true; |
563 | 524 | vcaballero | |
564 | 3963 | caballero | |
565 | 524 | vcaballero | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
566 | 533 | vcaballero | FLayer capa = (FLayer) iter.next(); |
567 | 3478 | caballero | try{
|
568 | if (first) {
|
||
569 | 524 | vcaballero | rAux = capa.getFullExtent(); |
570 | 3478 | caballero | first=false;
|
571 | 524 | vcaballero | } else {
|
572 | rAux.add(capa.getFullExtent()); |
||
573 | } |
||
574 | 3478 | caballero | }catch (Exception e) { |
575 | e.printStackTrace();//TODO hay que revisar para determinar el comportamiento que espera el usuario.
|
||
576 | } |
||
577 | 524 | vcaballero | } |
578 | |||
579 | return rAux;
|
||
580 | } |
||
581 | 1005 | vcaballero | |
582 | 524 | vcaballero | /**
|
583 | 1005 | vcaballero | * Llama al m?todo layerAdding de los listeners dados de alta.
|
584 | 524 | vcaballero | *
|
585 | 1005 | vcaballero | * @param event
|
586 | 524 | vcaballero | *
|
587 | * @throws CancelationException
|
||
588 | */
|
||
589 | 8765 | jjdelcerro | protected void callLayerAdding(LayerCollectionEvent event) |
590 | 524 | vcaballero | throws CancelationException {
|
591 | 3772 | fjp | ArrayList aux = (ArrayList) layerCollectionListeners.clone(); |
592 | 2284 | jmorell | for (Iterator iter = aux.iterator(); iter.hasNext();) { |
593 | 524 | vcaballero | ((LayerCollectionListener) iter.next()).layerAdding(event); |
594 | } |
||
595 | } |
||
596 | 257 | vcaballero | |
597 | 524 | vcaballero | /**
|
598 | 1005 | vcaballero | * Llama al m?todo layerRemoving de los listeners dados de alta.
|
599 | 524 | vcaballero | *
|
600 | 1005 | vcaballero | * @param event
|
601 | 524 | vcaballero | *
|
602 | * @throws CancelationException
|
||
603 | */
|
||
604 | 8765 | jjdelcerro | protected void callLayerRemoving(LayerCollectionEvent event) |
605 | 524 | vcaballero | throws CancelationException {
|
606 | 3772 | fjp | ArrayList aux = (ArrayList) layerCollectionListeners.clone(); |
607 | 2284 | jmorell | for (Iterator iter = aux.iterator(); iter.hasNext();) { |
608 | 524 | vcaballero | ((LayerCollectionListener) iter.next()).layerRemoving(event); |
609 | } |
||
610 | } |
||
611 | 257 | vcaballero | |
612 | 3963 | caballero | |
613 | 524 | vcaballero | /**
|
614 | 1005 | vcaballero | * Llama al m?todo layerMoving de los listeners dados de alta.
|
615 | 524 | vcaballero | *
|
616 | 1005 | vcaballero | * @param event
|
617 | 524 | vcaballero | *
|
618 | * @throws CancelationException
|
||
619 | */
|
||
620 | 8765 | jjdelcerro | protected void callLayerMoving(LayerPositionEvent event) |
621 | 524 | vcaballero | throws CancelationException {
|
622 | 3772 | fjp | ArrayList aux = (ArrayList) layerCollectionListeners.clone(); |
623 | 2284 | jmorell | for (Iterator iter = aux.iterator(); iter.hasNext();) { |
624 | 524 | vcaballero | ((LayerCollectionListener) iter.next()).layerMoving(event); |
625 | } |
||
626 | } |
||
627 | 353 | fernando | |
628 | 524 | vcaballero | /**
|
629 | 1005 | vcaballero | * Llama al m?todo layerAdded de los listeners dados de alta.
|
630 | 524 | vcaballero | *
|
631 | 1005 | vcaballero | * @param event
|
632 | 524 | vcaballero | */
|
633 | 8765 | jjdelcerro | protected void callLayerAdded(LayerCollectionEvent event) { |
634 | 3772 | fjp | ArrayList aux = (ArrayList) layerCollectionListeners.clone(); |
635 | 2284 | jmorell | for (Iterator iter = aux.iterator(); iter.hasNext();) { |
636 | 524 | vcaballero | ((LayerCollectionListener) iter.next()).layerAdded(event); |
637 | } |
||
638 | } |
||
639 | 353 | fernando | |
640 | 524 | vcaballero | /**
|
641 | 1005 | vcaballero | * Llama al m?todo layerRemoved de los listeners dados de alta.
|
642 | 524 | vcaballero | *
|
643 | 1005 | vcaballero | * @param event
|
644 | 524 | vcaballero | */
|
645 | 8765 | jjdelcerro | protected void callLayerRemoved(LayerCollectionEvent event) { |
646 | 3772 | fjp | ArrayList aux = (ArrayList) layerCollectionListeners.clone(); |
647 | 2284 | jmorell | for (Iterator iter = aux.iterator(); iter.hasNext();) { |
648 | 524 | vcaballero | ((LayerCollectionListener) iter.next()).layerRemoved(event); |
649 | } |
||
650 | } |
||
651 | 353 | fernando | |
652 | 435 | vcaballero | /**
|
653 | 1005 | vcaballero | * Llama al m?todo layerMoved de los listeners dados de alta.
|
654 | 524 | vcaballero | *
|
655 | 1005 | vcaballero | * @param event
|
656 | 524 | vcaballero | */
|
657 | 8765 | jjdelcerro | protected void callLayerMoved(LayerPositionEvent event) { |
658 | 3772 | fjp | ArrayList aux = (ArrayList) layerCollectionListeners.clone(); |
659 | 2284 | jmorell | for (Iterator iter = aux.iterator(); iter.hasNext();) { |
660 | 524 | vcaballero | ((LayerCollectionListener) iter.next()).layerMoved(event); |
661 | } |
||
662 | } |
||
663 | |||
664 | /**
|
||
665 | 1828 | fernando | * @throws XMLException
|
666 | 435 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperties()
|
667 | */
|
||
668 | 1828 | fernando | public XMLEntity getXMLEntity() throws XMLException { |
669 | 524 | vcaballero | XMLEntity xml = super.getXMLEntity();
|
670 | xml.putProperty("numLayers", layers.size());
|
||
671 | 1005 | vcaballero | |
672 | String[] s = new String[layers.size()]; |
||
673 | |||
674 | for (int i = 0; i < layers.size(); i++) { |
||
675 | s[i] = ((FLayer) layers.get(i)).getName(); |
||
676 | 558 | vcaballero | } |
677 | 1005 | vcaballero | |
678 | xml.putProperty("LayerNames", s);
|
||
679 | |||
680 | 524 | vcaballero | for (int i = 0; i < layers.size(); i++) { |
681 | xml.addChild(((FLayer) layers.get(i)).getXMLEntity()); |
||
682 | 435 | vcaballero | } |
683 | 524 | vcaballero | |
684 | 435 | vcaballero | return xml;
|
685 | } |
||
686 | 341 | fernando | |
687 | 435 | vcaballero | /**
|
688 | 1056 | vcaballero | * DOCUMENT ME!
|
689 | *
|
||
690 | * @param xml DOCUMENT ME!
|
||
691 | *
|
||
692 | * @throws XMLException
|
||
693 | *
|
||
694 | 435 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#setXMLEntity(com.iver.utiles.XMLEntity)
|
695 | */
|
||
696 | 3481 | caballero | public void setXMLEntity03(XMLEntity xml) throws XMLException{ |
697 | 2183 | fernando | super.setXMLEntity03(xml);
|
698 | int numLayers = xml.getIntProperty("numLayers"); |
||
699 | |||
700 | String[] s = xml.getStringArrayProperty("LayerNames"); |
||
701 | try {
|
||
702 | for (int i = 0; i < numLayers; i++) { |
||
703 | FLayer layer = null;
|
||
704 | 3963 | caballero | |
705 | 2183 | fernando | String className = xml.getChild(i).getStringProperty("className"); |
706 | 3963 | caballero | |
707 | 2183 | fernando | if (className.equals(FLyrVect.class.getName())) {
|
708 | if (xml.getChild(i).contains("file")) { |
||
709 | 3963 | caballero | |
710 | 2183 | fernando | layer = LayerFactory.createLayer(s[i], |
711 | (VectorialFileDriver)LayerFactory.getDM().getDriver(xml.getChild(i).getStringProperty("driverName")),
|
||
712 | new File(xml.getChild(i).getStringProperty("file")), |
||
713 | 6881 | cesar | this.getMapContext().getViewPort().getProjection());
|
714 | 3963 | caballero | |
715 | 2183 | fernando | } else if (true) { |
716 | //TODO falta por implementar
|
||
717 | } else if (true) { |
||
718 | //TODO falta por implementar
|
||
719 | } |
||
720 | 3963 | caballero | |
721 | 2183 | fernando | layer.setXMLEntity03(xml.getChild(i)); |
722 | // Comprobar que la proyecci?n es la misma que la de FMap
|
||
723 | 3963 | caballero | // Si no lo es, es una capa que est? reproyectada al vuelo
|
724 | 2183 | fernando | IProjection proj = layer.getProjection(); |
725 | if (proj != null) |
||
726 | if (proj != fmap.getProjection())
|
||
727 | { |
||
728 | 6164 | luisw2 | ICoordTrans ct = proj.getCT(fmap.getProjection()); |
729 | 2183 | fernando | layer.setCoordTrans(ct); |
730 | System.err.println("coordTrans = " + |
||
731 | proj.getAbrev() + " " +
|
||
732 | fmap.getProjection().getAbrev()); |
||
733 | } |
||
734 | 3963 | caballero | |
735 | 3174 | ldiaz | // } else if (className.equals(FLyrWMS.class.getName())) {
|
736 | // try {
|
||
737 | // layer = LayerFactory.createLayer(s[i],
|
||
738 | // StringUtilities.string2Rect(
|
||
739 | // xml.getChild(i).getStringProperty("fullExtent")),
|
||
740 | // new URL(xml.getChild(i).getStringProperty("host")),
|
||
741 | // xml.getChild(i).getStringProperty("format"),
|
||
742 | // xml.getChild(i).getStringProperty("layerQuery"),
|
||
743 | // xml.getChild(i).getStringProperty("infoLayerQuery"),
|
||
744 | // xml.getChild(i).getStringProperty("srs"));
|
||
745 | // } catch (MalformedURLException e) {
|
||
746 | // throw new XMLException(e);
|
||
747 | // }
|
||
748 | 2183 | fernando | } else if (className.equals((FLyrRaster.class.getName()))) { |
749 | //if (xml.getChild(i).contains("file")) {
|
||
750 | /*layer = LayerFactory.createLayer(s[i],
|
||
751 | xml.getChild(i).getStringProperty("driverName"),
|
||
752 | new File(xml.getChild(i).getStringProperty("file")),
|
||
753 | this.getFMap().getViewPort().getProjection());*/
|
||
754 | layer = new FLyrRaster();
|
||
755 | layer.setName(s[i]); |
||
756 | if (!xml.getChild(i).contains("proj")) |
||
757 | 6881 | cesar | ((FLyrRaster)layer).setProjection(this.getMapContext().getViewPort().getProjection());
|
758 | 2183 | fernando | layer.setXMLEntity03(xml.getChild(i)); |
759 | try {
|
||
760 | 3431 | caballero | layer.load(); |
761 | 3963 | caballero | |
762 | 2183 | fernando | } catch (DriverIOException e) {
|
763 | throw new XMLException(e); |
||
764 | } |
||
765 | 3963 | caballero | |
766 | 2234 | vcaballero | }else if (className.equals((FLayers.class.getName()))) { |
767 | 6881 | cesar | layer = new FLayers(getMapContext(),this); |
768 | 2234 | vcaballero | layer.setXMLEntity(xml.getChild(i)); |
769 | 2183 | fernando | } else {
|
770 | // Capas Nuevas (externas)
|
||
771 | try {
|
||
772 | Class clase = Class.forName(className); |
||
773 | layer = (FLayer) clase.newInstance(); |
||
774 | layer.setName(s[i]); |
||
775 | layer.setXMLEntity03(xml.getChild(i)); |
||
776 | try {
|
||
777 | 3431 | caballero | layer.load(); |
778 | 2183 | fernando | } catch (DriverIOException e) {
|
779 | throw new XMLException(e); |
||
780 | } |
||
781 | } catch (Exception e) { |
||
782 | //e.printStackTrace();
|
||
783 | throw new XMLException(e); |
||
784 | } |
||
785 | } |
||
786 | 3963 | caballero | |
787 | 2234 | vcaballero | this.addLayer(layer);
|
788 | 2183 | fernando | } |
789 | 8765 | jjdelcerro | } /*azabala-modificaciones en layerfactory-
|
790 | catch (DriverException e) {
|
||
791 | 2183 | fernando | throw new XMLException(e);
|
792 | 8765 | jjdelcerro | }*/
|
793 | catch (DriverLoadException e) {
|
||
794 | 2183 | fernando | throw new XMLException(e); |
795 | } |
||
796 | 3963 | caballero | |
797 | 2183 | fernando | } |
798 | |||
799 | /**
|
||
800 | * DOCUMENT ME!
|
||
801 | *
|
||
802 | * @param xml DOCUMENT ME!
|
||
803 | *
|
||
804 | * @throws XMLException
|
||
805 | *
|
||
806 | * @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#setXMLEntity(com.iver.utiles.XMLEntity)
|
||
807 | */
|
||
808 | 3481 | caballero | public void setXMLEntity(XMLEntity xml) throws XMLException{ |
809 | 442 | vcaballero | super.setXMLEntity(xml);
|
810 | 3481 | caballero | //LoadLayerException loadLayerException=new LoadLayerException();
|
811 | 894 | vcaballero | int numLayers = xml.getIntProperty("numLayers"); |
812 | 524 | vcaballero | |
813 | 1005 | vcaballero | String[] s = xml.getStringArrayProperty("LayerNames"); |
814 | 3304 | jmorell | // try {
|
815 | 3492 | jaume | fmap.clearErrors(); |
816 | 1060 | fjp | for (int i = 0; i < numLayers; i++) { |
817 | 6437 | jmvivo | this.addLayerFromXML(xml.getChild(i),s[i]);
|
818 | 3963 | caballero | |
819 | |||
820 | 894 | vcaballero | } |
821 | 3304 | jmorell | /* } catch (DriverException e) {
|
822 | 1060 | fjp | throw new XMLException(e);
|
823 | 3304 | jmorell | } */
|
824 | 3481 | caballero | /*if (loadLayerException.getExceptions().size()>0){
|
825 | throw loadLayerException;
|
||
826 | }*/
|
||
827 | 435 | vcaballero | } |
828 | 562 | fernando | |
829 | /**
|
||
830 | 1005 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData#process(com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor,
|
831 | 2969 | fjp | * FBitSet)
|
832 | 562 | fernando | */
|
833 | 2969 | fjp | public void process(FeatureVisitor visitor, FBitSet subset) |
834 | 1005 | vcaballero | throws DriverException, VisitException {
|
835 | 562 | fernando | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
836 | FLayer layer = (FLayer) iter.next(); |
||
837 | 1005 | vcaballero | |
838 | 562 | fernando | if (layer instanceof VectorialData) { |
839 | ((VectorialData) layer).process(visitor, subset); |
||
840 | } |
||
841 | } |
||
842 | } |
||
843 | |||
844 | /**
|
||
845 | * @see com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData#process(com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor)
|
||
846 | */
|
||
847 | 1005 | vcaballero | public void process(FeatureVisitor visitor) |
848 | throws DriverException, VisitException {
|
||
849 | 562 | fernando | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
850 | FLayer layer = (FLayer) iter.next(); |
||
851 | 1005 | vcaballero | |
852 | 9474 | fdiaz | if (layer instanceof FLayers){ |
853 | FLayers lyrs=(FLayers)layer; |
||
854 | for (int i=0;i<lyrs.getLayersCount();i++){ |
||
855 | FLayer lyr=lyrs.getLayer(i); |
||
856 | if (lyr.isActive()) {
|
||
857 | if (lyr instanceof VectorialData) { |
||
858 | ((VectorialData) lyr).process(visitor); |
||
859 | } |
||
860 | } |
||
861 | } |
||
862 | } |
||
863 | 1005 | vcaballero | if (layer.isActive()) {
|
864 | 661 | fjp | if (layer instanceof VectorialData) { |
865 | ((VectorialData) layer).process(visitor); |
||
866 | } |
||
867 | 1005 | vcaballero | } |
868 | 562 | fernando | } |
869 | } |
||
870 | 4200 | azabala | /**
|
871 | * @see com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData#process(com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor, Rectangle2D)
|
||
872 | */
|
||
873 | public void process(FeatureVisitor visitor, Rectangle2D rect) throws DriverException, VisitException { |
||
874 | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
||
875 | FLayer layer = (FLayer) iter.next(); |
||
876 | 694 | fernando | |
877 | 4200 | azabala | if (layer.isActive()) {
|
878 | if (layer instanceof VectorialData) { |
||
879 | ((VectorialData) layer).process(visitor, rect); |
||
880 | } |
||
881 | } |
||
882 | } |
||
883 | 5228 | caballero | |
884 | 4200 | azabala | } |
885 | |||
886 | 694 | fernando | /**
|
887 | 6881 | cesar | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMapContext()
|
888 | 694 | fernando | */
|
889 | 6881 | cesar | public MapContext getMapContext() {
|
890 | 694 | fernando | return fmap;
|
891 | } |
||
892 | 885 | fjp | |
893 | /* (non-Javadoc)
|
||
894 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setCoordTrans(org.cresques.cts.ICoordTrans)
|
||
895 | */
|
||
896 | public void setCoordTrans(ICoordTrans ct) { |
||
897 | super.setCoordTrans(ct);
|
||
898 | 1005 | vcaballero | |
899 | 885 | fjp | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
900 | FLayer layer = (FLayer) iter.next(); |
||
901 | layer.setCoordTrans(ct); |
||
902 | 1005 | vcaballero | } |
903 | 885 | fjp | } |
904 | 1005 | vcaballero | |
905 | /**
|
||
906 | * @see com.iver.cit.gvsig.fmap.layers.layerOperations.LayerCollection#setAllActives(boolean)
|
||
907 | */
|
||
908 | public void setAllActives(boolean active) { |
||
909 | FLayer lyr; |
||
910 | |||
911 | for (int i = 0; i < layers.size(); i++) { |
||
912 | lyr = ((FLayer) layers.get(i)); |
||
913 | lyr.setActive(active); |
||
914 | |||
915 | if (lyr instanceof LayerCollection) { |
||
916 | ((LayerCollection) lyr).setAllActives(active); |
||
917 | } |
||
918 | } |
||
919 | } |
||
920 | |||
921 | /**
|
||
922 | * @see com.iver.cit.gvsig.fmap.layers.layerOperations.LayerCollection#getActives()
|
||
923 | */
|
||
924 | public FLayer[] getActives() { |
||
925 | ArrayList ret = new ArrayList(); |
||
926 | 8765 | jjdelcerro | LayersIterator it = new LayersIterator(this) { |
927 | 1005 | vcaballero | |
928 | 9013 | caballero | public boolean evaluate(FLayer layer) { |
929 | 8765 | jjdelcerro | return layer.isActive();
|
930 | 1005 | vcaballero | } |
931 | 9013 | caballero | |
932 | 8765 | jjdelcerro | }; |
933 | 9013 | caballero | |
934 | 8765 | jjdelcerro | while (it.hasNext())
|
935 | { |
||
936 | ret.add(it.next()); |
||
937 | 1005 | vcaballero | } |
938 | return (FLayer[]) ret.toArray(new FLayer[0]); |
||
939 | } |
||
940 | 1176 | fjp | |
941 | /* (non-Javadoc)
|
||
942 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMinScale()
|
||
943 | */
|
||
944 | public double getMinScale() { |
||
945 | return -1; // La visibilidad o no la controla cada capa |
||
946 | // dentro de una colecci?n
|
||
947 | } |
||
948 | |||
949 | /* (non-Javadoc)
|
||
950 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMaxScale()
|
||
951 | */
|
||
952 | public double getMaxScale() { |
||
953 | return -1; |
||
954 | } |
||
955 | public void setMinScale(double minScale) |
||
956 | { |
||
957 | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
||
958 | FLayer lyr = (FLayer) iter.next(); |
||
959 | lyr.setMinScale(minScale); |
||
960 | } |
||
961 | } |
||
962 | public void setMaxScale(double maxScale) |
||
963 | { |
||
964 | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
||
965 | FLayer lyr = (FLayer) iter.next(); |
||
966 | lyr.setMinScale(maxScale); |
||
967 | } |
||
968 | } |
||
969 | 2411 | caballero | public void setActive(boolean b){ |
970 | super.setActive(b);
|
||
971 | for (int i=0;i<layers.size();i++){ |
||
972 | ((FLayer)layers.get(i)).setActive(b); |
||
973 | } |
||
974 | } |
||
975 | 3963 | caballero | |
976 | 4147 | fjp | /* (non-Javadoc)
|
977 | * @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#addLayerListener(com.iver.cit.gvsig.fmap.layers.LayerListener)
|
||
978 | */
|
||
979 | public boolean addLayerListener(LayerListener o) { |
||
980 | 5228 | caballero | for (int i = 0; i < layers.size(); i++) |
981 | 4147 | fjp | ((FLayer) layers.get(i)).addLayerListener(o); |
982 | return true; |
||
983 | } |
||
984 | |||
985 | 8765 | jjdelcerro | public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancel) throws DriverException { |
986 | 4928 | ldiaz | int i;
|
987 | 5057 | ldiaz | Vector items = new Vector(); |
988 | FLayer layer; |
||
989 | XMLItem[] aux;
|
||
990 | 4928 | ldiaz | for (i = 0; i < this.layers.size(); i++){ |
991 | 5057 | ldiaz | layer = (FLayer)layers.get(i); |
992 | if (layer instanceof InfoByPoint){ |
||
993 | InfoByPoint queryable_layer = (InfoByPoint) layer; |
||
994 | 8765 | jjdelcerro | aux = queryable_layer.getInfo(p, tolerance, null);
|
995 | if (!(queryable_layer instanceof FLayers)){ |
||
996 | 9013 | caballero | for(int j = 0; j < aux.length; j++){ |
997 | 8765 | jjdelcerro | items.add(aux[j]); |
998 | } |
||
999 | 4928 | ldiaz | } |
1000 | 5228 | caballero | } |
1001 | 5057 | ldiaz | } |
1002 | return (XMLItem[])items.toArray(new XMLItem[0]); |
||
1003 | 5228 | caballero | |
1004 | 5057 | ldiaz | // for (i = 0; i < this.layers.size(); i++){
|
1005 | // FLayer laCapa = (FLayer) layers.get(i);
|
||
1006 | // if (laCapa instanceof FLyrVect){
|
||
1007 | // }
|
||
1008 | // else if (laCapa instanceof RasterOperations) {
|
||
1009 | // try {
|
||
1010 | // RasterOperations layer = (RasterOperations) laCapa;
|
||
1011 | // sb.append(layer.getInfo(p, tolerance));
|
||
1012 | // } catch (DriverException e) {
|
||
1013 | 5228 | caballero | // e.printStackTrace();
|
1014 | // }
|
||
1015 | 5057 | ldiaz | // }
|
1016 | // else if (laCapa instanceof InfoByPoint) {
|
||
1017 | // try {
|
||
1018 | // InfoByPoint layer = (InfoByPoint) laCapa;
|
||
1019 | // sb.append(layer.getInfo(p, tolerance));
|
||
1020 | // } catch (DriverException e) {
|
||
1021 | 5228 | caballero | // e.printStackTrace();
|
1022 | 5057 | ldiaz | // }
|
1023 | // }
|
||
1024 | 5228 | caballero | // }
|
1025 | 5057 | ldiaz | |
1026 | 4928 | ldiaz | } |
1027 | |||
1028 | 6480 | jaume | public ImageIcon getTocImageIcon() { |
1029 | 5761 | jmvivo | return new ImageIcon(MapControl.class.getResource("images/layerGroup.png")); |
1030 | } |
||
1031 | 6480 | jaume | |
1032 | 5923 | fjp | public boolean isDirty() { |
1033 | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
||
1034 | FLayer lyr = (FLayer) iter.next(); |
||
1035 | if (lyr.isDirty())
|
||
1036 | return true; |
||
1037 | } |
||
1038 | return false; |
||
1039 | 6480 | jaume | } |
1040 | 4200 | azabala | |
1041 | 5923 | fjp | public void setDirty(boolean dirty) { |
1042 | for (Iterator iter = layers.iterator(); iter.hasNext();) { |
||
1043 | FLayer lyr = (FLayer) iter.next(); |
||
1044 | lyr.setDirty(dirty); |
||
1045 | } |
||
1046 | |||
1047 | } |
||
1048 | 6480 | jaume | |
1049 | 6437 | jmvivo | public boolean addLayerFromXMLEntity(XMLEntity xml, String name) { |
1050 | fmap.clearErrors(); |
||
1051 | this.addLayerFromXML(xml,name);
|
||
1052 | 5923 | fjp | |
1053 | 6480 | jaume | return (fmap.getLayersError().size() == 0); |
1054 | |||
1055 | 6437 | jmvivo | } |
1056 | 5923 | fjp | |
1057 | 6437 | jmvivo | private void addLayerFromXML(XMLEntity xml, String name) { |
1058 | 6480 | jaume | FLayer layer = null;
|
1059 | 9287 | fjp | long t1 = System.currentTimeMillis(); |
1060 | 6437 | jmvivo | try {
|
1061 | if (name == null) name = xml.getName(); |
||
1062 | |||
1063 | |||
1064 | String className = xml.getStringProperty("className"); |
||
1065 | |||
1066 | if (className.equals(FLyrVect.class.getName())) {
|
||
1067 | String type = xml.getStringProperty("type"); |
||
1068 | if ("vectorial".equals(type)){ |
||
1069 | //String recordsetName = xml.getChild(i).getStringProperty("recordset-name");
|
||
1070 | IProjection proj = null;
|
||
1071 | if (xml.contains("proj")) { |
||
1072 | proj = CRSFactory.getCRS(xml.getStringProperty("proj"));
|
||
1073 | } |
||
1074 | else
|
||
1075 | { |
||
1076 | 6881 | cesar | proj = this.getMapContext().getViewPort().getProjection();
|
1077 | 6437 | jmvivo | } |
1078 | if (xml.contains("file")) { |
||
1079 | Driver d;
|
||
1080 | try {
|
||
1081 | d = LayerFactory.getDM().getDriver(xml.getStringProperty("driverName"));
|
||
1082 | } catch (DriverLoadException e1) {
|
||
1083 | throw new XMLException(e1); |
||
1084 | } |
||
1085 | layer = LayerFactory.createLayer(name, (VectorialFileDriver) d, |
||
1086 | new File(xml.getStringProperty("file")), |
||
1087 | proj); |
||
1088 | |||
1089 | |||
1090 | } |
||
1091 | if (xml.contains("db")) { |
||
1092 | |||
1093 | String driverName = xml.getStringProperty("db"); |
||
1094 | VectorialDatabaseDriver driver; |
||
1095 | try {
|
||
1096 | driver = (VectorialDatabaseDriver) LayerFactory.getDM().getDriver(driverName); |
||
1097 | //Hay que separar la carga de los datos del XMLEntity del load.
|
||
1098 | driver.setXMLEntity(xml.getChild(2));
|
||
1099 | 6556 | caballero | |
1100 | 6537 | jmvivo | boolean loadOk = false; |
1101 | try {
|
||
1102 | ((DefaultDBDriver)driver).load(); |
||
1103 | if (((DefaultDBDriver)driver).getConnection() != null) { |
||
1104 | loadOk = true;
|
||
1105 | 6556 | caballero | } |
1106 | |||
1107 | 6537 | jmvivo | } catch (DriverException e) {
|
1108 | e.printStackTrace(); |
||
1109 | loadOk = false;
|
||
1110 | 6556 | caballero | |
1111 | 6537 | jmvivo | } |
1112 | 6556 | caballero | |
1113 | 6437 | jmvivo | layer = LayerFactory.createDBLayer(driver, name, proj); |
1114 | 6537 | jmvivo | if (!loadOk) {
|
1115 | layer.setAvailable(false);
|
||
1116 | } |
||
1117 | 6480 | jaume | |
1118 | 6437 | jmvivo | } catch (DriverLoadException e) {
|
1119 | e.printStackTrace(); |
||
1120 | throw new XMLException(e); |
||
1121 | } |
||
1122 | |||
1123 | } |
||
1124 | // Clases con algun driver gen?rico creado por otro
|
||
1125 | // programador
|
||
1126 | if (xml.contains("other")) { |
||
1127 | |||
1128 | String driverName = xml.getStringProperty("other"); |
||
1129 | VectorialDriver driver = null;
|
||
1130 | try {
|
||
1131 | driver = (VectorialDriver) LayerFactory.getDM().getDriver(driverName); |
||
1132 | } catch (DriverLoadException e) {
|
||
1133 | // Si no existe ese driver, no pasa nada.
|
||
1134 | // Puede que el desarrollador no quiera que
|
||
1135 | // aparezca en el cuadro de di?logo y ha metido
|
||
1136 | // el jar con sus clases en nuestro directorio lib.
|
||
1137 | // Intentamos cargar esa clase "a pelo".
|
||
1138 | if (xml.getChild(2).contains("className")) |
||
1139 | { |
||
1140 | String className2 = xml.getChild(2).getStringProperty("className"); |
||
1141 | try {
|
||
1142 | driver = (VectorialDriver) Class.forName(className2).newInstance();
|
||
1143 | } catch (Exception e1) { |
||
1144 | throw new XMLException(e1); |
||
1145 | } |
||
1146 | } |
||
1147 | } catch (NullPointerException npe) { |
||
1148 | // Si no existe ese driver, no pasa nada.
|
||
1149 | // Puede que el desarrollador no quiera que
|
||
1150 | // aparezca en el cuadro de di?logo y ha metido
|
||
1151 | // el jar con sus clases en nuestro directorio lib.
|
||
1152 | // Intentamos cargar esa clase "a pelo".
|
||
1153 | if (xml.getChild(2).contains("className")) |
||
1154 | { |
||
1155 | String className2 = xml.getChild(2).getStringProperty("className"); |
||
1156 | try {
|
||
1157 | driver = (VectorialDriver) Class.forName(className2).newInstance();
|
||
1158 | } catch (Exception e1) { |
||
1159 | throw new XMLException(e1); |
||
1160 | } |
||
1161 | } |
||
1162 | } |
||
1163 | if (driver instanceof IPersistance) |
||
1164 | { |
||
1165 | IPersistance persist = (IPersistance) driver; |
||
1166 | persist.setXMLEntity(xml.getChild(2));
|
||
1167 | } |
||
1168 | layer = LayerFactory.createLayer(name, driver, proj); |
||
1169 | } |
||
1170 | |||
1171 | |||
1172 | } else if ("raster".equals(type)) { |
||
1173 | /* if (xml.getChild(i).contains("file")) {
|
||
1174 | Driver d = LayerFactory.getDM().getDriver(xml.getChild(i).getStringProperty("driverName"));
|
||
1175 | layer = LayerFactory.createLayer(s[i],
|
||
1176 | ,
|
||
1177 | new File(xml.getChild(i).getStringProperty("file")),
|
||
1178 | this.getFMap().getViewPort().getProjection());
|
||
1179 | |||
1180 | }
|
||
1181 | */ }
|
||
1182 | |||
1183 | layer.setXMLEntity(xml); |
||
1184 | |||
1185 | // } else if (className.equals(FLyrWMS.class.getName())) {
|
||
1186 | // try {
|
||
1187 | // layer = LayerFactory.createLayer(s[i],
|
||
1188 | // StringUtilities.string2Rect(
|
||
1189 | // xml.getChild(i).getStringProperty("fullExtent")),
|
||
1190 | // new URL(xml.getChild(i).getStringProperty("host")),
|
||
1191 | // xml.getChild(i).getStringProperty("format"),
|
||
1192 | // xml.getChild(i).getStringProperty("layerQuery"),
|
||
1193 | // xml.getChild(i).getStringProperty("infoLayerQuery"),
|
||
1194 | // xml.getChild(i).getStringProperty("srs"));
|
||
1195 | // layer.setXMLEntity(xml.getChild(i));
|
||
1196 | // } catch (MalformedURLException e) {
|
||
1197 | // throw new XMLException(e);
|
||
1198 | // }
|
||
1199 | } else if (className.equals((FLyrRaster.class.getName()))) { |
||
1200 | //if (xml.getChild(i).contains("file")) {
|
||
1201 | /*layer = LayerFactory.createLayer(s[i],
|
||
1202 | xml.getChild(i).getStringProperty("driverName"),
|
||
1203 | new File(xml.getChild(i).getStringProperty("file")),
|
||
1204 | this.getFMap().getViewPort().getProjection());*/
|
||
1205 | layer = new FLyrRaster();
|
||
1206 | layer.setName(name); |
||
1207 | if (!xml.contains("proj")) |
||
1208 | 6881 | cesar | ((FLyrRaster)layer).setProjection(this.getMapContext().getViewPort().getProjection());
|
1209 | 6437 | jmvivo | layer.setXMLEntity(xml); |
1210 | try {
|
||
1211 | layer.load(); |
||
1212 | } catch (DriverIOException e) {
|
||
1213 | throw new XMLException(e); |
||
1214 | } |
||
1215 | |||
1216 | }else if (className.equals((FLayers.class.getName()))) { |
||
1217 | 6881 | cesar | layer = new FLayers(getMapContext(),this); |
1218 | 6437 | jmvivo | layer.setXMLEntity(xml); |
1219 | } else {
|
||
1220 | // Capas Nuevas (externas)
|
||
1221 | Class clase = Class.forName(className); |
||
1222 | layer = (FLayer) clase.newInstance(); |
||
1223 | layer.setName(name); |
||
1224 | layer.setXMLEntity(xml); |
||
1225 | try {
|
||
1226 | layer.load(); |
||
1227 | }catch (DriverIOException e) {
|
||
1228 | throw new XMLException(e); |
||
1229 | } |
||
1230 | |||
1231 | } |
||
1232 | |||
1233 | this.addLayer(layer);
|
||
1234 | 9287 | fjp | long t2 = System.currentTimeMillis(); |
1235 | logger.debug("layer: "+ layer.getName() +" loaded. " + (t2-t1) + " msecs."); |
||
1236 | 6437 | jmvivo | // Comprobar que la proyecci?n es la misma que la de FMap
|
1237 | // Si no lo es, es una capa que est? reproyectada al vuelo
|
||
1238 | IProjection proj = layer.getProjection(); |
||
1239 | if ((proj != null)) |
||
1240 | 6881 | cesar | if (proj != getMapContext().getProjection())
|
1241 | 6437 | jmvivo | { |
1242 | 6881 | cesar | ICoordTrans ct = proj.getCT(getMapContext().getProjection()); |
1243 | 6437 | jmvivo | // TODO: REVISAR CON LUIS
|
1244 | // Se lo fijamos a todas, luego cada una que se reproyecte
|
||
1245 | // si puede, o que no haga nada
|
||
1246 | layer.setCoordTrans(ct); |
||
1247 | // NOTA: DESPU?S DE ESTO DEBER?AMOS CREAR LAS ETIQUETAS
|
||
1248 | // SI ES NECESARIO.
|
||
1249 | // TODO: REVISAR A FONDO ESTO, PORQUE LAS ETIQUETAS SE CREAN
|
||
1250 | // 2 VECES SI HAY REPROYECC?N
|
||
1251 | if (layer instanceof FLyrVect) |
||
1252 | { |
||
1253 | FLyrVect lyrVect = (FLyrVect)layer; |
||
1254 | VectorialLegend legend = (VectorialLegend) lyrVect.getLegend(); |
||
1255 | if (legend.getLabelField() != null) { |
||
1256 | lyrVect.createLabelLayer(lyrVect.getRecordset()); |
||
1257 | } |
||
1258 | |||
1259 | } |
||
1260 | } |
||
1261 | }catch (Exception e) { |
||
1262 | fmap.addLayerError(xml.getStringProperty("name"));
|
||
1263 | //loadLayerException.addException(e);
|
||
1264 | /*if (layer!=null){
|
||
1265 | layer.setActive(false);
|
||
1266 | layer.setVisible(false);
|
||
1267 | this.addLayer(layer);
|
||
1268 | }*/
|
||
1269 | //throw new XMLException(e);
|
||
1270 | System.err.println("No se ha podido cargar la capa : "+xml.getStringProperty("name")); |
||
1271 | logger.debug("No se ha podido cargar la capa : "+xml.getStringProperty("name") + ". Raz?n:"); |
||
1272 | // logger.debug(e.fillInStackTrace());
|
||
1273 | e.printStackTrace(); |
||
1274 | 6480 | jaume | } |
1275 | 6437 | jmvivo | } |
1276 | 8765 | jjdelcerro | |
1277 | 6762 | jmvivo | private void addLayerFromXMLNew(XMLEntity xml, String name) { |
1278 | FLayer layer = null;
|
||
1279 | 6437 | jmvivo | |
1280 | 8765 | jjdelcerro | |
1281 | 6762 | jmvivo | try {
|
1282 | String className = xml.getStringProperty("className"); |
||
1283 | |||
1284 | if (className.equals((FLayers.class.getName()))){
|
||
1285 | 8765 | jjdelcerro | layer = new FLayers(getMapContext(),this); |
1286 | 6762 | jmvivo | } else {
|
1287 | // Por compatibilidad
|
||
1288 | if (className.equals(FLyrVect.class.getName())) {
|
||
1289 | if (xml.contains("file")) { |
||
1290 | 8765 | jjdelcerro | layer = new FLayerFileVectorial();
|
1291 | 6762 | jmvivo | } else if (xml.contains("db")) { |
1292 | try {
|
||
1293 | 8765 | jjdelcerro | layer = (FLayer)((ExtensionPoint)ExtensionPointsSingleton.getInstance().get("Layers")).create("com.iver.cit.gvsig.fmap.layers.FLayerJDBCVectorial"); |
1294 | 6762 | jmvivo | } catch (Exception e) { |
1295 | throw new XMLException(new Exception("No se tiene registrada la capa de tipo JDBC")); |
||
1296 | 8765 | jjdelcerro | } |
1297 | //className = FLayerJDBCVectorial.class.getName();
|
||
1298 | 6762 | jmvivo | } else if (xml.contains("other")){ |
1299 | 8765 | jjdelcerro | layer = new FLayerGenericVectorial();
|
1300 | 6762 | jmvivo | } else {
|
1301 | throw new XMLException(new Exception("Capa vectorial de tipo no reconocido")); |
||
1302 | } |
||
1303 | 8765 | jjdelcerro | // Fin por compatibilidad
|
1304 | 6762 | jmvivo | } else {
|
1305 | try {
|
||
1306 | layer = (FLayer)(((ExtensionPoint)ExtensionPointsSingleton.getInstance().get("Layers")).create(className));
|
||
1307 | } catch (Exception e) { |
||
1308 | 8765 | jjdelcerro | //puende que no este registrada como punto de extension
|
1309 | 6762 | jmvivo | Class clase = Class.forName(className); |
1310 | layer = (FLayer) clase.newInstance(); |
||
1311 | // FIXME: Hacemos algo aqui o dejamos que suba el error?
|
||
1312 | } |
||
1313 | } |
||
1314 | 8765 | jjdelcerro | |
1315 | } |
||
1316 | 6762 | jmvivo | layer.setXMLEntity(xml); |
1317 | if (name != null) layer.setName(name); |
||
1318 | try {
|
||
1319 | layer.load(); |
||
1320 | }catch (DriverIOException e) {
|
||
1321 | throw new XMLException(e); |
||
1322 | } |
||
1323 | |||
1324 | this.addLayer(layer);
|
||
1325 | logger.debug("layer: "+ layer.getName() +" loaded"); |
||
1326 | // Comprobar que la proyecci?n es la misma que la de FMap
|
||
1327 | // Si no lo es, es una capa que est? reproyectada al vuelo
|
||
1328 | IProjection proj = layer.getProjection(); |
||
1329 | if ((proj != null)) |
||
1330 | 6881 | cesar | if (proj != getMapContext().getProjection())
|
1331 | 6762 | jmvivo | { |
1332 | 6881 | cesar | ICoordTrans ct = proj.getCT(getMapContext().getProjection()); |
1333 | 6762 | jmvivo | // TODO: REVISAR CON LUIS
|
1334 | // Se lo fijamos a todas, luego cada una que se reproyecte
|
||
1335 | // si puede, o que no haga nada
|
||
1336 | layer.setCoordTrans(ct); |
||
1337 | // NOTA: DESPU?S DE ESTO DEBER?AMOS CREAR LAS ETIQUETAS
|
||
1338 | // SI ES NECESARIO.
|
||
1339 | // TODO: REVISAR A FONDO ESTO, PORQUE LAS ETIQUETAS SE CREAN
|
||
1340 | // 2 VECES SI HAY REPROYECC?N
|
||
1341 | if (layer instanceof FLyrVect) |
||
1342 | { |
||
1343 | FLyrVect lyrVect = (FLyrVect)layer; |
||
1344 | VectorialLegend legend = (VectorialLegend) lyrVect.getLegend(); |
||
1345 | if (legend.getLabelField() != null) { |
||
1346 | lyrVect.createLabelLayer(lyrVect.getRecordset()); |
||
1347 | } |
||
1348 | |||
1349 | } |
||
1350 | } |
||
1351 | }catch (Exception e) { |
||
1352 | fmap.addLayerError(xml.getStringProperty("name"));
|
||
1353 | //loadLayerException.addException(e);
|
||
1354 | /*if (layer!=null){
|
||
1355 | layer.setActive(false);
|
||
1356 | layer.setVisible(false);
|
||
1357 | this.addLayer(layer);
|
||
1358 | }*/
|
||
1359 | //throw new XMLException(e);
|
||
1360 | System.err.println("No se ha podido cargar la capa : "+xml.getStringProperty("name")); |
||
1361 | logger.debug("No se ha podido cargar la capa : "+xml.getStringProperty("name") + ". Raz?n:"); |
||
1362 | // logger.debug(e.fillInStackTrace());
|
||
1363 | e.printStackTrace(); |
||
1364 | } |
||
1365 | } |
||
1366 | |||
1367 | 10048 | fjp | /**
|
1368 | * This method calls recursively to its layer children to tell that the layer is going
|
||
1369 | * to be removed from the view. This overwrites FLyrDefault.removingThisLayer().
|
||
1370 | */
|
||
1371 | public void removingThisLayer() { |
||
1372 | |||
1373 | for (int i=0; i < layers.size(); i++) { |
||
1374 | FLayer lyr = (FLayer) layers.get(i); |
||
1375 | if (lyr instanceof FLyrDefault) { |
||
1376 | ((FLyrDefault) lyr).removingThisLayer(); |
||
1377 | } |
||
1378 | } |
||
1379 | } |
||
1380 | |||
1381 | 214 | fernando | } |