public abstract class Layer extends Object
Layers usually represent a single dataset; and arranged into a z-order by a Map for display.
Modifier and Type | Field and Description |
---|---|
protected CopyOnWriteArrayList<MapLayerListener> |
listenerList
Listeners to be notified when layer contents change.
|
protected static Logger |
LOGGER
The logger for the map module.
|
protected boolean |
selected
Flag to mark the layer as selected (for general use by clients)
|
protected String |
title
Human readable title for the layer.
|
protected Map<String,Object> |
userData
Map of application supplied information.
|
protected boolean |
visible
Flag to mark the layer as visible when being rendered
|
Modifier | Constructor and Description |
---|---|
protected |
Layer()
Layer creation; please use a concrete subclass to work with specific content.
|
Modifier and Type | Method and Description |
---|---|
void |
addMapLayerListener(MapLayerListener listener)
The listener is notified when the layer information changes; or when the contents of the
layer changes.
|
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.
|
void |
dispose()
Allows a Layer to clean up any listeners, or internal caches or resources it has added during
use.
|
protected void |
finalize() |
protected void |
fireMapLayerListenerLayerChanged(int eventType)
Notifies all registered listeners about the event.
|
protected void |
fireMapLayerListenerLayerDeselected()
Notifies all registered listeners about the deselection event.
|
protected void |
fireMapLayerListenerLayerHidden()
Notifies all registered listeners about the event.
|
protected void |
fireMapLayerListenerLayerPreDispose()
Notifies all registered listeners that the layer is scheduled to be disposed.
|
protected void |
fireMapLayerListenerLayerSelected()
Notifies all registered listeners about the selection event.
|
protected void |
fireMapLayerListenerLayerShown()
Notifies all registered listeners about the event.
|
abstract ReferencedEnvelope |
getBounds()
The bounds of the Layer content (if known).
|
FeatureSource<?,?> |
getFeatureSource()
Used to access the feature collection for this layer; if available.
|
Query |
getQuery()
The definition query (including filter) for this layer, or
Query.ALL if no definition
query has been provided by the user. |
Style |
getStyle()
Get the style for this layer.
|
String |
getTitle()
Get the title of this layer.
|
Map<String,Object> |
getUserData()
Application supplied information; may be used as a scatch pad for information such selection.
|
boolean |
isSelected()
Determines whether this layer is selected.
|
boolean |
isVisible()
Determines whether this layer is visible or hidden.
|
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.
|
void |
removeMapLayerListener(MapLayerListener listener)
Removes a listener from the listener list for this layer.
|
void |
setSelected(boolean selected)
Sets layer selection status.
|
void |
setTitle(String title)
Set the title of this layer.
|
void |
setVisible(boolean visible)
Sets whether the layer is to be shown or hidden when rendering.
|
String |
toString() |
protected static final Logger LOGGER
protected String title
protected boolean visible
protected boolean selected
protected CopyOnWriteArrayList<MapLayerListener> listenerList
protected Layer()
Note you should dispose() a layer after use.
protected void fireMapLayerListenerLayerChanged(int eventType)
event
- The event to be firedprotected void fireMapLayerListenerLayerShown()
event
- The event to be firedprotected void fireMapLayerListenerLayerHidden()
event
- The event to be firedprotected void fireMapLayerListenerLayerSelected()
event
- The event to be firedprotected void fireMapLayerListenerLayerDeselected()
event
- The event to be firedprotected void fireMapLayerListenerLayerPreDispose()
event
- The event to be firedprotected void finalize() throws Throwable
public void preDispose()
public void dispose()
public String getTitle()
public void setTitle(String title)
LayerEvent
is fired if the new title is different from
the previous one.title
- The title of this layer.public boolean isVisible()
true
if the layer is visible, or false
if hiddenpublic void setVisible(boolean visible)
LayerEvent
is fired
if the visibility changed.visible
- true
to show the layer; false
to hide itpublic boolean isSelected()
JMapPane
for selective processing of layers.true
if the layer is selected, or false
otherwisepublic void setSelected(boolean selected)
JMapPane
for
selective processing of layers.selected
- new selection status.public Map<String,Object> getUserData()
Example:
layer.getUserData().put("selectable", true)
public abstract ReferencedEnvelope getBounds()
The returned bounds are a ReferencedEnvelope using the same CoordinateReferenceSystem as the layers contents.
public void addMapLayerListener(MapLayerListener listener)
listener
- The listener to add to the listener list.public void removeMapLayerListener(MapLayerListener listener)
listener
- The listener to remove from the listener list.protected void connectDataListener(boolean listen)
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.
listen
- true to connect, false to disconnectpublic Style getStyle()
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.
public FeatureSource<?,?> getFeatureSource()
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).
public Query getQuery()
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 ); }
Query.ALL
, if set, returns a copy of the actual query object to avoid external
modificationCopyright © 1996–2019 Geotools. All rights reserved.