JHotDraw 6.0b1

Class SelectionTool

  extended by org.jhotdraw.standard.AbstractTool
      extended by org.jhotdraw.standard.SelectionTool
All Implemented Interfaces:
Direct Known Subclasses:
CustomSelectionTool, MySelectionTool

public class SelectionTool
extends AbstractTool

Tool to select and manipulate figures. A selection tool is in one of three states, e.g., background selection, figure selection, handle manipulation. The different states are handled by different child tools.

Design Patterns

 o State
SelectionTool is the StateContext and child is the State. The SelectionTool delegates state specific behavior to its current child tool.

Nested Class Summary
Nested classes/interfaces inherited from class org.jhotdraw.standard.AbstractTool
Constructor Summary
SelectionTool(DrawingEditor newDrawingEditor)
Method Summary
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(DrawingView view, Handle handle)
          Factory method to create a Handle tracker.
protected  Tool getDelegateTool()
 void mouseDown(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse down events and starts the corresponding tracker.
 void mouseDrag(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse drag events.
 void mouseMove(java.awt.event.MouseEvent evt, int x, int y)
          Handles mouse moves (if the mouse button is up).
 void mouseUp(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse up events.
protected  void setDelegateTool(Tool newDelegateTool)
Methods inherited from class org.jhotdraw.standard.AbstractTool
activate, addToolListener, checkUsable, createEventDispatcher, createViewChangeListener, deactivate, drawing, editor, getActiveDrawing, getActiveView, getAnchorX, getAnchorY, getEventDispatcher, getUndoActivity, isActive, isEnabled, isUsable, keyDown, removeToolListener, setAnchorX, setAnchorY, setEditor, setEnabled, setUndoActivity, setUsable, setView, view, viewCreated, viewDestroying, viewSelectionChanged
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public SelectionTool(DrawingEditor newDrawingEditor)
Method Detail


public void mouseDown(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Handles mouse down events and starts the corresponding tracker.

Specified by:
mouseDown in interface Tool
mouseDown in class AbstractTool


public void mouseMove(java.awt.event.MouseEvent evt,
                      int x,
                      int y)
Handles mouse moves (if the mouse button is up). Switches the cursors depending on whats under them.

Specified by:
mouseMove in interface Tool
mouseMove in class AbstractTool


public void mouseDrag(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Handles mouse drag events. The events are forwarded to the current tracker.

Specified by:
mouseDrag in interface Tool
mouseDrag in class AbstractTool


public void mouseUp(java.awt.event.MouseEvent e,
                    int x,
                    int y)
Handles mouse up events. The events are forwarded to the current tracker.

Specified by:
mouseUp in interface Tool
mouseUp in class AbstractTool


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


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


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


protected Tool getDelegateTool()


protected final void setDelegateTool(Tool newDelegateTool)

JHotDraw 6.0b1