JHotDraw 7.1

org.jhotdraw.draw
Class SelectionTool

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.draw.AbstractTool
          extended by org.jhotdraw.draw.SelectionTool
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, Tool, ToolListener
Direct Known Subclasses:
DelegationSelectionTool

public class SelectionTool
extends AbstractTool
implements ToolListener

Tool to select and manipulate figures.

A selection tool is in one of three states: 1) area selection, 2) figure dragging, 3) handle manipulation. The different states are handled by different tracker objects: the SelectAreaTracker, the DragTracker and the HandleTracker.

A Figure can be selected by clicking at it. Holding the alt key or the ctrl key down, selects the Figure behind it.

Version:
1.1 2007-11-05 Added property selectBehindEnabled.
1.0 2003-12-01 Derived from JHotDraw 5.4b1.
Author:
Werner Randelshofer
See Also:
SelectAreaTracker, DragTracker, HandleTracker, Serialized Form

Field Summary
static java.lang.String SELECT_BEHIND_ENABLED_PROPERTY
          Constant for the name of the selectBehindEnabled property.
 
Fields inherited from class org.jhotdraw.draw.AbstractTool
anchor, editor, isWorking, listenerList
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Constructor Summary
SelectionTool()
          Creates a new instance.
 
Method Summary
 void activate(DrawingEditor editor)
          Activates the tool for the given editor.
 void areaInvalidated(ToolEvent e)
          Sent when an area of the drawing view needs to be repainted.
protected  Tool createAreaTracker()
          Factory method to create an area tracker.
protected  Tool createDragTracker(Figure f)
          Factory method to create a Drag tracker.
protected  Tool createHandleTracker(Handle handle)
          Factory method to create a Handle tracker.
 void deactivate(DrawingEditor editor)
          Deactivates the tool.
 void draw(java.awt.Graphics2D g)
          Draws the tool.
 boolean isSelectBehindEnabled()
          Returns the value of the selectBehindEnabled property.
 void keyPressed(java.awt.event.KeyEvent e)
          The Tool uses the InputMap to determine what to do, when a key is pressed.
 void keyReleased(java.awt.event.KeyEvent evt)
           
 void keyTyped(java.awt.event.KeyEvent evt)
           
 void mouseClicked(java.awt.event.MouseEvent evt)
           
 void mouseDragged(java.awt.event.MouseEvent evt)
           
 void mouseEntered(java.awt.event.MouseEvent evt)
           
 void mouseExited(java.awt.event.MouseEvent evt)
           
 void mouseMoved(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
           
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 void setSelectBehindEnabled(boolean newValue)
          Sets the selectBehindEnabled property.
protected  void setTracker(Tool newTracker)
           
 void toolDone(ToolEvent event)
          Informs the listener that a tool has done its interaction.
 void toolStarted(ToolEvent event)
          Informs the listener that a tool has starteds interacting with a specific drawing view.
 
Methods inherited from class org.jhotdraw.draw.AbstractTool
addToolListener, addUndoableEditListener, constrainPoint, constrainPoint, createActionMap, createInputMap, editCopy, editCut, editDelete, editDuplicate, editPaste, fireAreaInvalidated, fireAreaInvalidated, fireToolDone, fireToolStarted, getActionMap, getDrawing, getEditor, getInputMap, getView, isActive, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, updateCursor, viewToDrawing
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT_BEHIND_ENABLED_PROPERTY

public static final java.lang.String SELECT_BEHIND_ENABLED_PROPERTY
Constant for the name of the selectBehindEnabled property.

See Also:
Constant Field Values
Constructor Detail

SelectionTool

public SelectionTool()
Creates a new instance.

Method Detail

setSelectBehindEnabled

public void setSelectBehindEnabled(boolean newValue)
Sets the selectBehindEnabled property. This is a bound property.

Parameters:
newValue - The new value.

isSelectBehindEnabled

public boolean isSelectBehindEnabled()
Returns the value of the selectBehindEnabled property. This is a bound property.

Returns:
The property value.

activate

public void activate(DrawingEditor editor)
Description copied from interface: Tool
Activates the tool for the given editor. This method is called whenever the user switches to this tool.

Specified by:
activate in interface Tool
Overrides:
activate in class AbstractTool

deactivate

public void deactivate(DrawingEditor editor)
Description copied from interface: Tool
Deactivates the tool. This method is called whenever the user switches to another tool.

Specified by:
deactivate in interface Tool
Overrides:
deactivate in class AbstractTool

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Description copied from class: AbstractTool
The Tool uses the InputMap to determine what to do, when a key is pressed. If the corresponding value of the InputMap is a String, the ActionMap of the tool is used, to find the action to be performed. If the corresponding value of the InputMap is a ActionListener, the actionPerformed method of the ActionListener is performed.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Overrides:
keyPressed in class AbstractTool

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Specified by:
keyReleased in interface java.awt.event.KeyListener
Overrides:
keyReleased in class AbstractTool

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Specified by:
keyTyped in interface java.awt.event.KeyListener
Overrides:
keyTyped in class AbstractTool

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class AbstractTool

mouseDragged

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

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class AbstractTool

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class AbstractTool

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent evt)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class AbstractTool

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class AbstractTool

draw

public void draw(java.awt.Graphics2D g)
Description copied from interface: Tool
Draws the tool.

Specified by:
draw in interface Tool
Overrides:
draw in class AbstractTool

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class AbstractTool

setTracker

protected void setTracker(Tool newTracker)

createHandleTracker

protected Tool createHandleTracker(Handle handle)
Factory method to create a Handle tracker. It is used to track a handle.


createDragTracker

protected Tool createDragTracker(Figure f)
Factory method to create a Drag tracker. It is used to drag a figure.


createAreaTracker

protected Tool createAreaTracker()
Factory method to create an area tracker. It is used to select an area.


toolStarted

public void toolStarted(ToolEvent event)
Description copied from interface: ToolListener
Informs the listener that a tool has starteds interacting with a specific drawing view.

Specified by:
toolStarted in interface ToolListener

toolDone

public void toolDone(ToolEvent event)
Description copied from interface: ToolListener
Informs the listener that a tool has done its interaction. This method can be used to switch back to the default tool.

Specified by:
toolDone in interface ToolListener

areaInvalidated

public void areaInvalidated(ToolEvent e)
Sent when an area of the drawing view needs to be repainted.

Specified by:
areaInvalidated in interface ToolListener

Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.