org.das2.event
Class DasMouseInputAdapter

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by javax.swing.event.MouseInputAdapter
          extended by org.das2.event.DasMouseInputAdapter
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener, javax.swing.event.MouseInputListener, Editable

public class DasMouseInputAdapter
extends javax.swing.event.MouseInputAdapter
implements Editable, java.awt.event.MouseWheelListener

DasMouseInputAdapter delegates mouse and key events to mouse modules, which do something with the events. Also, mouse events are promoted to MouseDragEvents which conveniently store information about the entire drag gesture. The base class of MouseModule has do-nothing stubs for KeyListener, MouseListener, MouseMotionListener, and MouseWheelListener, which can be implemented if the module wants to do something with these events. Also MouseDragEvents will be sent to the module as its DragRenderer has requested: after the mouse release, during the drag, or when keys are pressed. The module will first receive the low-level events before receiving the MouseDragEvents.


Field Summary
protected  DasCanvasComponent parent
           
protected  java.awt.event.ActionListener popupListener
           
protected  javax.swing.JPopupMenu primaryPopup
           
protected  javax.swing.JPopupMenu secondaryPopup
           
 
Constructor Summary
DasMouseInputAdapter(DasCanvasComponent parent)
          Creates a new instance of dasMouseInputAdapter
 
Method Summary
 javax.swing.JMenu addMenu(java.lang.String label)
          return a menu with font to match LAF.
 void addMenuItem(java.awt.Component b)
           
 void addMouseModule(MouseModule module)
          add a mouse module to the list of available modules.
 java.awt.event.KeyAdapter getKeyAdapter()
           
 MouseModule getModuleByLabel(java.lang.String label)
           
 MouseModule getMouseModule(int i)
          Getter for property mouseModules.
 MouseModule[] getMouseModules()
           
 java.awt.Point getMousePressPosition()
          returns the position of the last mouse press.
 boolean getPinned()
           
 MouseModule getPrimaryModule()
           
 java.lang.String getPrimaryModuleByLabel()
           
 java.lang.String getPrimaryModuleLabel()
          Deprecated. use getPrimaryModuleByLabel
 MouseModule getSecondaryModule()
           
 java.lang.String getSecondaryModuleByLabel()
           
 java.lang.String getSecondaryModuleLabel()
          Deprecated. use getSecondaryModuleByLabel
 boolean isHoverHighlite()
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
 void paint(java.awt.Graphics g1)
           
 void removeMenuItem(java.lang.String label)
          hack to provide way to get rid of "Dump Data".
 void removeMouseModule(MouseModule module)
           
 void replaceMouseModule(MouseModule oldModule, MouseModule newModule)
           
 void setHoverHighlite(boolean value)
           
 void setMouseModule(int i, MouseModule mouseModule)
          //TODO: check this Setter for property mouseModules.
 void setPinned(boolean b)
           
 void setPrimaryModule(MouseModule module)
          set the primary module, the module receiving left-button events, to the module provided.
 void setPrimaryModuleByLabel(java.lang.String label)
           
 void setSecondaryModule(MouseModule module)
          set the secondary module, the module receiving middle-button events, to the module provided.
 void setSecondaryModuleByLabel(java.lang.String label)
           
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.MouseListener
mouseClicked
 

Field Detail

primaryPopup

protected javax.swing.JPopupMenu primaryPopup

secondaryPopup

protected javax.swing.JPopupMenu secondaryPopup

popupListener

protected java.awt.event.ActionListener popupListener

parent

protected DasCanvasComponent parent
Constructor Detail

DasMouseInputAdapter

public DasMouseInputAdapter(DasCanvasComponent parent)
Creates a new instance of dasMouseInputAdapter

Method Detail

replaceMouseModule

public void replaceMouseModule(MouseModule oldModule,
                               MouseModule newModule)

addMouseModule

public void addMouseModule(MouseModule module)
add a mouse module to the list of available modules. If a module with the same label exists already, it will be replaced.


getKeyAdapter

public java.awt.event.KeyAdapter getKeyAdapter()

getPrimaryModule

public MouseModule getPrimaryModule()

getSecondaryModule

public MouseModule getSecondaryModule()

setPrimaryModule

public void setPrimaryModule(MouseModule module)
set the primary module, the module receiving left-button events, to the module provided. If the module is not already loaded, implicitly addMouseModule is called.


setSecondaryModule

public void setSecondaryModule(MouseModule module)
set the secondary module, the module receiving middle-button events, to the module provided. If the module is not already loaded, implicitly addMouseModule is called.


paint

public void paint(java.awt.Graphics g1)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class java.awt.event.MouseAdapter

setPinned

public void setPinned(boolean b)

getPinned

public boolean getPinned()

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class java.awt.event.MouseAdapter

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class java.awt.event.MouseAdapter

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class java.awt.event.MouseAdapter

removeMouseModule

public void removeMouseModule(MouseModule module)

getMouseModule

public MouseModule getMouseModule(int i)
Getter for property mouseModules.

Returns:
Value of property mouseModules.

getMouseModules

public MouseModule[] getMouseModules()

getPrimaryModuleLabel

public java.lang.String getPrimaryModuleLabel()
Deprecated. use getPrimaryModuleByLabel

Returns:

getPrimaryModuleByLabel

public java.lang.String getPrimaryModuleByLabel()

setPrimaryModuleByLabel

public void setPrimaryModuleByLabel(java.lang.String label)

getSecondaryModuleLabel

public java.lang.String getSecondaryModuleLabel()
Deprecated. use getSecondaryModuleByLabel

Returns:

getSecondaryModuleByLabel

public java.lang.String getSecondaryModuleByLabel()

setSecondaryModuleByLabel

public void setSecondaryModuleByLabel(java.lang.String label)

setMouseModule

public void setMouseModule(int i,
                           MouseModule mouseModule)
//TODO: check this Setter for property mouseModules.

Parameters:
mouseModule - the new mouseModule to use.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class java.awt.event.MouseAdapter

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class java.awt.event.MouseAdapter

removeMenuItem

public void removeMenuItem(java.lang.String label)
hack to provide way to get rid of "Dump Data".

Parameters:
label - string to search for.

addMenuItem

public void addMenuItem(java.awt.Component b)

addMenu

public javax.swing.JMenu addMenu(java.lang.String label)
return a menu with font to match LAF.

Parameters:
label -
Returns:

getModuleByLabel

public MouseModule getModuleByLabel(java.lang.String label)

isHoverHighlite

public boolean isHoverHighlite()

setHoverHighlite

public void setHoverHighlite(boolean value)

getMousePressPosition

public java.awt.Point getMousePressPosition()
returns the position of the last mouse press. This is a hack so that the mouse position can be obtained to get the context of the press. The result point is in the parent's coordinate system.


mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener
Overrides:
mouseWheelMoved in class java.awt.event.MouseAdapter