http://www.jpicedt.org

jpicedt.graphic.toolkit
Class SelectionTool

java.lang.Object
  extended by java.awt.event.KeyAdapter
      extended by jpicedt.graphic.toolkit.MouseTool
          extended by jpicedt.graphic.toolkit.SelectionTool
All Implemented Interfaces:
KeyListener, EventListener, PEMouseInputListener

public class SelectionTool
extends MouseTool

This generic mouse-tool is dedicated to applying MouseTransform's to elements of a Drawing, following a uniform sequence of mouse-events. This class works hand-in-hand with a pluggable MouseTransformFactory which produces MouseTransform's on the fly from incoming mouse-events. Then any ensuing mouse-event invokes a specific method from the produced MouseTransform.

Basically, the sequence of mouse-events comprises :

Besides, this tool opens a context-sensitive popup menu when a right-click occurs, by delegating to the hosting EditorKit to obtain a suitable PopupMenuFactory. It also sets the cursor shape according to the currently installed MouseTransform.

[SR:pending] refactor class name to sth like "GenericTool" or "MouseTransformTool"...

Since:
jPicEdt 1.3.2
Version:
$Id: SelectionTool.java,v 1.13.2.1 2007/09/02 11:56:29 reynal Exp $

Author:
Sylvain Reynal

Field Summary
 
Fields inherited from class jpicedt.graphic.toolkit.MouseTool
lastMouseEvent, mouseOutside
 
Method Summary
 void flush()
          called when this tool is being replaced by another mouse-tool in the hosting editor kit ; this delegates to the underlying MouseTransform factory
 void init()
          called when this tool is being activated in the hosting editor kit ; this delegates to the underlying MouseTransform factory
 void mouseDragged(PEMouseEvent e)
          Invoke "process" on the current MouseTransform (if non-null).
 void mouseMoved(PEMouseEvent e)
          Change mouse cursor according to the MouseTransform returned by the factory for the given PEMouseEvent.
 void mousePressed(PEMouseEvent e)
          - right button click (popup trigger) -> raise popup menu.
- left button -> createMouseTransform using the mtFactory given in the constructor.
 void mouseReleased(PEMouseEvent e)
          Invokes "end" on the current MouseTransform if non-null.
 void paint(Graphics2D g, Rectangle2D allocation, double scale)
          Do tool specific painting.
 
Methods inherited from class jpicedt.graphic.toolkit.MouseTool
getLastMouseEvent, keyPressed, keyReleased, mouseClicked, mouseEntered, mouseExited, processKeyEvent
 
Methods inherited from class java.awt.event.KeyAdapter
keyTyped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

paint

public void paint(Graphics2D g,
                  Rectangle2D allocation,
                  double scale)
Do tool specific painting. Merely delegates to the currently active mouse transform, as well as to the installed MouseTransformFactory.

Overrides:
paint in class MouseTool

init

public void init()
called when this tool is being activated in the hosting editor kit ; this delegates to the underlying MouseTransform factory

Overrides:
init in class MouseTool

flush

public void flush()
called when this tool is being replaced by another mouse-tool in the hosting editor kit ; this delegates to the underlying MouseTransform factory

Overrides:
flush in class MouseTool

mousePressed

public void mousePressed(PEMouseEvent e)
- right button click (popup trigger) -> raise popup menu.
- left button -> createMouseTransform using the mtFactory given in the constructor.

Specified by:
mousePressed in interface PEMouseInputListener
Overrides:
mousePressed in class MouseTool

mouseDragged

public void mouseDragged(PEMouseEvent e)
Invoke "process" on the current MouseTransform (if non-null).

Specified by:
mouseDragged in interface PEMouseInputListener
Overrides:
mouseDragged in class MouseTool

mouseReleased

public void mouseReleased(PEMouseEvent e)
Invokes "end" on the current MouseTransform if non-null.

Specified by:
mouseReleased in interface PEMouseInputListener
Overrides:
mouseReleased in class MouseTool

mouseMoved

public void mouseMoved(PEMouseEvent e)
Change mouse cursor according to the MouseTransform returned by the factory for the given PEMouseEvent.

Specified by:
mouseMoved in interface PEMouseInputListener
Overrides:
mouseMoved in class MouseTool

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org