## com.bbn.openmap.event
Class NavMouseMode

    java.lang.Object
      com.bbn.openmap.MapHandlerChild
          com.bbn.openmap.OMComponent
              com.bbn.openmap.event.AbstractMouseMode
                  com.bbn.openmap.event.CoordMouseMode
                      com.bbn.openmap.event.NavMouseMode

All Implemented Interfaces:
  java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.util.EventListener, LightMapHandlerChild, MapMouseMode, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, PaintListener, PropertyConsumer, java.io.Serializable

Direct Known Subclasses:
  NavMouseMode2

public class NavMouseMode
extends CoordMouseMode

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. If a box is drawn by clicking down and dragging the mouse, the map is centered on the dot in the center of the box, and the scale is adjusted so the screen fills the area designated by the box.

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 inherited from class com.bbn.openmap.event.AbstractMouseMode
`AbstractMouseMode.MouseWheelZoomEditor`

Field Summary
`protected boolean` `autoZoom`
`static java.lang.String` `modeID` Mouse Mode identifier, which is "Navigation".
`protected java.awt.Point` `point1`
`protected java.awt.Point` `point2`

Fields inherited from class com.bbn.openmap.event.CoordMouseMode
`infoDelegator`

Fields inherited from class com.bbn.openmap.event.AbstractMouseMode
`cursor, CursorIDProperty, df, guiIcon, iconName, IconProperty, ID, IDProperty, mouseSupport, MouseWheelZoomProperty, prettyName, PrettyNameProperty, 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`

Fields inherited from interface com.bbn.openmap.PropertyConsumer
`EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty`

Constructor Summary
`NavMouseMode()` Construct a NavMouseMode.
`NavMouseMode(boolean shouldConsumeEvents)` Construct a NavMouseMode.

Method Summary
`protected java.awt.Point` `getRatioPoint(MapBean map, java.awt.Point pt1, java.awt.Point pt2)` Given a MapBean, which provides the projection, and the starting point of a box (pt1), look at pt2 to see if it represents the ratio of the projection map size.
`void` `listenerPaint(java.awt.Graphics g)` Called by the MapBean when it repaints, to let the MouseMode know when to update itself on the map.
`void` `mouseClicked(java.awt.event.MouseEvent e)` Invoked when the mouse has been clicked on a component.
`void` `mouseDragged(java.awt.event.MouseEvent e)` Handle a mouseDragged MouseMotionListener event.
`void` `mouseEntered(java.awt.event.MouseEvent e)` Handle a mouseEntered MouseListener event.
`void` `mouseExited(java.awt.event.MouseEvent e)` Handle a mouseExited MouseListener event.
`void` `mousePressed(java.awt.event.MouseEvent e)` Handle a mousePressed MouseListener event.
`void` `mouseReleased(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.
`protected void` `paintRectangle(MapBean map, 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.CoordMouseMode
`createCoordinateInformationLine, findAndInit, findAndUndo, fireMouseLocation, getInfoDelegator, mouseMoved, setActive, setInfoDelegator`

Methods inherited from class com.bbn.openmap.event.AbstractMouseMode

`actAsProxyFor, actAsProxyFor, addMapMouseListener, getClassToUseForIconRetrieval, getGUIIcon, getIconName, getID, getModeCursor, getMouseSupport, getPrettyName, getProperties, getPropertyInfo, getProxyDistributionMask, isConsumeEvents, isProxyFor, isVisible, isZoomWhenMouseWheelUp, mouseWheelMoved, releaseProxy, removeAllMapMouseListeners, removeMapMouseListener, setConsumeEvents, setGUIIcon, setIconName, setID, setModeCursor, setModeCursor, setMouseSupport, setPrettyName, setProperties, setProxyDistributionMask, setVisible, setZoomWhenMouseWheelUp`

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, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext`

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

Field Detail

### modeID

    public static final transient java.lang.String modeID

  Mouse Mode identifier, which is "Navigation".

  See Also:
    Constant Field Values

### point1

    protected java.awt.Point point1

### point2

    protected java.awt.Point point2

### autoZoom

    protected boolean autoZoom

Constructor Detail

### NavMouseMode

    public NavMouseMode()

  Construct a NavMouseMode. Sets the ID of the mode to the modeID, the consume mode to true, and the cursor to the crosshair.

### NavMouseMode

    public NavMouseMode(boolean shouldConsumeEvents)

  Construct a NavMouseMode. 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

### mousePressed

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

  Handle a mousePressed MouseListener event. Erases the old navigation rectangle if there is one, and then keeps the press point for reference later.

  Specified by:
    `mousePressed` in interface `java.awt.event.MouseListener`
  Overrides:
    `mousePressed` in class `AbstractMouseMode`
  Parameters:
    `e` - MouseEvent to be handled

### mouseClicked

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

  Description copied from class: `AbstractMouseMode`
  Invoked when the mouse has been clicked on a component. Calls fireMapMouseClicked on MouseSupport.

  Specified by:
    `mouseClicked` in interface `java.awt.event.MouseListener`
  Overrides:
    `mouseClicked` in class `AbstractMouseMode`
  Parameters:
    `e` - MouseEvent

### mouseReleased

    public void mouseReleased(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 occurence 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.

  Specified by:
    `mouseReleased` in interface `java.awt.event.MouseListener`
  Overrides:
    `mouseReleased` in class `AbstractMouseMode`
  Parameters:
    `e` - MouseEvent to be handled

### mouseEntered

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

  Handle a mouseEntered MouseListener event. The boolean autoZoom is set to true, which will make the delegate ask the map to zoom in to a box that is drawn.

  Specified by:
    `mouseEntered` in interface `java.awt.event.MouseListener`
  Overrides:
    `mouseEntered` in class `AbstractMouseMode`
  Parameters:
    `e` - MouseEvent to be handled

### mouseExited

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

  Handle a mouseExited MouseListener event. The boolean autoZoom is set to false, which will cause the delegate to NOT ask the map to zoom in on a box. If a box is being drawn, it will be erased. The point1 is kept in case the mouse comes back on the screen with the button still down. Then, a new box will be drawn with the original mouse press position.

  Specified by:
    `mouseExited` in interface `java.awt.event.MouseListener`
  Overrides:
    `mouseExited` in class `AbstractMouseMode`
  Parameters:
    `e` - MouseEvent to be handled

### mouseDragged

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

  Handle a mouseDragged MouseMotionListener event. A rectangle is drawn from the mousePressed point, since I'm assuming that I'm drawing a box to zoom the map to. If a previous box was drawn, it is erased.

  Specified by:
    `mouseDragged` in interface `java.awt.event.MouseMotionListener`
  Overrides:
    `mouseDragged` in class `CoordMouseMode`
  Parameters:
    `e` - MouseEvent to be handled

### getRatioPoint

    protected java.awt.Point getRatioPoint(MapBean map,
                                           java.awt.Point pt1,
                                           java.awt.Point pt2)

  Given a MapBean, which provides the projection, and the starting point of a box (pt1), look at pt2 to see if it represents the ratio of the projection map size. If it doesn't, provide a point that does.

### paintRectangle

    protected void paintRectangle(MapBean map,
                                  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.

  Parameters:
    `pt1` - one corner of the box to drawn, in window pixel coordinates.
    `pt2` - the opposite corner of the box.

### 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.

  Parameters:
    `pt1` - one corner of the box to drawn, in window pixel coordinates.
    `pt2` - the opposite corner of the box.

### listenerPaint

    public void listenerPaint(java.awt.Graphics g)

  Called by the MapBean when it repaints, to let the MouseMode know when to update itself on the map. PaintListener interface.

  Specified by:
    `listenerPaint` in interface `PaintListener`
  Overrides:
    `listenerPaint` in class `AbstractMouseMode`

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