org.tigris.gef.base
Class SelectionManager

java.lang.Object
  extended by org.tigris.gef.base.SelectionManager
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.util.EventListener

public class SelectionManager
extends java.lang.Object
implements java.io.Serializable, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

This class handles Manager selections. It is basically a collection of Selection instances. Most of its operations just dispatch the same operation to each of the Selection instances in turn.

The SelectionManager is also responsible for sending out GraphSelectionEvents to any GraphSelectionListeners that are registered.

See Also:
Selection, Serialized Form

Field Summary
protected  Editor _editor
           
protected  javax.swing.event.EventListenerList _listeners
           
protected  java.util.Vector _selections
          The collection of Selection instances
 
Constructor Summary
SelectionManager(Editor ed)
           
 
Method Summary
protected  void addAllFigs(java.util.Collection c)
           
protected  void addEnclosed(java.util.Collection affected, Fig f)
           
protected  void addFig(Fig f)
           
 void addGraphSelectionListener(GraphSelectionListener listener)
           
protected  void addSelection(Selection s)
          Add a new selection to the collection of selections
 void addToSelection(Fig fig)
          Adds an additional fig to the current selection.
protected  void allDamaged()
           
 void cleanUp()
           
 boolean contains(int x, int y)
          Reply true iff the given point is inside one of the selected Fig's
 boolean contains(Selection s)
          Reply true if the given selection instance is part of my collection
 boolean containsFig(Fig f)
          Reply true if the given Fig is selected by any of my selection objects
 void damage()
          When the SelectionManager is damageAll, that implies that each Selection should be damageAll.
 void deleteFromModel()
          When a multiple selection are deleted, each selection is deleted
 void deselect(Fig f)
          Deselect the given Fig
 void deselectAll()
           
 void dispose()
          When a multiple selection are deleted, each selection is deleted
 void drag(int dx, int dy)
           
 void dragHandle(int mx, int my, int an_x, int an_y, Handle h)
          If only one thing is selected, then it is possible to mouse on one of its handles, but if Manager things are selected, users can only drag the objects around
 void endTrans()
          End a transaction that damages all selected Fig's
 java.lang.Class findCommonSuperClass()
          Determines and returns the first common superclass of all selected items.
 java.lang.Object findFirstSelectionOfType(java.lang.Class type)
          Searches for the first appearance of an object of the designated type in the current selection.
 Selection findSelectionAt(int x, int y)
           
 Selection findSelectionFor(Fig f)
           
protected  void fireSelectionChanged()
           
 java.awt.Rectangle getBounds()
           
 java.awt.Rectangle getContentBounds()
           
 java.awt.Point getDragLocation()
           
 java.util.Vector getFigs()
          Reply the collection of all selected Fig's
 java.awt.Point getLocation()
          This method will return the upper-left coordinate point of the entire selection by iterating through the figs
 boolean getLocked()
           
 boolean hit(java.awt.Rectangle r)
          Reply true iff the given point is inside one of the selected Fig's
 void hitHandle(java.awt.Rectangle r, Handle h)
          If only one thing is selected, then it is possible to mouse on one of its handles, but if Manager things are selected, users can only drag the objects around
 void keyPressed(java.awt.event.KeyEvent ke)
           
 void keyReleased(java.awt.event.KeyEvent ke)
           
 void keyTyped(java.awt.event.KeyEvent ke)
          When an event is passed to a multiple selection, try to pass it off to the first selection that will handle it.
static Selection makeSelectionFor(Fig f)
           
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseDragged(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mouseMoved(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.MouseEvent me)
           
 void paint(java.awt.Graphics g)
          Paint all selection objects
protected  void removeAllElements()
           
protected  void removeFig(Fig f)
           
 void removeFromGraph()
          When a multiple selection are deleted, each selection is deleted
 void removeGraphSelectionListener(GraphSelectionListener listener)
           
protected  void removeSelection(Selection s)
           
 void reorder(int func, Layer lay)
          When Manager selections are sent to back, each of them is sent to back.
 void select(java.util.Collection items)
           
 void select(Fig f)
           
 java.util.Vector selections()
           
 int size()
          Reply the number of selected Fig's.
 void startDrag()
           
 void stopDrag()
           
 void toggle(Fig f)
           
 void toggle(java.util.Vector items)
           
 void translate(int dx, int dy)
          When Manager selections are moved, each of them is moved
 void updatePropertySheet()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_selections

protected java.util.Vector _selections
The collection of Selection instances


_editor

protected Editor _editor

_listeners

protected javax.swing.event.EventListenerList _listeners
Constructor Detail

SelectionManager

public SelectionManager(Editor ed)
Method Detail

addSelection

protected void addSelection(Selection s)
Add a new selection to the collection of selections


addFig

protected void addFig(Fig f)

addAllFigs

protected void addAllFigs(java.util.Collection c)

removeAllElements

protected void removeAllElements()

removeSelection

protected void removeSelection(Selection s)

removeFig

protected void removeFig(Fig f)

allDamaged

protected void allDamaged()

select

public void select(Fig f)

addToSelection

public void addToSelection(Fig fig)
Adds an additional fig to the current selection.

Parameters:
fig - Additional fig to select.

deselect

public void deselect(Fig f)
Deselect the given Fig


toggle

public void toggle(Fig f)

deselectAll

public void deselectAll()

select

public void select(java.util.Collection items)

toggle

public void toggle(java.util.Vector items)

findSelectionFor

public Selection findSelectionFor(Fig f)

findSelectionAt

public Selection findSelectionAt(int x,
                                 int y)

contains

public boolean contains(Selection s)
Reply true if the given selection instance is part of my collection


containsFig

public boolean containsFig(Fig f)
Reply true if the given Fig is selected by any of my selection objects


getLocked

public boolean getLocked()

size

public int size()
Reply the number of selected Fig's. This assumes that this collection holds only Selection instances and each of those holds one Fig


selections

public java.util.Vector selections()

getFigs

public java.util.Vector getFigs()
Reply the collection of all selected Fig's


endTrans

public void endTrans()
End a transaction that damages all selected Fig's


paint

public void paint(java.awt.Graphics g)
Paint all selection objects


damage

public void damage()
When the SelectionManager is damageAll, that implies that each Selection should be damageAll.


contains

public boolean contains(int x,
                        int y)
Reply true iff the given point is inside one of the selected Fig's


hit

public boolean hit(java.awt.Rectangle r)
Reply true iff the given point is inside one of the selected Fig's


getBounds

public java.awt.Rectangle getBounds()

getContentBounds

public java.awt.Rectangle getContentBounds()

getLocation

public java.awt.Point getLocation()
This method will return the upper-left coordinate point of the entire selection by iterating through the figs

Returns:
Point - the point for that upper left corner

reorder

public void reorder(int func,
                    Layer lay)
When Manager selections are sent to back, each of them is sent to back.


translate

public void translate(int dx,
                      int dy)
When Manager selections are moved, each of them is moved


addEnclosed

protected void addEnclosed(java.util.Collection affected,
                           Fig f)

startDrag

public void startDrag()

drag

public void drag(int dx,
                 int dy)

stopDrag

public void stopDrag()

getDragLocation

public java.awt.Point getDragLocation()

hitHandle

public void hitHandle(java.awt.Rectangle r,
                      Handle h)
If only one thing is selected, then it is possible to mouse on one of its handles, but if Manager things are selected, users can only drag the objects around


dragHandle

public void dragHandle(int mx,
                       int my,
                       int an_x,
                       int an_y,
                       Handle h)
If only one thing is selected, then it is possible to mouse on one of its handles, but if Manager things are selected, users can only drag the objects around


cleanUp

public void cleanUp()

removeFromGraph

public void removeFromGraph()
When a multiple selection are deleted, each selection is deleted


dispose

public void dispose()
When a multiple selection are deleted, each selection is deleted


deleteFromModel

public void deleteFromModel()
When a multiple selection are deleted, each selection is deleted


keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
When an event is passed to a multiple selection, try to pass it off to the first selection that will handle it.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Specified by:
keyPressed in interface java.awt.event.KeyListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

addGraphSelectionListener

public void addGraphSelectionListener(GraphSelectionListener listener)

removeGraphSelectionListener

public void removeGraphSelectionListener(GraphSelectionListener listener)

fireSelectionChanged

protected void fireSelectionChanged()

updatePropertySheet

public void updatePropertySheet()

findCommonSuperClass

public java.lang.Class findCommonSuperClass()
Determines and returns the first common superclass of all selected items.


findFirstSelectionOfType

public java.lang.Object findFirstSelectionOfType(java.lang.Class type)
Searches for the first appearance of an object of the designated type in the current selection.

Parameters:
type - Type of selection class to look for.
Returns:
The first selected object being instance of the designated type.

makeSelectionFor

public static Selection makeSelectionFor(Fig f)