http://www.jpicedt.org

jpicedt.graphic.toolkit
Class AbstractMouseTransform

java.lang.Object
  extended by jpicedt.graphic.toolkit.AbstractMouseTransform
All Implemented Interfaces:
MouseTransform
Direct Known Subclasses:
EditElementMouseTransformFactory._MoveControlPointTransform, EditElementMouseTransformFactory._MoveElementTransform

public abstract class AbstractMouseTransform
extends Object
implements MouseTransform

This implementation allows subclassers to modify a clone of the target Element, then to update the original Element when the operation is completed. The aim is to reduce the burden of repainting a (possibly) complex Element while transforming it, by painting the Element using very lightweight View. This is done as follow :

Since:
jPicEdt 1.3.2
Author:
Sylvain Reynal

Constructor Summary
protected AbstractMouseTransform(Element target)
           
 
Method Summary
protected  Element getClone()
          Return the clone of the target element, which was init'd by startTransform
protected  Element getTarget()
          Return the element this transform acts upon
 boolean next(PEMouseEvent e)
          Called by mouseReleased.
 void paint(Graphics2D g, Rectangle2D allocation, double scale)
          Paints the clone.
 void start(PEMouseEvent e)
          Called by mousePressed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jpicedt.graphic.toolkit.MouseTransform
getCursor, getHelpMessage, process
 

Constructor Detail

AbstractMouseTransform

protected AbstractMouseTransform(Element target)
Parameters:
target - The target-element upon which this transform will act.
Method Detail

start

public void start(PEMouseEvent e)
Called by mousePressed.
Creates a clone of the target (e.g. a clicked Element) given as a parameter to the constructor, and sets its View using a dedicated ViewFactory (defined as an inner class) so that only the stroke of the element will be painted (using a default basic stroke to reduce the burden of repainting).

Specified by:
start in interface MouseTransform

next

public boolean next(PEMouseEvent e)
Called by mouseReleased.
This implementation set the clone's parent and view to null so as to make it elligible for gc. This should be called by subclassers at the end of the implementation of their "next" method.

Specified by:
next in interface MouseTransform
Returns:
true if there's another task in the sequence, false if mouse-transform has completed with this mouse-event.

paint

public void paint(Graphics2D g,
                  Rectangle2D allocation,
                  double scale)
Paints the clone. This is normally called by EditorKit upon request by the installed PECanvas.

Specified by:
paint in interface MouseTransform

getTarget

protected Element getTarget()
Return the element this transform acts upon


getClone

protected Element getClone()
Return the clone of the target element, which was init'd by startTransform


http://www.jpicedt.org

Submit a bug : syd@jpicedt.org