Class Layer

  • Direct Known Subclasses:
    DirectLayer, StyleLayer

    public abstract class Layer
    extends Object
    A Layer to be rendered.

    Layers usually represent a single dataset; and arranged into a z-order by a Map for display.

    Since:
    2.7
    • Field Detail

      • LOGGER

        protected static final Logger LOGGER
        The logger for the map module.
      • title

        protected String title
        Human readable title for the layer.
      • visible

        protected boolean visible
        Flag to mark the layer as visible when being rendered
      • selected

        protected boolean selected
        Flag to mark the layer as selected (for general use by clients)
      • userData

        protected Map<String,​Object> userData
        Map of application supplied information.
    • Constructor Detail

      • Layer

        protected Layer()
        Layer creation; please use a concrete subclass to work with specific content.

        Note you should dispose() a layer after use.

    • Method Detail

      • fireMapLayerListenerLayerChanged

        protected void fireMapLayerListenerLayerChanged​(int eventType)
        Notifies all registered listeners about the event.
        Parameters:
        eventType - The event to be fired
      • fireMapLayerListenerLayerShown

        protected void fireMapLayerListenerLayerShown()
        Notifies all registered listeners about the event.
      • fireMapLayerListenerLayerHidden

        protected void fireMapLayerListenerLayerHidden()
        Notifies all registered listeners about the event.
      • fireMapLayerListenerLayerSelected

        protected void fireMapLayerListenerLayerSelected()
        Notifies all registered listeners about the selection event.
      • fireMapLayerListenerLayerDeselected

        protected void fireMapLayerListenerLayerDeselected()
        Notifies all registered listeners about the deselection event.
      • fireMapLayerListenerLayerPreDispose

        protected void fireMapLayerListenerLayerPreDispose()
        Notifies all registered listeners that the layer is scheduled to be disposed.
      • preDispose

        public void preDispose()
        Alerts listeners that this layer has been scheduled to be disposed to give them a chance to finish or cancel any tasks using the layer.
      • dispose

        public void dispose()
        Allows a Layer to clean up any listeners, or internal caches or resources it has added during use.
      • getTitle

        public String getTitle()
        Get the title of this layer. If title has not been defined then an empty string is returned.
        Returns:
        The title of this layer.
      • setTitle

        public void setTitle​(String title)
        Set the title of this layer. A { LayerEvent} is fired if the new title is different from the previous one.
        Parameters:
        title - The title of this layer.
      • isVisible

        public boolean isVisible()
        Determines whether this layer is visible or hidden.
        Returns:
        true if the layer is visible, or false if hidden
      • setVisible

        public void setVisible​(boolean visible)
        Sets whether the layer is to be shown or hidden when rendering. LayerEvent is fired if the visibility changed.
        Parameters:
        visible - true to show the layer; false to hide it
      • isSelected

        public boolean isSelected()
        Determines whether this layer is selected. Selection status can be used by clients such as JMapPane for selective processing of layers.
        Returns:
        true if the layer is selected, or false otherwise
      • setSelected

        public void setSelected​(boolean selected)
        Sets layer selection status. This can be used by clients such as JMapPane for selective processing of layers.
        Parameters:
        selected - new selection status.
      • getUserData

        public Map<String,​Object> getUserData()
        Application supplied information; may be used as a scatch pad for information such selection.

        Example:

         layer.getUserData().put("selectable", true)
         
        Returns:
        Application parameters
      • getBounds

        public abstract ReferencedEnvelope getBounds()
        The bounds of the Layer content (if known). The bounds can be used to determine if any of the layers content is "on screen" when rendering the map; however often it is expensive to calculate a layers bounds up front so we are allowing this value to be optional.

        The returned bounds are a ReferencedEnvelope using the same CoordinateReferenceSystem as the layers contents.

        Returns:
        layer bounds, null if unknown
      • addMapLayerListener

        public void addMapLayerListener​(MapLayerListener listener)
        The listener is notified when the layer information changes; or when the contents of the layer changes. This is used by interactive map displays to detect when information is modified and needs to be redrawn.
        Parameters:
        listener - The listener to add to the listener list.
      • removeMapLayerListener

        public void removeMapLayerListener​(MapLayerListener listener)
        Removes a listener from the listener list for this layer.
        Parameters:
        listener - The listener to remove from the listener list.
      • connectDataListener

        protected void connectDataListener​(boolean listen)
        Called in an interactive environment where a Layer is expected to listen to the data source on behalf of the application.

        This method is called as needed by addMapListener and removeMapListener to allow subclasses to connect any data listeners required in order to issue fireMapLayerChanged events.

        Parameters:
        listen - true to connect, false to disconnect
      • getStyle

        public Style getStyle()
        Get the style for this layer. If style has not been set, then null is returned.

        This is an optional method that is used to support feature based rendering systems such as as KML.

        Please note that feature based renders can be very flexible; as an example raster content is asked to return the outline of each raster - in the event that the user has supplied a style drawing the raster as a Polygon outlines.

        Returns:
        The style (SLD).
      • getFeatureSource

        public FeatureSource<?,​?> getFeatureSource()
        Used to access the feature collection for this layer; if available.

        This is an optional method that is used to support feature based rendering systems such as as KML.

        Please note that feature based renders can be very flexible; as an example raster content is asked to return the outline of each raster - in the event that the user has supplied a style drawing the raster as a Polygon outlines.

        Override: Implementors should override this method to provide access to a feature representation of the layer contents if available. For DirectLayers displaying abstract concepts like a scale bar this may not be possible (however for some that display a grid this may in fact be possible).

        Returns:
        The features for this layer, or an an empty ArrayFeatureSource if not available.
      • getQuery

        public Query getQuery()
        The definition query (including filter) for this layer, or Query.ALL if no definition query has been provided by the user.

        This is an optional method that is used to support feature based rendering systems such as as KML.

        Please note that feature based renders can be very flexible; as an example raster content is asked to return the outline of each raster - in the event that the user has supplied a style drawing the raster as a Polygon outlines.

        Implementors should take care to return a copy of their internal Query to be safe from modificaiton:

         if( query == null || query == Query.ALL ){
             return Query.ALL;
         }
         else {
             return new Query( query );
         }
         

        Returns:
        the definition query established for this layer. If not set, just returns Query.ALL, if set, returns a copy of the actual query object to avoid external modification