public class StandardMapMouseInterpreter extends java.lang.Object implements MapMouseInterpreter
The StandardMapMouseInterpreter uses highlighting 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.
Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
active |
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 and Description |
---|
StandardMapMouseInterpreter()
The OMGraphicLayer should be set at some point before use.
|
StandardMapMouseInterpreter(OMGraphicHandlerLayer l)
The standard constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
deselect(OMGraphic omg)
Notify the GRP that the OMGraphic has been deselected.
|
protected boolean |
displayPopup(java.util.List<java.awt.Component> contents,
java.awt.event.MouseEvent me)
Create a pop-up 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 occurrence 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 |
isActive()
Check whether the MapMouseInterpreter is responding to events.
|
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.
|
void |
setActive(boolean active)
Set whether the MapMouseInterpreter responds
|
protected void |
setClickInterest(StandardMapMouseInterpreter.GeometryOfInterest goi)
Set the GeometryOfInterest as one that could possibly be in the process
of being clicked upon.
|
protected boolean |
setClickInterestFromMouseEvent(java.awt.event.MouseEvent e)
Set the GeometryOfInterest based on MouseEvent.
|
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.
|
protected boolean DEBUG
protected OMGraphicHandlerLayer layer
protected java.lang.String[] mouseModeServiceList
protected java.lang.String lastToolTip
protected GestureResponsePolicy grp
protected StandardMapMouseInterpreter.GeometryOfInterest clickInterest
protected StandardMapMouseInterpreter.GeometryOfInterest movementInterest
protected boolean consumeEvents
protected boolean active
protected boolean noTimerOverOMGraphic
protected int mouseTimerInterval
protected javax.swing.Timer mouseTimer
protected StandardMapMouseInterpreter.MouseTimerListener mouseTimerListener
protected java.awt.event.MouseEvent currentMouseEvent
public StandardMapMouseInterpreter()
public StandardMapMouseInterpreter(OMGraphicHandlerLayer l)
public void setConsumeEvents(boolean consume)
public boolean getConsumeEvents()
public void setLayer(OMGraphicHandlerLayer l)
public OMGraphicHandlerLayer getLayer()
public void setMouseModeServiceList(java.lang.String[] list)
public boolean isLeftMouseButton(java.awt.event.MouseEvent me)
public java.lang.String[] getMouseModeServiceList()
getMouseModeServiceList
in interface MapMouseListener
NavMouseMode.modeID
,
SelectMouseMode.modeID
,
NullMouseMode.modeID
protected void setClickInterest(StandardMapMouseInterpreter.GeometryOfInterest goi)
protected StandardMapMouseInterpreter.GeometryOfInterest getClickInterest()
protected void setMovementInterest(StandardMapMouseInterpreter.GeometryOfInterest goi)
protected StandardMapMouseInterpreter.GeometryOfInterest getMovementInterest()
public OMGraphic getGeometryUnder(java.awt.event.MouseEvent me)
public boolean mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface MapMouseListener
e
- MouseEventprotected boolean setClickInterestFromMouseEvent(java.awt.event.MouseEvent e)
e
- MouseEventpublic boolean mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface MapMouseListener
e
- MouseEventpublic boolean testForAndHandlePopupTrigger(java.awt.event.MouseEvent e)
e
- MouseEventpublic boolean mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface MapMouseListener
e
- MouseEventpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface MapMouseListener
e
- MouseEventpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface MapMouseListener
e
- MouseEventpublic boolean mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface MapMouseListener
e
- MouseEventpublic boolean mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface MapMouseListener
e
- MouseEventpublic void setNoTimerOverOMGraphic(boolean val)
public boolean getNoTimerOverOMGraphic()
public void setMouseTimerInterval(int interval)
public int getMouseTimerInterval()
protected boolean updateMouseMoved(java.awt.event.MouseEvent e)
public void mouseMoved()
mouseMoved
in interface MapMouseListener
public boolean leftClick(java.awt.event.MouseEvent me)
leftClick
in interface MapMouseInterpreter
public boolean leftClick(OMGraphic omg, java.awt.event.MouseEvent me)
leftClick
in interface MapMouseInterpreter
public boolean leftClickOff(OMGraphic omg, java.awt.event.MouseEvent me)
leftClickOff
in interface MapMouseInterpreter
public boolean rightClick(java.awt.event.MouseEvent me)
rightClick
in interface MapMouseInterpreter
public boolean rightClick(OMGraphic omg, java.awt.event.MouseEvent me)
rightClick
in interface MapMouseInterpreter
protected boolean displayPopup(java.util.List<java.awt.Component> contents, java.awt.event.MouseEvent me)
public boolean rightClickOff(OMGraphic omg, java.awt.event.MouseEvent me)
rightClickOff
in interface MapMouseInterpreter
public boolean mouseOver(java.awt.event.MouseEvent me)
mouseOver
in interface MapMouseInterpreter
public boolean mouseOver(OMGraphic omg, java.awt.event.MouseEvent me)
mouseOver
in interface MapMouseInterpreter
protected void handleToolTip(java.lang.String tip, java.awt.event.MouseEvent me)
protected void handleInfoLine(java.lang.String line)
public boolean mouseNotOver(OMGraphic omg)
mouseNotOver
in interface MapMouseInterpreter
public void select(OMGraphic omg)
public void deselect(OMGraphic omg)
protected void setCurrentMouseEvent(java.awt.event.MouseEvent me)
public java.awt.event.MouseEvent getCurrentMouseEvent()
getCurrentMouseEvent
in interface MapMouseInterpreter
public void setGRP(GestureResponsePolicy grp)
setGRP
in interface MapMouseInterpreter
public GestureResponsePolicy getGRP()
getGRP
in interface MapMouseInterpreter
public boolean isActive()
isActive
in interface MapMouseInterpreter
public void setActive(boolean active)
setActive
in interface MapMouseInterpreter
active
- Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details