skrueger.geotools.selection
Class StyledLayerSelectionModel<E>

java.lang.Object
  extended by schmitzm.swing.event.PropertyChangeEmitter<StyledLayerSelectionModelSynchronizer<StyledLayerSelectionModel<E>>>
      extended by skrueger.geotools.selection.StyledLayerSelectionModel<E>
Direct Known Subclasses:
StyledFeatureLayerSelectionModel

public abstract class StyledLayerSelectionModel<E>
extends PropertyChangeEmitter<StyledLayerSelectionModelSynchronizer<StyledLayerSelectionModel<E>>>

This manager holds a set of objects which are selected for a StyledLayerInterface. Several components can connect to this model to keep their selection synchronized.

Author:
Martin Schmitz (University of Bonn/Germany)
See Also:
#addSelectionListener(java.beans.PropertyChangeListener), StyledLayerSelectionModelSynchronizer

Field Summary
protected  EventListenerList listenerList
          Holds the connected listeners.
protected  Logger LOGGER
          A static logger for this class
static String SELECTION
          Indicates that the selection has changed in PropertyChangeEvent.
protected  HashSet<E> selectionObjects
          Holds the current selection (e.g.
 
Fields inherited from class schmitzm.swing.event.PropertyChangeEmitter
eventFiringEnabled
 
Constructor Summary
StyledLayerSelectionModel(StyledLayerInterface<?> styledLayer)
          Creates a new selection model.
 
Method Summary
 boolean addSelection(Collection<E> selectedObjects)
          Extends the current selection by individual objects.
 boolean addSelection(E selectedObject)
          Extends the current selection by an individual object.
 void addSelectionListener(StyledLayerSelectionModelSynchronizer<StyledLayerSelectionModel<E>> listener)
          Adds a listener to the listener list.
 void clearSelection()
          Clears the selection and fires an event to every connected listener to update their selection.
 StyledLayerSelectionEvent createSelectionChangeEvent(Object respObject)
          Creates a simple PropertyChangeEvent for property SELECTION with no new and old value, just to inform the listeners THAT some selection has changed.
 Vector<E> getSelection()
          Returns all selected objects as list.
 StyledLayerInterface<?> getStyledLayer()
           
 boolean getValueIsAdjusting()
          Returns whether the current selection change is a part of multiple changes.
 void refreshSelection()
          Fires an event to every connected listener to update their selection according to the selection of this model.
 boolean removeSelection(Collection<E> unselectedObjects)
          Removes individual objects from the current selection.
 boolean removeSelection(E unselectedObject)
          Removes an individual object from the current selection.
 boolean removeSelectionListener(StyledLayerSelectionModelSynchronizer<StyledLayerSelectionModel<E>> listener)
          Removes a listener from the listener list.
 void setValueIsAdjusting(boolean valueIsAdjusting)
          Sets whether the following selection changes are part of multiple changes.
 
Methods inherited from class schmitzm.swing.event.PropertyChangeEmitter
addListener, firePropertyChangeEvent, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected final Logger LOGGER
A static logger for this class


SELECTION

public static final String SELECTION
Indicates that the selection has changed in PropertyChangeEvent.

See Also:
Constant Field Values

listenerList

protected EventListenerList listenerList
Holds the connected listeners.


selectionObjects

protected final HashSet<E> selectionObjects
Holds the current selection (e.g. Features).

Constructor Detail

StyledLayerSelectionModel

public StyledLayerSelectionModel(StyledLayerInterface<?> styledLayer)
Creates a new selection model.

Parameters:
styledLayer - styled layer the selection is controlled of
Method Detail

refreshSelection

public void refreshSelection()
Fires an event to every connected listener to update their selection according to the selection of this model.
Does nothing if adjusting is true.


clearSelection

public void clearSelection()
Clears the selection and fires an event to every connected listener to update their selection.


createSelectionChangeEvent

public StyledLayerSelectionEvent createSelectionChangeEvent(Object respObject)
Creates a simple PropertyChangeEvent for property SELECTION with no new and old value, just to inform the listeners THAT some selection has changed. Subclasses may overwrite this method to create more sophisticated events.

Parameters:
respObject - object which is responsible for the selection change; this object should ignore this event to avoid event circles (can be null in case of general refresh events; in this case all connected components will refresh their selection)

getValueIsAdjusting

public boolean getValueIsAdjusting()
Returns whether the current selection change is a part of multiple changes. If true refreshSelection() has no effect and no StyledLayerSelectionEvent is fired until setValueIsAdjusting(false) is called.


setValueIsAdjusting

public void setValueIsAdjusting(boolean valueIsAdjusting)
Sets whether the following selection changes are part of multiple changes. If true refreshSelection() has no effect and no StyledLayerSelectionEvent event is fired. If the value is set from true to false an automatic refresh is initiated.

See Also:
refreshSelection()

addSelection

public boolean addSelection(E selectedObject)
Extends the current selection by an individual object.

Parameters:
selectedObject - defines the (new) selected object
Returns:
true if selection has changed by calling this method

removeSelection

public boolean removeSelection(E unselectedObject)
Removes an individual object from the current selection.

Parameters:
unselectedObject - defines an object which will be unselected
Returns:
true if selection has changed by calling this method

addSelection

public boolean addSelection(Collection<E> selectedObjects)
Extends the current selection by individual objects.

Parameters:
selectedObjects - defines some objects which will be selected
Returns:
true if selection has changed by calling this method

removeSelection

public boolean removeSelection(Collection<E> unselectedObjects)
Removes individual objects from the current selection.

Parameters:
unselectedObjects - defines some objects which will be unselected
Returns:
true if selection has changed by calling this method

getSelection

public Vector<E> getSelection()
Returns all selected objects as list.

Returns:
a copy of the original list, so changes have no effect!

addSelectionListener

public void addSelectionListener(StyledLayerSelectionModelSynchronizer<StyledLayerSelectionModel<E>> listener)
Adds a listener to the listener list. Only alias for PropertyChangeEmitter.addListener(PropertyChangeListener).

Parameters:
listener - a listener

removeSelectionListener

public boolean removeSelectionListener(StyledLayerSelectionModelSynchronizer<StyledLayerSelectionModel<E>> listener)
Removes a listener from the listener list. Only alias for PropertyChangeEmitter.removeListener(PropertyChangeListener).

Parameters:
listener - a listener

getStyledLayer

public StyledLayerInterface<?> getStyledLayer()