Package jpicedt.graphic.toolkit
Class SelectionTool
- java.lang.Object
-
- java.awt.event.KeyAdapter
-
- jpicedt.graphic.toolkit.MouseTool
-
- jpicedt.graphic.toolkit.SelectionTool
-
- All Implemented Interfaces:
java.awt.event.KeyListener,java.util.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 :
- an initial mouse-pressed event, which asks the factory to create an appropriate MouseTransform
- a sequence of mouse-motion and mouse-button-changed events, where :
- mouse-motion events effectively apply the transform to the element ;
- mouse-button-changed events asks the transform to jump to its next available task, if any.
[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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflush()called when this tool is being replaced by another mouse-tool in the hosting editor kit ; this delegates to the underlying MouseTransform factoryvoidinit()called when this tool is being activated in the hosting editor kit ; this delegates to the underlying MouseTransform factoryvoidmouseDragged(PEMouseEvent e)Invoke "process" on the current MouseTransform (if non-null).voidmouseMoved(PEMouseEvent e)Change mouse cursor according to the MouseTransform returned by the factory for the given PEMouseEvent.voidmousePressed(PEMouseEvent e)- right button click (popup trigger) -> raise popup menu.
- left button -> createMouseTransform using the mtFactory given in the constructor.voidmouseReleased(PEMouseEvent e)Invokes "end" on the current MouseTransform if non-null.voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)Do tool specific painting.-
Methods inherited from class jpicedt.graphic.toolkit.MouseTool
getLastMouseEvent, keyPressed, keyReleased, mouseClicked, mouseEntered, mouseExited, processKeyEvent
-
-
-
-
Method Detail
-
paint
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)Do tool specific painting. Merely delegates to the currently active mouse transform, as well as to the installed MouseTransformFactory.
-
init
public void init()
called when this tool is being activated in the hosting editor kit ; this delegates to the underlying MouseTransform factory
-
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
-
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:
mousePressedin interfacePEMouseInputListener- Overrides:
mousePressedin classMouseTool
-
mouseDragged
public void mouseDragged(PEMouseEvent e)
Invoke "process" on the current MouseTransform (if non-null).- Specified by:
mouseDraggedin interfacePEMouseInputListener- Overrides:
mouseDraggedin classMouseTool
-
mouseReleased
public void mouseReleased(PEMouseEvent e)
Invokes "end" on the current MouseTransform if non-null.- Specified by:
mouseReleasedin interfacePEMouseInputListener- Overrides:
mouseReleasedin classMouseTool
-
mouseMoved
public void mouseMoved(PEMouseEvent e)
Change mouse cursor according to the MouseTransform returned by the factory for the given PEMouseEvent.- Specified by:
mouseMovedin interfacePEMouseInputListener- Overrides:
mouseMovedin classMouseTool
-
-