[Schmitzm-commits] r634 - in branches/2.0-RC2/src: schmitzm/swing/event skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 28 16:23:03 CET 2010


Author: mojays
Date: 2010-01-28 16:22:58 +0100 (Thu, 28 Jan 2010)
New Revision: 634

Modified:
   branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.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 15:03:31 UTC (rev 633)
+++ branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java	2010-01-28 15:22:58 UTC (rev 634)
@@ -73,6 +73,7 @@
   public Point2D getDragStartPoint() {
     return dragStartPos;
   }
+  
 
   /**
    * Calls {@link #performMouseClicked(MouseEvent)} if the mouse
@@ -84,16 +85,8 @@
    */
   @Override
   public final void mouseClicked(MouseEvent e) {
-    switch ( e.getButton() ) {
-      case 1: if ( isEnabled(MouseInputType.LClick) )
-                performMouseClicked(e);
-              break;
-      case 3: if ( isEnabled(MouseInputType.RClick) )
-                performMouseClicked(e);
-              break;
-      default: performMouseClicked(e);
-               break;
-    }
+    if ( isMouseClickEnabled(e) )
+      performMouseClicked(e);
     dragStartPos = null;
   }
 
@@ -105,16 +98,8 @@
    */
   @Override
   public final void mouseDragged(MouseEvent e) {
-    switch ( e.getButton() ) {
-      case 1: if ( isEnabled(MouseInputType.LDrag) )
-                performMouseDragged(e);
-              break;
-      case 3: if ( isEnabled(MouseInputType.RDrag) )
-                performMouseDragged(e);
-              break;
-      default: performMouseDragged(e);
-               break;
-    }
+    if ( isMouseDragEnabled(e) )
+      performMouseDragged(e);
   }
   
   /**
@@ -146,18 +131,41 @@
 
   
   /**
-   * Stored the current mouse location in {@link #dragStartPos}.
+   * Stores the current mouse location in {@link #dragStartPos}.
+   * {@link #performMousePressed(MouseEvent)} is only called, if
+   * the respective click action is enabled.
    */
   @Override
   public final void mousePressed(MouseEvent e) {
     dragStartPos = e.getPoint();
-    
+    if ( isMouseClickEnabled(e) )
+      performMouseClicked(e);
   }
 
+  /**
+   * Calls {@link #performMouseReleased(MouseEvent)} only in the
+   * following cases
+   * <ul>
+   *   <li>Startposition = Endposition and the mouse click action is activated</li>
+   *   <li>Startposition != Endposition and the mouse drag or window action is activated</li>
+   * </ul>
+   */
   @Override
   public final void mouseReleased(MouseEvent e) {
     Point2D dragEndPos = e.getPoint();
     
+    if (  dragEndPos.equals(dragStartPos) ) {
+      // Startposition = Endposition
+      // --> nur wenn Klick aktiviert
+      if ( isMouseClickEnabled(e) )
+        performMouseReleased(e);
+    } else {
+      // Startposition <> Endposition
+      // --> nur wenn Drag oder Fenster aktiviert
+      if ( isMouseDragEnabled(e) || isMouseWindowEnabled(e) )
+        performMouseReleased(e);
+    }
+  
     dragStartPos = null;
   }
 
@@ -172,8 +180,6 @@
   
   
   
-  
-  
   public void performMouseClicked(MouseEvent e) {
   }
 
@@ -198,4 +204,32 @@
   public void performMouseWheelMoved(MouseEvent e) {
   }
 
+
+  private boolean isMouseClickEnabled(MouseEvent e) {
+    switch ( e.getButton() ) {
+      case 1: return isEnabled(MouseInputType.LClick);
+      case 3: return isEnabled(MouseInputType.RClick);
+    }
+    return true;
+  }
+  
+  private boolean isMouseDragEnabled(MouseEvent e) {
+    switch ( e.getButton() ) {
+      case 1: return isEnabled(MouseInputType.LDrag);
+      case 3: return isEnabled(MouseInputType.RDrag);
+    }
+    return true;
+  }
+
+  private boolean isMouseWindowEnabled(MouseEvent e) {
+    switch ( e.getButton() ) {
+      case 1: return isEnabled(MouseInputType.LWin);
+      case 3: return isEnabled(MouseInputType.RWin);
+    }
+    return true;
+  }
+
+
 }
+
+

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java	2010-01-28 15:03:31 UTC (rev 633)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java	2010-01-28 15:22:58 UTC (rev 634)
@@ -30,6 +30,7 @@
 package skrueger.geotools;
 
 import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
 import java.awt.geom.Point2D;
 
 import org.opengis.geometry.DirectPosition;
@@ -76,4 +77,14 @@
    * @param endCoord     geo coordinate the window ends
    */
   public void performWindow(XMapPane mapPane, MouseEvent ev, Point2D dragStartPos, DirectPosition startCoord, DirectPosition endCoord);
+
+  /**
+   * Defines the action in case of a mouse wheel action on the map (the moment
+   * a drag ends).
+   * @param mapPane      map pane the action should be performed on
+   * @param ev           mouse event of the action
+   * @param coord        geo coordinate the wheel is turned on
+   */
+  public void performWheel(XMapPane mapPane, MouseWheelEvent ev, DirectPosition coord);
+
 }



More information about the Schmitzm-commits mailing list