Revision 37204 branches/dal_time_support/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/FLayers.java
FLayers.java | ||
---|---|---|
323 | 323 |
* |
324 | 324 |
* @param layerName the name of the layer to be replaced |
325 | 325 |
* @param layer the new layer |
326 |
* @deprecated use {@link FLayers#replaceLayer(FLayer, FLayer)} |
|
326 | 327 |
*/ |
327 | 328 |
public void replaceLayer(String layerName, FLayer layer) throws LoadLayerException |
328 | 329 |
{ |
329 |
FLayer lyr; |
|
330 |
FLayer parent; |
|
331 |
for (int i = 0; i < layers.size(); i++) { |
|
332 |
lyr = ((FLayer) layers.get(i)); |
|
333 |
|
|
334 |
if (lyr.getName().compareToIgnoreCase(layerName) == 0) { |
|
335 |
parent = lyr.getParentLayer(); |
|
336 |
removeLayer(i); |
|
337 |
if (parent != null) { |
|
338 |
//Notificamos a la capa que va a ser a?adida |
|
339 |
if (layer instanceof FLyrDefault) { |
|
340 |
((FLyrDefault)layer).wakeUp(); |
|
341 |
} |
|
342 |
} |
|
343 |
|
|
344 |
if (layer instanceof FLayers){ |
|
345 |
FLayers layers=(FLayers)layer; |
|
346 |
fmap.addAsCollectionListener(layers); |
|
347 |
} |
|
348 |
callLayerAdding(LayerCollectionEvent.createLayerAddingEvent(layer)); |
|
349 |
|
|
350 |
// layers.add(i,layer); |
|
351 |
// layer.setParentLayer(this); |
|
352 |
this.doAddLayer(i, layer); |
|
353 |
|
|
354 |
callLayerAdded(LayerCollectionEvent.createLayerAddedEvent(layer)); |
|
355 |
break; |
|
356 |
} |
|
357 |
} |
|
330 |
replaceLayer(getLayer(layerName), layer); |
|
358 | 331 |
} |
332 |
|
|
333 |
/** |
|
334 |
* Replace a layer by another layer. It search recursively by all the |
|
335 |
* ILayerCollection nodes |
|
336 |
* |
|
337 |
* @param layer |
|
338 |
* the layer to be replaced |
|
339 |
* @param newLayer |
|
340 |
* the new layer |
|
341 |
*/ |
|
342 |
public void replaceLayer(FLayer layer, FLayer newLayer) throws LoadLayerException |
|
343 |
{ |
|
344 |
replaceLayer(this, layer, newLayer); |
|
345 |
} |
|
346 |
|
|
347 |
/** |
|
348 |
* Replace a layer by other layer. It search recursively by all the |
|
349 |
* ILayerCollection nodes |
|
350 |
* @param parentLayer |
|
351 |
* the parent layer |
|
352 |
* @param layer |
|
353 |
* the layer to be replaced |
|
354 |
* @param newLayer |
|
355 |
* the new layer |
|
356 |
* @throws LoadLayerException |
|
357 |
*/ |
|
358 |
private void replaceLayer(FLayers parentLayer, FLayer layer, FLayer newLayer) throws LoadLayerException |
|
359 |
{ |
|
360 |
FLayer lyr; |
|
361 |
for (int i = 0; i < parentLayer.getLayersCount(); i++) { |
|
362 |
lyr = ((FLayer) parentLayer.getLayer(i)); |
|
363 |
if (lyr.equals(layer)) { |
|
364 |
parentLayer.removeLayer(i); |
|
365 |
parentLayer.addLayer(i, newLayer); |
|
366 |
break; |
|
367 |
} |
|
368 |
if (lyr instanceof LayerCollection){ |
|
369 |
replaceLayer((FLayers)lyr, layer, newLayer); |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
359 | 373 |
|
360 | 374 |
/* |
361 | 375 |
* (non-Javadoc) |
Also available in: Unified diff