com.bbn.openmap.layer
Class BufferedLayer

java.lang.Object
  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.BufferedLayer
All Implemented Interfaces:
ProjectionListener, GestureResponsePolicy, OMGraphicHandler, ProjectionPainter, PropertyConsumer, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener

public class BufferedLayer
extends OMGraphicHandlerLayer
implements java.beans.PropertyChangeListener

A BufferedLayer is a layer that buffers a group of layers into an image. When this layer repaints, the image gets rendered. This layer can be used to group a set of layers into one, and was designed with the idea that it is a background layer where a more animated layer would be on top of it.

This layer contains a MapBean, and any layer that gets added to it simply gets added to the MapBean. When a layer needs to redraw itself, it can act normally, and the BufferedLayer will get updated as needed. If the MapBean is a BufferedMapBean (which it is by default), then the layers will get buffered into an image.

The BufferedLayer can be configured in the openmap.properties file:



  bufLayer.class=com.bbn.openmap.layer.BufferedLayer
  bufLayer.prettyName=My Layer Group
  bufLayer.layers=layer1 layer2 layer3
  bufLayer.visibleLayers=layer1 layer3
 
layer1, layer2, etc should be defined as any other openmap layer.

See Also:
Serialized Form

Nested Class Summary
 class BufferedLayer.BLMapBean
          An simple extension of the BufferedMapBean that calls a layer, presumably its parent, to call repaint().
protected  class BufferedLayer.VisHelper
          Class that helps track turning on/off layers in the buffered layer.
 
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  boolean hasTransparentBackground
          Used to tell the BufferedLayer that the background is transparent.
static java.lang.String LayersProperty
           
static java.lang.String VisibleLayersProperty
           
 
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
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
BufferedLayer()
           
 
Method Summary
 void addLayer(Layer layer)
          Add a layer to the group.
 void clearLayers()
          Remove all layers from the group.
 void dispose()
          Overrides Layer.dispose(), makes sure the OMGraphicList is cleared.
 java.awt.Color getBackground()
          Get the background color of the image.
 java.awt.Paint getBckgrnd(java.awt.Paint paint)
          Get the background Paint object used for the internal MapBean.
 java.awt.Component getGUI()
          Get the GUI (palettes) for the layers.
 boolean getHasTransparentBackground()
           
 java.awt.Component[] getLayers()
          Get the layers assigned to the internal MapBean.
 MapBean getMapBean()
          Get the current MapBean used in the BufferedLayer.
 java.util.Properties getProperties(java.util.Properties props)
          Overrides Layer getProperties method., also calls that method on Layer.
 java.util.Properties getPropertyInfo(java.util.Properties props)
          Not really implemented, because the mechanism for providing a set of properties that let you add a variable number of new objects as children to this one.
 boolean hasLayers()
          Return if there is at least one layer assigned to the group.
 boolean isReadyToPaint()
          Returns true if all children are are ready to be painted - that is, they have called for a repaint.
 void paint(java.awt.Graphics g)
          The default action is to get the OMGraphicList and render it.
 void projectionChanged(ProjectionEvent pevent)
          We don't want a projection change policy called here, because that will call for a repaint.
 void propertyChange(java.beans.PropertyChangeEvent pce)
          PropertyChangeListener method, to listen for the source map's background changes.
 void removed(java.awt.Container cont)
          Called when the layer is removed from the MapBean, and after the projection changes.
 void removeLayer(Layer layer)
          Remove the layer from group.
 void renderDataForProjection(Projection proj, java.awt.Graphics g)
          Part of the ProjectionPainter interface.
 void resetPalette()
          Should be called if layers are added or removed from the buffer.
 void setBackground(java.awt.Color color)
          Set the background color of the group.
 void setBckgrnd(java.awt.Paint paint)
          Set the background paint of the group.
 void setBeanContext(java.beans.beancontext.BeanContext in_bc)
          Method for BeanContextChild interface.
 void setBufferDirty(boolean value)
           
 void setHasTransparentBackground(boolean value)
          If true, will create a new image buffer when the projection changes.
 void setMapBean(MapBean mb)
          You can change what kind of MapBean is used to hold onto the layers.
 void setProperties(java.lang.String prefix, java.util.Properties props)
          Overrides the Layer setProperties method.
 void setReadyToPaint(boolean readyToPaint)
          Set whether this layer should be ready to paint.
 
Methods inherited from class com.bbn.openmap.layer.OMGraphicHandlerLayer
actionPerformed, canSetList, copy, createLayerWorker, cut, deselect, doAction, doPrepare, filter, filter, filter, getConsumeEvents, getDefaultSettingsPanel, getFilter, getInfoText, getItemsForMapMenu, getItemsForOMGraphicMenu, getLayerWorker, getList, getMapMouseListener, getMouseEventInterpreter, getMouseModeIDsForEvents, getProjectionChangePolicy, getRedrawButton, getRenderPolicy, getSelected, getSettingsButton, getToolTipTextFor, getTransparency, getTransparencyAdjustmentPanel, highlight, isCancelled, isHighlightable, isInterruptable, isSelectable, isWorking, leftClick, mouseOver, paste, prepare, receivesMapEvents, resetFiltering, select, 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, findAndInit, findAndUndo, 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, isRemovable, notifyHideHack, prependDataPathPrefix, putAttribute, removeComponentListener, removeConfirmed, removeInfoDisplayListener, removeLayerStatusListener, removeVetoableChangeListener, repaint, setAddAsBackground, setAddToBeanContext, setAutoPalette, setCoordTransform, setIcon, setLayerProperties, setMaxScale, setMinScale, setName, setPaletteVisible, setProjection, setProjection, setProperties, setPropertyPrefix, 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, 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, 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 java.beans.beancontext.BeanContextChild
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

LayersProperty

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

VisibleLayersProperty

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

hasTransparentBackground

protected boolean hasTransparentBackground
Used to tell the BufferedLayer that the background is transparent. Will cause a new image buffer to be created when the projection changes, in order to cover up what was already there. This is set to true but default, since the internal MapBean color is set to OMColor.clear.

Constructor Detail

BufferedLayer

public BufferedLayer()
Method Detail

setProperties

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
Overrides:
setProperties in class OMGraphicHandlerLayer
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: OMGraphicHandlerLayer
Overrides Layer getProperties method., also calls that method on Layer. Sets the properties from the policy objects used by this OMGraphicHandler layer.

Specified by:
getProperties in interface PropertyConsumer
Overrides:
getProperties in class OMGraphicHandlerLayer
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)
Not really implemented, because the mechanism for providing a set of properties that let you add a variable number of new objects as children to this one.

Specified by:
getPropertyInfo in interface PropertyConsumer
Overrides:
getPropertyInfo in class OMGraphicHandlerLayer
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.

setHasTransparentBackground

public void setHasTransparentBackground(boolean value)
If true, will create a new image buffer when the projection changes. Should be set to true if the background has any transparency.


getHasTransparentBackground

public boolean getHasTransparentBackground()

clearLayers

public void clearLayers()
Remove all layers from the group.


setBeanContext

public void setBeanContext(java.beans.beancontext.BeanContext in_bc)
                    throws java.beans.PropertyVetoException
Method for BeanContextChild interface. Gets an iterator from the BeanContext to call findAndInit() over. Sets BeanContext on sub-layers.

Specified by:
setBeanContext in interface java.beans.beancontext.BeanContextChild
Overrides:
setBeanContext in class Layer
Throws:
java.beans.PropertyVetoException

addLayer

public void addLayer(Layer layer)
Add a layer to the group. Sets the BeanContext on the added layer.


removeLayer

public void removeLayer(Layer layer)
Remove the layer from group.


hasLayers

public boolean hasLayers()
Return if there is at least one layer assigned to the group.


getLayers

public java.awt.Component[] getLayers()
Get the layers assigned to the internal MapBean.

Returns:
a Component[].

isReadyToPaint

public boolean isReadyToPaint()
Returns true if all children are are ready to be painted - that is, they have called for a repaint.

Overrides:
isReadyToPaint in class Layer
Returns:
the readyToPaint

setReadyToPaint

public void setReadyToPaint(boolean readyToPaint)
Set whether this layer should be ready to paint. Called when the projection changes, to make child layers 'dirty'. We don't change the super classes' version of the variable, because it's never consulted and it's probably better that it's always true by default.

Overrides:
setReadyToPaint in class Layer
Parameters:
readyToPaint - the readyToPaint to set

setMapBean

public void setMapBean(MapBean mb)
You can change what kind of MapBean is used to hold onto the layers. This method just sets the new MapBean into the layer, as is. If there was a previous MapBean with layers, they're gone and replaces with whatever is attached to the new MapBean.

Parameters:
mb - new MapBean

getMapBean

public MapBean getMapBean()
Get the current MapBean used in the BufferedLayer.

Returns:
MapBean

setBackground

public void setBackground(java.awt.Color color)
Set the background color of the group. Actually sets the background color of the projection used by the internal MapBean, and which then forces a repaint() on it.

Overrides:
setBackground in class javax.swing.JComponent
Parameters:
color - java.awt.Color.

setBckgrnd

public void setBckgrnd(java.awt.Paint paint)
Set the background paint of the group. Actually sets the background paint of the projection used by the internal MapBean.

Parameters:
paint - java.awt.Paint

getBackground

public java.awt.Color getBackground()
Get the background color of the image. Actually returns the background color of the projection of the internal MapBean.

Overrides:
getBackground in class java.awt.Component
Returns:
color java.awt.Color

getBckgrnd

public java.awt.Paint getBckgrnd(java.awt.Paint paint)
Get the background Paint object used for the internal MapBean.

Returns:
java.awt.Paint

projectionChanged

public void projectionChanged(ProjectionEvent pevent)
We don't want a projection change policy called here, because that will call for a repaint. We want the buffered layers to call for a repaint if necessary.

Specified by:
projectionChanged in interface ProjectionListener
Overrides:
projectionChanged in class OMGraphicHandlerLayer
Parameters:
pevent - ProjectionEvent
See Also:
ProjectionChangePolicy, StandardPCPolicy, ListResetPCPolicy

removed

public void removed(java.awt.Container cont)
Called when the layer is removed from the MapBean, and after the projection changes. Lets the layer know to release memory that might not be needed.

Overrides:
removed in class Layer
Parameters:
cont - Container

resetPalette

public void resetPalette()
Should be called if layers are added or removed from the buffer.

Overrides:
resetPalette in class Layer

getGUI

public java.awt.Component getGUI()
Get the GUI (palettes) for the layers. The BufferedLayer actually creates a JTabbedPane holding the palettes for all of its layers, and also has a pane for itself that provides visibility control for the group layers.

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

paint

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

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

renderDataForProjection

public void renderDataForProjection(Projection proj,
                                    java.awt.Graphics g)
Part of the ProjectionPainter interface. The group layers are given the projection and the graphics to paint into.

Specified by:
renderDataForProjection in interface ProjectionPainter
Overrides:
renderDataForProjection in class OMGraphicHandlerLayer
Parameters:
proj - Projection of the map.
g - java.awt.Graphics to draw into.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent pce)
PropertyChangeListener method, to listen for the source map's background changes. Act on if necessary.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

dispose

public void dispose()
Description copied from class: OMGraphicHandlerLayer
Overrides Layer.dispose(), makes sure the OMGraphicList is cleared.

Overrides:
dispose in class OMGraphicHandlerLayer

setBufferDirty

public void setBufferDirty(boolean value)


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