## com.bbn.openmap.omGraphics.event
Class StandardMapMouseInterpreter

    java.lang.Object
      com.bbn.openmap.omGraphics.event.StandardMapMouseInterpreter

All Implemented Interfaces:
  MapMouseInterpreter, MapMouseListener

Direct Known Subclasses:
  AbstractEditorTool

public class StandardMapMouseInterpreter
extends java.lang.Object
implements MapMouseInterpreter

The StandardMapMouseInterpreter is a basic implementation of the MapMouseInterpreter, working with an OMGraphicHandlerLayer to handle MouseEvents on it. This class allows the OMGraphicHandlerLayer, which implements the GestureResponsePolicy, to not have to deal with MouseEvents and the OMGraphicList, but to just react to the meanings of the user's gestures.

The StandardMapMouseInterpreter uses highlighing to indicate that mouse movement is occurring over an OMGraphic, and gives the layer three ways to react to that movement. After finding out if the OMGraphic is highlightable, the SMMI will tell the layer to highlight the OMGraphic (which usually means to call select() on it), provide a tool tip string for the OMGraphic, and provide a string to use on the InformationDelegator info line. The layer can reply or ignore any and all of these notifications, depending on how it's supposed to act.

For left mouse clicks, the SMMI uses selection as a notification that the user is choosing an OMGraphic, and that the OMGraphic should be prepared to be moved, modified or deleted. For a single OMGraphic, this is usually handled by handing the OMGraphic off to the OMDrawingTool. However the GestureResponsPolicy handles the situation where the selection is of multiple OMGraphics, and the layer should prepare to handle those situations as movement or deletion notifications. This usually means to change the OMGraphic's display to indicate that the OMGraphics have been selected. Selection notifications can come in series, and the GestureResponsePolicy is expected to keep track of which OMGraphics it has been told are selected. Deselection notifications may come as well, or other action notifications such as cut or copy may arrive. For cut and copy notifications, the OMGraphics should be removed from any selection list. For pastings, the OMGraphics should be added to the selection list.

For right mouse clicks, the layer will be provided with a JPopupMenu to use to populate with options for actions over a OMGraphic or over the map.

The StandardMapMouseInterpreter uses a timer to pace how mouse movement actions are responded to. Highlight reactions only occur after the mouse has paused over the map for the timer interval, so the application doesn't try to respond to constantly changing mouse locations. You can disable this delay by setting the timer interval to zero.

Nested Class Summary
`class` `StandardMapMouseInterpreter.GeometryOfInterest` Helper class used to keep track of OMGraphics of interest.
`protected class` `StandardMapMouseInterpreter.MouseTimerListener` The definition of the listener that calls updateMouseMoved when the timer goes off.

Field Summary
`protected StandardMapMouseInterpreter.GeometryOfInterest` `clickInterest`
`protected boolean` `consumeEvents`
`protected java.awt.event.MouseEvent` `currentMouseEvent` The last MouseEvent received, for later reference.
`protected boolean` `DEBUG`
`protected GestureResponsePolicy` `grp`
`protected java.lang.String` `lastToolTip`
`protected OMGraphicHandlerLayer` `layer`
`protected java.lang.String[]` `mouseModeServiceList`
`protected javax.swing.Timer` `mouseTimer` The timer used to track the wait interval.
`protected int` `mouseTimerInterval` The wait interval before a mouse over event gets triggered.
`protected StandardMapMouseInterpreter.MouseTimerListener` `mouseTimerListener` The timer listener that calls updateMouseMoved.
`protected StandardMapMouseInterpreter.GeometryOfInterest` `movementInterest`
`protected boolean` `noTimerOverOMGraphic`

Constructor Summary
`StandardMapMouseInterpreter()` The OMGraphicLayer should be set at some point before use.
`StandardMapMouseInterpreter(OMGraphicHandlerLayer l)` The standard constructor.

Method Summary
`void` `deselect(OMGraphic omg)` Notify the GRP that the OMGraphic has been deselected.
`protected boolean` `displayPopup(java.util.List contents, java.awt.event.MouseEvent me)` Create a popup menu from GRP requests, over the mouse event location.
`protected StandardMapMouseInterpreter.GeometryOfInterest` `getClickInterest()` Get the GeometryOfInterest as one that could possibly be in the process of being clicked upon.
`boolean` `getConsumeEvents()`
`java.awt.event.MouseEvent` `getCurrentMouseEvent()` Get the last MouseEvent received.
`OMGraphic` `getGeometryUnder(java.awt.event.MouseEvent me)` Return the OMGraphic object that is under a mouse event occurrance on the map, null if nothing applies.
`GestureResponsePolicy` `getGRP()` Get the GestureResponsePolicy that is being notified of the mouse actions over the layer's OMGraphicList.
`OMGraphicHandlerLayer` `getLayer()`
`java.lang.String[]` `getMouseModeServiceList()` Return a list of the modes that are interesting to the MapMouseListener.
`int` `getMouseTimerInterval()`
`protected StandardMapMouseInterpreter.GeometryOfInterest` `getMovementInterest()` Get the GeometryOfInterest for something that the mouse is over.
`boolean` `getNoTimerOverOMGraphic()` Get whether the timer should be ignored when movement is occurring over an OMGraphic.
`protected void` `handleInfoLine(java.lang.String line)` Given an information line, use the layer to get it displayed on the InformationDelegator.
`protected void` `handleToolTip(java.lang.String tip, java.awt.event.MouseEvent me)` Given a tool tip String, use the layer to get it displayed.
`boolean` `isLeftMouseButton(java.awt.event.MouseEvent me)` A method to set how a left mouse button is interpreted.
`boolean` `leftClick(java.awt.event.MouseEvent me)` Handle a left-click on the map.
`boolean` `leftClick(OMGraphic omg, java.awt.event.MouseEvent me)` Handle a left-click on an OMGraphic.
`boolean` `leftClickOff(OMGraphic omg, java.awt.event.MouseEvent me)` Notification that the user clicked on something else other than the provided OMGraphic that was previously left-clicked on.
`boolean` `mouseClicked(java.awt.event.MouseEvent e)` Invoked when the mouse has been clicked.
`boolean` `mouseDragged(java.awt.event.MouseEvent e)` Invoked when a mouse button has been pressed and is moving.
`void` `mouseEntered(java.awt.event.MouseEvent e)` Invoked when the mouse enters a component.
`void` `mouseExited(java.awt.event.MouseEvent e)` Invoked when the mouse exits a component.
`void` `mouseMoved()` Handle notification that another layer consumed a mouse moved event.
`boolean` `mouseMoved(java.awt.event.MouseEvent e)` Invoked when the mouse has been moved.
`boolean` `mouseNotOver(OMGraphic omg)` Notification that the mouse has moved off of an OMGraphic.
`boolean` `mouseOver(java.awt.event.MouseEvent me)` Notification that the mouse is not over an OMGraphic, but over the map at some location.
`boolean` `mouseOver(OMGraphic omg, java.awt.event.MouseEvent me)` Notification that the mouse is over an OMGraphic.
`boolean` `mousePressed(java.awt.event.MouseEvent e)` Invoked when a mouse button has been pressed on a component.
`boolean` `mouseReleased(java.awt.event.MouseEvent e)` Invoked when a mouse button has been released on a component.
`boolean` `rightClick(java.awt.event.MouseEvent me)` Notification that the map was right-clicked on.
`boolean` `rightClick(OMGraphic omg, java.awt.event.MouseEvent me)` Notification that an OMGraphic was right-clicked on.
`boolean` `rightClickOff(OMGraphic omg, java.awt.event.MouseEvent me)` Notification that the user clicked on something else other than the provided OMGraphic that was previously right-clicked on.
`void` `select(OMGraphic omg)` Notify the GRP that the OMGraphic has been selected.
`protected void` `setClickInterest(StandardMapMouseInterpreter.GeometryOfInterest goi)` Set the GeometryOfInterest as one that could possibly be in the process of being clicked upon.
`void` `setConsumeEvents(boolean consume)` A flag to tell the interpreter to be selfish about consuming MouseEvents it receives.
`protected void` `setCurrentMouseEvent(java.awt.event.MouseEvent me)` Set the last MouseEvent received.
`void` `setGRP(GestureResponsePolicy grp)` Set the GestureResponsePolicy to notify of the mouse actions over the layer's OMGraphicList.
`void` `setLayer(OMGraphicHandlerLayer l)`
`void` `setMouseModeServiceList(java.lang.String[] list)` Set the ID's of the mouse modes that this interpreter should be listening to.
`void` `setMouseTimerInterval(int interval)` Set the time interval that the mouse timer waits before calling upateMouseMoved.
`protected void` `setMovementInterest(StandardMapMouseInterpreter.GeometryOfInterest goi)` Set the GeometryOfInterest for something that the mouse is over.
`void` `setNoTimerOverOMGraphic(boolean val)` Set whether to ignore the timer when movement is occurring over an OMGraphic.
`boolean` `testForAndHandlePopupTrigger(java.awt.event.MouseEvent e)` Tests the MouseEvent to see if it's a popup trigger, and calls rightClick appropriately if there is an OMGraphic involved.
`protected boolean` `updateMouseMoved(java.awt.event.MouseEvent e)` The real mouseMoved call, called when mouseMoved is called and, if there is a mouse timer interval set, that interval time has passed.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEBUG

    protected boolean DEBUG

### layer

    protected OMGraphicHandlerLayer layer

### mouseModeServiceList

    protected java.lang.String[] mouseModeServiceList

### lastToolTip

    protected java.lang.String lastToolTip

### grp

    protected GestureResponsePolicy grp

### clickInterest

    protected StandardMapMouseInterpreter.GeometryOfInterest clickInterest

### movementInterest

    protected StandardMapMouseInterpreter.GeometryOfInterest movementInterest

### consumeEvents

    protected boolean consumeEvents

### noTimerOverOMGraphic

    protected boolean noTimerOverOMGraphic

### mouseTimerInterval

    protected int mouseTimerInterval

  The wait interval before a mouse over event gets triggered.

### mouseTimer

    protected javax.swing.Timer mouseTimer

  The timer used to track the wait interval.

### mouseTimerListener

    protected StandardMapMouseInterpreter.MouseTimerListener mouseTimerListener

  The timer listener that calls updateMouseMoved.

### currentMouseEvent

    protected java.awt.event.MouseEvent currentMouseEvent

  The last MouseEvent received, for later reference.

Constructor Detail

### StandardMapMouseInterpreter

    public StandardMapMouseInterpreter()

  The OMGraphicLayer should be set at some point before use.

### StandardMapMouseInterpreter

    public StandardMapMouseInterpreter(OMGraphicHandlerLayer l)

  The standard constructor.

Method Detail

### setConsumeEvents

    public void setConsumeEvents(boolean consume)

  A flag to tell the interpreter to be selfish about consuming MouseEvents it receives. If set to true, it will consume events so that other MapMouseListeners will not receive the events. If false, lower layers will also receive events, which will let them react too. Intended to let other layers provide information about what the mouse is over when editing is occurring.

### getConsumeEvents

    public boolean getConsumeEvents()

### setLayer

    public void setLayer(OMGraphicHandlerLayer l)

### getLayer

    public OMGraphicHandlerLayer getLayer()

### setMouseModeServiceList

    public void setMouseModeServiceList(java.lang.String[] list)

  Set the ID's of the mouse modes that this interpreter should be listening to. If set to null, this SMMI won't receive MouseEvents.

### isLeftMouseButton

    public boolean isLeftMouseButton(java.awt.event.MouseEvent me)

  A method to set how a left mouse button is interpreted. We count control-clicks as not a left mouse click.

### getMouseModeServiceList

    public java.lang.String[] getMouseModeServiceList()

  Return a list of the modes that are interesting to the MapMouseListener. You MUST override this with the modes you're interested in, or set the mouse mode service list, or you won't receive mouse events.

  Specified by:
    `getMouseModeServiceList` in interface `MapMouseListener`
  Returns:
    String[] of modeID's
  See Also:
    `NavMouseMode.modeID`, `SelectMouseMode.modeID`, `NullMouseMode.modeID`

### setClickInterest

    protected void setClickInterest(StandardMapMouseInterpreter.GeometryOfInterest goi)

  Set the GeometryOfInterest as one that could possibly be in the process of being clicked upon.

### getClickInterest

    protected StandardMapMouseInterpreter.GeometryOfInterest getClickInterest()

  Get the GeometryOfInterest as one that could possibly be in the process of being clicked upon.

### setMovementInterest

    protected void setMovementInterest(StandardMapMouseInterpreter.GeometryOfInterest goi)

  Set the GeometryOfInterest for something that the mouse is over. Prevents excessive modifications of the GUI if this remains constant.

### getMovementInterest

    protected StandardMapMouseInterpreter.GeometryOfInterest getMovementInterest()

  Get the GeometryOfInterest for something that the mouse is over. Prevents excessive modifications of the GUI if this remains constant.

### getGeometryUnder

    public OMGraphic getGeometryUnder(java.awt.event.MouseEvent me)

  Return the OMGraphic object that is under a mouse event occurrance on the map, null if nothing applies.

### mousePressed

    public boolean mousePressed(java.awt.event.MouseEvent e)

  Invoked when a mouse button has been pressed on a component.

  Specified by:
    `mousePressed` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    false if nothing was pressed over, or the consumeEvents setting if something was.

### mouseReleased

    public boolean mouseReleased(java.awt.event.MouseEvent e)

  Invoked when a mouse button has been released on a component.

  Specified by:
    `mouseReleased` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    false

### testForAndHandlePopupTrigger

    public boolean testForAndHandlePopupTrigger(java.awt.event.MouseEvent e)

  Tests the MouseEvent to see if it's a popup trigger, and calls rightClick appropriately if there is an OMGraphic involved.

  Parameters:
    `e` - MouseEvent
  Returns:
    true if the MouseEvent is a popup trigger and has been consumed.

### mouseClicked

    public boolean mouseClicked(java.awt.event.MouseEvent e)

  Invoked when the mouse has been clicked. Notifies the left click methods for the applicable OMGraphic or the map. Right click methods are handled when the testForAndHandlePopupTrigger method is called in mousePressed and mouseReleased.

  Specified by:
    `mouseClicked` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    the consumeEvents setting.

### mouseEntered

    public void mouseEntered(java.awt.event.MouseEvent e)

  Invoked when the mouse enters a component.

  Specified by:
    `mouseEntered` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent

### mouseExited

    public void mouseExited(java.awt.event.MouseEvent e)

  Invoked when the mouse exits a component.

  Specified by:
    `mouseExited` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent

### mouseDragged

    public boolean mouseDragged(java.awt.event.MouseEvent e)

  Invoked when a mouse button has been pressed and is moving. Resets the click geometry of interest to null.

  Specified by:
    `mouseDragged` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    the result from mouseMoved (also called from this method) combined with the consumeEvents setting.

### mouseMoved

    public boolean mouseMoved(java.awt.event.MouseEvent e)

  Invoked when the mouse has been moved. Sets the movement geometry of interest and updates the movement timer.

  Specified by:
    `mouseMoved` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    the result of updateMouseMoved() if the timer isn't being used, or false.

### setNoTimerOverOMGraphic

    public void setNoTimerOverOMGraphic(boolean val)

  Set whether to ignore the timer when movement is occurring over an OMGraphic. Sometimes unhighlight can be inappropriately delayed when timer is enabled.

### getNoTimerOverOMGraphic

    public boolean getNoTimerOverOMGraphic()

  Get whether the timer should be ignored when movement is occurring over an OMGraphic.

### setMouseTimerInterval

    public void setMouseTimerInterval(int interval)

  Set the time interval that the mouse timer waits before calling upateMouseMoved. A negative number or zero will disable the timer.

### getMouseTimerInterval

    public int getMouseTimerInterval()

### updateMouseMoved

    protected boolean updateMouseMoved(java.awt.event.MouseEvent e)

  The real mouseMoved call, called when mouseMoved is called and, if there is a mouse timer interval set, that interval time has passed.

  Returns:
    the consumeEvents setting of the mouse event concerns an OMGraphic, false if it didn't.

### mouseMoved

    public void mouseMoved()

  Handle notification that another layer consumed a mouse moved event. Sets movement interest to null.

  Specified by:
    `mouseMoved` in interface `MapMouseListener`

### leftClick

    public boolean leftClick(java.awt.event.MouseEvent me)

  Handle a left-click on the map. Does nothing by default.

  Specified by:
    `leftClick` in interface `MapMouseInterpreter`
  Returns:
    false

### leftClick

    public boolean leftClick(OMGraphic omg,
                             java.awt.event.MouseEvent me)

  Handle a left-click on an OMGraphic. Does nothing by default.

  Specified by:
    `leftClick` in interface `MapMouseInterpreter`
  Returns:
    true

### leftClickOff

    public boolean leftClickOff(OMGraphic omg,
                                java.awt.event.MouseEvent me)

  Notification that the user clicked on something else other than the provided OMGraphic that was previously left-clicked on. Calls deselect(omg).

  Specified by:
    `leftClickOff` in interface `MapMouseInterpreter`
  Returns:
    false

### rightClick

    public boolean rightClick(java.awt.event.MouseEvent me)

  Notification that the map was right-clicked on.

  Specified by:
    `rightClick` in interface `MapMouseInterpreter`
  Returns:
    false

### rightClick

    public boolean rightClick(OMGraphic omg,
                              java.awt.event.MouseEvent me)

  Notification that an OMGraphic was right-clicked on.

  Specified by:
    `rightClick` in interface `MapMouseInterpreter`
  Returns:
    true

### displayPopup

    protected boolean displayPopup(java.util.List contents,
                                   java.awt.event.MouseEvent me)

  Create a popup menu from GRP requests, over the mouse event location.

  Returns:
    true if popup was presented, false if not.

### rightClickOff

    public boolean rightClickOff(OMGraphic omg,
                                 java.awt.event.MouseEvent me)

  Notification that the user clicked on something else other than the provided OMGraphic that was previously right-clicked on.

  Specified by:
    `rightClickOff` in interface `MapMouseInterpreter`
  Returns:
    false

### mouseOver

    public boolean mouseOver(java.awt.event.MouseEvent me)

  Notification that the mouse is not over an OMGraphic, but over the map at some location.

  Specified by:
    `mouseOver` in interface `MapMouseInterpreter`
  Returns:
    false

### mouseOver

    public boolean mouseOver(OMGraphic omg,
                             java.awt.event.MouseEvent me)

  Notification that the mouse is over an OMGraphic. Makes all the highlight calls.

  Specified by:
    `mouseOver` in interface `MapMouseInterpreter`
  Returns:
    true

### handleToolTip

    protected void handleToolTip(java.lang.String tip,
                                 java.awt.event.MouseEvent me)

  Given a tool tip String, use the layer to get it displayed.

### handleInfoLine

    protected void handleInfoLine(java.lang.String line)

  Given an information line, use the layer to get it displayed on the InformationDelegator.

### mouseNotOver

    public boolean mouseNotOver(OMGraphic omg)

  Notification that the mouse has moved off of an OMGraphic.

  Specified by:
    `mouseNotOver` in interface `MapMouseInterpreter`

### select

    public void select(OMGraphic omg)

  Notify the GRP that the OMGraphic has been selected. Wraps the OMGraphic in an OMGraphicList.

### deselect

    public void deselect(OMGraphic omg)

  Notify the GRP that the OMGraphic has been deselected. Wraps the OMGraphic in an OMGraphicList.

### setCurrentMouseEvent

    protected void setCurrentMouseEvent(java.awt.event.MouseEvent me)

  Set the last MouseEvent received.

### getCurrentMouseEvent

    public java.awt.event.MouseEvent getCurrentMouseEvent()

  Get the last MouseEvent received.

  Specified by:
    `getCurrentMouseEvent` in interface `MapMouseInterpreter`

### setGRP

    public void setGRP(GestureResponsePolicy grp)

  Set the GestureResponsePolicy to notify of the mouse actions over the layer's OMGraphicList.

  Specified by:
    `setGRP` in interface `MapMouseInterpreter`

### getGRP

    public GestureResponsePolicy getGRP()

  Get the GestureResponsePolicy that is being notified of the mouse actions over the layer's OMGraphicList.

  Specified by:
    `getGRP` in interface `MapMouseInterpreter`

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details