Class Layer
- Object
- 
- 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 SummaryFields Modifier and Type Field Description protected CopyOnWriteArrayList<MapLayerListener>listenerListListeners to be notified when layer contents change.protected static LoggerLOGGERThe logger for the map module.protected booleanselectedFlag to mark the layer as selected (for general use by clients)protected StringtitleHuman readable title for the layer.protected Map<String,Object>userDataMap of application supplied information.protected booleanvisibleFlag to mark the layer as visible when being rendered
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedLayer()Layer creation; please use a concrete subclass to work with specific content.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddMapLayerListener(MapLayerListener listener)The listener is notified when the layer information changes; or when the contents of the layer changes.protected voidconnectDataListener(boolean listen)Called in an interactive environment where a Layer is expected to listen to the data source on behalf of the application.voiddispose()Allows a Layer to clean up any listeners, or internal caches or resources it has added during use.protected voidfinalize()protected voidfireMapLayerListenerLayerChanged(int eventType)Notifies all registered listeners about the event.protected voidfireMapLayerListenerLayerDeselected()Notifies all registered listeners about the deselection event.protected voidfireMapLayerListenerLayerHidden()Notifies all registered listeners about the event.protected voidfireMapLayerListenerLayerPreDispose()Notifies all registered listeners that the layer is scheduled to be disposed.protected voidfireMapLayerListenerLayerSelected()Notifies all registered listeners about the selection event.protected voidfireMapLayerListenerLayerShown()Notifies all registered listeners about the event.abstract ReferencedEnvelopegetBounds()The bounds of the Layer content (if known).FeatureSource<?,?>getFeatureSource()Used to access the feature collection for this layer; if available.QuerygetQuery()The definition query (including filter) for this layer, orQuery.ALLif no definition query has been provided by the user.StylegetStyle()Get the style for this layer.StringgetTitle()Get the title of this layer.Map<String,Object>getUserData()Application supplied information; may be used as a scatch pad for information such selection.booleanisSelected()Determines whether this layer is selected.booleanisVisible()Determines whether this layer is visible or hidden.voidpreDispose()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.voidremoveMapLayerListener(MapLayerListener listener)Removes a listener from the listener list for this layer.voidsetSelected(boolean selected)Sets layer selection status.voidsetTitle(String title)Set the title of this layer.voidsetVisible(boolean visible)Sets whether the layer is to be shown or hidden when rendering.StringtoString()
 
- 
- 
- 
Field Detail- 
LOGGERprotected static final Logger LOGGER The logger for the map module.
 - 
titleprotected String title Human readable title for the layer.
 - 
visibleprotected boolean visible Flag to mark the layer as visible when being rendered
 - 
selectedprotected boolean selected Flag to mark the layer as selected (for general use by clients)
 - 
listenerListprotected CopyOnWriteArrayList<MapLayerListener> listenerList Listeners to be notified when layer contents change.
 
- 
 - 
Method Detail- 
fireMapLayerListenerLayerChangedprotected void fireMapLayerListenerLayerChanged(int eventType) Notifies all registered listeners about the event.- Parameters:
- eventType- The event to be fired
 
 - 
fireMapLayerListenerLayerShownprotected void fireMapLayerListenerLayerShown() Notifies all registered listeners about the event.
 - 
fireMapLayerListenerLayerHiddenprotected void fireMapLayerListenerLayerHidden() Notifies all registered listeners about the event.
 - 
fireMapLayerListenerLayerSelectedprotected void fireMapLayerListenerLayerSelected() Notifies all registered listeners about the selection event.
 - 
fireMapLayerListenerLayerDeselectedprotected void fireMapLayerListenerLayerDeselected() Notifies all registered listeners about the deselection event.
 - 
fireMapLayerListenerLayerPreDisposeprotected void fireMapLayerListenerLayerPreDispose() Notifies all registered listeners that the layer is scheduled to be disposed.
 - 
finalizeprotected void finalize() throws Throwable
 - 
preDisposepublic 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.
 - 
disposepublic void dispose() Allows a Layer to clean up any listeners, or internal caches or resources it has added during use.
 - 
getTitlepublic 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.
 
 - 
setTitlepublic 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.
 
 - 
isVisiblepublic boolean isVisible() Determines whether this layer is visible or hidden.- Returns:
- trueif the layer is visible, or- falseif hidden
 
 - 
setVisiblepublic void setVisible(boolean visible) Sets whether the layer is to be shown or hidden when rendering.LayerEventis fired if the visibility changed.- Parameters:
- visible-- trueto show the layer;- falseto hide it
 
 - 
isSelectedpublic boolean isSelected() Determines whether this layer is selected. Selection status can be used by clients such asJMapPanefor selective processing of layers.- Returns:
- trueif the layer is selected, or- falseotherwise
 
 - 
setSelectedpublic void setSelected(boolean selected) Sets layer selection status. This can be used by clients such asJMapPanefor selective processing of layers.- Parameters:
- selected- new selection status.
 
 - 
getUserDatapublic 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
 
 - 
getBoundspublic 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
 
 - 
addMapLayerListenerpublic 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.
 
 - 
removeMapLayerListenerpublic void removeMapLayerListener(MapLayerListener listener) Removes a listener from the listener list for this layer.- Parameters:
- listener- The listener to remove from the listener list.
 
 - 
connectDataListenerprotected 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
 
 - 
getStylepublic 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).
 
 - 
getFeatureSourcepublic 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.
 
 - 
getQuerypublic Query getQuery() The definition query (including filter) for this layer, orQuery.ALLif 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
 
 
- 
 
-