Package jpicedt.graphic.toolkit
Class AbstractMouseTransform
- java.lang.Object
-
- jpicedt.graphic.toolkit.AbstractMouseTransform
-
- All Implemented Interfaces:
MouseTransform
- Direct Known Subclasses:
EditElementMouseTransformFactory._MoveControlPointTransform,EditElementMouseTransformFactory._MoveElementTransform
public abstract class AbstractMouseTransform extends java.lang.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 :- first clone the given Element, and add it to a transient RootElement defined as an inner class ;
- then create a "lightweight" View for this Element using a dedicated ViewFactory defined as an inner class ;
- apply the transformation to the clone while the mouse is being dragged/moved/pressed ... Note that the implementation of MouseTransform.paint() arranges for properly painting the clone by asking its lightweight View.
- when the transformation has completed, update the original Element and delete the clone.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMouseTransform(Element target)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ElementgetClone()Return the clone of the target element, which was init'd bystartTransformprotected ElementgetTarget()Return the element this transform acts uponbooleannext(PEMouseEvent e)Called by mouseReleased.
This implementation set the clone's parent and view to null so as to make it elligible for gc.voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)Paints the clone.voidstart(PEMouseEvent e)Called by mousePressed.
Creates a clone of the target (e.g.-
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:
startin interfaceMouseTransform
-
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:
nextin interfaceMouseTransform- Returns:
- true if there's another task in the sequence, false if mouse-transform has completed with this mouse-event.
-
paint
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)Paints the clone. This is normally called by EditorKit upon request by the installed PECanvas.- Specified by:
paintin interfaceMouseTransform
-
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 bystartTransform
-
-