diva.canvas.interactor
Class BasicSelectionModel

java.lang.Object
  extended by diva.canvas.interactor.BasicSelectionModel
All Implemented Interfaces:
SelectionModel

public class BasicSelectionModel
extends Object
implements SelectionModel

A basic implementation of the SelectionModel interface. This model requires that each object in the selection be an instance of Figure. When each item is added to the selection, the model gets its interactor, and if it is an instance of SelectionInteractor, gets a selection renderer from the interactor and uses it to highlight the selected figures.

Version:
$Revision: 1.16 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu)

Field Summary
 
Fields inherited from interface diva.canvas.interactor.SelectionModel
MULTIPLE_SELECTION, SINGLE_SELECTION
 
Constructor Summary
BasicSelectionModel()
          Construct an empty selection.
 
Method Summary
 void addSelection(Object sel)
          Add an object to the selection.
 void addSelectionListener(SelectionListener l)
          Add a selection listener to this model.
 void addSelections(Object[] sels)
          Add an array of objects to the selection and highlight the selected objects.
 void clearSelection()
          Clear the selection.
 boolean containsSelection(Object sel)
          Test if the selection contains the given object
 void dispatchSelectionEvent(SelectionEvent e)
          Dispatch a selection event to all registered listeners
 Object getFirstSelection()
          Return the first selection in the list.
 Object getLastSelection()
          Return the last selection in the list.
 Iterator getSelection()
          Return an iterator over the selected objects.
 Object[] getSelectionAsArray()
          Return the contents of the selection as an array.
 int getSelectionCount()
          Return the number of selected objects.
 int getSelectionMode()
          Return the mode of the selection, either SINGLE_SELECTION or MULTIPLE_SELECTION.
 void removeSelection(Object sel)
          Remove an object from the selection.
 void removeSelectionListener(SelectionListener l)
          Remove a listener from the list of listeners.
 void setSelectionMode(int mode)
          Set the selection mode, either SINGLE_SELECTION or MULTIPLE_SELECTION.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicSelectionModel

public BasicSelectionModel()
Construct an empty selection.

Method Detail

addSelectionListener

public void addSelectionListener(SelectionListener l)
Add a selection listener to this model.

Specified by:
addSelectionListener in interface SelectionModel

addSelection

public void addSelection(Object sel)
Add an object to the selection. The model highlights the selection. If the given object is null, then it is not added to the selection, but if the selection model is a single selection, the current selection is cleared.

Specified by:
addSelection in interface SelectionModel

addSelections

public void addSelections(Object[] sels)
Add an array of objects to the selection and highlight the selected objects.

Specified by:
addSelections in interface SelectionModel

clearSelection

public void clearSelection()
Clear the selection. The model should remove highlighting from the previously selected objects.

Specified by:
clearSelection in interface SelectionModel

containsSelection

public boolean containsSelection(Object sel)
Test if the selection contains the given object

Specified by:
containsSelection in interface SelectionModel

dispatchSelectionEvent

public void dispatchSelectionEvent(SelectionEvent e)
Dispatch a selection event to all registered listeners


getFirstSelection

public Object getFirstSelection()
Return the first selection in the list.

Specified by:
getFirstSelection in interface SelectionModel

getLastSelection

public Object getLastSelection()
Return the last selection in the list.

Specified by:
getLastSelection in interface SelectionModel

getSelection

public Iterator getSelection()
Return an iterator over the selected objects.

Specified by:
getSelection in interface SelectionModel

getSelectionAsArray

public Object[] getSelectionAsArray()
Return the contents of the selection as an array. This method is typically used by clients that need to pass the selection contents to another object that does not know about selection models, and which needs to traverse the selection contents multiple times.

Specified by:
getSelectionAsArray in interface SelectionModel

getSelectionCount

public int getSelectionCount()
Return the number of selected objects.

Specified by:
getSelectionCount in interface SelectionModel

getSelectionMode

public int getSelectionMode()
Return the mode of the selection, either SINGLE_SELECTION or MULTIPLE_SELECTION.

Specified by:
getSelectionMode in interface SelectionModel

removeSelection

public void removeSelection(Object sel)
Remove an object from the selection.

Specified by:
removeSelection in interface SelectionModel

removeSelectionListener

public void removeSelectionListener(SelectionListener l)
Remove a listener from the list of listeners.

Specified by:
removeSelectionListener in interface SelectionModel

setSelectionMode

public void setSelectionMode(int mode)
Set the selection mode, either SINGLE_SELECTION or MULTIPLE_SELECTION.

Specified by:
setSelectionMode in interface SelectionModel


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.