Class Layer
- Direct Known Subclasses:
DirectLayer,StyleLayer
Layers usually represent a single dataset; and arranged into a z-order by a Map for display.
- Since:
- 2.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CopyOnWriteArrayList<MapLayerListener>Listeners to be notified when layer contents change.protected static final LoggerThe logger for the map module.protected booleanFlag to mark the layer as selected (for general use by clients)protected StringHuman readable title for the layer.Map of application supplied information.protected booleanFlag to mark the layer as visible when being rendered -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLayer()Layer creation; please use a concrete subclass to work with specific content. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMapLayerListener(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 voidNotifies all registered listeners about the deselection event.protected voidNotifies all registered listeners about the event.protected voidNotifies all registered listeners that the layer is scheduled to be disposed.protected voidNotifies all registered listeners about the selection event.protected voidNotifies all registered listeners about the event.abstract ReferencedEnvelopeThe bounds of the Layer content (if known).FeatureSource<?,?> Used to access the feature collection for this layer; if available.getQuery()The definition query (including filter) for this layer, orQuery.ALLif no definition query has been provided by the user.getStyle()Get the style for this layer.getTitle()Get the title of this layer.Application supplied information; may be used as a scatch pad for information such selection.booleanDetermines whether this layer is selected.booleanDetermines whether this layer is visible or hidden.voidAlerts 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.voidSet the title of this layer.voidsetVisible(boolean visible) Sets whether the layer is to be shown or hidden when rendering.toString()
-
Field Details
-
LOGGER
The logger for the map module. -
title
Human readable title for the layer. -
visible
protected boolean visibleFlag to mark the layer as visible when being rendered -
selected
protected boolean selectedFlag to mark the layer as selected (for general use by clients) -
userData
Map of application supplied information. -
listenerList
Listeners to be notified when layer contents change.
-
-
Constructor Details
-
Layer
protected Layer()Layer creation; please use a concrete subclass to work with specific content.Note you should dispose() a layer after use.
-
-
Method Details
-
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. -
finalize
-
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
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
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:
trueif the layer is visible, orfalseif hidden
-
setVisible
public 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
-
isSelected
public 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, orfalseotherwise
-
setSelected
public 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.
-
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
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
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
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
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
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
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
-
toString
-