com.bbn.openmap
Class BufferedMapBean

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.bbn.openmap.MapBean
                  extended by com.bbn.openmap.BufferedMapBean
All Implemented Interfaces:
CenterListener, LayerListener, PanListener, ProjectionListener, ZoomListener, SoloMapComponent, java.awt.event.ComponentListener, java.awt.event.ContainerListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
BufferedLayer.BLMapBean, BufferedLayerMapBean

public class BufferedMapBean
extends MapBean

The BufferedMapBean extends the MapBean by adding (you guessed it) buffering.

Specifically, the layers are stored in a java.awt.Image so that the frequent painting done by Swing on lightweight components will not cause the layers to do unnecessary work re-rendering themselves each time.

Changing the default clipping area may cause some Layers to not be drawn completely, depending on what the clipping area is set to and when the layer is trying to get itself painted. When manually adjusting clipping area, make sure that when restricted clipping is over that a full repaint occurs if there is a chance that another layer may be trying to paint itself.

See Also:
Serialized Form

Nested Class Summary
protected  class BufferedMapBean.PanHelper
           
 
Nested classes/interfaces inherited from class com.bbn.openmap.MapBean
MapBean.RotationHelper
 
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 bufferDirty
           
protected  java.awt.image.BufferedImage drawingBuffer
           
protected  BufferedMapBean.PanHelper panningTransform
           
 
Fields inherited from class com.bbn.openmap.MapBean
addedLayers, background, BackgroundProperty, currentLayers, CursorProperty, DEFAULT_BACKGROUND_COLOR, DEFAULT_CENTER_LAT, DEFAULT_CENTER_LON, DEFAULT_HEIGHT, DEFAULT_SCALE, DEFAULT_WIDTH, doContainerChange, layerRemovalDelayed, LayersProperty, minHeight, minWidth, painters, projection, projectionFactory, ProjectionProperty, projectionSupport, ProjectionVetoedProperty, removedLayers, repaintPolicy, rotationAngle, rotHelper, suppressCopyright, title, version
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BufferedMapBean()
           
BufferedMapBean(boolean useThreadedNotification)
           
 
Method Summary
 void componentResized(java.awt.event.ComponentEvent e)
          Invoked when component has been resized.
 void dispose()
          Call when getting rid of the MapBean, it releases pointers to all listeners and kills the ProjectionSupport thread.
protected  void disposeDrawingBuffer()
          Clear out resources for the current drawing buffer.
 java.awt.geom.AffineTransform getPanningTransform()
           
 boolean isBufferDirty()
          Checks whether the image buffer should be repainted.
 boolean isBuffered()
          Interface-like method to query if the MapBean is buffered, so you can control behavior better.
 void paintChildren(java.awt.Graphics g, java.awt.Rectangle clip)
          Same as paintChildren, but allows you to set a clipping area to paint.
protected  java.awt.image.BufferedImage resetDrawingBuffer(java.awt.image.BufferedImage currentImageBuffer, Projection proj)
          Provide a drawing buffer for the layers based on the projection parameters.
 void setBufferDirty(boolean value)
          Marks the image buffer as dirty if value is true.
 void setPanningTransform(java.awt.geom.AffineTransform transform)
          Set a panning transform on the buffer for rendering in a different place, quickly.
 
Methods inherited from class com.bbn.openmap.MapBean
addImpl, addPaintListener, addProjectionListener, addPropertyChangeListener, center, changeLayers, componentAdded, componentHidden, componentMoved, componentRemoved, componentShown, debugmsg, drawProjectionBackground, fireProjectionChanged, getBackground, getBckgrnd, getCenter, getCoordinates, getCoordinates, getCopyrightMessage, getDoContainerChange, getGraphics, getInsets, getMapBeanRepaintPolicy, getMinimumSize, getNonRotatedLocation, getNonRotatedLocation, getNonRotatedShape, getProjection, getProjectionFactory, getRotatedProjection, getRotationAngle, getRotHelper, getScale, getUpdatedRotHelper, hideLayerPalettes, inverse, isLayerRemovalDelayed, paint, paintBorder, paintChildren, paintChildrenWithBorder, paintLayers, paintPainters, pan, projectionChanged, purgeAndNotifyRemovedLayers, removePaintListener, removeProjectionListener, repaint, setBackground, setBackgroundColor, setBckgrnd, setCenter, setCenter, setCenter, setCursor, setDoContainerChange, setLayerRemovalDelayed, setLayers, setLayout, setMapBeanRepaintPolicy, setMinimumSize, setProjection, setProjectionFactory, setRotationAngle, setRotationAngle, setRotHelper, setScale, showLayerPalettes, toString, zoom
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getListeners, getLocation, getMaximumSize, 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, paintComponent, paintImmediately, paintImmediately, paramString, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, 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, 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, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bufferDirty

protected boolean bufferDirty

drawingBuffer

protected java.awt.image.BufferedImage drawingBuffer

panningTransform

protected BufferedMapBean.PanHelper panningTransform
Constructor Detail

BufferedMapBean

public BufferedMapBean()

BufferedMapBean

public BufferedMapBean(boolean useThreadedNotification)
Method Detail

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Invoked when component has been resized. Layer buffer is nullified. and super.componentResized(e) is called.

Specified by:
componentResized in interface java.awt.event.ComponentListener
Overrides:
componentResized in class MapBean
Parameters:
e - ComponentEvent

resetDrawingBuffer

protected java.awt.image.BufferedImage resetDrawingBuffer(java.awt.image.BufferedImage currentImageBuffer,
                                                          Projection proj)
Provide a drawing buffer for the layers based on the projection parameters. If the currentImageBuffer is the right size, the pixels will be cleared.

Parameters:
currentImageBuffer - the buffer to reuse and return, if the size is appropriate. Flushed if another BufferedImage is returned.
proj - the current projection of the map
Returns:
BufferedImage to be used for image buffer.

paintChildren

public void paintChildren(java.awt.Graphics g,
                          java.awt.Rectangle clip)
Same as paintChildren, but allows you to set a clipping area to paint. Be careful with this, because if the clipping area is set while some layer decides to paint itself, that layer may not have all it's objects painted. Same warnings apply.

Overrides:
paintChildren in class MapBean

isBuffered

public boolean isBuffered()
Interface-like method to query if the MapBean is buffered, so you can control behavior better. Allows the removal of specific instance-like queries for, say, BufferedMapBean, when all you really want to know is if you have the data is buffered, and if so, should be buffer be cleared. For the BufferedMapBean, always true.

Overrides:
isBuffered in class MapBean

setBufferDirty

public void setBufferDirty(boolean value)
Marks the image buffer as dirty if value is true. On the next paintChildren(), we will call paint() on all Layer components.

Overrides:
setBufferDirty in class MapBean
Parameters:
value - boolean

isBufferDirty

public boolean isBufferDirty()
Checks whether the image buffer should be repainted.

Overrides:
isBufferDirty in class MapBean
Returns:
boolean whether the layer buffer is dirty

disposeDrawingBuffer

protected void disposeDrawingBuffer()
Clear out resources for the current drawing buffer.


dispose

public void dispose()
Description copied from class: MapBean
Call when getting rid of the MapBean, it releases pointers to all listeners and kills the ProjectionSupport thread.

Overrides:
dispose in class MapBean

getPanningTransform

public java.awt.geom.AffineTransform getPanningTransform()

setPanningTransform

public void setPanningTransform(java.awt.geom.AffineTransform transform)
Set a panning transform on the buffer for rendering in a different place, quickly. Sets the buffer to be dirty, so when the panning transform is removed, it will be recreated.

Parameters:
transform -


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