org.jhotdraw.contrib
Class CustomSelectionTool

java.lang.Object
  extended by org.jhotdraw.standard.AbstractTool
      extended by org.jhotdraw.standard.SelectionTool
          extended by org.jhotdraw.contrib.CustomSelectionTool
All Implemented Interfaces:
Tool

public class CustomSelectionTool
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. Popup menus must be registered with a Figure using the setAttribute() method. The key which associates a popup menu as an attribute is Figure.POPUP_MENU.

Version:
<$CURRENT_VERSION$>
Author:
Wolfram Kaiser

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jhotdraw.standard.AbstractTool
AbstractTool.EventDispatcher
 
Constructor Summary
CustomSelectionTool(DrawingEditor editor)
          Create an instance of this SelectionTool for the given view
 
Method Summary
 void mouseDown(java.awt.event.MouseEvent e, int x, int y)
          MouseListener method for mouseDown events.
 void mouseDrag(java.awt.event.MouseEvent e, int x, int y)
          MouseListener method for mouseDrag events.
 void mouseUp(java.awt.event.MouseEvent e, int x, int y)
          MouseListener method for mouseUp events.
 
Methods inherited from class org.jhotdraw.standard.SelectionTool
mouseMove
 
Methods inherited from class org.jhotdraw.standard.AbstractTool
activate, addToolListener, deactivate, drawing, editor, getActiveDrawing, getActiveView, getUndoActivity, isActive, isEnabled, isUsable, keyDown, removeToolListener, setEnabled, setUndoActivity, setUsable, view
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomSelectionTool

public CustomSelectionTool(DrawingEditor editor)
Create an instance of this SelectionTool for the given view

Parameters:
editor - DrawingEditor for which the SelectionTool gets the active view
Method Detail

mouseDown

public void mouseDown(java.awt.event.MouseEvent e,
                      int x,
                      int y)
MouseListener method for mouseDown events. If the popup trigger has been activated, then the appropriate hook method is called.

Specified by:
mouseDown in interface Tool
Overrides:
mouseDown in class SelectionTool
Parameters:
e - MouseEvent which should be interpreted
x - x coordinate of the MouseEvent
y - y coordinate of the MouseEvent

mouseDrag

public void mouseDrag(java.awt.event.MouseEvent e,
                      int x,
                      int y)
MouseListener method for mouseDrag events. Usually, mouse drags are ignored for popup menus or double clicks.

Specified by:
mouseDrag in interface Tool
Overrides:
mouseDrag in class SelectionTool
Parameters:
e - MouseEvent which should be interpreted
x - x coordinate of the MouseEvent
y - y coordinate of the MouseEvent

mouseUp

public void mouseUp(java.awt.event.MouseEvent e,
                    int x,
                    int y)
MouseListener method for mouseUp events. Depending on the kind of event the appropriate hook method is called (popupMenuUp for popup trigger, doubleMouseClick for a double click, and mouseUp() and mouseClick() for normal mouse clicks).

Specified by:
mouseUp in interface Tool
Overrides:
mouseUp in class SelectionTool
Parameters:
e - MouseEvent which should be interpreted
x - x coordinate of the MouseEvent
y - y coordinate of the MouseEvent