com.bbn.openmap.event
Class NavMouseMode2

java.lang.Object
  extended by com.bbn.openmap.MapHandlerChild
      extended by com.bbn.openmap.OMComponent
          extended by com.bbn.openmap.event.AbstractMouseMode
              extended by com.bbn.openmap.event.CoordMouseMode
                  extended by com.bbn.openmap.event.NavMouseMode
                      extended by com.bbn.openmap.event.NavMouseMode2
All Implemented Interfaces:
MapMouseMode, PaintListener, LightMapHandlerChild, PropertyConsumer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
DefaultOverviewMouseMode

public class NavMouseMode2
extends NavMouseMode

The Navigation Mouse Mode interprets mouse clicks and mouse drags to recenter and rescale the map. The map is centered on the location where a click occurs. The difference between this MouseMode and the original NavMouseMode is that the box drawn is interpreted differently. The point where the mouse is pressed is interpreted to be the center of the new zoom area (instead of one of the corners), and the dragged mouse point is the edge of the box, reflected equally on the other side of the center point.

You MUST add this MouseMode as a ProjectionListener to the MapBean to get it to work. If you use a MouseDelegator with the bean, it will take care of that for you.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.bbn.openmap.event.AbstractMouseMode
AbstractMouseMode.MouseWheelTimerListener
 
Field Summary
 
Fields inherited from class com.bbn.openmap.event.NavMouseMode
autoZoom, modeID, point1, point2, rectAttributes
 
Fields inherited from class com.bbn.openmap.event.CoordMouseMode
coordFormatter, coordFormatterHandler, CoordFormatterProperty, infoDelegator
 
Fields inherited from class com.bbn.openmap.event.AbstractMouseMode
cursor, CursorIDProperty, guiIcon, iconName, IconProperty, ID, IDProperty, logger, mouseSupport, mouseTimer, mouseWheelListener, MouseWheelListenerProperty, mouseWheelTimerInterval, MouseWheelTimerIntervalProperty, mouseWheelTimerListener, MouseWheelZoomProperty, noMouseWheelListenerTimer, NoMouseWheelListenerTimerProperty, prettyName, PrettyNameProperty, propertyChangeSupport, visible, ZOOM_IN, ZOOM_OUT, zoomWhenMouseWheelUp
 
Fields inherited from class com.bbn.openmap.OMComponent
i18n, propertyPrefix
 
Fields inherited from class com.bbn.openmap.MapHandlerChild
beanContextChildSupport, isolated
 
Fields inherited from interface com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Constructor Summary
NavMouseMode2()
          Construct a NavMouseMode2.
NavMouseMode2(boolean shouldConsumeEvents)
          Construct a NavMouseMode2.
 
Method Summary
 void handleMouseReleased(java.awt.event.MouseEvent e)
          Handle a mouseReleased MouseListener event.
protected  void paintRectangle(java.awt.Graphics g, java.awt.Point pt1, java.awt.Point pt2)
          Draws or erases boxes between two screen pixel points.
 
Methods inherited from class com.bbn.openmap.event.NavMouseMode
cleanUp, getProperties, getPropertyInfo, getRatioPoint, getRectAttributes, listenerPaint, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, setProperties, setRectAttributes
 
Methods inherited from class com.bbn.openmap.event.CoordMouseMode
findAndInit, findAndUndo, fireMouseLocation, getCoordFormatter, getCoordFormatterHandler, getInfoDelegator, propertyChange, setActive, setCoordFormatter, setCoordFormatterHandler, setInfoDelegator
 
Methods inherited from class com.bbn.openmap.event.AbstractMouseMode
actAsProxyFor, actAsProxyFor, addMapMouseListener, addPropertyChangeListener, getClassToUseForIconRetrieval, getGUIIcon, getIconName, getID, getModeCursor, getMouseSupport, getMouseWheelTimerInterval, getNoMouseWheelListener, getPrettyName, getProxied, getProxyDistributionMask, isConsumeEvents, isMouseWheelListener, isNoMouseWheelListenerTimer, isProxyFor, isVisible, isZoomWhenMouseWheelUp, mouseWheelMoved, releaseProxy, removeAllMapMouseListeners, removeMapMouseListener, removePropertyChangeListener, setConsumeEvents, setGUIIcon, setIconName, setID, setModeCursor, setModeCursor, setMouseSupport, setMouseWheelListener, setMouseWheelTimerInterval, setNoMouseWheelListener, setNoMouseWheelListenerTimer, setPrettyName, setProxyDistributionMask, setVisible, setZoomWhenMouseWheelUp, updateMouseWheelMoved
 
Methods inherited from class com.bbn.openmap.OMComponent
getPropertyPrefix, setProperties, setPropertyPrefix
 
Methods inherited from class com.bbn.openmap.MapHandlerChild
addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, firePropertyChange, fireVetoableChange, getBeanContext, isIsolated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, setIsolated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NavMouseMode2

public NavMouseMode2()
Construct a NavMouseMode2. Sets the ID of the mode to the modeID, the consume mode to true, and the cursor to the crosshair.


NavMouseMode2

public NavMouseMode2(boolean shouldConsumeEvents)
Construct a NavMouseMode2. Lets you set the consume mode. If the events are consumed, then a MouseEvent is sent only to the first MapMouseListener that successfully processes the event. If they are not consumed, then all of the listeners get a chance to act on the event.

Parameters:
shouldConsumeEvents - the mode setting.
Method Detail

handleMouseReleased

public void handleMouseReleased(java.awt.event.MouseEvent e)
Handle a mouseReleased MouseListener event. If there was no drag events, or if there was only a small amount of dragging between the occurrence of the mousePressed and this event, then recenter the map. Otherwise we get the second corner of the navigation rectangle and try to figure out the best scale and location to zoom in to based on that rectangle.

Overrides:
handleMouseReleased in class NavMouseMode
Parameters:
e - MouseEvent to be handled

paintRectangle

protected void paintRectangle(java.awt.Graphics g,
                              java.awt.Point pt1,
                              java.awt.Point pt2)
Draws or erases boxes between two screen pixel points. The graphics from the map is set to XOR mode, and this method uses two colors to make the box disappear if on has been drawn at these coordinates, and the box to appear if it hasn't.

Overrides:
paintRectangle in class NavMouseMode
Parameters:
pt1 - one corner of the box to drawn, in window pixel coordinates.
pt2 - the opposite corner of the box.


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