Class DemoLayer

  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.bbn.openmap.Layer
                  extended by com.bbn.openmap.layer.OMGraphicHandlerLayer
                      extended by com.bbn.openmap.layer.DemoLayer
All Implemented Interfaces:
ProjectionListener, GestureResponsePolicy, OMGraphicHandler, ProjectionPainter, PropertyConsumer, DrawingToolRequestor, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener,, java.util.EventListener

public class DemoLayer
extends OMGraphicHandlerLayer
implements DrawingToolRequestor

This layer demonstrates interactive capabilities of OpenMap. Instantiating this layer should show an icon loaded using HTTP Protocol, which represents Boston, MA in USA. Above Boston it should show a square that would change color when mouse is moved over it in 'Gesture' mode. Also clicking once brings up a message box and more than once brings up browser.

The DemoLayer has also been modified to demonstrate the first uses of the OMDrawingTool. The Palette has buttons that can be used to start the tool in several different ways.

See Also:
Just added some decorated splines to test them. EL, Serialized Form

Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
Nested classes/interfaces inherited from class java.awt.Container
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
protected  DrawingTool drawingTool
          Found in the findAndInit() method, in the MapHandler.
protected static java.lang.String externalKey
          Used by geometries created in GUI for specify if the spatial filter is for objects outside the drawn shape.
protected  GraphicAttributes filterGA
protected static java.lang.String internalKey
          Used by geometries created in GUI for specify if the spatial filter is for objects inside the drawn shape.
protected  DrawingToolRequestor layer
          Used by the internal ActionListeners for a callback, see getGUI().
protected  javax.swing.JPanel legend
protected  OMGraphicList objects
          This is a list to hold the non-changing OMGraphics to display on the layer.
protected  SymbolReferenceLibrary srl
          Found in the findAndInit() method, in the MapHandler.
Fields inherited from class com.bbn.openmap.layer.OMGraphicHandlerLayer
consumeEvents, ConsumeEventsProperty, filter, interruptable, InterruptableProperty, layerWorker, LAYERWORKER_LOCK, layerWorkerQueue, logger, mouseEventInterpreter, mouseModeIDs, MouseModesProperty, projectionChangePolicy, ProjectionChangePolicyProperty, renderPolicy, RenderPolicyProperty, selectedList, TransparencyProperty
Fields inherited from class com.bbn.openmap.Layer
addAsBackground, AddAsBackgroundProperty, addToBeanContext, AddToBeanContextProperty, attributes, autoPalette, AutoPaletteProperty, beanContextChildSupport, coordTransform, DataPathPrefixProperty, DisplayPaletteCmd, DisplayPropertiesCmd, doHack, HidePaletteCmd, i18n, localHackList, maxScale, MaxScaleProperty, minScale, MinScaleProperty, palette, paletteListener, PrettyNameProperty, propertyPrefix, readyToPaint, RedrawCmd, removable, RemovableProperty, SWING_PACKAGE, TransformProperty, windowSupport
Fields inherited from class javax.swing.JComponent
Fields inherited from class java.awt.Component
Fields inherited from interface com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
Fields inherited from interface java.awt.image.ImageObserver
Constructor Summary
Method Summary
 void drawingComplete(OMGraphic omg, OMAction action)
          Called when the DrawingTool is complete, providing the layer with the modified OMGraphic.
 void findAndInit(java.lang.Object someObj)
          Called when a component that is needed, and not available with an appropriate iterator from the BeanContext.
 void findAndUndo(java.lang.Object someObj)
          BeanContextMembershipListener method.
 DrawingTool getDrawingTool()
protected  GraphicAttributes getFilterGA()
 java.awt.Component getGUI()
          Gets the gui controls associated with the layer.
 java.lang.String getInfoText(OMGraphic omg)
          Query for what text should be placed over the information bar when the mouse is over a particular OMGraphic.
 java.util.List<java.awt.Component> getItemsForMapMenu(MapMouseEvent me)
          Return a JMenu with contents applicable to a pop-up menu for a location over the map.
 java.util.List<java.awt.Component> getItemsForOMGraphicMenu(OMGraphic omg)
          Return a java.util.List containing input for a JMenu with contents applicable to a pop-up menu for a location over an OMGraphic.
 SymbolReferenceLibrary getSymbolReferenceLibrary()
 java.lang.String getToolTipTextFor(OMGraphic omg)
          Query for what tooltip to display for an OMGraphic when the mouse is over it.
 OMGraphicList init()
 boolean isHighlightable(OMGraphic omg)
          Query that an OMGraphic can be highlighted when the mouse moves over it.
 boolean isSelectable(OMGraphic omg)
          Query that an OMGraphic is selectable.
 void paint(java.awt.Graphics g)
          The default action is to get the OMGraphicList and render it.
 OMGraphicList prepare()
          This is an important Layer method to override.
 void select(OMGraphicList list)
          Called if isSelectable(OMGraphic) was true, so the list has the OMGraphic.
 void setDrawingTool(DrawingTool dt)
 void setProperties(java.lang.String prefix, java.util.Properties props)
          Overrides the Layer setProperties method.
 void setSymbolReferenceLibrary(SymbolReferenceLibrary library)
          Set the MilStd2525 SymbolReferenceLibrary object used to create symbols.
Methods inherited from class com.bbn.openmap.layer.OMGraphicHandlerLayer
actionPerformed, canSetList, copy, createLayerWorker, cut, deselect, dispose, doAction, doPrepare, filter, filter, filter, getConsumeEvents, getDefaultSettingsPanel, getFilter, getLayerWorker, getList, getMapMouseListener, getMouseEventInterpreter, getMouseModeIDsForEvents, getProjectionChangePolicy, getProperties, getPropertyInfo, getRedrawButton, getRenderPolicy, getSelected, getSettingsButton, getTransparency, getTransparencyAdjustmentPanel, highlight, isCancelled, isInterruptable, isWorking, leftClick, mouseOver, paste, projectionChanged, receivesMapEvents, renderDataForProjection, resetFiltering, setConsumeEvents, setFilter, setInterruptable, setLayerWorker, setList, setMouseEventInterpreter, setMouseModeIDsForEvents, setProjectionChangePolicy, setRenderPolicy, setTransparency, supportsSQL, unhighlight, workerComplete
Methods inherited from class com.bbn.openmap.Layer
addComponentListener, added, addInfoDisplayListener, addLayerStatusListener, addMouseListener, addVetoableChangeListener, childrenAdded, childrenRemoved, clearListeners, connectToBeanContext, createWindowSupport, disconnectFromBeanContext, finalize, findAndInit, fireHideToolTip, firePaletteEvent, fireRequestBrowserContent, fireRequestBrowserContent, fireRequestCursor, fireRequestInfoLine, fireRequestInfoLine, fireRequestInfoLine, fireRequestMessage, fireRequestMessage, fireRequestToolTip, fireRequestToolTip, fireRequestURL, fireRequestURL, fireStatusUpdate, fireStatusUpdate, fireVetoableChange, getAddAsBackground, getAddToBeanContext, getAttribute, getBeanContext, getCoordTransform, getIcon, getMaxScale, getMinScale, getPackage, getPalette, getProjection, getPropertyPrefix, getWindowSupport, hasGUI, hidePalette, isAutoPalette, isProjectionOK, isReadyToPaint, isRemovable, notifyHideHack, prependDataPathPrefix, putAttribute, removeComponentListener, removeConfirmed, removed, removeInfoDisplayListener, removeLayerStatusListener, removeVetoableChangeListener, repaint, resetPalette, setAddAsBackground, setAddToBeanContext, setAutoPalette, setBeanContext, setCoordTransform, setIcon, setLayerProperties, setMaxScale, setMinScale, setName, setPaletteVisible, setProjection, setProjection, setProperties, setPropertyPrefix, setReadyToPaint, setRemovable, setVisible, setWindowSupport, showPalette
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, 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, unregisterKeyboardAction, update, updateUI
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, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, 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, 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, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface
Methods inherited from interface java.beans.beancontext.BeanContextChild
addPropertyChangeListener, removePropertyChangeListener

Field Detail


protected javax.swing.JPanel legend


protected DrawingTool drawingTool
Found in the findAndInit() method, in the MapHandler.


protected SymbolReferenceLibrary srl
Found in the findAndInit() method, in the MapHandler.


protected final DrawingToolRequestor layer
Used by the internal ActionListeners for a callback, see getGUI().


protected static final java.lang.String internalKey
Used by geometries created in GUI for specify if the spatial filter is for objects inside the drawn shape.

See Also:
Constant Field Values


protected static final java.lang.String externalKey
Used by geometries created in GUI for specify if the spatial filter is for objects outside the drawn shape.

See Also:
Constant Field Values


protected GraphicAttributes filterGA


protected OMGraphicList objects
This is a list to hold the non-changing OMGraphics to display on the layer. It is used to load the OMGraphicList that the layer actually paints.

Constructor Detail


public DemoLayer()
Method Detail


public void paint(java.awt.Graphics g)
Description copied from class: OMGraphicHandlerLayer
The default action is to get the OMGraphicList and render it.

paint in class OMGraphicHandlerLayer
g - java.awt.Graphics object to render OMGraphics into.


public OMGraphicList init()


public void setProperties(java.lang.String prefix,
                          java.util.Properties props)
Description copied from class: OMGraphicHandlerLayer
Overrides the Layer setProperties method. Also calls Layer's version. If the ProjectionChangePolicy and RenderPolicy objects are set programmatically, are PropertyConsumers and the .class property is not set, they will still have access to properties if this method is called. Their property prefix will be scoped as if the OMGraphicHandlerLayer had them created, with their prefix being prefix + . + PropertyChangePolicyProperty and prefix + . + RenderPolicyProperty. If the .class property is set, then a new policy object will be created and replace the one set before this method is called.

Specified by:
setProperties in interface PropertyConsumer
setProperties in class OMGraphicHandlerLayer
prefix - the token to prefix the property names
props - the Properties object


public OMGraphicList prepare()
This is an important Layer method to override. The prepare method gets called when the layer is added to the map, or when the map projection changes. We need to make sure the OMGraphicList returned from this method is what we want painted on the map. The OMGraphics need to be generated with the current projection. We test for a null OMGraphicList in the layer to see if we need to create the OMGraphics. This layer doesn't change it's OMGraphics for different projections, if your layer does, you need to clear out the OMGraphicList and add the OMGraphics you want for the current projection.

prepare in class OMGraphicHandlerLayer


protected GraphicAttributes getFilterGA()


public java.awt.Component getGUI()
Description copied from class: Layer
Gets the gui controls associated with the layer. This default implementation returns null indicating that the layer has no gui controls.

getGUI in class Layer
java.awt.Component or null, null by default.


public DrawingTool getDrawingTool()


public void setDrawingTool(DrawingTool dt)


public void drawingComplete(OMGraphic omg,
                            OMAction action)
Called when the DrawingTool is complete, providing the layer with the modified OMGraphic.

Specified by:
drawingComplete in interface DrawingToolRequestor


public void findAndInit(java.lang.Object someObj)
Called when a component that is needed, and not available with an appropriate iterator from the BeanContext. This lets this object hook up with what it needs. For Layers, this method doesn't do anything by default. If you need your layer to get ahold of another object, then you can use the Iterator to go through the objects to look for the one you need.

findAndInit in class Layer


public void setSymbolReferenceLibrary(SymbolReferenceLibrary library)
Set the MilStd2525 SymbolReferenceLibrary object used to create symbols.

library -


public SymbolReferenceLibrary getSymbolReferenceLibrary()


public void findAndUndo(java.lang.Object someObj)
BeanContextMembershipListener method. Called when a new object is removed from the BeanContext of this object. For the Layer, this method doesn't do anything. If your layer does something with the childrenAdded method, or findAndInit, you should take steps in this method to unhook the layer from the object used in those methods.

findAndUndo in class Layer


public boolean isHighlightable(OMGraphic omg)
Query that an OMGraphic can be highlighted when the mouse moves over it. If the answer is true, then highlight with this OMGraphics will be called.

Specified by:
isHighlightable in interface GestureResponsePolicy
isHighlightable in class OMGraphicHandlerLayer


public boolean isSelectable(OMGraphic omg)
Query that an OMGraphic is selectable.

Specified by:
isSelectable in interface GestureResponsePolicy
isSelectable in class OMGraphicHandlerLayer


public java.lang.String getInfoText(OMGraphic omg)
Query for what text should be placed over the information bar when the mouse is over a particular OMGraphic.

Specified by:
getInfoText in interface GestureResponsePolicy
getInfoText in class OMGraphicHandlerLayer


public java.lang.String getToolTipTextFor(OMGraphic omg)
Query for what tooltip to display for an OMGraphic when the mouse is over it.

Specified by:
getToolTipTextFor in interface GestureResponsePolicy
getToolTipTextFor in class OMGraphicHandlerLayer


public void select(OMGraphicList list)
Called if isSelectable(OMGraphic) was true, so the list has the OMGraphic. A list is used in case underlying code is written to handle more than one OMGraphic being selected at a time.

Specified by:
select in interface GestureResponsePolicy
select in class OMGraphicHandlerLayer


public java.util.List<java.awt.Component> getItemsForMapMenu(MapMouseEvent me)
Description copied from class: OMGraphicHandlerLayer
Return a JMenu with contents applicable to a pop-up menu for a location over the map. The pop-up doesn't concern any OMGraphics, and should be presented for a click on the map background.

Specified by:
getItemsForMapMenu in interface GestureResponsePolicy
getItemsForMapMenu in class OMGraphicHandlerLayer
me - a MapMouseEvent describing the location over where the menu items should apply, in case different options are appropriate for different places.
a JMenu for the map. Return null or empty List if no input required.


public java.util.List<java.awt.Component> getItemsForOMGraphicMenu(OMGraphic omg)
Description copied from class: OMGraphicHandlerLayer
Return a java.util.List containing input for a JMenu with contents applicable to a pop-up menu for a location over an OMGraphic.

Specified by:
getItemsForOMGraphicMenu in interface GestureResponsePolicy
getItemsForOMGraphicMenu in class OMGraphicHandlerLayer
a List containing options for the given OMGraphic. Return null or empty list if there are no options.

Copyright (C) BBNT Solutions LLC; See for details