|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.bbn.openmap.Layer
com.bbn.openmap.layer.BufferedLayer
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.
There are some special considerations to think about when using this layer if the background is at all transparent. The image buffer will need to be recreated at certain times in order to prevent leftover images from the previous paintings. When the background is set for the layer, the transparency is tested if the background is a Color and the setHasTransparentBackground() method is called accordingly. If a different Paint object is set in the BufferedLayer, it's up to you to set this variable. This causes a new image to be created every time a new projection is provided to the layer. If the layers added to this BufferedLayer are active, meaning that their content could change between projection changes, you should set the hasActiveLayers flag to true. this causes a new image buffer to be created every time a layer repaints itself. Again, this is only important if the background color of the layer is transparent.
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 bufLayer.hasActiveLayers=falselayer1, layer2, etc should be defined as any other openmap layer.
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 inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
protected boolean |
hasActiveLayers
Used to recreate the buffer on every repaint() call made by every layer. |
static java.lang.String |
HasActiveLayersProperty
|
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 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 |
firePaletteEvent(java.awt.event.ComponentEvent event)
Fire a component event to the Layer component listeners, with the palette as the component, letting them know if it's visible or not. |
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 |
getHasActiveLayers()
|
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)
PropertyConsumer method, to fill in a Properties object, reflecting the current values of the 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. |
void |
paint(java.awt.Graphics g)
|
void |
projectionChanged(ProjectionEvent pe)
Part of the Layer/ProjectionListener thing. |
void |
propertyChange(java.beans.PropertyChangeEvent pce)
PropertyChangeListener method, to listen for the source map's background 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 |
setHasActiveLayers(boolean value)
If true, will cause a new image buffer to be recreated for every layer.repaint() call. |
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)
Sets the properties for the Layer . |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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 |
public static final java.lang.String LayersProperty
public static final java.lang.String VisibleLayersProperty
public static final java.lang.String HasActiveLayersProperty
protected boolean hasActiveLayers
protected boolean hasTransparentBackground
Constructor Detail |
public BufferedLayer()
Method Detail |
public void setProperties(java.lang.String prefix, java.util.Properties props)
Layer
Layer
. Part of the
PropertyConsumer interface. Layers which override this method should do
something like:
public void setProperties(String prefix, Properties props) {
super.setProperties(prefix, props);
// do local stuff
}
If the addToBeanContext property is not defined, it maintains the same
state.
setProperties
in interface PropertyConsumer
setProperties
in class Layer
prefix
- the token to prefix the property namesprops
- the Properties
objectpublic java.util.Properties getProperties(java.util.Properties props)
Layer
getProperties
in interface PropertyConsumer
getProperties
in class Layer
props
- a Properties object to load the PropertyConsumer properties
into. If props equals null, then a new Properties object should be
created.
public java.util.Properties getPropertyInfo(java.util.Properties props)
getPropertyInfo
in interface PropertyConsumer
getPropertyInfo
in class Layer
props
- a Properties object to load the PropertyConsumer properties
into. If getList equals null, then a new Properties object should
be created.
public void setHasActiveLayers(boolean value)
public boolean getHasActiveLayers()
public void setHasTransparentBackground(boolean value)
public boolean getHasTransparentBackground()
public void clearLayers()
public void setBeanContext(java.beans.beancontext.BeanContext in_bc) throws java.beans.PropertyVetoException
setBeanContext
in interface java.beans.beancontext.BeanContextChild
setBeanContext
in class Layer
java.beans.PropertyVetoException
public void addLayer(Layer layer)
public void removeLayer(Layer layer)
public boolean hasLayers()
public java.awt.Component[] getLayers()
public void firePaletteEvent(java.awt.event.ComponentEvent event)
Layer
firePaletteEvent
in class Layer
public void setMapBean(MapBean mb)
mb
- new MapBeanpublic MapBean getMapBean()
public void setBackground(java.awt.Color color)
color
- java.awt.Color.public void setBckgrnd(java.awt.Paint paint)
paint
- java.awt.Paintpublic java.awt.Color getBackground()
public java.awt.Paint getBckgrnd(java.awt.Paint paint)
public void projectionChanged(ProjectionEvent pe)
projectionChanged
in interface ProjectionListener
pe
- ProjectionEventpublic void resetPalette()
resetPalette
in class Layer
public java.awt.Component getGUI()
getGUI
in class Layer
public void paint(java.awt.Graphics g)
public void renderDataForProjection(Projection proj, java.awt.Graphics g)
renderDataForProjection
in interface ProjectionPainter
renderDataForProjection
in class Layer
proj
- Projection of the map.g
- java.awt.Graphics to draw into.public void propertyChange(java.beans.PropertyChangeEvent pce)
propertyChange
in interface java.beans.PropertyChangeListener
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |