com.bbn.openmap.gui
Class BasicMapPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.bbn.openmap.gui.OMComponentPanel
                      extended by com.bbn.openmap.gui.BasicMapPanel
All Implemented Interfaces:
MapPanel, LightMapHandlerChild, PropertyConsumer, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible
Direct Known Subclasses:
DockMapPanel, OverlayMapPanel, TimelinePanel, TimeSliderPanel

public class BasicMapPanel
extends OMComponentPanel
implements MapPanel

The BasicMapPanel is a MapPanel and OMComponentPanel that is the heart of the OpenMap application framework. It can be used in a application or applet. The Panel has a BorderLayout, and creates a MapBean for its center area. It creates a MapHandler to use to hold all of its OpenMap components, and uses the PropertyHandler given to it in its constructor to create and configure all of the application components. The best way to add components to the MapPanel is to get the MapHandler from it and add components to that. The BasicMapPanel also adds itself to its MapHandler, so when the PropertyHandler adds MapPanelChildren components to the MapHandler, the BasicMapPanel is able to find them via the findAndInit method. By default, the BasicMapPanel looks for MapPanelChildren and asks them for where they would prefer to be located (BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST). If you extend this component, though, other components could be found via that same findAndInit method.

If a property prefix is set on this MapPanel, that property prefix can be used to designate MapPanelChild objects for this MapPanel. The setName variable should be set to true, and the children's parent name should match whatever property prefix is given to the panel.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.util.logging.Logger logger
           
protected  MapBean mapBean
           
protected  MapHandler mapHandler
           
protected  MenuList menuList
           
protected  PropertyHandler propertyHandler
           
static java.lang.String SET_NAME_PROPERTY
           
protected  boolean setName
           
 
Fields inherited from class com.bbn.openmap.gui.OMComponentPanel
beanContextChildSupport, i18n, isolated, orientation, propertyPrefix, windowSupport
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BasicMapPanel()
          Creates an empty MapPanel that creates its own empty PropertyHandler.
BasicMapPanel(boolean delayCreation)
          Create a MapPanel with the option of delaying the search for properties until the create() call is made.
BasicMapPanel(PropertyHandler propertyHandler)
          Create a MapPanel that configures itself with the properties contained in the PropertyHandler provided.
BasicMapPanel(PropertyHandler propertyHandler, boolean delayCreation)
          Create a MapPanel that configures itself with properties contained in the PropertyHandler provided, and with the option of delaying the search for properties until the create() call is made.
 
Method Summary
protected  void addMapBeanToPanel(MapBean map)
          Position the map bean in this panel according to the layout manger.
 void addMapComponent(java.lang.Object mapComponent)
          Adds a component to the map bean context.
protected  void addMapPanelChild(MapPanelChild mpc)
          Add a child to the MapPanel.
 void addProperties(java.util.Properties p)
          Add in the properties from the given Properties object.
 void addProperties(java.lang.String propFile)
          Add in the properties from the given source, which can be a resource, file or URL.
 void addProperties(java.net.URL urlToProperties)
          Add in the properties from the given URL.
 void addProperty(java.lang.String property, java.lang.String value)
          Add (or overwrite) a property to the current properties
 void appendProperty(java.lang.String property, java.util.Properties src)
          Append the given property into the current properties
 void appendProperty(java.lang.String property, java.lang.String value)
          Append the given property into the current properties
 void create()
          The method that triggers setLayout() and createComponents() to be called.
protected  void createComponents()
          The constructor calls this method that creates the MapHandler and MapBean, and then tells the PropertyHandler to create the components described in its properties.
protected  java.awt.LayoutManager createLayoutManager()
          The constructor calls this method that sets the LayoutManager for this MapPanel.
static MapBean createMapBean()
          A static method that creates a MapBean with it's projection set to the values set in the Environment.
static MapBean createMapBean(Projection proj, javax.swing.border.Border border)
          A static method that creates a MapBean and sets its projection and border to the values given.
 void dispose()
          Sets the MapBean variable to null and removes all children.
 void findAndInit(java.lang.Object someObj)
          The BasicMapPanel looks for MapPanelChild components, finds out from them where they prefer to be placed, and adds them.
 void findAndUndo(java.lang.Object someObj)
          The MapPanel looks for MapPanelChild components and removes them from itself.
 MapBean getMapBean()
          MapPanel method.
 java.lang.Object getMapComponent(java.lang.String prefix)
          Find the object with the given prefix by looking it up in the prefix librarian in the MapHandler.
 java.lang.Object getMapComponentByType(java.lang.Class<?> c)
          Given a Class, find the object in the MapHandler.
 java.util.Collection<?> getMapComponentsByType(java.lang.Class<?> c)
          Get all of the mapComponents that are of the given class type.
 MapHandler getMapHandler()
          MapPanel method.
 javax.swing.JMenu getMapMenu()
          MapPanel method.
 javax.swing.JMenuBar getMapMenuBar()
          MapPanel method.
 java.util.Properties getProperties()
          Get the current properties.
 PropertyHandler getPropertyHandler()
          Get the PropertyHandler containing properties used to configure the panel, creating it if it doesn't exist.
 boolean isSetName()
           
 void prependProperty(java.lang.String property, java.util.Properties src)
          Prepend the given property into the current properties
 void prependProperty(java.lang.String property, java.lang.String value)
          Prepend the given property into the current properties
 boolean removeMapComponent(java.lang.Object mapComponent)
          Remove a component from the map bean context.
 void removeMarker(java.lang.String property, java.lang.String marker)
          remove a marker from a space delimited set of properties.
 boolean removeProperty(java.lang.String property)
          Remove an existing property if it exists.
 void setMapBean(MapBean bean)
          Set the map bean used in this map panel, replace the map bean in the MapHandler if there isn't already one, or if the policy allows replacement.
 void setProperties(java.lang.String prefix, java.util.Properties props)
          Sets the properties in the PropertyHandler managed by this BasicMapPanel.
 void setPropertyHandler(PropertyHandler handler)
          Set the PropertyHandler containing the properties used to configure this panel.
 void setSetName(boolean setName)
           
 
Methods inherited from class com.bbn.openmap.gui.OMComponentPanel
addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, fireVetoableChange, getBeanContext, getOrientation, getProperties, getPropertyInfo, getPropertyPrefix, getWindowSupport, isIsolated, removeVetoableChangeListener, setBeanContext, setIsolated, setOrientation, setProperties, setPropertyPrefix, setWindowSupport
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.beans.beancontext.BeanContextChild
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

logger

public static java.util.logging.Logger logger

SET_NAME_PROPERTY

public static final java.lang.String SET_NAME_PROPERTY
See Also:
Constant Field Values

mapHandler

protected MapHandler mapHandler

mapBean

protected MapBean mapBean

propertyHandler

protected PropertyHandler propertyHandler

menuList

protected MenuList menuList

setName

protected boolean setName
Constructor Detail

BasicMapPanel

public BasicMapPanel()
Creates an empty MapPanel that creates its own empty PropertyHandler. The MapPanel will contain a MapBean, a MapHandler, and a PropertyHandler with no properties. The constructor to use to create a blank map framework to add components to.


BasicMapPanel

public BasicMapPanel(boolean delayCreation)
Create a MapPanel with the option of delaying the search for properties until the create() call is made.

Parameters:
delayCreation - true to let the MapPanel know that the artful programmer will call create()

BasicMapPanel

public BasicMapPanel(PropertyHandler propertyHandler)
Create a MapPanel that configures itself with the properties contained in the PropertyHandler provided. If the PropertyHandler is null, a new one will be created.


BasicMapPanel

public BasicMapPanel(PropertyHandler propertyHandler,
                     boolean delayCreation)
Create a MapPanel that configures itself with properties contained in the PropertyHandler provided, and with the option of delaying the search for properties until the create() call is made.

Parameters:
delayCreation - true to let the MapPanel know that the artful programmer will call create()
Method Detail

setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties props)
Sets the properties in the PropertyHandler managed by this BasicMapPanel. This method is intended to be called when the PropertyHandler is set on the panel, in order for configuration parameters to be set on this panel before configuration.

Specified by:
setProperties in interface PropertyConsumer
Overrides:
setProperties in class OMComponentPanel
Parameters:
prefix - property prefix for scoping properties for this panel
props - the properties to search for properties in.

create

public void create()
The method that triggers setLayout() and createComponents() to be called. If you've told the BasicMapPanel to delay creation, you should call this method to trigger the PropertyHandler to create components based on the contents of its properties.


createLayoutManager

protected java.awt.LayoutManager createLayoutManager()
The constructor calls this method that sets the LayoutManager for this MapPanel. It returns a BorderLayout by default, but this method can be overridden to change how the MapPanel places components. If you change what this method returns, you should also change how components are added in the findAndInit() method.


addMapBeanToPanel

protected void addMapBeanToPanel(MapBean map)
Position the map bean in this panel according to the layout manger. Defaults to BorderLayout.CENTER.


createComponents

protected void createComponents()
The constructor calls this method that creates the MapHandler and MapBean, and then tells the PropertyHandler to create the components described in its properties. This method calls getMapHandler() and getMapBean(). If the PropertyHandler is not null, it will be called to created components based on its properties, and those components will be added to the MapHandler in this MapPanel.


getMapBean

public MapBean getMapBean()
MapPanel method. Get the MapBean used for the MapPanel. If the MapBean is null, calls createMapBean() which will create a BufferedLayerMapBean and add it to the MapHandler via a setMapBean call. If you want something different, override this method.

Specified by:
getMapBean in interface MapPanel

setMapBean

public void setMapBean(MapBean bean)
Set the map bean used in this map panel, replace the map bean in the MapHandler if there isn't already one, or if the policy allows replacement. The MapHandler will be created if it doesn't exist via a getMapHandler() method call.

Throws:
MultipleSoloMapComponentException - if there is already a map bean in the map handler and the policy is to reject duplicates (since the MapBean is a SoloMapComponent).

getPropertyHandler

public PropertyHandler getPropertyHandler()
Get the PropertyHandler containing properties used to configure the panel, creating it if it doesn't exist.


setPropertyHandler

public void setPropertyHandler(PropertyHandler handler)
Set the PropertyHandler containing the properties used to configure this panel. Adds the PropertyHandler to the MapHandler. If the MapHandler isn't set at this point, it will be created via a getMapHandler() call.


getMapHandler

public MapHandler getMapHandler()
MapPanel method. Get the MapHandler used for the MapPanel. Creates a standard MapHandler if it hasn't been created yet.

Specified by:
getMapHandler in interface MapPanel

getMapMenuBar

public javax.swing.JMenuBar getMapMenuBar()
MapPanel method. Get a JMenuBar containing menus created from properties.

Specified by:
getMapMenuBar in interface MapPanel

getMapMenu

public javax.swing.JMenu getMapMenu()
MapPanel method. Get a JMenu containing sub-menus created from properties.

Specified by:
getMapMenu in interface MapPanel

addMapComponent

public void addMapComponent(java.lang.Object mapComponent)
Adds a component to the map bean context. This makes the mapComponent available to the map layers and other components.

Specified by:
addMapComponent in interface MapPanel
Parameters:
mapComponent - a component to be added to the map bean context
Throws:
MultipleSoloMapComponentException - if mapComponent is a SoloMapComponent and another instance already exists and the policy is a reject policy.

removeMapComponent

public boolean removeMapComponent(java.lang.Object mapComponent)
Remove a component from the map bean context.

Parameters:
mapComponent - a component to be removed to the map bean context
Returns:
true if the mapComponent was removed.

getMapComponentByType

public java.lang.Object getMapComponentByType(java.lang.Class<?> c)
Given a Class, find the object in the MapHandler. If the class is not a SoloMapComponent and there are more than one of them in the MapHandler, you will get the first one found.


getMapComponentsByType

public java.util.Collection<?> getMapComponentsByType(java.lang.Class<?> c)
Get all of the mapComponents that are of the given class type.


getMapComponent

public java.lang.Object getMapComponent(java.lang.String prefix)
Find the object with the given prefix by looking it up in the prefix librarian in the MapHandler.


findAndInit

public void findAndInit(java.lang.Object someObj)
The BasicMapPanel looks for MapPanelChild components, finds out from them where they prefer to be placed, and adds them.

Specified by:
findAndInit in interface LightMapHandlerChild
Overrides:
findAndInit in class OMComponentPanel

addMapPanelChild

protected void addMapPanelChild(MapPanelChild mpc)
Add a child to the MapPanel.


findAndUndo

public void findAndUndo(java.lang.Object someObj)
The MapPanel looks for MapPanelChild components and removes them from itself.

Specified by:
findAndUndo in interface LightMapHandlerChild
Overrides:
findAndUndo in class OMComponentPanel

dispose

public void dispose()
Sets the MapBean variable to null and removes all children.

Specified by:
dispose in interface MapPanel

createMapBean

public static MapBean createMapBean()
A static method that creates a MapBean with it's projection set to the values set in the Environment. Also creates a BevelBorder.LOWERED border for the MapBean.


createMapBean

public static MapBean createMapBean(Projection proj,
                                    javax.swing.border.Border border)
A static method that creates a MapBean and sets its projection and border to the values given.


getProperties

public java.util.Properties getProperties()
Get the current properties.


removeProperty

public boolean removeProperty(java.lang.String property)
Remove an existing property if it exists.

Returns:
true if a property was actually removed.

addProperty

public void addProperty(java.lang.String property,
                        java.lang.String value)
Add (or overwrite) a property to the current properties


addProperties

public void addProperties(java.net.URL urlToProperties)
Add in the properties from the given URL. Any existing properties will be overwritten except for openmap.components, openmap.layers and openmap.startUpLayers which will be appended.


addProperties

public void addProperties(java.lang.String propFile)
                   throws java.net.MalformedURLException
Add in the properties from the given source, which can be a resource, file or URL. Any existing properties will be overwritten except for openmap.components, openmap.layers and openmap.startUpLayers which will be appended.

Throws:
MalformedURLException - if propFile doesn't resolve properly.

removeMarker

public void removeMarker(java.lang.String property,
                         java.lang.String marker)
remove a marker from a space delimited set of properties.


addProperties

public void addProperties(java.util.Properties p)
Add in the properties from the given Properties object. Any existing properties will be overwritten except for openmap.components, openmap.layers and openmap.startUpLayers which will be appended.


appendProperty

public void appendProperty(java.lang.String property,
                           java.util.Properties src)
Append the given property into the current properties


appendProperty

public void appendProperty(java.lang.String property,
                           java.lang.String value)
Append the given property into the current properties


prependProperty

public void prependProperty(java.lang.String property,
                            java.util.Properties src)
Prepend the given property into the current properties


prependProperty

public void prependProperty(java.lang.String property,
                            java.lang.String value)
Prepend the given property into the current properties


isSetName

public boolean isSetName()
Returns:
the setName setting, whether the property prefix will be set on the MapPanel when setProperties is called.

setSetName

public void setSetName(boolean setName)
Parameters:
setName - whether the property prefix provided in setProperties will be set on the MapPanel. If it is, then when MapPanelChild objects are found in the MapHandler, they will only be added if the names match.


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