/** * Splits up a layer group in order to get a layer by name when there are layer groups * * <p>In <code>result</code> always will be at least one layer. * * @param layer the layer we are looking for * @param result an array list that will have the results of the search */ private void splitLayerGroup(FLayer layer, ArrayList result) { int i; FLayers layerGroup; if (layer instanceof FLayers) { layerGroup = (FLayers) layer; for (i = 0; i < layerGroup.getLayersCount(); i++) { splitLayerGroup(layerGroup.getLayer(i), result); } } else { result.add(layer); } }
/* * (non-Javadoc) * @see com.iver.cit.gvsig.fmap.layers.layerOperations.LayerCollection#getLayer(java.lang.String) */ public FLayer getLayer(String layerName) { FLayer lyr; FLayer lyr2; ArrayList layerList; for (int i = 0; i < layers.size(); i++) { lyr = ((FLayer) layers.get(i)); if (lyr.getName().compareToIgnoreCase(layerName) == 0) { return lyr; } layerList = new ArrayList(); splitLayerGroup(lyr, layerList); for (int j = 0; j < layerList.size(); j++) { lyr2 = ((FLayer) layerList.get(j)); if (lyr2.getName().compareToIgnoreCase(layerName) == 0) { return lyr2; } } } return null; }