/** * Adds a layer if it is not already present. * * @param element the layer to add * @return {@code true} if the layer was added; {@code false} if it was already present in * this list */ @Override public boolean addIfAbsent(Layer element) { boolean added = super.addIfAbsent(element); if (added) { if (layerListener != null) { element.addMapLayerListener(layerListener); } checkViewportCRS(); fireLayerAdded(element, size() - 1, size() - 1); } return added; }
/** * Removes any layers from this list that are not contained in the input collection. * * @param layers the layers which should not be removed * @return {@code true} if any layers were removed; {@code false} otherwise */ @Override public boolean retainAll(Collection<?> layers) { for (Layer element : this) { if (!layers.contains(element)) { if (layerListener != null) { element.removeMapLayerListener(layerListener); } element.dispose(); } } boolean removed = super.retainAll(layers); if (removed) { fireLayerRemoved(null, 0, size() - 1); } return removed; }
/** * Adds a layer if it is not already present. * * @param element the layer to add * @return {@code true} if the layer was added; {@code false} if * it was already present in this list */ @Override public boolean addIfAbsent(Layer element) { boolean added = super.addIfAbsent(element); if (added) { if (layerListener != null) { element.addMapLayerListener(layerListener); } checkViewportCRS(); fireLayerAdded(element, size() - 1, size() - 1); } return added; }
fireLayerAdded(null, index, size() - 1);
/** * Removes any layers from this list that are not contained in the * input collection. * * @param layers the layers which should not be removed * @return {@code true} if any layers were removed; {@code false} otherwise */ @Override public boolean retainAll(Collection<?> layers) { for (Layer element : this) { if (!layers.contains(element)) { if (layerListener != null) { element.removeMapLayerListener(layerListener); } element.dispose(); } } boolean removed = super.retainAll(layers); if (removed) { fireLayerRemoved(null, 0, size() - 1); } return removed; }
/** * Removes all layers in the input collection from this list, if present. * * @param layers the candidate layers to remove * @return {@code true} if any layers were removed; {@code false} otherwise */ @Override public boolean removeAll(Collection<?> layers) { for (Object obj : layers) { Layer element = (Layer) obj; if (!contains(element)) { continue; } if (layerListener != null) { element.removeMapLayerListener(layerListener); } element.dispose(); } boolean removed = super.removeAll(layers); fireLayerRemoved(null, 0, size() - 1); return removed; }
/** * Adds all layers from the input collection that are not already * present in this list. * * @param layers candidate layers to add * @return the number of layers added */ @Override public int addAllAbsent(Collection<? extends Layer> layers) { int start = size(); int added = super.addAllAbsent(layers); if (added > 0) { if (layerListener != null) { for (int i = start; i < size(); i++) { get(i).addMapLayerListener(layerListener); } } checkViewportCRS(); fireLayerAdded(null, start, size() - 1); } return added; }
/** * Adds all layers from the input collection that are not already present in this list, with * the first added layer taking position {@code index}. * * @param index position of the first added layer in this list * @param layers candidate layers to add * @return {@code true} if any layers were added; {@code false} otherwise */ @Override public boolean addAll(int index, Collection<? extends Layer> layers) { boolean added = false; int pos = index; for (Layer layer : layers) { if (!contains(layer)) { add(pos, layer); if (layerListener != null) { layer.addMapLayerListener(layerListener); } added = true; pos++; } } if (added) { checkViewportCRS(); fireLayerAdded(null, index, size() - 1); } return added; }
/** * Removes all layers in the input collection from this list, if present. * * @param layers the candidate layers to remove * @return {@code true} if any layers were removed; {@code false} otherwise */ @Override public boolean removeAll(Collection<?> layers) { for (Object obj : layers) { Layer element = (Layer) obj; if (!contains(element)) { continue; } if (layerListener != null) { element.removeMapLayerListener(layerListener); } element.dispose(); } boolean removed = super.removeAll(layers); fireLayerRemoved(null, 0, size() - 1); return removed; }
/** * Adds all layers from the input collection that are not already present in this list. * * @param layers candidate layers to add * @return the number of layers added */ @Override public int addAllAbsent(Collection<? extends Layer> layers) { int start = size(); int added = super.addAllAbsent(layers); if (added > 0) { if (layerListener != null) { for (int i = start; i < size(); i++) { get(i).addMapLayerListener(layerListener); } } checkViewportCRS(); fireLayerAdded(null, start, size() - 1); } return added; }