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

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


Author: mojays
Date: 2010-01-28 16:38:33 +0100 (Thu, 28 Jan 2010)
New Revision: 638

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 15:34:01 UTC (rev 637)
+++ branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java	2010-01-28 15:38:33 UTC (rev 638)
@@ -48,6 +48,14 @@
   protected Point2D dragStartPos = null;
   
   /**
+   * Creates a new mouse adapter. All actions are activated initially.
+   */
+  public SelectiveMouseAdapter() {
+    for ( MouseInputType type : MouseInputType.values() )
+      setEnabled(type, true);
+  }
+  
+  /**
    * Sets whether a specific input action of the mouse adapter is
    * enabled.
    * @param type mouse input type 
@@ -133,7 +141,9 @@
   /**
    * Stores the current mouse location in {@link #dragStartPos}.
    * {@link #performMousePressed(MouseEvent)} is only called, if
-   * the respective click action is enabled.
+   * the respective click action is enabled.<br>
+   * For actions which can not be specified by {@link MouseInputType} (e.g. 3rd
+   * mouse button) the perform-method is called generally.
    */
   @Override
   public final void mousePressed(MouseEvent e) {
@@ -149,6 +159,8 @@
    *   <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>
+   * In any case the drag start position is initialized with {@code null}
+   * at the end of this method.
    */
   @Override
   public final void mouseReleased(MouseEvent e) {
@@ -169,67 +181,96 @@
     dragStartPos = null;
   }
 
+  /**
+   * Calls {@link #performMouseWheelMoved(MouseWheelEvent)} if the mouse
+   * action is enabled for mouse wheel events.<br>
+   */
   @Override
   public final void mouseWheelMoved(MouseWheelEvent e) {
+    if ( isEnabled(MouseInputType.Wheel) )
+      performMouseWheelMoved(e);
   }
 
-  
-  
-  
-  
-  
-  
-  
+  /**
+   * Empty implementation.  
+   */
   public void performMouseClicked(MouseEvent e) {
   }
 
+  /**
+   * Empty implementation.  
+   */
   public void performMouseDragged(MouseEvent e) {
   }
   
+  /**
+   * Empty implementation.  
+   */
   public void performMouseEntered(MouseEvent e) {
   }
   
+  /**
+   * Empty implementation.  
+   */
   public void performMouseExited(MouseEvent e) {
   }
 
+  /**
+   * Empty implementation.  
+   */
   public void performMouseMoved(MouseEvent e) {
   }
 
+  /**
+   * Empty implementation.  
+   */
   public void performMousePressed(MouseEvent e) {
   }
 
+  /**
+   * Empty implementation.  
+   */
   public void performMouseReleased(MouseEvent e) {
   }
 
+  /**
+   * Empty implementation.  
+   */
   public void performMouseWheelMoved(MouseWheelEvent e) {
   }
 
-
+  /**
+   * Checks whether the click is enabled for a mouse event.
+   */
   private boolean isMouseClickEnabled(MouseEvent e) {
     switch ( e.getButton() ) {
-      case 1: return isEnabled(MouseInputType.LClick);
-      case 3: return isEnabled(MouseInputType.RClick);
+      case MouseEvent.BUTTON1: return isEnabled(MouseInputType.LClick);
+      case MouseEvent.BUTTON3: return isEnabled(MouseInputType.RClick);
     }
-    return true;
+    return e.getButton() != MouseEvent.NOBUTTON;
   }
   
+  /**
+   * Checks whether dragging is enabled for a mouse event.
+   */
   private boolean isMouseDragEnabled(MouseEvent e) {
     switch ( e.getButton() ) {
-      case 1: return isEnabled(MouseInputType.LDrag);
-      case 3: return isEnabled(MouseInputType.RDrag);
+      case MouseEvent.BUTTON1: return isEnabled(MouseInputType.LDrag);
+      case MouseEvent.BUTTON3: return isEnabled(MouseInputType.RDrag);
     }
-    return true;
+    return e.getButton() != MouseEvent.NOBUTTON;
   }
 
+  /**
+   * Checks whether window selection is enabled for a mouse event.
+   */
   private boolean isMouseWindowEnabled(MouseEvent e) {
     switch ( e.getButton() ) {
-      case 1: return isEnabled(MouseInputType.LWin);
-      case 3: return isEnabled(MouseInputType.RWin);
+      case MouseEvent.BUTTON1: return isEnabled(MouseInputType.LWin);
+      case MouseEvent.BUTTON3: return isEnabled(MouseInputType.RWin);
     }
-    return true;
+    return e.getButton() != MouseEvent.NOBUTTON;
   }
-
-
 }
 
 



More information about the Schmitzm-commits mailing list