## com.bbn.openmap
Class BufferedMapBean

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  com.bbn.openmap.MapBean
                      com.bbn.openmap.BufferedMapBean

All Implemented Interfaces:
  CenterListener, java.awt.event.ComponentListener, java.awt.event.ContainerListener, java.util.EventListener, java.awt.image.ImageObserver, LayerListener, java.awt.MenuContainer, PanListener, ProjectionListener, java.io.Serializable, SoloMapComponent, ZoomListener

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 rerendering 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

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` `bufferDirty`
`protected java.awt.Image` `drawingBuffer`

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, ProjectionProperty, projectionSupport, ProjectionVetoedProperty, removedLayers, repaintPolicy, 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()`

Method Summary
`void` `componentResized(java.awt.event.ComponentEvent e)` Invoked when component has been resized.
`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)` Paint the child components of this component.
`void` `paintChildren(java.awt.Graphics g, java.awt.Rectangle clip)` Same as paintChildren, but allows you to set a clipping area to paint.
`void` `setBufferDirty(boolean value)` Marks the image buffer as dirty if value is false.
`void` `setLayers(LayerEvent evt)` Set the layers of the MapBean.

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, getInsets, getMapBeanRepaintPolicy, getMinimumSize, getProjection, getProjectionType, getScale, hideLayerPalettes, isLayerRemovalDelayed, paint, paintBorder, paintChildrenWithBorder, pan, projectionChanged, purgeAndNotifyRemovedLayers, removePaintListener, removeProjectionListener, repaint, setBackground, setBackgroundColor, setBckgrnd, setCenter, setCenter, setCursor, setDoContainerChange, setLayerRemovalDelayed, setLayout, setMapBeanRepaintPolicy, setMinimumSize, setProjection, setProjectionType, setScale, showLayerPalettes, toString, zoom`

Methods inherited from class javax.swing.JComponent

`addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, 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, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, 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, 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, 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, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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 drawingBuffer

Constructor Detail

### BufferedMapBean

    public BufferedMapBean()

Method Detail

### setLayers

    public void setLayers(LayerEvent evt)

  Set the layers of the MapBean.

  Specified by:
    `setLayers` in interface `LayerListener`
  Overrides:
    `setLayers` in class `MapBean`
  Parameters:
    `evt` - LayerEvent

### 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

### paintChildren

    public void paintChildren(java.awt.Graphics g)

  Paint the child components of this component.

  WE STRONGLY RECOMMEND THAT YOU DO NOT OVERRIDE THIS METHOD The map layers are buffered in an Image which is drawn to the screen. The buffer is refreshed after repaint() is called on a layer.

  In our view, paint() is called on the MapBean excessively, such as when tool tips are displayed and removed on the LayerPanel, or on when menu items are highlighted. This method should greatly reduce the number of times Layers are rendered.

  Overrides:
    `paintChildren` in class `MapBean`
  Parameters:
    `g` - Graphics

### 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 quieries 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 false. 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

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