@Override public void dispose() { // We assume that preDispose has been called by // the sub-class style = null; super.dispose(); }
@Override protected void finalize() throws Throwable { if (listenerList != null) { LOGGER.severe("Layer dispose not called; possible memory leak"); dispose(); } super.finalize(); }
/** Removes all layers from this list and calls their {@code dispose} methods. */ @Override public void clear() { for (Layer element : this) { if (layerListener != null) { element.removeMapLayerListener(layerListener); } element.dispose(); } super.clear(); fireLayerRemoved(null, -1, -1); }
/** * Removes the layer at position {@code index} from this list. Note: removing a layer causes * its {@code dispose} method to be called, so although a reference to the removed layer is * returned by this method it should not be used subsequently. * * @param index the position of the layer to be removed * @return the layer that was removed (will have been disposed) */ @Override public Layer remove(int index) { Layer removed = super.remove(index); fireLayerRemoved(removed, index, index); if (layerListener != null) { removed.removeMapLayerListener(layerListener); } removed.dispose(); return removed; }
/** * Removes the specified element, which much be a Layer, from this list if present. This * method calls the layer's {@code dispose} method, so any external references to the layer * should be discarded. * * @param element the element to remove * @return {@code true} if removed; {@code false} if not present in this list */ @Override public boolean remove(Object element) { boolean removed = super.remove(element); if (removed) { fireLayerRemoved((Layer) element, -1, -1); if (element instanceof Layer) { Layer layer = (Layer) element; if (layerListener != null) { layer.removeMapLayerListener(layerListener); } layer.dispose(); } } return removed; }
layer.dispose();
@Override public void dispose() { preDispose(); super.dispose(); disposed = true; }
/** * 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; }
@Override public void dispose() { // We assume that preDispose has been called by // the sub-class style = null; super.dispose(); }
@Override protected void finalize() throws Throwable { if (listenerList != null) { LOGGER.severe("Layer dispose not called; possible memory leak"); dispose(); } super.finalize(); }
/** * Removes all layers from this list and calls their {@code dispose} methods. */ @Override public void clear() { for (Layer element : this) { if (layerListener != null) { element.removeMapLayerListener(layerListener); } element.dispose(); } super.clear(); fireLayerRemoved(null, -1, -1); }
/** * Removes the layer at position {@code index} from this list. * Note: removing a layer causes its {@code dispose} method to be called, so * although a reference to the removed layer is returned by this method it * should not be used subsequently. * * @param index the position of the layer to be removed * @return the layer that was removed (will have been disposed) */ @Override public Layer remove(int index) { Layer removed = super.remove(index); fireLayerRemoved(removed, index, index); if (layerListener != null) { removed.removeMapLayerListener(layerListener); } removed.dispose(); return removed; }
/** * Removes the specified element, which much be a Layer, from this list * if present. This method calls the layer's {@code dispose} method, so any * external references to the layer should be discarded. * * @param element the element to remove * @return {@code true} if removed; {@code false} if not present in this list */ @Override public boolean remove(Object element) { boolean removed = super.remove(element); if (removed) { fireLayerRemoved((Layer) element, -1, -1); if (element instanceof Layer) { Layer layer = (Layer) element; if (layerListener != null) { layer.removeMapLayerListener(layerListener); } layer.dispose(); } } return removed; }
/** * 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; }