Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## anl.repast.gis.display
Class RepastMapMouseInterpreter

    java.lang.Object
      anl.repast.gis.display.RepastMapMouseInterpreter

All Implemented Interfaces:
  com.bbn.openmap.event.MapMouseListener, com.bbn.openmap.omGraphics.event.MapMouseInterpreter

    public class RepastMapMouseInterpreter

extends java.lang.Object
implements com.bbn.openmap.omGraphics.event.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 occuring 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 movment 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.

Author:
  Robert Najlis (based on OpenMap code)

Nested Class Summary
`protected class` | `RepastMapMouseInterpreter.MouseTimerListener` The definition of the listener that calls updateMouseMoved when the timer goes off.

Field Summary
`protected anl.repast.gis.display.RepastGeometryOfInterest` | `clickInterest`
`protected boolean` | `consumeEvents`
`protected java.awt.event.MouseEvent` | `currentMouseEvent` The last MouseEvent received, for later reference.
`protected boolean` | `DEBUG`
`protected com.bbn.openmap.omGraphics.event.GestureResponsePolicy` | `grp`
`protected java.lang.String` | `lastToolTip`
`protected com.bbn.openmap.layer.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 RepastMapMouseInterpreter.MouseTimerListener` | `mouseTimerListener` The timer listener that calls updateMouseMoved.
`protected anl.repast.gis.display.RepastGeometryOfInterest` | `movementInterest`
`protected boolean` | `noTimerOverOMGraphic`

Constructor Summary
`RepastMapMouseInterpreter()` The OMGraphicLayer should be set at some point before use.
`RepastMapMouseInterpreter(com.bbn.openmap.layer.OMGraphicHandlerLayer l)` The standard constructor.

Method Summary
`void` | `deselect(com.bbn.openmap.omGraphics.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 anl.repast.gis.display.RepastGeometryOfInterest` | `getClickInterest()` Get the RepastGeometryOfInterest 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.
`com.bbn.openmap.omGraphics.OMGraphic` | `getGeometryUnder(java.awt.event.MouseEvent me)` Return the OMGraphic object that is under a mouse event occurance on the map, null if nothing applies.
`com.bbn.openmap.omGraphics.event.GestureResponsePolicy` | `getGRP()` Get the GestureResponsePolicy that is being notified of the mouse actions over the layer's OMGraphicList.
`com.bbn.openmap.layer.OMGraphicHandlerLayer` | `getLayer()`
`java.lang.String[]` | `getMouseModeServiceList()` Return a list of the modes that are interesting to the MapMouseListener.
`int` | `getMouseTimerInterval()`
`protected anl.repast.gis.display.RepastGeometryOfInterest` | `getMovementInterest()` Get the RepastGeometryOfInterest for something that the mouse is over.
`boolean` | `getNoTimerOverOMGraphic()` Get whether the timer should be ignored when movement is occuring 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)` 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(com.bbn.openmap.omGraphics.OMGraphic omg, java.awt.event.MouseEvent me)` Handle a left-click on an OMGraphic.
`boolean` | `leftClickOff(com.bbn.openmap.omGraphics.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(com.bbn.openmap.omGraphics.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(com.bbn.openmap.omGraphics.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(com.bbn.openmap.omGraphics.OMGraphic omg, java.awt.event.MouseEvent me)` Notification that an OMGraphic was right-clicked on.
`boolean` | `rightClickOff(com.bbn.openmap.omGraphics.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(com.bbn.openmap.omGraphics.OMGraphic omg)` Notify the GRP that the OMGraphic has been selected.
`protected void` | `setClickInterest(anl.repast.gis.display.RepastGeometryOfInterest goi)` Set the RepastGeometryOfInterest 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(com.bbn.openmap.omGraphics.event.GestureResponsePolicy grp)` Set the GestureResponsePolicy to notify of the mouse actions over the layer's OMGraphicList.
`void` | `setLayer(com.bbn.openmap.layer.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(anl.repast.gis.display.RepastGeometryOfInterest goi)` Set the RepastGeometryOfInterest for something that the mouse is over.
`void` | `setNoTimerOverOMGraphic(boolean val)` Set whether to ignore the timer when movement is occuring over an OMGraphic.
`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 com.bbn.openmap.layer.OMGraphicHandlerLayer layer

### mouseModeServiceList

    protected java.lang.String[] mouseModeServiceList

### lastToolTip

    protected java.lang.String lastToolTip

### grp

    protected com.bbn.openmap.omGraphics.event.GestureResponsePolicy grp

### clickInterest

    protected anl.repast.gis.display.RepastGeometryOfInterest clickInterest

### movementInterest

    protected anl.repast.gis.display.RepastGeometryOfInterest 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 RepastMapMouseInterpreter.MouseTimerListener mouseTimerListener

  The timer listener that calls updateMouseMoved.

### currentMouseEvent

    protected java.awt.event.MouseEvent currentMouseEvent

  The last MouseEvent received, for later reference.

Constructor Detail

### RepastMapMouseInterpreter

    public RepastMapMouseInterpreter()

  The OMGraphicLayer should be set at some point before use.

### RepastMapMouseInterpreter

    public RepastMapMouseInterpreter(com.bbn.openmap.layer.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 occuring.

### getConsumeEvents

    public boolean getConsumeEvents()

### setLayer

    public void setLayer(com.bbn.openmap.layer.OMGraphicHandlerLayer l)

### getLayer

    public com.bbn.openmap.layer.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 `com.bbn.openmap.event.MapMouseListener`

### setClickInterest

    protected void setClickInterest(anl.repast.gis.display.RepastGeometryOfInterest goi)

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

### getClickInterest

    protected anl.repast.gis.display.RepastGeometryOfInterest getClickInterest()

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

### setMovementInterest

    protected void setMovementInterest(anl.repast.gis.display.RepastGeometryOfInterest goi)

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

### getMovementInterest

    protected anl.repast.gis.display.RepastGeometryOfInterest getMovementInterest()

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

### getGeometryUnder

    public com.bbn.openmap.omGraphics.OMGraphic getGeometryUnder(java.awt.event.MouseEvent me)

  Return the OMGraphic object that is under a mouse event occurance 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 `com.bbn.openmap.event.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 `com.bbn.openmap.event.MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    false

### mouseClicked

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

  Invoked when the mouse has been clicked. Notifies the left, right click methods for the applicable OMGraphic or the map.

  Specified by:
    `mouseClicked` in interface `com.bbn.openmap.event.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 `com.bbn.openmap.event.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 `com.bbn.openmap.event.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 `com.bbn.openmap.event.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 `com.bbn.openmap.event.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 occuring 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 occuring 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 `com.bbn.openmap.event.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 `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`
  Returns:
    false

### leftClick

    public boolean leftClick(com.bbn.openmap.omGraphics.OMGraphic omg,
                             java.awt.event.MouseEvent me)

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

  Specified by:
    `leftClick` in interface `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`
  Returns:
    true

### leftClickOff

    public boolean leftClickOff(com.bbn.openmap.omGraphics.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 `com.bbn.openmap.omGraphics.event.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 `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`
  Returns:
    false

### rightClick

    public boolean rightClick(com.bbn.openmap.omGraphics.OMGraphic omg,
                              java.awt.event.MouseEvent me)

  Notification that an OMGraphic was right-clicked on.

  Specified by:
    `rightClick` in interface `com.bbn.openmap.omGraphics.event.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(com.bbn.openmap.omGraphics.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 `com.bbn.openmap.omGraphics.event.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 `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`
  Returns:
    false

### mouseOver

    public boolean mouseOver(com.bbn.openmap.omGraphics.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 `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`
  Returns:
    true

### handleToolTip

    protected void handleToolTip(java.lang.String tip)

  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(com.bbn.openmap.omGraphics.OMGraphic omg)

  Notification that the mouse has moved off of an OMGraphic.

  Specified by:
    `mouseNotOver` in interface `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`

### select

    public void select(com.bbn.openmap.omGraphics.OMGraphic omg)

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

### deselect

    public void deselect(com.bbn.openmap.omGraphics.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 `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`

### setGRP

    public void setGRP(com.bbn.openmap.omGraphics.event.GestureResponsePolicy grp)

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

  Specified by:
    `setGRP` in interface `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`

### getGRP

    public com.bbn.openmap.omGraphics.event.GestureResponsePolicy getGRP()

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

  Specified by:
    `getGRP` in interface `com.bbn.openmap.omGraphics.event.MapMouseInterpreter`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD