org.concord.biologica.ui
Class SelectionSet

java.lang.Object
  |
  +--org.concord.biologica.ui.SelectionSet
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener

public final class SelectionSet
extends java.lang.Object
implements java.beans.PropertyChangeListener

A selection set, an object which manages a set of selected engine objects, notifies listeners that the selection set has changed, etc. A script may create a selection set and then assign it to one or more views. Those views will then reflect the state of the selection set in that the correct object(s) will be selected, etc.

An object of this class will generate the following property change events:

Version:
$Revision: 1.1.1.1 $ $Date: 2001/04/28 00:39:20 $
Author:
$Author: ed $
See Also:
UIProp.SELECTED_OBJECTS, PropertyChangeListener

Field Summary
protected  java.beans.PropertyChangeSupport changes
          Utility object which manages property change events and listeners.
static int SELECTION_MODE_MULTIPLE_OBJECTS
          Normal, multiple object selection mode.
static int SELECTION_MODE_ONE_OBJECT
          Single objects selection mode.
static int SELECTION_MODE_TWO_OBJECTS
          Two object selection mode.
static int SELECTION_MODE_TWO_ORGANISMS_OPPOSITE_SEXES
          Two organism, mixed gender selection mode.
static int SELECTION_MODE_ZERO_OBJECTS
          Zero objects selection mode.
 
Constructor Summary
SelectionSet()
          Creates a new, empty selection set.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener aListener)
          Add a property change listener for properties.
 void addSelectionPresenter(SelectionPresenter aSelectionPresenter)
          Add a selection presenter
 boolean contains(EngineObject anObject)
          Returns whether or not this selection set contains the given object.
 void deselectAllObjects()
          Deselect all objects
 void deselectObject(EngineObject anObject)
          Deselect the given object.
static SelectionSet getDefaultSelectionSet()
          Get default selection set
 int getNumberOfSelectedObjects()
          Get the number of selected objects in this view.
 EngineObject getSelectedObjectAtIndex(int index)
          Get the selected object at the given index in the selection set.
 java.util.Enumeration getSelectedObjects()
          Get the set of selected objects in this view.
 int getSelectionMode()
          Get the current selection mode.
 java.util.Enumeration getSelectionPresenters()
          Get the selection presenters
 void propertyChange(java.beans.PropertyChangeEvent event)
          Handle property change events
 void removePropertyChangeListener(java.beans.PropertyChangeListener aListener)
          Remove a property change listener for properties.
 boolean removeSelectionPresenter(SelectionPresenter aSelectionPresenter)
          Remove a selection presenter
 void selectObject(EngineObject anObject, boolean aShiftDown, boolean aControlDown)
          Select an object.
static void setDefaultSelectionSet(SelectionSet selectionSet)
          Set default selection set
 void setSelectionMode(int aSelectionMode)
          Set the current selection mode.
 void updatePresenters()
          Update the selection presenters because the selection changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTION_MODE_ZERO_OBJECTS

public static final int SELECTION_MODE_ZERO_OBJECTS
Zero objects selection mode. When this is the current selection mode, no objects may be selected.


SELECTION_MODE_ONE_OBJECT

public static final int SELECTION_MODE_ONE_OBJECT
Single objects selection mode. When this is the current selection mode, a maximum of one object may be selected at any time. So extend selection and multiple selections do not work.


SELECTION_MODE_TWO_OBJECTS

public static final int SELECTION_MODE_TWO_OBJECTS
Two object selection mode. When this is the current selection mode, a maximum of two objects may be selected at any time. Selecting a new object deselects the oldest-selected object. Extend selection and multiple selection works to a maximum of 2 objects selected.


SELECTION_MODE_TWO_ORGANISMS_OPPOSITE_SEXES

public static final int SELECTION_MODE_TWO_ORGANISMS_OPPOSITE_SEXES
Two organism, mixed gender selection mode. When this is the current selection mode, two organisms may be selected and they must be of opposite sexes. So selecting a male organism deselects the previously selected male organism. Ditto for female organisms. Extend selection and multiple selection works to a maximum of 2 opposite gender organisms selected.


SELECTION_MODE_MULTIPLE_OBJECTS

public static final int SELECTION_MODE_MULTIPLE_OBJECTS
Normal, multiple object selection mode. When this is the current selection mode, single and multiple objects may be selected, extend selection works, etc. This is the default selection mode.


changes

protected transient java.beans.PropertyChangeSupport changes
Utility object which manages property change events and listeners. Needed here since we don't inherit from UIView.
Constructor Detail

SelectionSet

public SelectionSet()
Creates a new, empty selection set.
Method Detail

getDefaultSelectionSet

public static SelectionSet getDefaultSelectionSet()
Get default selection set
Returns:
SelectionSet - default selection set

setDefaultSelectionSet

public static void setDefaultSelectionSet(SelectionSet selectionSet)
Set default selection set
Parameters:
selectionSet - SelectionSet - new default selection set

selectObject

public void selectObject(EngineObject anObject,
                         boolean aShiftDown,
                         boolean aControlDown)
Select an object.

If extendSelect is false, then all other organisms will be deselected first.

If anOrganism is null and extendSelect is true, then do nothing.

If anOrganism is null and extendSelect is false, deselect everything.

If anOrganism is not null but the organism is not in this view, then this method will return without doing anything.

Parameters:
anObject - EngineObject - an object to select, may be null
aShiftDown - boolean - shift key down
aControlDown - boolean - control key down
Throws:
java.lang.IllegalArgumentException - - input organism not already in view

deselectObject

public void deselectObject(EngineObject anObject)
Deselect the given object.
Parameters:
anObject - EngineObject - an object to deselect, may be null

deselectAllObjects

public void deselectAllObjects()
Deselect all objects

updatePresenters

public void updatePresenters()
Update the selection presenters because the selection changed. If aSelectionPresenter is non-null, then that selection presenter will not be updated. Usually this is because that presenter called the selection set originally and already knows it must update itself.


getNumberOfSelectedObjects

public int getNumberOfSelectedObjects()
Get the number of selected objects in this view.
Returns:
int - number of selected objects in this view (0 or greater)

getSelectedObjects

public java.util.Enumeration getSelectedObjects()
Get the set of selected objects in this view.
Returns:
Enumeration - enumeration over the set of selected objects in this view

getSelectedObjectAtIndex

public EngineObject getSelectedObjectAtIndex(int index)
Get the selected object at the given index in the selection set. Return null if the index is bad.
Parameters:
index - int - selected object index (zero based)
Returns:
EngineObject - selected engine object

contains

public boolean contains(EngineObject anObject)
Returns whether or not this selection set contains the given object.

Parameters:
boolean - - returns true of object in selected set, else false

getSelectionMode

public int getSelectionMode()
Get the current selection mode.
Returns:
int - current selection mode

setSelectionMode

public void setSelectionMode(int aSelectionMode)
Set the current selection mode.
Parameters:
aSelectionMode - int - a new selection mode

getSelectionPresenters

public java.util.Enumeration getSelectionPresenters()
Get the selection presenters
Parameters:
Enumeration - of SelectionPresenter objects

addSelectionPresenter

public void addSelectionPresenter(SelectionPresenter aSelectionPresenter)
Add a selection presenter
Parameters:
aSelectionPresenter - SelectionPresenter - a selection presenter

removeSelectionPresenter

public boolean removeSelectionPresenter(SelectionPresenter aSelectionPresenter)
Remove a selection presenter
Parameters:
aSelectionPresenter - SelectionPresenter - a selection presenter

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Handle property change events
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - PropertyChangeEvent - the property change event

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener aListener)
Add a property change listener for properties.
Parameters:
aListener - PropertyChangeListener - a new listener

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener aListener)
Remove a property change listener for properties.
Parameters:
aListener - PropertyChangeListener - a listener to remove