Package jpicedt.graphic.toolkit
Class DrawToolFactory.GenericDrawTool
- java.lang.Object
-
- java.awt.event.KeyAdapter
-
- jpicedt.graphic.toolkit.MouseTool
-
- jpicedt.graphic.toolkit.DrawToolFactory.GenericDrawTool
-
- All Implemented Interfaces:
java.awt.event.KeyListener,java.util.EventListener,PEMouseInputListener
- Enclosing class:
- DrawToolFactory
protected class DrawToolFactory.GenericDrawTool extends MouseTool
A MouseTool aimed at drawing new Elements. It works like an iterator, by iterating (cyclically, creating a new Element at each cycle) through a given array of point indexes, or (if the latter are not provided in the constructor) by computing it from the available control points for the given element.GenericDrawTool targets Element having a finite number of control points ONLY !
- Author:
- Sylvain Reynal
-
-
Field Summary
-
Fields inherited from class jpicedt.graphic.toolkit.MouseTool
lastMouseEvent, mouseOutside
-
-
Constructor Summary
Constructors Constructor Description GenericDrawTool(Element prototype, EditPointConstraint constraint)ThedrawPointsarray gets computed from all available control-points for the given element.GenericDrawTool(Element prototype, EditPointConstraint constraint, int[][] drawPoints)
-
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 is mainly for mousetools using more than one sequence, for it gives them a chance to clean themselves up for the next timevoidinit()called when this tool is being activated in the hosting editor kitvoidmouseDragged(PEMouseEvent e)set current pointvoidmouseMoved(PEMouseEvent e)set cursor for canvas, then call mouseDraggedvoidmousePressed(PEMouseEvent e)A popup-trigger mouse event (e.g.voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)This method is called by the hosting EditorKit : this implementation paints the current element's highlighter.voidsetCurrentPoint(PEMouseEvent e)move the points indexed in drawPoints[currentTaskIndex] to the current click-point (possibly after grid alignment).-
Methods inherited from class jpicedt.graphic.toolkit.MouseTool
getLastMouseEvent, keyPressed, keyReleased, mouseClicked, mouseEntered, mouseExited, mouseReleased, processKeyEvent
-
-
-
-
Constructor Detail
-
GenericDrawTool
public GenericDrawTool(Element prototype, EditPointConstraint constraint, int[][] drawPoints)
- Parameters:
prototype- the Element that will serve as the prototype (getting cloned, then added to the drawing).constraint- which constraint to use when moving control-pointsdrawPoints- an array of array of point indexes which the iterator will iterate through (in ascending order) to draw the element (at each iteration, the corresponding list of points will be updated together).- See Also:
Element.setPoint(int, jpicedt.graphic.PicPoint)
-
GenericDrawTool
public GenericDrawTool(Element prototype, EditPointConstraint constraint)
ThedrawPointsarray gets computed from all available control-points for the given element.- Parameters:
prototype- the Element that will serve as the prototype (getting cloned, then added to the drawing).inputAttributes- the input attribute set for the Element to be created.
-
-
Method Detail
-
mousePressed
public void mousePressed(PEMouseEvent e)
A popup-trigger mouse event (e.g. a right click on Unix/Windows) :
- switches back to SELECT_MODE if the task-iterator is completed
- or cancels the current task if the task-iterator is underway.
A left- or middle-button SINGLE click either :
- (re)start the task iterator if it was completed
- or select the next point if there are more points
- or terminate the drawing process if there are no more points.- Specified by:
mousePressedin interfacePEMouseInputListener- Overrides:
mousePressedin classMouseTool- Since:
- jPicEdt
-
mouseDragged
public void mouseDragged(PEMouseEvent e)
set current point- Specified by:
mouseDraggedin interfacePEMouseInputListener- Overrides:
mouseDraggedin classMouseTool
-
mouseMoved
public void mouseMoved(PEMouseEvent e)
set cursor for canvas, then call mouseDragged- Specified by:
mouseMovedin interfacePEMouseInputListener- Overrides:
mouseMovedin classMouseTool
-
setCurrentPoint
public void setCurrentPoint(PEMouseEvent e)
move the points indexed in drawPoints[currentTaskIndex] to the current click-point (possibly after grid alignment).
-
init
public void init()
called when this tool is being activated in the hosting editor kit
-
flush
public void flush()
called when this tool is being replaced by another mouse-tool in the hosting editor kit ; this is mainly for mousetools using more than one sequence, for it gives them a chance to clean themselves up for the next time
-
-