Class DragableArea

  • All Implemented Interfaces:
    org.w3c.dom.events.EventListener

    public class DragableArea
    extends java.lang.Object
    implements org.w3c.dom.events.EventListener
    A simple dragable area for Batik.
    Since:
    0.4.0
    Author:
    Erich Schubert
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  DragableArea.DragListener
      Listener interface for drag events.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.w3c.dom.Element coordref
      The coordinate system node.
      protected org.w3c.dom.Element element
      Our element node.
      protected DragableArea.DragListener listener
      A listener to notify on drags (when not subclassing).
      protected org.w3c.dom.svg.SVGPoint startDragPoint
      The point where the drag started.
      protected SVGPlot svgp
      The plot we are attached to.
    • Constructor Summary

      Constructors 
      Constructor Description
      DragableArea​(SVGPlot plot, double x, double y, double w, double h)
      Constructor for a dragable area. use getElement() to get the DOM node.
      DragableArea​(SVGPlot plot, double x, double y, double w, double h, DragableArea.DragListener listener)
      Constructor for a dragable area. use getElement() to get the DOM node.
      DragableArea​(SVGPlot plot, org.w3c.dom.Element coordref, double x, double y, double w, double h)
      Constructor for a dragable area. use getElement() to get the DOM node.
      DragableArea​(SVGPlot plot, org.w3c.dom.Element coordref, double x, double y, double w, double h, DragableArea.DragListener listener)
      Constructor for a dragable area. use getElement() to get the DOM node.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      Remove the listeners
      void disableStart()
      Disable capturing of 'mousedown' events.
      protected void disableStop()
      Disable capturing of 'mousemove' and 'mouseup' events.
      protected boolean duringDrag​(org.w3c.dom.svg.SVGPoint startPoint, org.w3c.dom.svg.SVGPoint dragPoint, org.w3c.dom.events.Event evt, boolean inside)
      Method called during drags.
      void enableStart()
      Enable capturing of 'mousedown' events.
      protected void enableStop()
      Enable capturing of 'mousemove' and 'mouseup' events.
      protected boolean endDrag​(org.w3c.dom.svg.SVGPoint startPoint, org.w3c.dom.svg.SVGPoint dragPoint, org.w3c.dom.events.Event evt, boolean inside)
      Method called when a drag was ended.
      protected org.w3c.dom.svg.SVGPoint getCoordinates​(org.w3c.dom.events.Event evt)
      Return the event coordinates for this event.
      org.w3c.dom.Element getElement()
      The DOM element.
      void handleEvent​(org.w3c.dom.events.Event evt)  
      void makeInvisible()
      Make the rectangle invisible.
      void makeVisible()
      Make the rectangle visible, for debug purposes.
      protected boolean startDrag​(org.w3c.dom.svg.SVGPoint startPoint, org.w3c.dom.events.Event evt)
      Action to do on drag start.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • element

        protected final org.w3c.dom.Element element
        Our element node.
      • coordref

        protected final org.w3c.dom.Element coordref
        The coordinate system node.
      • svgp

        protected final SVGPlot svgp
        The plot we are attached to.
      • startDragPoint

        protected org.w3c.dom.svg.SVGPoint startDragPoint
        The point where the drag started.
    • Constructor Detail

      • DragableArea

        public DragableArea​(SVGPlot plot,
                            double x,
                            double y,
                            double w,
                            double h)
        Constructor for a dragable area. use getElement() to get the DOM node.

        Note: always remember to call 'destroy()' to remove listeners!

        Parameters:
        plot - Plot we'll be added to
        x - X position
        y - Y position
        w - Width
        h - Height
      • DragableArea

        public DragableArea​(SVGPlot plot,
                            org.w3c.dom.Element coordref,
                            double x,
                            double y,
                            double w,
                            double h)
        Constructor for a dragable area. use getElement() to get the DOM node.

        Note: always remember to call 'destroy()' to remove listeners!

        Parameters:
        plot - Plot we'll be added to
        coordref - Element defining the coordinate system
        x - X position
        y - Y position
        w - Width
        h - Height
      • DragableArea

        public DragableArea​(SVGPlot plot,
                            double x,
                            double y,
                            double w,
                            double h,
                            DragableArea.DragListener listener)
        Constructor for a dragable area. use getElement() to get the DOM node.

        Note: always remember to call 'destroy()' to remove listeners!

        Parameters:
        plot - Plot we'll be added to
        x - X position
        y - Y position
        w - Width
        h - Height
        listener - Drag listener
      • DragableArea

        public DragableArea​(SVGPlot plot,
                            org.w3c.dom.Element coordref,
                            double x,
                            double y,
                            double w,
                            double h,
                            DragableArea.DragListener listener)
        Constructor for a dragable area. use getElement() to get the DOM node.

        Note: always remember to call 'destroy()' to remove listeners!

        Parameters:
        plot - Plot we'll be added to
        coordref - Element defining the coordinate system
        x - X position
        y - Y position
        w - Width
        h - Height
        listener - Drag listener
    • Method Detail

      • destroy

        public void destroy()
        Remove the listeners
      • getElement

        public org.w3c.dom.Element getElement()
        The DOM element.
        Returns:
        the element
      • enableStart

        public void enableStart()
        Enable capturing of 'mousedown' events.
      • disableStart

        public void disableStart()
        Disable capturing of 'mousedown' events.
      • enableStop

        protected void enableStop()
        Enable capturing of 'mousemove' and 'mouseup' events.
      • disableStop

        protected void disableStop()
        Disable capturing of 'mousemove' and 'mouseup' events.
      • handleEvent

        public void handleEvent​(org.w3c.dom.events.Event evt)
        Specified by:
        handleEvent in interface org.w3c.dom.events.EventListener
      • getCoordinates

        protected org.w3c.dom.svg.SVGPoint getCoordinates​(org.w3c.dom.events.Event evt)
        Return the event coordinates for this event.
        Parameters:
        evt - Event
        Returns:
        Coordinates
      • startDrag

        protected boolean startDrag​(org.w3c.dom.svg.SVGPoint startPoint,
                                    org.w3c.dom.events.Event evt)
        Action to do on drag start.
        Parameters:
        startPoint - Point where the drag was started.
        evt - The event object
        Returns:
        true to start the drag operation
      • duringDrag

        protected boolean duringDrag​(org.w3c.dom.svg.SVGPoint startPoint,
                                     org.w3c.dom.svg.SVGPoint dragPoint,
                                     org.w3c.dom.events.Event evt,
                                     boolean inside)
        Method called during drags.
        Parameters:
        startPoint - Drag starting point
        dragPoint - Drag end point
        evt - The event object
        inside - Inside the tracked element
        Returns:
        true to continue the drag
      • endDrag

        protected boolean endDrag​(org.w3c.dom.svg.SVGPoint startPoint,
                                  org.w3c.dom.svg.SVGPoint dragPoint,
                                  org.w3c.dom.events.Event evt,
                                  boolean inside)
        Method called when a drag was ended.
        Parameters:
        startPoint - Drag starting point
        dragPoint - Drag end point
        evt - The event object
        inside - Success flag
        Returns:
        true to complete the drag
      • makeInvisible

        public void makeInvisible()
        Make the rectangle invisible.
      • makeVisible

        public void makeVisible()
        Make the rectangle visible, for debug purposes.