## com.bbn.openmap.event
Class AbstractMouseMode

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

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:
  CoordMouseMode, NullMouseMode

public class AbstractMouseMode
extends OMComponent
implements MapMouseMode, java.io.Serializable

Base class of the MouseModes. It takes care of the administrative aspects of being a mouse mode, but does not respond to MouseEvents.

The ID and pretty name can be set in the properties file.

        # Name that layers use to get events from this mode
        mousemode.id=ID
        # Tooltip and Menu name for mode
        mousemode.prettyName=Display Name

This class delegates much of the work of managing its listeners to a MapMouseSupport object.

See Also:
  `MapMouseSupport`, Serialized Form

Nested Class Summary
`static class` `AbstractMouseMode.MouseWheelZoomEditor`

Field Summary
`protected java.awt.Cursor` `cursor` The cursor that appears on the map when this Mouse Mode is active.
`static java.lang.String` `CursorIDProperty` The java.awt.Cursor id that should be used for the mouse mode.
`java.text.DecimalFormat` `df`
`protected javax.swing.Icon` `guiIcon` The Icon that can be used in a GUI.
`protected java.lang.String` `iconName`
`static java.lang.String` `IconProperty` A property that lets you specify the resource to use for the icon for the MouseMode.
`protected java.lang.String` `ID` The identifier for the mode, which is also the name that will be used in a used interface describing the mode to a user.
`static java.lang.String` `IDProperty` The MouseModeID to use for a particular instance of a MapMouseMode.
`protected MapMouseSupport` `mouseSupport` The object used to handle the listeners and to pass out the event to the layers interesed in it.
`static java.lang.String` `MouseWheelZoomProperty` A property that lets you specify if the mode zooms in or out when the mouse wheel is rotated up.
`protected java.lang.String` `prettyName`
`static java.lang.String` `PrettyNameProperty` The String to use for a key lookup in a Properties object to find the name to use in a GUI relating to this Mouse Mode.
`protected boolean` `visible`
`static boolean` `ZOOM_IN` Zoom direction in when mouse wheel rotated up.
`static boolean` `ZOOM_OUT` Zoom direction out when mouse wheel rotated up.
`protected boolean` `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
`AbstractMouseMode()` Construct an AbstractMouseMode.
`AbstractMouseMode(java.lang.String name, boolean shouldConsumeEvents)` Construct an AbstractMouseMode.

Method Summary
`boolean` `actAsProxyFor(MapMouseMode mmm)` Request to have the parent MapMouseMode act as a proxy for a MapMouseMode that wants to remain hidden.
`boolean` `actAsProxyFor(MapMouseMode mmm, int pdm)` Request to have the MapMouseMode act as a proxy for a MapMouseMode that wants to remain hidden.
`void` `addMapMouseListener(MapMouseListener l)` Add a MapMouseListener to the MouseMode.
`protected java.lang.Class` `getClassToUseForIconRetrieval()` Internal callback method that lets subclasses override a class to use as a resource point for icon image retrieval.
`javax.swing.Icon` `getGUIIcon()` Gets the Icon to represent the Mouse Mode in a GUI.
`java.lang.String` `getIconName()`
`java.lang.String` `getID()` Returns the id (mode name).
`java.awt.Cursor` `getModeCursor()` Gets the mouse cursor recommended for use when this mouse mode is active.
`MapMouseSupport` `getMouseSupport()` Get the MouseSupport.
`java.lang.String` `getPrettyName()` Return a pretty name, suitable for the GUI.
`java.util.Properties` `getProperties(java.util.Properties props)` PropertyConsumer method, to fill in a Properties object, reflecting the current values of the OMComponent.
`java.util.Properties` `getPropertyInfo(java.util.Properties props)` Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer.
`int` `getProxyDistributionMask()` Get the mask that dictates which events get sent to this support object's targets even if the parent mouse mode is acting as a proxy.
`boolean` `isConsumeEvents()` Returns how the delegate (and it's mouse support) is set up to distribute events.
`boolean` `isProxyFor(MapMouseMode mmm)` Can check if the MapMouseMode is acting as a proxy for another MapMouseMode.
`boolean` `isVisible()` Method to let the MouseDelegator know if the MapMouseMode should be visible, as opposed to a MapMouseMode that is being provided and controlled by another tool.
`boolean` `isZoomWhenMouseWheelUp()`
`void` `listenerPaint(java.awt.Graphics g)` PaintListener interface, notifying the MouseMode that the MapBean has repainted itself.
`void` `mouseClicked(java.awt.event.MouseEvent e)` Invoked when the mouse has been clicked on a component.
`void` `mouseDragged(java.awt.event.MouseEvent e)` Invoked when a mouse button is pressed on a component and then dragged.
`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(java.awt.event.MouseEvent e)` Invoked when the mouse button has been moved on a component (with no buttons no down).
`void` `mousePressed(java.awt.event.MouseEvent e)` Invoked when a mouse button has been pressed on a component.
`void` `mouseReleased(java.awt.event.MouseEvent e)` Invoked when a mouse button has been released on a component.
`void` `mouseWheelMoved(java.awt.event.MouseWheelEvent e)` Invoked from the MouseWheelListener interface.
`void` `releaseProxy()` Release the proxy lock on the MapMouseMode.
`void` `removeAllMapMouseListeners()` Remove all MapMouseListeners from the mode.
`void` `removeMapMouseListener(MapMouseListener l)` Remove a MapMouseListener from the MouseMode.
`void` `setActive(boolean active)` Part of the MapMouseMode interface.
`void` `setConsumeEvents(boolean value)` Sets how the delegate passes out events.
`void` `setGUIIcon(javax.swing.Icon icon)` Set the icon that should be used for this Mouse Mode in a GUI.
`void` `setIconName(java.lang.String iName)` Sets the GUI icon based on the name of the resource provided.
`void` `setID(java.lang.String id)` Set the id (mode name).
`void` `setModeCursor(java.awt.Cursor curs)` Sets the cursor that is recommended for use on the map when this mouse mode is active.
`void` `setModeCursor(java.lang.String cursorID)` Sets the cursor that is recommended for use on the map when this mouse mode is active.
`void` `setMouseSupport(MapMouseSupport support)` Set a MouseSupport explicitly.
`void` `setPrettyName(java.lang.String pn)`
`void` `setProperties(java.lang.String prefix, java.util.Properties props)` Sets the properties for the OMComponent.
`void` `setProxyDistributionMask(int mask)` Set the mask that dictates which events get sent to this support object's targets even if the parent mouse mode is acting as a proxy.
`void` `setVisible(boolean value)` Method to set if the MapMouseMode should be visible, as opposed to a MapMouseMode that is being provided and controlled by another tool.
`void` `setZoomWhenMouseWheelUp(boolean zoomWhenMouseWheelUp)`

Methods inherited from class com.bbn.openmap.OMComponent
`getPropertyPrefix, setProperties, setPropertyPrefix`

Methods inherited from class com.bbn.openmap.MapHandlerChild
`addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, findAndInit, findAndUndo, 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

### ID

    protected java.lang.String ID

  The identifier for the mode, which is also the name that will be used in a used interface describing the mode to a user.

### mouseSupport

    protected MapMouseSupport mouseSupport

  The object used to handle the listeners and to pass out the event to the layers interesed in it.

### cursor

    protected java.awt.Cursor cursor

  The cursor that appears on the map when this Mouse Mode is active.

### guiIcon

    protected transient javax.swing.Icon guiIcon

  The Icon that can be used in a GUI. Can be null. The class will look for a resource gif file that has the same ID string - Navigation.gif for the NavMouseMode, for instance.

### df

    public transient java.text.DecimalFormat df

### visible

    protected transient boolean visible

### prettyName

    protected java.lang.String prettyName

### iconName

    protected java.lang.String iconName

### zoomWhenMouseWheelUp

    protected boolean zoomWhenMouseWheelUp

### ZOOM_IN

    public static final boolean ZOOM_IN

  Zoom direction in when mouse wheel rotated up.

  See Also:
    Constant Field Values

### ZOOM_OUT

    public static final boolean ZOOM_OUT

  Zoom direction out when mouse wheel rotated up.

  See Also:
    Constant Field Values

### IDProperty

    public static final java.lang.String IDProperty

  The MouseModeID to use for a particular instance of a MapMouseMode. If not set, the default mouse mode ID of the MapMouseMode will be used.

  See Also:
    Constant Field Values

### PrettyNameProperty

    public static final java.lang.String PrettyNameProperty

  The String to use for a key lookup in a Properties object to find the name to use in a GUI relating to this Mouse Mode.

  See Also:
    Constant Field Values

### CursorIDProperty

    public static final java.lang.String CursorIDProperty

  The java.awt.Cursor id that should be used for the mouse mode.

  See Also:
    `Cursor`, Constant Field Values

### IconProperty

    public static final java.lang.String IconProperty

  A property that lets you specify the resource to use for the icon for the MouseMode.

  See Also:
    Constant Field Values

### MouseWheelZoomProperty

    public static final java.lang.String MouseWheelZoomProperty

  A property that lets you specify if the mode zooms in or out when the mouse wheel is rotated up. Appropriate values are ZOOM_IN or ZOOM_OUT.

  See Also:
    Constant Field Values

Constructor Detail

### AbstractMouseMode

    public AbstractMouseMode()

  Construct an AbstractMouseMode. Default constructor, allocates the mouse support object.

### AbstractMouseMode

    public AbstractMouseMode(java.lang.String name,
                             boolean shouldConsumeEvents)

  Construct an AbstractMouseMode.

Parameters:
  `name` - the ID of the mode.
  `shouldConsumeEvents` - if true, events are propagated to the first MapMouseListener that successfully processes the event, if false, events are propagated to all MapMouseListeners

Method Detail

### getClassToUseForIconRetrieval

    protected java.lang.Class getClassToUseForIconRetrieval()

  Internal callback method that lets subclasses override a class to use as a resource point for icon image retrieval.

  Returns:
    Class that has icon image file next to it in classpath.

### setIconName

    public void setIconName(java.lang.String iName)

  Sets the GUI icon based on the name of the resource provided. The resource will be checked against the classpath, and if it isn't found, the mouse mode will be asked for the class to use for icon retrieval.

  Parameters:
    `iName` -

### getIconName

    public java.lang.String getIconName()

### getID

    public java.lang.String getID()

  Returns the id (mode name).

  Specified by:
    `getID` in interface `MapMouseMode`
  Returns:
    String ID

### setID

    public void setID(java.lang.String id)

  Set the id (mode name).

  Parameters:
    `id` - string that identifies the delegate.

### setPrettyName

    public void setPrettyName(java.lang.String pn)

### getPrettyName

    public java.lang.String getPrettyName()

  Return a pretty name, suitable for the GUI. If set, is independent of the mode ID. If not set, is the same as the mode ID.

  Specified by:
    `getPrettyName` in interface `MapMouseMode`

### getModeCursor

    public java.awt.Cursor getModeCursor()

  Gets the mouse cursor recommended for use when this mouse mode is active.

  Specified by:
    `getModeCursor` in interface `MapMouseMode`
  Returns:
    Cursor the mouse cursor recommended for use when this mouse mode is active.

### setModeCursor

    public void setModeCursor(java.awt.Cursor curs)

  Sets the cursor that is recommended for use on the map when this mouse mode is active.

  Parameters:
    `curs` - the cursor that is recommended for use on the map when this mouse mode is active.

### setModeCursor

    public void setModeCursor(java.lang.String cursorID)

  Sets the cursor that is recommended for use on the map when this mouse mode is active.

  Parameters:
    `cursorID` - the cursor ID member variable string, i.e. DEFAULT_CURSOR
  See Also:
    `Cursor`

### getGUIIcon

    public javax.swing.Icon getGUIIcon()

  Gets the Icon to represent the Mouse Mode in a GUI. May be null.

  Specified by:
    `getGUIIcon` in interface `MapMouseMode`

### setGUIIcon

    public void setGUIIcon(javax.swing.Icon icon)

  Set the icon that should be used for this Mouse Mode in a GUI.

### setConsumeEvents

    public void setConsumeEvents(boolean value)

  Sets how the delegate passes out events. If the value passed in is true, the delegate will only pass the event to the first listener that can respond to the event. If false, the delegate will pass the event on to all its listeners.

  Parameters:
    `value` - true for limited distribution.

### isConsumeEvents

    public boolean isConsumeEvents()

  Returns how the delegate (and it's mouse support) is set up to distribute events.

  Returns:
    true if only one listner gets to act on an event.

### isZoomWhenMouseWheelUp

    public boolean isZoomWhenMouseWheelUp()

### setZoomWhenMouseWheelUp

    public void setZoomWhenMouseWheelUp(boolean zoomWhenMouseWheelUp)

### addMapMouseListener

    public void addMapMouseListener(MapMouseListener l)

  Add a MapMouseListener to the MouseMode. The listener will then get events from the delegator if the delegator is active.

  Specified by:
    `addMapMouseListener` in interface `MapMouseMode`
  Parameters:
    `l` - the MapMouseListener to add.

### removeMapMouseListener

    public void removeMapMouseListener(MapMouseListener l)

  Remove a MapMouseListener from the MouseMode.

  Specified by:
    `removeMapMouseListener` in interface `MapMouseMode`
  Parameters:
    `l` - the MapMouseListener to remove.

### removeAllMapMouseListeners

    public void removeAllMapMouseListeners()

  Remove all MapMouseListeners from the mode.

  Specified by:
    `removeAllMapMouseListeners` in interface `MapMouseMode`

### mouseClicked

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

  Invoked when the mouse has been clicked on a component. Calls fireMapMouseClicked on MouseSupport.

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

### mousePressed

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

  Invoked when a mouse button has been pressed on a component. Calls fiewMapMousePressed on the MouseSupport. Also requests focus on the source of the MouseEvent, so that key events can be processed.

  Specified by:
    `mousePressed` in interface `java.awt.event.MouseListener`
  Parameters:
    `e` - MouseEvent

### mouseReleased

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

  Invoked when a mouse button has been released on a component. Calls fireMapMouseReleased on the MouseSupport.

  Specified by:
    `mouseReleased` in interface `java.awt.event.MouseListener`
  Parameters:
    `e` - MouseEvent

### mouseEntered

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

  Invoked when the mouse enters a component. Calls fireMapMouseEntered on the MouseSupport.

  Specified by:
    `mouseEntered` in interface `java.awt.event.MouseListener`
  Parameters:
    `e` - MouseEvent

### mouseExited

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

  Invoked when the mouse exits a component. This does nothing. Extend this class to add functionality.

  Specified by:
    `mouseExited` in interface `java.awt.event.MouseListener`
  Parameters:
    `e` - MouseEvent

### mouseDragged

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

  Invoked when a mouse button is pressed on a component and then dragged. Calls fireMapMouseDragged on the MouseSupport.

  Specified by:
    `mouseDragged` in interface `java.awt.event.MouseMotionListener`
  Parameters:
    `e` - MouseEvent

### mouseMoved

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

  Invoked when the mouse button has been moved on a component (with no buttons no down). Calls fireMapMouseMoved on the MouseSupport.

  Specified by:
    `mouseMoved` in interface `java.awt.event.MouseMotionListener`
  Parameters:
    `e` - MouseEvent

### mouseWheelMoved

    public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)

  Invoked from the MouseWheelListener interface.

  Specified by:
    `mouseWheelMoved` in interface `java.awt.event.MouseWheelListener`

### setActive

    public void setActive(boolean active)

  Part of the MapMouseMode interface. Called when the MouseMode is made active or inactive.

  Specified by:
    `setActive` in interface `MapMouseMode`
  Parameters:
    `active` - true if the mode has been made active, false if it has been made inactive.

### setMouseSupport

    public void setMouseSupport(MapMouseSupport support)

  Set a MouseSupport explicitly.

  Parameters:
    `support` - The new MapMouseSupport instance

### getMouseSupport

    public MapMouseSupport getMouseSupport()

  Get the MouseSupport.

  Returns:
    the MapMouseSupport used by the MouseMode.

### isVisible

    public boolean isVisible()

  Method to let the MouseDelegator know if the MapMouseMode should be visible, as opposed to a MapMouseMode that is being provided and controlled by another tool. True by default.

  Specified by:
    `isVisible` in interface `MapMouseMode`

### setVisible

    public void setVisible(boolean value)

  Method to set if the MapMouseMode should be visible, as opposed to a MapMouseMode that is being provided and controlled by another tool.

### actAsProxyFor

    public boolean actAsProxyFor(MapMouseMode mmm)

  Request to have the parent MapMouseMode act as a proxy for a MapMouseMode that wants to remain hidden. Can be useful for directing events to one object. This version sets the proxy distribution mask to zero, which means that none of this support objects targets will be notified of events.

  Specified by:
    `actAsProxyFor` in interface `MapMouseMode`
  Parameters:
    `mmm` - the hidden MapMouseMode for this MapMouseMode to send events to.
  Returns:
    true if the proxy setup (essentially a lock) is successful, false if the proxy is already set up for another listener.

### actAsProxyFor

    public boolean actAsProxyFor(MapMouseMode mmm,
                                 int pdm)

  Request to have the MapMouseMode act as a proxy for a MapMouseMode that wants to remain hidden. Can be useful for directing events to one object.

  Specified by:
    `actAsProxyFor` in interface `MapMouseMode`
  Parameters:
    `mmm` - the hidden MapMouseMode for this MapMouseMode to send events to.
    `pdm` - the proxy distribution mask to use, which lets this support object notify its targets of events if the parent is acting as a proxy.
  Returns:
    true if the proxy setup (essentially a lock) is successful, false if the proxy is already set up for another listener.

### isProxyFor

    public boolean isProxyFor(MapMouseMode mmm)

  Can check if the MapMouseMode is acting as a proxy for another MapMouseMode.

  Specified by:
    `isProxyFor` in interface `MapMouseMode`

### releaseProxy

    public void releaseProxy()

  Release the proxy lock on the MapMouseMode.

  Specified by:
    `releaseProxy` in interface `MapMouseMode`

### setProxyDistributionMask

    public void setProxyDistributionMask(int mask)

  Set the mask that dictates which events get sent to this support object's targets even if the parent mouse mode is acting as a proxy.

  Specified by:
    `setProxyDistributionMask` in interface `MapMouseMode`
  See Also:
    `for definitions of mask bits.`

### getProxyDistributionMask

    public int getProxyDistributionMask()

  Get the mask that dictates which events get sent to this support object's targets even if the parent mouse mode is acting as a proxy.

  Specified by:
    `getProxyDistributionMask` in interface `MapMouseMode`
  See Also:
    `for definitions of mask bits.`

### setProperties

    public void setProperties(java.lang.String prefix,
                              java.util.Properties props)

  Description copied from class: `OMComponent`
  Sets the properties for the OMComponent.

  Specified by:
    `setProperties` in interface `PropertyConsumer`
  Overrides:
    `setProperties` in class `OMComponent`
  Parameters:
    `prefix` - the token to prefix the property names
    `props` - the `Properties` object

### getProperties

    public java.util.Properties getProperties(java.util.Properties props)

  Description copied from class: `OMComponent`
  PropertyConsumer method, to fill in a Properties object, reflecting the current values of the OMComponent. If the component has a propertyPrefix set, the property keys should have that prefix plus a separating '.' prepended to each propery key it uses for configuration.

  Specified by:
    `getProperties` in interface `PropertyConsumer`
  Overrides:
    `getProperties` in class `OMComponent`
  Parameters:
    `props` - a Properties object to load the PropertyConsumer properties into. If props equals null, then a new Properties object should be created.
  Returns:
    Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

### getPropertyInfo

    public java.util.Properties getPropertyInfo(java.util.Properties props)

  Description copied from class: `OMComponent`
  Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer. The key for each property should be the raw property name (without a prefix) with a value that is a String that describes what the property key represents, along with any other information about the property that would be helpful (range, default value, etc.). For Layer, this method should at least return the 'prettyName' property.

  Specified by:
    `getPropertyInfo` in interface `PropertyConsumer`
  Overrides:
    `getPropertyInfo` in class `OMComponent`
  Parameters:
    `props` - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
  Returns:
    Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

### listenerPaint

    public void listenerPaint(java.awt.Graphics g)

  PaintListener interface, notifying the MouseMode that the MapBean has repainted itself. Useful if the MouseMode is drawing stuff.

  Specified by:
    `listenerPaint` in interface `PaintListener`

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