schmitzm.swing.event
Class SelectiveMouseAdapter

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by schmitzm.swing.event.SelectiveMouseAdapter
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener
Direct Known Subclasses:
XMapPaneMouseListener

public class SelectiveMouseAdapter
extends MouseAdapter

Author:
Martin Schmitz (University of Bonn/Germany)

Field Summary
protected  Map<MouseInputType,Boolean> activationMap
          Holds the activation of the several MouseInputTypes.
protected  int dragButton
          Holds the button the drag is performed with.
protected  Point dragLastPos
          Holds the window position of last mouseDragged(MouseEvent) call (e.g. to remove a dragging rectangle).
protected  Point dragStartPos
          Holds the window position a drag is started on.
 
Constructor Summary
SelectiveMouseAdapter()
          Creates a new mouse adapter.
 
Method Summary
 int getDragButton()
          Returns the button a drag is performed with.
 Point getDragLastPoint()
          Returns the window selection of the last mouseDragged(MouseEvent) call.
 Point getDragStartPoint()
          Returns the start point of a drag or window selection.
 boolean isEnabled(MouseInputType type)
          Returns whether a specific input action of the mouse adapter is enabled.
 void mouseClicked(MouseEvent e)
          Calls performMouseClicked(MouseEvent) if the mouse action is enabled for the click.
 void mouseDragged(MouseEvent e)
          Calls performMouseDragged(MouseEvent) if the mouse action is enabled for the drag.
 void mouseEntered(MouseEvent e)
          Calls performMouseDragged(MouseEvent) in any case, because enter, exit and move can not be specified by MouseInputType.
 void mouseExited(MouseEvent e)
          Calls performMouseExited(MouseEvent) in any case, because enter, exit and move can not be specified by MouseInputType.
 void mouseMoved(MouseEvent e)
          Calls performMouseExited(MouseEvent) in any case, because enter, exit and move can not be specified by MouseInputType.
 void mousePressed(MouseEvent e)
          Stores the current mouse location in dragStartPos.
 void mouseReleased(MouseEvent e)
          Calls performMouseReleased(MouseEvent) only in the following cases Startposition = Endposition and the mouse click action is activated Startposition !
 void mouseWheelMoved(MouseWheelEvent e)
          Calls performMouseWheelMoved(MouseWheelEvent) if the mouse action is enabled for mouse wheel events.
 void performMouseClicked(MouseEvent e)
          Empty implementation.
 void performMouseDragged(MouseEvent e)
          Empty implementation.
 void performMouseEntered(MouseEvent e)
          Empty implementation.
 void performMouseExited(MouseEvent e)
          Empty implementation.
 void performMouseMoved(MouseEvent e)
          Empty implementation.
 void performMousePressed(MouseEvent e)
          Empty implementation.
 void performMouseReleased(MouseEvent e)
          Empty implementation.
 void performMouseWheelMoved(MouseWheelEvent e)
          Empty implementation.
 void setEnabled(MouseInputType type, boolean enabled)
          Sets whether a specific input action of the mouse adapter is enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activationMap

protected Map<MouseInputType,Boolean> activationMap
Holds the activation of the several MouseInputTypes.


dragButton

protected int dragButton
Holds the button the drag is performed with.


dragStartPos

protected Point dragStartPos
Holds the window position a drag is started on.


dragLastPos

protected Point dragLastPos
Holds the window position of last mouseDragged(MouseEvent) call (e.g. to remove a dragging rectangle).

Constructor Detail

SelectiveMouseAdapter

public SelectiveMouseAdapter()
Creates a new mouse adapter. All actions are activated initially.

Method Detail

setEnabled

public void setEnabled(MouseInputType type,
                       boolean enabled)
Sets whether a specific input action of the mouse adapter is enabled.

Parameters:
type - mouse input type
enabled - true to enable the action

isEnabled

public boolean isEnabled(MouseInputType type)
Returns whether a specific input action of the mouse adapter is enabled.

Parameters:
type - mouse input type

getDragStartPoint

public Point getDragStartPoint()
Returns the start point of a drag or window selection.


getDragLastPoint

public Point getDragLastPoint()
Returns the window selection of the last mouseDragged(MouseEvent) call.


getDragButton

public int getDragButton()
Returns the button a drag is performed with.
Note: This method only returns the button DURING a drag. If no drag is performed MouseEvent.NOBUTTON is returned! call.


mouseClicked

public final void mouseClicked(MouseEvent e)
Calls performMouseClicked(MouseEvent) if the mouse action is enabled for the click.
For actions which can not be specified by MouseInputType (e.g. 3rd mouse button) the perform-method is called generally.
In any case the drag start position is initialized with null at the end of this method.

Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class MouseAdapter

mouseDragged

public final void mouseDragged(MouseEvent e)
Calls performMouseDragged(MouseEvent) if the mouse action is enabled for the drag.
For actions which can not be specified by MouseInputType (e.g. 3rd mouse button) the perform-method is called generally.

Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class MouseAdapter

mouseEntered

public final void mouseEntered(MouseEvent e)
Calls performMouseDragged(MouseEvent) in any case, because enter, exit and move can not be specified by MouseInputType.

Specified by:
mouseEntered in interface MouseListener
Overrides:
mouseEntered in class MouseAdapter

mouseExited

public final void mouseExited(MouseEvent e)
Calls performMouseExited(MouseEvent) in any case, because enter, exit and move can not be specified by MouseInputType.

Specified by:
mouseExited in interface MouseListener
Overrides:
mouseExited in class MouseAdapter

mouseMoved

public final void mouseMoved(MouseEvent e)
Calls performMouseExited(MouseEvent) in any case, because enter, exit and move can not be specified by MouseInputType.

Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class MouseAdapter

mousePressed

public final void mousePressed(MouseEvent e)
Stores the current mouse location in dragStartPos. performMousePressed(MouseEvent) is only called, if the respective click action is enabled.
For actions which can not be specified by MouseInputType (e.g. 3rd mouse button) the perform-method is called generally.

Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseAdapter

mouseReleased

public final void mouseReleased(MouseEvent e)
Calls performMouseReleased(MouseEvent) only in the following cases In any case the drag start position is initialized with null at the end of this method.

Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseAdapter

mouseWheelMoved

public final void mouseWheelMoved(MouseWheelEvent e)
Calls performMouseWheelMoved(MouseWheelEvent) if the mouse action is enabled for mouse wheel events.

Specified by:
mouseWheelMoved in interface MouseWheelListener
Overrides:
mouseWheelMoved in class MouseAdapter

performMouseClicked

public void performMouseClicked(MouseEvent e)
Empty implementation.


performMouseDragged

public void performMouseDragged(MouseEvent e)
Empty implementation.


performMouseEntered

public void performMouseEntered(MouseEvent e)
Empty implementation.


performMouseExited

public void performMouseExited(MouseEvent e)
Empty implementation.


performMouseMoved

public void performMouseMoved(MouseEvent e)
Empty implementation.


performMousePressed

public void performMousePressed(MouseEvent e)
Empty implementation.


performMouseReleased

public void performMouseReleased(MouseEvent e)
Empty implementation.


performMouseWheelMoved

public void performMouseWheelMoved(MouseWheelEvent e)
Empty implementation.