org.geotools.map
Class FeatureLayer

Object
  extended by Layer
      extended by StyleLayer
          extended by FeatureLayer

public class FeatureLayer
extends StyleLayer

Layer responsible for rendering vector information provided by a FeatureSource.

The FeatureLayer combines:

Please note that a StyleLayerDescriptor (defined by SLD) document is usually used to describe the rendering requirements for an entire Map; while a Style (defined by SE) is focused on a single layer of content

Since:
2.7

Field Summary
protected  FeatureSource<? extends FeatureType,? extends Feature> featureSource
          FeatureSource offering content for display
protected  Query query
          Query use to limit content of featureSource
protected  FeatureListener sourceListener
          Listener to forward feature source events as layer events
 
Fields inherited from class StyleLayer
style
 
Fields inherited from class Layer
listenerList, LOGGER, selected, title, userData, visible
 
Constructor Summary
FeatureLayer(FeatureCollection collection, Style style)
           
FeatureLayer(FeatureCollection collection, Style style, String title)
           
FeatureLayer(FeatureSource featureSource, Style style)
          Creates a new instance of FeatureLayer
FeatureLayer(FeatureSource featureSource, Style style, String title)
           
 
Method Summary
protected  void connectDataListener(boolean listen)
          Used to connect/disconnect a FeatureListener if any map layer listeners are registered.
 void dispose()
          Allows a Layer to clean up any listeners, or internal caches or resources it has added during use.
 ReferencedEnvelope getBounds()
          The bounds of the Layer content (if known).
 FeatureSource<?,?> getFeatureSource()
          Get the feature source for this layer.
 Query getQuery()
          Returns the definition query (filter) for this layer.
 SimpleFeatureSource getSimpleFeatureSource()
          Get the feature source for this layer.
 void setQuery(Query query)
          Sets a definition query for the layer which acts as a filter for the features that the layer will draw.
 
Methods inherited from class StyleLayer
getStyle, setStyle
 
Methods inherited from class Layer
addMapLayerListener, finalize, fireMapLayerListenerLayerChanged, fireMapLayerListenerLayerDeselected, fireMapLayerListenerLayerHidden, fireMapLayerListenerLayerPreDispose, fireMapLayerListenerLayerSelected, fireMapLayerListenerLayerShown, getTitle, getUserData, isSelected, isVisible, preDispose, removeMapLayerListener, setSelected, setTitle, setVisible, toString
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

featureSource

protected FeatureSource<? extends FeatureType,? extends Feature> featureSource
FeatureSource offering content for display


query

protected Query query
Query use to limit content of featureSource


sourceListener

protected FeatureListener sourceListener
Listener to forward feature source events as layer events

Constructor Detail

FeatureLayer

public FeatureLayer(FeatureSource featureSource,
                    Style style)
Creates a new instance of FeatureLayer

Parameters:
featureSource - the data source for this layer
style - the style used to represent this layer

FeatureLayer

public FeatureLayer(FeatureSource featureSource,
                    Style style,
                    String title)

FeatureLayer

public FeatureLayer(FeatureCollection collection,
                    Style style)

FeatureLayer

public FeatureLayer(FeatureCollection collection,
                    Style style,
                    String title)
Method Detail

connectDataListener

protected void connectDataListener(boolean listen)
Used to connect/disconnect a FeatureListener if any map layer listeners are registered.

Overrides:
connectDataListener in class Layer
Parameters:
listen - true to connect, false to disconnect

dispose

public void dispose()
Description copied from class: Layer
Allows a Layer to clean up any listeners, or internal caches or resources it has added during use.

Overrides:
dispose in class StyleLayer

getFeatureSource

public FeatureSource<?,?> getFeatureSource()
Get the feature source for this layer.

Overrides:
getFeatureSource in class Layer
Returns:
feature source for the contents of this layer

getSimpleFeatureSource

public SimpleFeatureSource getSimpleFeatureSource()
Get the feature source for this layer.

Returns:
SimpleFeatureSource for this layer, or null if not available

getQuery

public Query getQuery()
Returns the definition query (filter) for this layer. If no definition query has been defined Query.ALL is returned.

Overrides:
getQuery in class Layer
Returns:
Query used to process content prior to display, or Query.ALL to indicate all content is used

setQuery

public void setQuery(Query query)
Sets a definition query for the layer which acts as a filter for the features that the layer will draw.

A consumer must ensure that this query is used in combination with the bounding box filter generated on each map interaction to limit the number of features returned to those that complains both the definition query and relies inside the area of interest.

IMPORTANT: only include attribute names in the query if you want them to be ALWAYS returned. It is desirable to not include attributes at all but let the layer user (a renderer?) to decide wich attributes are actually needed to perform its requiered operation.

Parameters:
query -

getBounds

public ReferencedEnvelope getBounds()
Description copied from class: Layer
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.

Specified by:
getBounds in class Layer
Returns:
layer bounds, null if unknown


Copyright © 1996-2014 Geotools. All Rights Reserved.