com.bbn.openmap.gui
Class LayersMenu

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.AbstractButton
                  extended by javax.swing.JMenuItem
                      extended by javax.swing.JMenu
                          extended by com.bbn.openmap.gui.AbstractOpenMapMenu
                              extended by com.bbn.openmap.gui.LayersMenu
All Implemented Interfaces:
LayerListener, MenuBarMenu, LightMapHandlerChild, PropertyConsumer, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.MenuElement, javax.swing.SwingConstants

public class LayersMenu
extends AbstractOpenMapMenu
implements java.io.Serializable, LayerListener

The LayersMenu is a JMenu which is a list of the layers of the map. This LayersMenu expects to work with a LayerHandler containing all the possible layers that may be added to the map. This list defaults to being checkbuttons which add and remove the named layer to/from the Map. You can also use an instance of this object to show/hide layer palettes.

This object is interested in contacting a LayerHandler to find out all the layers available, and optionally, a LayersPanel in order to provide a menu item that will call up the GUI for the LayersPanel. If this LayersMenu is a member of a BeanContext, it expects that only one of each of these objects will be added, but if more than one per type is added, the last one added to be BeanContext will be the one hooked up to this LayersMenu.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JMenu
javax.swing.JMenu.AccessibleJMenu, javax.swing.JMenu.WinListener
 
Nested classes/interfaces inherited from class javax.swing.JMenuItem
javax.swing.JMenuItem.AccessibleJMenuItem
 
Nested classes/interfaces inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
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
protected  javax.swing.JMenuItem add
          The menu item to add a layer to the map.
protected  java.lang.String addLayersButtonTitle
          The default add button title.
static java.lang.String defaultEditLayersButtonTitle
          The default edit button title.
protected  javax.swing.JMenuItem edit
          A button on the bottom of the menu to bring up the layersPanel.
protected  java.lang.String editLayersButtonTitle
          The actual edit button title.
protected  LayerHandler layerHandler
          The LayerHandler to listen to for layers available for the map.
static int LAYERS_ON_OFF
          Static value to set this menu to control layer visibility.
protected  LayersPanel layersPanel
          Used by the BeanContext methods to insure that the component we disconnect the edit button from is the same one being removed from the BeanContext.
protected  int menuType
          The flag setting the behavior of the menu, whether it controls the layers or the layers palettes.
static int PALETTES_ON_OFF
          Static value to set this menu to control layer palette visibility.
 
Fields inherited from class com.bbn.openmap.gui.AbstractOpenMapMenu
beanContextChildSupport, i18n, items, itemsProperties, ItemsProperty, itemsPropertyContents, MnemonicProperty, PrettyNameProperty, propertyPrefix, SeparatorProperty
 
Fields inherited from class javax.swing.JMenu
popupListener
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
LayersMenu()
          Construct LayersMenu.
LayersMenu(LayerHandler lHandler)
          Construct LayersMenu.
LayersMenu(LayerHandler lHandler, java.lang.String menuName, int menuType)
          Construct LayersMenu.
 
Method Summary
 void findAndInit(java.lang.Object someObj)
          Called when the BeanContext membership changes with object from the BeanContext.
 void findAndUndo(java.lang.Object someObj)
          Called when objects are removed from the BeanContext.
 void fireVetoableChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
          Report a vetoable property update to any registered listeners.
 javax.swing.JMenuItem getEdit()
          Get the edit menu item that triggers the LayersPanel action listener.
 java.lang.String getEditLayersButtonTitle()
          Return the title of the menu option to call up LayersPanel.
 LayerHandler getLayerHandler()
          Get the LayerHandler that the LayersPanel listens to.
protected  LayersPanel getLayersPanel()
          Get the LayersPanel, privately held to keep track of what object is being used from the BeanContext.
 void removeAll()
          Remove all the components from the menu.
 void setAdd(javax.swing.JMenuItem a)
          Set the add menu item.
 void setEdit(javax.swing.JMenuItem e)
          Set the edit menu item that triggers the LayersPanel action listener.
 void setEditLayersButtonTitle(java.lang.String buttonTitle)
          Return the title of the menu option to call up LayersPanel.
 void setLayerHandler(LayerHandler lh)
          Set the LayerHandler that the LayersPanel listens to.
 void setLayers(Layer[] inLayers)
          Set the layers that are on the menu.
 void setLayers(LayerEvent evt)
          LayerListener interface method.
protected  void setLayersFromEDT(Layer[] inLayers)
           
protected  void setLayersPanel(LayersPanel lp)
          Set the LayersPanel privately to keep track of what object is being used from the BeanContext.
 void setupEditLayersButton(LayersPanel lp)
          Given a LayersPanel, set up a JButton to add to the end of the LayersMenu that will trigger the action listener of the LayersPanel.
 void setupLayerAddButton(LayerAddPanel menu)
          Constructs the menu item that will bring up the LayerAddPanel.
 void updateLayerLabels()
          Update the layer names.
 
Methods inherited from class com.bbn.openmap.gui.AbstractOpenMapMenu
addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, findAndUndo, getBeanContext, getMapHandler, getProperties, getPropertyInfo, getPropertyPrefix, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, setProperties, setProperties, setPropertyPrefix
 
Methods inherited from class javax.swing.JMenu
add, add, add, add, add, addMenuListener, addSeparator, applyComponentOrientation, createActionChangeListener, createActionComponent, createWinListener, doClick, fireMenuCanceled, fireMenuDeselected, fireMenuSelected, getAccessibleContext, getComponent, getDelay, getItem, getItemCount, getMenuComponent, getMenuComponentCount, getMenuComponents, getMenuListeners, getPopupMenu, getPopupMenuOrigin, getSubElements, getUIClassID, insert, insert, insert, insertSeparator, isMenuComponent, isPopupMenuVisible, isSelected, isTearOff, isTopLevelMenu, menuSelectionChanged, paramString, processKeyEvent, remove, remove, remove, removeMenuListener, setAccelerator, setComponentOrientation, setDelay, setMenuLocation, setModel, setPopupMenuVisible, setSelected, updateUI
 
Methods inherited from class javax.swing.JMenuItem
actionPropertyChanged, addMenuDragMouseListener, addMenuKeyListener, configurePropertiesFromAction, fireMenuDragMouseDragged, fireMenuDragMouseEntered, fireMenuDragMouseExited, fireMenuDragMouseReleased, fireMenuKeyPressed, fireMenuKeyReleased, fireMenuKeyTyped, getAccelerator, getMenuDragMouseListeners, getMenuKeyListeners, init, isArmed, processKeyEvent, processMenuDragMouseEvent, processMenuKeyEvent, processMouseEvent, removeMenuDragMouseListener, removeMenuKeyListener, setArmed, setEnabled, setUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, paintBorder, removeActionListener, removeChangeListener, removeItemListener, removeNotify, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
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, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, 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, addContainerListener, addPropertyChangeListener, 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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, repaint, repaint, repaint, resize, resize, setBounds, setBounds, 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 javax.swing.MenuElement
processKeyEvent, processMouseEvent
 

Field Detail

LAYERS_ON_OFF

public static final transient int LAYERS_ON_OFF
Static value to set this menu to control layer visibility.

See Also:
Constant Field Values

PALETTES_ON_OFF

public static final transient int PALETTES_ON_OFF
Static value to set this menu to control layer palette visibility.

See Also:
Constant Field Values

menuType

protected int menuType
The flag setting the behavior of the menu, whether it controls the layers or the layers palettes.


layerHandler

protected transient LayerHandler layerHandler
The LayerHandler to listen to for layers available for the map.


layersPanel

protected transient LayersPanel layersPanel
Used by the BeanContext methods to insure that the component we disconnect the edit button from is the same one being removed from the BeanContext.


edit

protected transient javax.swing.JMenuItem edit
A button on the bottom of the menu to bring up the layersPanel.


defaultEditLayersButtonTitle

public static final java.lang.String defaultEditLayersButtonTitle
The default edit button title.

See Also:
Constant Field Values

editLayersButtonTitle

protected transient java.lang.String editLayersButtonTitle
The actual edit button title.


add

protected transient javax.swing.JMenuItem add
The menu item to add a layer to the map.


addLayersButtonTitle

protected transient java.lang.String addLayersButtonTitle
The default add button title.

Constructor Detail

LayersMenu

public LayersMenu()
Construct LayersMenu.


LayersMenu

public LayersMenu(LayerHandler lHandler)
Construct LayersMenu.

Parameters:
lHandler - the handler for the layer

LayersMenu

public LayersMenu(LayerHandler lHandler,
                  java.lang.String menuName,
                  int menuType)
Construct LayersMenu.

Parameters:
lHandler - the handler for the layer
menuName - the name of the menu
menuType - either LAYERS_ON_OFF, or PALETTES_ON_OFF
Method Detail

setLayerHandler

public void setLayerHandler(LayerHandler lh)
Set the LayerHandler that the LayersPanel listens to. If the LayerHandler is not null, the LayersMenu will be added to the LayerHandler LayerListener list, and the LayersMenu will receive a LayerEvent with the current layers.

If there is a LayerHandler that is already being listened to, then the LayersPanel will remove itself from current LayerHandler as a LayerListener, before adding itself to the new LayerHandler.

Lastly, if the LayerHandler passed in is null, the LayersPanel will disconnect itself from any LayerHandler currently held, and reset itself with no layers.

Parameters:
lh - the LayerHandler containing the layers.

getLayerHandler

public LayerHandler getLayerHandler()
Get the LayerHandler that the LayersPanel listens to.


setLayersPanel

protected void setLayersPanel(LayersPanel lp)
Set the LayersPanel privately to keep track of what object is being used from the BeanContext.


getLayersPanel

protected LayersPanel getLayersPanel()
Get the LayersPanel, privately held to keep track of what object is being used from the BeanContext.


setEditLayersButtonTitle

public void setEditLayersButtonTitle(java.lang.String buttonTitle)
Return the title of the menu option to call up LayersPanel.


getEditLayersButtonTitle

public java.lang.String getEditLayersButtonTitle()
Return the title of the menu option to call up LayersPanel.


setEdit

public void setEdit(javax.swing.JMenuItem e)
Set the edit menu item that triggers the LayersPanel action listener. Assumes that it's already wired up.


setAdd

public void setAdd(javax.swing.JMenuItem a)
Set the add menu item.


getEdit

public javax.swing.JMenuItem getEdit()
Get the edit menu item that triggers the LayersPanel action listener.


setLayers

public void setLayers(LayerEvent evt)
LayerListener interface method. A list of layers will be added, removed, or replaced based on on the type of LayerEvent.

Specified by:
setLayers in interface LayerListener
Parameters:
evt - a LayerEvent

setLayers

public void setLayers(Layer[] inLayers)
Set the layers that are on the menu. Calls for AWT thread to update layers

Parameters:
inLayers - the array of layers.

setLayersFromEDT

protected void setLayersFromEDT(Layer[] inLayers)

removeAll

public void removeAll()
Remove all the components from the menu. Also calls cleanup() on all the LayerCheckBoxMenuItems, so they can remove themselves from their layers.

Overrides:
removeAll in class javax.swing.JMenu

updateLayerLabels

public void updateLayerLabels()
Update the layer names.


setupEditLayersButton

public void setupEditLayersButton(LayersPanel lp)
Given a LayersPanel, set up a JButton to add to the end of the LayersMenu that will trigger the action listener of the LayersPanel.

Parameters:
lp - the LayersPanel to ask for an ActionListener from.

setupLayerAddButton

public void setupLayerAddButton(LayerAddPanel menu)
Constructs the menu item that will bring up the LayerAddPanel.


findAndInit

public void findAndInit(java.lang.Object someObj)
Called when the BeanContext membership changes with object from the BeanContext. This lets this object hook up with what it needs. It expects to find only one LayerHandler and LayersPanel in the BeanContext. If another LayerHandler/LayersPanel is somehow added to the BeanContext, however, it will drop the connection to the component it is set up to listen to, and rewire itself to reflect the status of the last version of the LayerHandler/LayersPanel found.

Specified by:
findAndInit in interface LightMapHandlerChild
Overrides:
findAndInit in class AbstractOpenMapMenu
Parameters:
someObj - Object received in the BeanContext or BeanContextMembershipEvent.

findAndUndo

public void findAndUndo(java.lang.Object someObj)
Called when objects are removed from the BeanContext. Should be used to check for relevant objects that need to be disconnected from this object. This method does check to see if a LayerHandler or LayersPanel is being removed, that it is the same object currently being used by this LayersMenu.

Specified by:
findAndUndo in interface LightMapHandlerChild
Overrides:
findAndUndo in class AbstractOpenMapMenu
Parameters:
someObj - the object being removed from the BeanContext

fireVetoableChange

public void fireVetoableChange(java.lang.String name,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
                        throws java.beans.PropertyVetoException
Report a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event reverting everyone to the old value and then rethrow the PropertyVetoException.

No event is fired if old and new are equal and non-null.

Overrides:
fireVetoableChange in class javax.swing.JComponent
Parameters:
name - The programmatic name of the property that is about to change
oldValue - The old value of the property
newValue - - The new value of the property
Throws:
java.beans.PropertyVetoException - if the recipient wishes the property change to be rolled back.


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