CH.ifa.draw.contrib
Class CustomSelectionTool

java.lang.Object
  extended by CH.ifa.draw.standard.AbstractTool
      extended by CH.ifa.draw.standard.SelectionTool
          extended by CH.ifa.draw.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:
JHotDraw 5.2 31.08.1999

Field Summary
 
Fields inherited from class CH.ifa.draw.standard.AbstractTool
fAnchorX, fAnchorY, fView
 
Constructor Summary
CustomSelectionTool(DrawingView view)
          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 Figure.POPUP_MENU which is used to indicate an association of a popup menu with the Figure).
 
Methods inherited from class CH.ifa.draw.standard.SelectionTool
createAreaTracker, createDragTracker, createHandleTracker
 
Methods inherited from class CH.ifa.draw.standard.AbstractTool
activate, deactivate, drawing, editor, keyDown, mouseMove, view
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomSelectionTool

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

Parameters:
view - DrawingView for which the SelectionTool operates
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 Figure.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
component - Component which invoked the popup menu