com.bbn.openmap.plugin
Class AbstractPlugIn

java.lang.Object
  extended by com.bbn.openmap.plugin.AbstractPlugIn
All Implemented Interfaces:
MapMouseListener, PlugIn, PropertyConsumer
Direct Known Subclasses:
BeanContextAbstractPlugIn, EarthImagePlugIn, WebImagePlugIn

public abstract class AbstractPlugIn
extends java.lang.Object
implements PlugIn, PropertyConsumer, MapMouseListener

This class is an abstract implementation of the PlugIn. It takes care of setting up the layer, setting properties, etc.

See Also:
PlugInLayer, PlugIn

Field Summary
protected  boolean addToBeanContext
          Flag to denote whether the plugin should be added to the bean context (MapHandler).
protected  java.awt.Component component
          The parent component, usually the PlugInLayer.
 I18n i18n
          Internationalization
protected  MapMouseListener mml
          The object handling mouse events for the plugin.
protected  java.lang.String name
          The pretty name for a plugin, if it was set in the properties.
protected  java.lang.String prefix
          The prefix for the plugin's properties.
protected  boolean removable
          Flag to designate the layer as removable or not.
static java.lang.String RemovableProperty
          Property 'removable' to designate this layer as removable from the application, or able to be deleted.
 
Fields inherited from interface com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Constructor Summary
AbstractPlugIn()
           
AbstractPlugIn(java.awt.Component comp)
           
 
Method Summary
 void dispose()
          Notification to the PlugIn that it has been removed from the application, so it can disconnect from all other objects that may be holding a reference to it.
 void doPrepare()
          Checks to see if the parent component is a PlugInLayer, and calls doPrepare() on it if it is.
 boolean getAddToBeanContext()
           
 java.awt.Component getComponent()
          Get the component that this plugin uses as a grip to the map.
 java.awt.Component getGUI()
          Gives the PlugIn a chance to present components that control its attributes.
 MapMouseListener getMapMouseListener()
          Returns the MapMouseListener that the plugin thinks should be used.
 java.lang.String[] getMouseModeServiceList()
          Return a list of the modes that are interesting to the MapMouseListener.
 java.lang.String getName()
          Get the pretty name of the plugin, which is really the pretty name of the parent component if it's set.
 java.util.Properties getProperties(java.util.Properties getList)
          Method to fill in a Properties object, reflecting the current values of the PropertyConsumer.
 java.util.Properties getPropertyInfo(java.util.Properties list)
          Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer.
 java.lang.String getPropertyPrefix()
          Get the property key prefix that is being used to prepend to the property keys for Properties lookups.
abstract  OMGraphicList getRectangle(Projection p)
          The getRectangle call is the main call into the PlugIn module.
 boolean isRemovable()
          Check to see if the plugin (and layer) is marked as one that can be removed from an application.
 boolean mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 boolean 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()
          Handle a mouse cursor moving without the button being pressed.
 boolean mouseMoved(java.awt.event.MouseEvent e)
          Invoked when the mouse button has been moved on a component (with no buttons down).
 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.
 void removed()
          Method that gets called when the PlugInLayer has been removed from the map, so the PlugIn can free up resources.
 void repaint()
          Call repaint on the parent component.
 void setAddToBeanContext(boolean value)
           
 void setComponent(java.awt.Component comp)
          Set the component that this PlugIn uses as a grip to the map.
 void setMapMouseListener(MapMouseListener mml)
          Set the MapMouseListener for this PlugIn.
 void setName(java.lang.String name)
          Set the name of the plugin.
 void setProperties(java.util.Properties setList)
          Method to set the properties in the PropertyConsumer.
 void setProperties(java.lang.String prefix, java.util.Properties setList)
          Method to set the properties in the PropertyConsumer.
 void setPropertyPrefix(java.lang.String prefix)
          Set the property key prefix that should be used by the PropertyConsumer.
 void setRemovable(boolean set)
          Mark the plugin (and layer) as removable, or one that can be deleted from the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RemovableProperty

public static final java.lang.String RemovableProperty
Property 'removable' to designate this layer as removable from the application, or able to be deleted. True by default.

See Also:
Constant Field Values

removable

protected boolean removable
Flag to designate the layer as removable or not.


component

protected java.awt.Component component
The parent component, usually the PlugInLayer.


prefix

protected java.lang.String prefix
The prefix for the plugin's properties.


name

protected java.lang.String name
The pretty name for a plugin, if it was set in the properties.


mml

protected MapMouseListener mml
The object handling mouse events for the plugin. By default, the Plugin is it, but it doesn't have to be.


addToBeanContext

protected boolean addToBeanContext
Flag to denote whether the plugin should be added to the bean context (MapHandler). True by default.


i18n

public I18n i18n
Internationalization

Constructor Detail

AbstractPlugIn

public AbstractPlugIn()

AbstractPlugIn

public AbstractPlugIn(java.awt.Component comp)
Method Detail

setName

public void setName(java.lang.String name)
Set the name of the plugin. If the parent component is a layer, set its pretty name as well.


getName

public java.lang.String getName()
Get the pretty name of the plugin, which is really the pretty name of the parent component if it's set.


setComponent

public void setComponent(java.awt.Component comp)
Set the component that this PlugIn uses as a grip to the map.

Specified by:
setComponent in interface PlugIn

getComponent

public java.awt.Component getComponent()
Get the component that this plugin uses as a grip to the map.

Specified by:
getComponent in interface PlugIn

repaint

public void repaint()
Call repaint on the parent component.


doPrepare

public void doPrepare()
Checks to see if the parent component is a PlugInLayer, and calls doPrepare() on it if it is.


setMapMouseListener

public void setMapMouseListener(MapMouseListener mml)
Set the MapMouseListener for this PlugIn. The MapMouseListener is responsible for handling the MouseEvents that are occurring over the layer using the PlugIn, as well as being able to let others know which MouseModes are of interest to receive MouseEvents from.

Specified by:
setMapMouseListener in interface PlugIn
Parameters:
mml - MapMouseListener.
See Also:
MapMouseListener

getMapMouseListener

public MapMouseListener getMapMouseListener()
Returns the MapMouseListener that the plugin thinks should be used.

Specified by:
getMapMouseListener in interface PlugIn
See Also:
MapMouseListener

getRectangle

public abstract OMGraphicList getRectangle(Projection p)
The getRectangle call is the main call into the PlugIn module. The module is expected to fill a graphics list with objects that are within the screen parameters passed. It's assumed that the PlugIn will call generate(projection) on the OMGraphics returned! If you don't call generate on the OMGraphics, they will not be displayed on the map.

Specified by:
getRectangle in interface PlugIn
Parameters:
p - projection of the screen, holding scale, center coords, height, width. May be null if the parent component hasn't been given a projection.
Returns:
OMGraphicList.
See Also:
Projection, OMGraphicList

getGUI

public java.awt.Component getGUI()
Description copied from interface: PlugIn
Gives the PlugIn a chance to present components that control its attributes.

Specified by:
getGUI in interface PlugIn

setAddToBeanContext

public void setAddToBeanContext(boolean value)

getAddToBeanContext

public boolean getAddToBeanContext()

setRemovable

public void setRemovable(boolean set)
Mark the plugin (and layer) as removable, or one that can be deleted from the application. What that means is up to the LayerHandler or other application components.


isRemovable

public boolean isRemovable()
Check to see if the plugin (and layer) is marked as one that can be removed from an application.

Returns:
true if plugin should be allowed to be deleted.

setProperties

public void setProperties(java.util.Properties setList)
Method to set the properties in the PropertyConsumer. It is assumed that the properties do not have a prefix associated with them, or that the prefix has already been set.

Specified by:
setProperties in interface PropertyConsumer
Parameters:
setList - a properties object that the PropertyConsumer can use to retrieve expected properties it can use for configuration.

setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties setList)
Method to set the properties in the PropertyConsumer. The prefix is a string that should be prepended to each property key (in addition to a separating '.') in order for the PropertyConsumer to uniquely identify properties meant for it, in the midst of of Properties meant for several objects.

Specified by:
setProperties in interface PropertyConsumer
Parameters:
prefix - a String used by the PropertyConsumer to prepend to each property value it wants to look up - setList.getProperty(prefix.propertyKey). If the prefix had already been set, then the prefix passed in should replace that previous value.
setList - a Properties object that the PropertyConsumer can use to retrieve expected properties it can use for configuration.

getProperties

public java.util.Properties getProperties(java.util.Properties getList)
Method to fill in a Properties object, reflecting the current values of the PropertyConsumer. If the PropertyConsumer has a prefix set, the property keys should have that prefix plus a separating '.' prepended to each property key it uses for configuration.

Specified by:
getProperties in interface PropertyConsumer
Parameters:
getList - 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.

getPropertyInfo

public java.util.Properties getPropertyInfo(java.util.Properties list)
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.).

Specified by:
getPropertyInfo in interface PropertyConsumer
Parameters:
list - 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.

setPropertyPrefix

public void setPropertyPrefix(java.lang.String prefix)
Set the property key prefix that should be used by the PropertyConsumer. The prefix, along with a '.', should be prepended to the property keys known by the PropertyConsumer.

Specified by:
setPropertyPrefix in interface PropertyConsumer
Parameters:
prefix - the prefix String.

getPropertyPrefix

public java.lang.String getPropertyPrefix()
Get the property key prefix that is being used to prepend to the property keys for Properties lookups.

Specified by:
getPropertyPrefix in interface PropertyConsumer
Returns:
the property prefix for the plugin.

getMouseModeServiceList

public java.lang.String[] getMouseModeServiceList()
Return a list of the modes that are interesting to the MapMouseListener. The source MouseEvents will only get sent to the MapMouseListener if the mode is set to one that the listener is interested in. Layers interested in receiving events should register for receiving events in "select" mode:
 return new String[] { SelectMouseMode.modeID };
 

Specified by:
getMouseModeServiceList in interface MapMouseListener
Returns:
String[] of modeID's
See Also:
NavMouseMode.modeID, SelectMouseMode.modeID, NullMouseMode.modeID

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 MapMouseListener
Parameters:
e - MouseEvent
Returns:
true if the listener was able to process the event.

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 MapMouseListener
Parameters:
e - MouseEvent
Returns:
true if the listener was able to process the event.

mouseClicked

public boolean mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a component. The listener will receive this event if it successfully processed mousePressed(), or if no other listener processes the event. If the listener successfully processes mouseClicked(), then it will receive the next mouseClicked() notifications that have a click count greater than one.

NOTE: We have noticed that this method can sometimes be erroneously invoked. It seems to occur when a light-weight AWT component (like an internal window or menu) closes (removes itself from the window hierarchy). A specific OpenMap example is when you make a menu selection when the MenuItem you select is above the MapBean canvas. After making the selection, the mouseClicked() gets invoked on the MouseDelegator, which passes it to the appropriate listeners depending on the MouseMode. The best way to avoid this problem is to not implement anything crucial in this method. Use a combination of mousePressed() and mouseReleased() instead.

Specified by:
mouseClicked in interface MapMouseListener
Parameters:
e - MouseEvent
Returns:
true if the listener was able to process the event.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface 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 MapMouseListener
Parameters:
e - MouseEvent

mouseDragged

public boolean mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. The listener will receive these events if it successfully processes mousePressed(), or if no other listener processes the event.

Specified by:
mouseDragged in interface MapMouseListener
Parameters:
e - MouseEvent
Returns:
true if the listener was able to process the event.

mouseMoved

public boolean mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a component (with no buttons down).

Specified by:
mouseMoved in interface MapMouseListener
Parameters:
e - MouseEvent
Returns:
true if the listener was able to process the event.

mouseMoved

public void mouseMoved()
Handle a mouse cursor moving without the button being pressed. This event is intended to tell the listener that there was a mouse movement, but that the event was consumed by another layer. This will allow a mouse listener to clean up actions that might have happened because of another motion event response.

Specified by:
mouseMoved in interface MapMouseListener

removed

public void removed()
Method that gets called when the PlugInLayer has been removed from the map, so the PlugIn can free up resources.

Specified by:
removed in interface PlugIn

dispose

public void dispose()
Notification to the PlugIn that it has been removed from the application, so it can disconnect from all other objects that may be holding a reference to it.

Specified by:
dispose in interface PlugIn


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