[Schmitzm-commits] r641 - branches/2.0-RC2/src/schmitzm/swing/event

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 28 17:12:47 CET 2010


Author: mojays
Date: 2010-01-28 17:12:46 +0100 (Thu, 28 Jan 2010)
New Revision: 641

Modified:
   branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java
Log:


Modified: branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java	2010-01-28 16:12:04 UTC (rev 640)
+++ branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java	2010-01-28 16:12:46 UTC (rev 641)
@@ -46,6 +46,9 @@
   protected Map<MouseInputType, Boolean> activationMap = new HashMap<MouseInputType, Boolean>();
   /** Holds the window position a drag is started on. */
   protected Point dragStartPos = null;
+  /** Holds the window position of last {@link #mouseDragged(MouseEvent)}
+   *  call (e.g. to remove a dragging rectangle). */
+  protected Point2D dragLastPos = null;
   
   /**
    * Creates a new mouse adapter. All actions are activated initially.
@@ -82,6 +85,13 @@
     return dragStartPos;
   }
   
+  /**
+   * Returns the window selection of the last {@link #mouseDragged(MouseEvent)}
+   * call.
+   */
+  public Point2D getDragLastPoint() {
+    return dragLastPos;
+  }
 
   /**
    * Calls {@link #performMouseClicked(MouseEvent)} if the mouse
@@ -96,6 +106,7 @@
     if ( isMouseClickEnabled(e) )
       performMouseClicked(e);
     dragStartPos = null;
+    dragLastPos = null;
   }
 
   /**
@@ -108,6 +119,8 @@
   public final void mouseDragged(MouseEvent e) {
     if ( isMouseDragEnabled(e) )
       performMouseDragged(e);
+    // remember the position of this call
+    dragLastPos = e.getPoint();
   }
   
   /**
@@ -148,6 +161,7 @@
   @Override
   public final void mousePressed(MouseEvent e) {
     dragStartPos = e.getPoint();
+    dragLastPos  = e.getPoint();
     if ( isMouseClickEnabled(e) )
       performMouseClicked(e);
   }
@@ -179,6 +193,7 @@
     }
   
     dragStartPos = null;
+    dragLastPos  = null;
   }
 
   /**



More information about the Schmitzm-commits mailing list