JHotDraw 7.4.1

org.jhotdraw.draw.tool
Class DefaultHandleTracker

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.draw.tool.AbstractTool
          extended by org.jhotdraw.draw.tool.DefaultHandleTracker
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, HandleTracker, Tool

public class DefaultHandleTracker
extends AbstractTool
implements HandleTracker

DefaultHandleTracker implements interactions with the handles of a Figure.

The DefaultHandleTracker handles one of the three states of the SelectionTool. Iz comes into action, when the user presses the mouse button over a Figure.

Design pattern:
Name: Chain of Responsibility.
Role: Handler.
Partners: SelectionTool as Handler, SelectAreaTracker as Handler, DragTracker as Handler, DefaultHandleTracker as Handler.

Design pattern:
Name: State.
Role: State.
Partners: SelectAreaTracker as State, DragTracker as State, SelectionTool as Context.

Version:
$Id: DefaultHandleTracker.java -1 $
Author:
Werner Randelshofer
See Also:
SelectionTool, Serialized Form

Field Summary
 
Fields inherited from class org.jhotdraw.draw.tool.AbstractTool
anchor, editor, isWorking, listenerList
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Constructor Summary
DefaultHandleTracker()
           
DefaultHandleTracker(Handle handle)
          Creates a new instance.
DefaultHandleTracker(Handle master, java.util.Collection<Handle> handles)
           
 
Method Summary
 void activate(DrawingEditor editor)
          Activates the tool for the given editor.
protected  void clearHoverHandles()
           
 void deactivate(DrawingEditor editor)
          Deactivates the tool.
 void draw(java.awt.Graphics2D g)
          Draws the tool.
 void keyPressed(java.awt.event.KeyEvent evt)
          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 setHandles(Handle handle, java.util.Collection<Handle> compatibleHandles)
           
protected  void updateHoverHandles(DrawingView view, Figure f)
           
 
Methods inherited from class org.jhotdraw.draw.tool.AbstractTool
addToolListener, addUndoableEditListener, constrainPoint, constrainPoint, createActionMap, createInputMap, editCopy, editCut, editDelete, editDuplicate, editPaste, fireAreaInvalidated, fireAreaInvalidated, fireBoundsInvalidated, fireToolDone, fireToolStarted, getActionMap, getDrawing, getEditor, getInputMap, getToolTipText, getView, isActive, maybeFireBoundsInvalidated, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, supportsHandleInteraction, updateCursor, viewToDrawing
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.draw.tool.Tool
addToolListener, editCopy, editCut, editDelete, editDuplicate, editPaste, getToolTipText, removeToolListener, supportsHandleInteraction
 

Constructor Detail

DefaultHandleTracker

public DefaultHandleTracker(Handle handle)
Creates a new instance.


DefaultHandleTracker

public DefaultHandleTracker(Handle master,
                            java.util.Collection<Handle> handles)

DefaultHandleTracker

public DefaultHandleTracker()
Method Detail

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

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 evt)
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

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed 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

clearHoverHandles

protected void clearHoverHandles()

updateHoverHandles

protected void updateHoverHandles(DrawingView view,
                                  Figure f)

setHandles

public void setHandles(Handle handle,
                       java.util.Collection<Handle> compatibleHandles)
Specified by:
setHandles in interface HandleTracker

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.