http://www.jpicedt.org

jpicedt.graphic
Class AbstractSelectionHandler

java.lang.Object
  extended by jpicedt.graphic.AbstractSelectionHandler
All Implemented Interfaces:
SelectionHandler

public abstract class AbstractSelectionHandler
extends Object
implements SelectionHandler

Provides some basic implementation of the SelectionHandler interface. This implementation merely targets methods that can access or modify the content of the SelectionHandler via the asCollection() method, hence the latter method is left unimplemented here.
Besides, no storage mechanism is implemented in this abstract class. Concrete implementation of this mechanism should be based on mutable Java Collection's, otherwise selection operation will fail.
Finally, the content of the selection-handler is supposed to reflect the z-ordering of the Drawing it is associated with. This abstract implementation does not take care of this.

Since:
jpicedt 1.3.2
Version:
$Id: AbstractSelectionHandler.java,v 1.5.2.1 2007/09/02 11:56:15 reynal Exp $
Author:
Sylvain Reynal

Constructor Summary
AbstractSelectionHandler()
           
 
Method Summary
 void addToSelection(Element e)
          Add the given Element to the current selection.
 Element[] asArray()
          Return the selected elements wrapped in an array.
abstract  Collection asCollection()
          Return the selected elements wrapped in a Collection
 void delete(Drawing d)
          Delete all selected Element's from the given Drawing, and remove the reference to them from this SelectionHandler.
 Iterator elements()
          Return an iterator over the selected Element's.
 boolean isSelected(Element e, boolean includeAncestors)
          Return whether the given Element is selected or not.
 void replaceSelection(Element e)
          Replace the current selection with the given element.
 void selectAll(Drawing d)
          Select all Element's in the given drawing.
 int size()
          Return the number of selected objects.
 void unSelect(Element e)
          Unselect the given Element, i.e.
 void unSelectAll()
          Unselect all Element's in the given drawing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jpicedt.graphic.SelectionHandler
containsClass, createFilteredCollection
 

Constructor Detail

AbstractSelectionHandler

public AbstractSelectionHandler()
Method Detail

size

public int size()
Return the number of selected objects. Convenience call to asCollection().

Specified by:
size in interface SelectionHandler

elements

public Iterator elements()
Return an iterator over the selected Element's. Convenience call to asCollection().

Specified by:
elements in interface SelectionHandler

asCollection

public abstract Collection asCollection()
Return the selected elements wrapped in a Collection

Specified by:
asCollection in interface SelectionHandler

asArray

public Element[] asArray()
Return the selected elements wrapped in an array. Convenience call to asCollection().

Specified by:
asArray in interface SelectionHandler

isSelected

public boolean isSelected(Element e,
                          boolean includeAncestors)
Return whether the given Element is selected or not. Convenience call to asCollection().

Specified by:
isSelected in interface SelectionHandler
Parameters:
includeAncestors - if true, return true if this Element or one of its ancestors is selected.

selectAll

public void selectAll(Drawing d)
Select all Element's in the given drawing.

Specified by:
selectAll in interface SelectionHandler

unSelectAll

public void unSelectAll()
Unselect all Element's in the given drawing. Convenience call to asCollection().

Specified by:
unSelectAll in interface SelectionHandler

addToSelection

public void addToSelection(Element e)
Add the given Element to the current selection. Convenience call to asCollection().

Specified by:
addToSelection in interface SelectionHandler

replaceSelection

public void replaceSelection(Element e)
Replace the current selection with the given element.

Specified by:
replaceSelection in interface SelectionHandler

unSelect

public void unSelect(Element e)
Unselect the given Element, i.e. remove it from the current selection. Convenience call to asCollection().

Specified by:
unSelect in interface SelectionHandler

delete

public void delete(Drawing d)
Delete all selected Element's from the given Drawing, and remove the reference to them from this SelectionHandler.

Specified by:
delete in interface SelectionHandler

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org