Class SelectionTool
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.tool.AbstractTool
-
- org.jhotdraw.draw.tool.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
- Direct Known Subclasses:
- DelegationSelectionTool
public class SelectionTool extends AbstractTool
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
DefaultSelectAreaTracker, theDefaultDragTrackerand theDefaultHandleTracker.A Figure can be selected by clicking at it. Holding the alt key or the ctrl key down, selects the Figure behind it.
Design PatternsStrategy
The different behavior states of the selection tool are implemented by trackers.
Context:SelectionTool; State:DragTracker,HandleTracker,SelectAreaTracker.Chain of responsibility
Mouse and keyboard events of the user occur on the drawing view, and are preprocessed by theDragTrackerof aSelectionTool. In turnDragTrackerinvokes "track" methods on aHandlewhich in turn changes an aspect of a figure.
Client:SelectionTool; Handler:DragTracker,Handle.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringSELECT_BEHIND_ENABLED_PROPERTYConstant for the name of the selectBehindEnabled property.
-
Constructor Summary
Constructors Constructor and Description SelectionTool()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidactivate(DrawingEditor editor)Activates the tool for the given editor.voiddeactivate(DrawingEditor editor)Deactivates the tool.voiddraw(java.awt.Graphics2D g)Draws the tool.booleanisSelectBehindEnabled()Returns the value of the selectBehindEnabled property.voidkeyPressed(java.awt.event.KeyEvent e)The Tool uses the InputMap to determine what to do, when a key is pressed.voidkeyReleased(java.awt.event.KeyEvent evt)voidkeyTyped(java.awt.event.KeyEvent evt)voidmouseClicked(java.awt.event.MouseEvent evt)voidmouseDragged(java.awt.event.MouseEvent evt)voidmouseEntered(java.awt.event.MouseEvent evt)voidmouseExited(java.awt.event.MouseEvent evt)voidmouseMoved(java.awt.event.MouseEvent evt)voidmousePressed(java.awt.event.MouseEvent evt)voidmouseReleased(java.awt.event.MouseEvent evt)voidsetDragTracker(DragTracker newValue)Method to set aDragTracker.voidsetHandleTracker(HandleTracker newValue)Method to set aHandleTracker.voidsetSelectAreaTracker(SelectAreaTracker newValue)Method to set aSelectAreaTracker.voidsetSelectBehindEnabled(boolean newValue)Sets the selectBehindEnabled property.booleansupportsHandleInteraction()Returns true, if this tool lets the user interact with handles.-
Methods inherited from class org.jhotdraw.draw.tool.AbstractTool
addToolListener, addUndoableEditListener, editCopy, editCut, editDelete, editDuplicate, editPaste, getActionMap, getInputMap, getToolTipText, isActive, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, updateCursor
-
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
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
-
-
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:ToolActivates the tool for the given editor. This method is called whenever the user switches to this tool.- Specified by:
activatein interfaceTool- Overrides:
activatein classAbstractTool
-
deactivate
public void deactivate(DrawingEditor editor)
Description copied from interface:ToolDeactivates the tool. This method is called whenever the user switches to another tool.- Specified by:
deactivatein interfaceTool- Overrides:
deactivatein classAbstractTool
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
Description copied from class:AbstractToolThe 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:
keyPressedin interfacejava.awt.event.KeyListener- Overrides:
keyPressedin classAbstractTool
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent evt)
- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener- Overrides:
keyReleasedin classAbstractTool
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent evt)
- Specified by:
keyTypedin interfacejava.awt.event.KeyListener- Overrides:
keyTypedin classAbstractTool
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent evt)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener- Overrides:
mouseClickedin classAbstractTool
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent evt)
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent evt)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener- Overrides:
mouseEnteredin classAbstractTool
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent evt)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener- Overrides:
mouseExitedin classAbstractTool
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent evt)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Overrides:
mouseMovedin classAbstractTool
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent evt)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Overrides:
mouseReleasedin classAbstractTool
-
draw
public void draw(java.awt.Graphics2D g)
Description copied from interface:ToolDraws the tool.- Specified by:
drawin interfaceTool- Overrides:
drawin classAbstractTool
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent evt)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener- Overrides:
mousePressedin classAbstractTool
-
setHandleTracker
public void setHandleTracker(HandleTracker newValue)
Method to set aHandleTracker. If you specify null, theSelectionTooluses theDefaultHandleTracker.
-
setSelectAreaTracker
public void setSelectAreaTracker(SelectAreaTracker newValue)
Method to set aSelectAreaTracker. If you specify null, theSelectionTooluses theDefaultSelectAreaTracker.
-
setDragTracker
public void setDragTracker(DragTracker newValue)
Method to set aDragTracker. If you specify null, theSelectionTooluses theDefaultDragTracker.
-
supportsHandleInteraction
public boolean supportsHandleInteraction()
Returns true, if this tool lets the user interact with handles.Handles may draw differently, if interaction is not possible.
- Specified by:
supportsHandleInteractionin interfaceTool- Overrides:
supportsHandleInteractionin classAbstractTool- Returns:
- True, if this tool supports interaction with the handles.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG