JHotDraw 6.0b1

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 FigureAttributeConstant.POPUP_MENU.


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
protected  void handleMouseClick(java.awt.event.MouseEvent e, int x, int y)
          Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a mouse click.
protected  void handleMouseDoubleClick(java.awt.event.MouseEvent e, int x, int y)
          Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a mouse double click.
protected  void handleMouseDown(java.awt.event.MouseEvent e, int x, int y)
          Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a mouse down.
protected  void handleMouseUp(java.awt.event.MouseEvent e, int x, int y)
          Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a mouse up.
protected  void handlePopupMenu(java.awt.event.MouseEvent e, int x, int y)
          Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a popup trigger.
 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.
protected  void showPopupMenu(Figure figure, int x, int y, java.awt.Component comp)
          This method displays a popup menu, if there is one registered with the Figure (the Figure's attributes are queried for FigureAttributeConstant.POPUP_MENU which is used to indicate an association of a popup menu with the Figure).
 
Methods inherited from class org.jhotdraw.standard.SelectionTool
createAreaTracker, createDragTracker, createHandleTracker, getDelegateTool, mouseMove, setDelegateTool
 
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

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

handleMouseDown

protected void handleMouseDown(java.awt.event.MouseEvent e,
                               int x,
                               int y)
Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a mouse down.


handleMouseUp

protected void handleMouseUp(java.awt.event.MouseEvent e,
                             int x,
                             int y)
Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a mouse up.


handleMouseClick

protected void handleMouseClick(java.awt.event.MouseEvent e,
                                int x,
                                int y)
Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a mouse click.


handleMouseDoubleClick

protected void handleMouseDoubleClick(java.awt.event.MouseEvent e,
                                      int x,
                                      int y)
Hook method which can be overriden by subclasses to provide specialised behaviour in the event of a mouse double click.


handlePopupMenu

protected void handlePopupMenu(java.awt.event.MouseEvent e,
                               int x,
                               int y)
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,
                             int x,
                             int y,
                             java.awt.Component comp)
This method displays a popup menu, if there is one registered with the Figure (the Figure's attributes are queried for FigureAttributeConstant.POPUP_MENU which is used to indicate an association of a popup menu with the Figure).

Parameters:
figure - Figure for which a popup menu should be displayed
x - x coordinate where the popup menu should be displayed
y - y coordinate where the popup menu should be displayed
comp - Component which invoked the popup menu

JHotDraw 6.0b1