Class LayerManager

  • Direct Known Subclasses:
    MainLayerManager

    public class LayerManager
    extends java.lang.Object
    This class handles the layer management.

    This manager handles a list of layers with the first layer being the front layer.

    Threading

    Synchronization of the layer manager is done by synchronizing all read/write access. All changes are internally done in the EDT thread.

    Methods of this manager may be called from any thread in any order. Listeners are called while this layer manager is locked, so they should not block on other threads.

    Since:
    10273
    • Method Detail

      • addLayer

        public void addLayer​(Layer layer)
        Add a layer. The layer will be added at a given position and the mapview zoomed at its projection bounds.
        Parameters:
        layer - The layer to add
      • addLayer

        public void addLayer​(Layer layer,
                             boolean initialZoom)
        Add a layer. The layer will be added at a given position.
        Parameters:
        layer - The layer to add
        initialZoom - whether if the mapview must be zoomed at layer projection bounds
      • realAddLayer

        protected void realAddLayer​(Layer layer,
                                    boolean initialZoom)
        Add a layer (implementation).
        Parameters:
        layer - The layer to add
        initialZoom - whether if the mapview must be zoomed at layer projection bounds
      • removeLayer

        public void removeLayer​(Layer layer)
        Remove the layer from the mapview. If the layer was in the list before, an LayerChange event is fired.
        Parameters:
        layer - The layer to remove
      • realRemoveLayer

        protected void realRemoveLayer​(Layer layer)
        Remove the layer from the mapview (implementation).
        Parameters:
        layer - The layer to remove
      • realRemoveSingleLayer

        protected java.util.Collection<LayerrealRemoveSingleLayer​(Layer layerToRemove)
        Remove a single layer from the mapview (implementation).
        Parameters:
        layerToRemove - The layer to remove
        Returns:
        A list of layers that should be removed afterwards.
      • moveLayer

        public void moveLayer​(Layer layer,
                              int position)
        Move a layer to a new position.
        Parameters:
        layer - The layer to move.
        position - The position.
        Throws:
        java.lang.IndexOutOfBoundsException - if the position is out of bounds.
      • realMoveLayer

        protected void realMoveLayer​(Layer layer,
                                     int position)
        Move a layer to a new position (implementation).
        Parameters:
        layer - The layer to move.
        position - The position.
        Throws:
        java.lang.IndexOutOfBoundsException - if the position is out of bounds.
      • insertLayerAt

        private void insertLayerAt​(Layer layer,
                                   int position)
        Insert a layer at a given position.
        Parameters:
        layer - The layer to add.
        position - The position on which we should add it.
      • checkPosition

        private void checkPosition​(int position)
        Check if the (new) position is valid
        Parameters:
        position - The position index
        Throws:
        java.lang.IndexOutOfBoundsException - if it is not.
      • updateLayers

        private void updateLayers​(java.util.function.Consumer<java.util.List<Layer>> mutator)
        Update the layers field. This method should be used instead of a direct field access.
        Parameters:
        mutator - A method that gets the writable list of layers and should modify it.
      • getLayers

        public java.util.List<LayergetLayers()
        Gets an unmodifiable list of all layers that are currently in this manager. This list won't update once layers are added or removed.
        Returns:
        The list of layers.
      • getLayersOfType

        public <T extends Layer> java.util.List<T> getLayersOfType​(java.lang.Class<T> ofType)
        Replies an unmodifiable list of layers of a certain type.

        Example:

             List<WMSLayer> wmsLayers = getLayersOfType(WMSLayer.class);
         
        Type Parameters:
        T - The layer type
        Parameters:
        ofType - The layer type.
        Returns:
        an unmodifiable list of layers of a certain type.
      • containsLayer

        public boolean containsLayer​(Layer layer)
        replies true if the list of layers managed by this map view contain layer
        Parameters:
        layer - the layer
        Returns:
        true if the list of layers managed by this map view contain layer
      • checkContainsLayer

        protected void checkContainsLayer​(Layer layer)
        Checks if the specified layer is handled by this layer manager.
        Parameters:
        layer - layer to check
        Throws:
        java.lang.IllegalArgumentException - if layer is not handled by this layer manager
      • fireLayerRemoving

        private java.util.Collection<LayerfireLayerRemoving​(Layer layer)
        Fire the layer remove event
        Parameters:
        layer - The layer that was removed
        Returns:
        A list of layers that should be removed afterwards.
      • resetState

        public void resetState()
        Reset all layer manager state. This includes removing all layers and then unregistering all listeners
        Since:
        10432
      • realResetState

        protected void realResetState()
        Reset all layer manager state (implementation).