org.jhotdraw.draw.tool
Class DelegationSelectionTool

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.draw.tool.AbstractTool
          extended by org.jhotdraw.draw.tool.SelectionTool
              extended by org.jhotdraw.draw.tool.DelegationSelectionTool
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

public class DelegationSelectionTool
extends SelectionTool

A SelectionTool, which recognizes double clicks and popup menu triggers. If a double click or popup trigger is encountered a hook method is called, which handles the event. This methods can be overriden in subclasse to provide customized behaviour.

By default, this Tool delegates mouse events to a specific Tool if the figure which has been double clicked, provides a specialized tool.

Version:
$Id: DelegationSelectionTool.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
private static boolean DEBUG
          Set this to true to turn on debugging output on System.out.
private  java.util.Collection<javax.swing.Action> drawingActions
          A set of actions which is applied to the drawing.
private  boolean isMousePressedPopupTrigger
          This variable is set to true, if a mouse pressed event is a popup trigger.
private  java.awt.event.MouseEvent lastClickEvent
          We store the last mouse click here, to support multi-click behavior, that is, a behavior that is invoked, when the user clicks multiple on the same spot, but in a longer interval than needed for a double click.
private  javax.swing.JPopupMenu popupMenu
          When the popup menu is visible, we do not track mouse movements.
private  javax.swing.Timer popupTimer
          We use this timer, to show a popup menu, when the user presses the mouse key for a second without moving the mouse.
private  java.util.Collection<javax.swing.Action> selectionActions
          A set of actions which is applied to a selection of figures.
 
Fields inherited from class org.jhotdraw.draw.tool.SelectionTool
SELECT_BEHIND_ENABLED_PROPERTY
 
Fields inherited from class org.jhotdraw.draw.tool.AbstractTool
anchor, editor, isWorking, listenerList
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Constructor Summary
DelegationSelectionTool()
          Creates a new instance.
DelegationSelectionTool(java.util.Collection<javax.swing.Action> drawingActions, java.util.Collection<javax.swing.Action> selectionActions)
          Creates a new instance.
 
Method Summary
 java.lang.String getToolTipText(DrawingView view, java.awt.event.MouseEvent evt)
          Returns the tooltip text for a mouse event on a drawing view.
protected  void handleDoubleClick(java.awt.event.MouseEvent evt)
          Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a double click.
protected  void handleMultiClick(java.awt.event.MouseEvent evt)
          Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a multi-click.
protected  void handlePopupMenu(java.awt.event.MouseEvent evt)
          Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a popup trigger.
 void mouseClicked(java.awt.event.MouseEvent evt)
           
 void mouseDragged(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
          MouseListener method for mousePressed events.
 void mouseReleased(java.awt.event.MouseEvent evt)
          MouseListener method for mouseReleased events.
 void setDrawingActions(java.util.Collection<javax.swing.Action> drawingActions)
           
 void setFigureActions(java.util.Collection<javax.swing.Action> selectionActions)
           
protected  void showPopupMenu(Figure figure, java.awt.Point p, java.awt.Component c)
           
 
Methods inherited from class org.jhotdraw.draw.tool.SelectionTool
activate, deactivate, draw, getDragTracker, getHandleTracker, getSelectAreaTracker, isSelectBehindEnabled, keyPressed, keyReleased, keyTyped, mouseEntered, mouseExited, mouseMoved, setDragTracker, setHandleTracker, setSelectAreaTracker, setSelectBehindEnabled, setTracker, supportsHandleInteraction
 
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, getView, isActive, maybeFireBoundsInvalidated, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, 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
 

Field Detail

DEBUG

private static final boolean DEBUG
Set this to true to turn on debugging output on System.out.

See Also:
Constant Field Values

drawingActions

private java.util.Collection<javax.swing.Action> drawingActions
A set of actions which is applied to the drawing.


selectionActions

private java.util.Collection<javax.swing.Action> selectionActions
A set of actions which is applied to a selection of figures.


popupTimer

private javax.swing.Timer popupTimer
We use this timer, to show a popup menu, when the user presses the mouse key for a second without moving the mouse.


popupMenu

private javax.swing.JPopupMenu popupMenu
When the popup menu is visible, we do not track mouse movements.


lastClickEvent

private java.awt.event.MouseEvent lastClickEvent
We store the last mouse click here, to support multi-click behavior, that is, a behavior that is invoked, when the user clicks multiple on the same spot, but in a longer interval than needed for a double click.


isMousePressedPopupTrigger

private boolean isMousePressedPopupTrigger
This variable is set to true, if a mouse pressed event is a popup trigger.

Constructor Detail

DelegationSelectionTool

public DelegationSelectionTool()
Creates a new instance.


DelegationSelectionTool

public DelegationSelectionTool(java.util.Collection<javax.swing.Action> drawingActions,
                               java.util.Collection<javax.swing.Action> selectionActions)
Creates a new instance.

Method Detail

setDrawingActions

public void setDrawingActions(java.util.Collection<javax.swing.Action> drawingActions)

setFigureActions

public void setFigureActions(java.util.Collection<javax.swing.Action> selectionActions)

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
MouseListener method for mousePressed events. If the popup trigger has been activated, then the appropriate hook method is called.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class SelectionTool

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
MouseListener method for mouseReleased events. If the popup trigger has been activated, then the appropriate hook method is called.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class SelectionTool

mouseDragged

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

mouseClicked

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

handlePopupMenu

protected void handlePopupMenu(java.awt.event.MouseEvent evt)
Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a popup trigger.


showPopupMenu

protected void showPopupMenu(Figure figure,
                             java.awt.Point p,
                             java.awt.Component c)

handleDoubleClick

protected void handleDoubleClick(java.awt.event.MouseEvent evt)
Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a double click.


handleMultiClick

protected void handleMultiClick(java.awt.event.MouseEvent evt)
Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a multi-click.


getToolTipText

public java.lang.String getToolTipText(DrawingView view,
                                       java.awt.event.MouseEvent evt)
Description copied from interface: Tool
Returns the tooltip text for a mouse event on a drawing view.

Specified by:
getToolTipText in interface Tool
Overrides:
getToolTipText in class AbstractTool
Parameters:
view - A drawing view.
evt - A mouse event.
Returns:
A tooltip text or null.