Class 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      This implementation set the clone's parent and view to null so as to make it elligible for gc.
      void paint​(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)
      Paints the clone.
      void start​(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
    • 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​(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:
        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