## com.bbn.openmap.layer
Class CacheLayer

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  com.bbn.openmap.Layer
                      com.bbn.openmap.layer.CacheLayer

All Implemented Interfaces:
  java.awt.event.ActionListener, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.util.EventListener, java.awt.image.ImageObserver, MapMouseListener, java.awt.MenuContainer, ProjectionListener, ProjectionPainter, PropertyConsumer, java.io.Serializable

public class CacheLayer
extends Layer
implements java.awt.event.ActionListener, MapMouseListener

A Layer that gets it's graphics from a URL containing a serialized OMGraphicList. This layer does respond to gesturing on the graphics, but doesn't do anything. You can extend this class to be more useful to you. It has one property that needs to be set in the properties file:

# CacheLayer property:
# The layer should figure out whether it's a file or URL.
cachelayer.cacheFile= <url of cachefile>

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
`static java.lang.String` `CacheFileProperty`
`protected java.net.URL` `cacheURL` URL to read data from.
`protected OMGraphicList` `omgraphics` A list of graphics to be painted on the map.

Fields inherited from class com.bbn.openmap.Layer

`addAsBackground, AddAsBackgroundProperty, addToBeanContext, AddToBeanContextProperty, attributes, autoPalette, AutoPaletteProperty, beanContextChildSupport, DisplayPaletteCmd, DisplayPropertiesCmd, doHack, HidePaletteCmd, i18n, IDListeners, localHackList, lsListeners, maxScale, MaxScaleProperty, minScale, MinScaleProperty, palette, paletteListener, PrettyNameProperty, propertyPrefix, RedrawCmd, removable, RemovableProperty, SWING_PACKAGE, 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
`CacheLayer()` Construct a default CacheLayer.

Method Summary
`void` `actionPerformed(java.awt.event.ActionEvent e)` The Action Listener method, that reacts to the palette widgets actions.
`java.awt.Component` `getGUI()` Provides the palette widgets to control the options of showing maps, or attribute text.
`MapMouseListener` `getMapMouseListener()` Returns self as the `MapMouseListener` in order to receive `MapMouseEvent`s.
`java.lang.String[]` `getMouseModeServiceList()` Indicates which mouse modes should send events to this `Layer`.
`boolean` `mouseClicked(java.awt.event.MouseEvent e)` Called whenever the mouse is clicked by the user and one of the requested mouse modes is active.
`boolean` `mouseDragged(java.awt.event.MouseEvent e)` Called whenever the mouse is dragged on this layer and one of the requested mouse modes is active.
`void` `mouseEntered(java.awt.event.MouseEvent e)` Called whenever the mouse enters this layer and one of the requested mouse modes is active.
`void` `mouseExited(java.awt.event.MouseEvent e)` Called whenever the mouse exits this layer and one of the requested mouse modes is active.
`void` `mouseMoved()` Called whenever the mouse is moved on this layer and one of the requested mouse modes is active, and the gesture is consumed by another active layer.
`boolean` `mouseMoved(java.awt.event.MouseEvent e)` Called whenever the mouse is moved on this layer and one of the requested mouse modes is active.
`boolean` `mousePressed(java.awt.event.MouseEvent e)` Called whenever the mouse is pressed by the user and one of the requested mouse modes is active.
`boolean` `mouseReleased(java.awt.event.MouseEvent e)` Called whenever the mouse is released by the user and one of the requested mouse modes is active.
`void` `paint(java.awt.Graphics g)` Renders the graphics list.
`void` `projectionChanged(ProjectionEvent e)` Handler for `ProjectionEvent`s.
`void` `readGraphics()` Read a cache of OMGraphics
`void` `setProperties(java.lang.String prefix, java.util.Properties props)` Initializes this layer from the given properties.

Methods inherited from class com.bbn.openmap.Layer

`addComponentListener, added, addInfoDisplayListener, addLayerStatusListener, addMouseListener, addVetoableChangeListener, childrenAdded, childrenRemoved, clearListeners, connectToBeanContext, createWindowSupport, 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, getIcon, getMaxScale, getMinScale, getPackage, getPalette, getProjection, getProperties, getPropertyInfo, getPropertyPrefix, getWindowSupport, hasGUI, hidePalette, isAutoPalette, isProjectionOK, isRemovable, notifyHideHack, putAttribute, removeComponentListener, removeConfirmed, removed, removeInfoDisplayListener, removeLayerStatusListener, removeVetoableChangeListener, renderDataForProjection, repaint, resetPalette, setAddAsBackground, setAddToBeanContext, setAutoPalette, setBeanContext, setIcon, setMaxScale, setMinScale, setName, setPaletteVisible, setProjection, setProjection, setProperties, setPropertyPrefix, setRemovable, setVisible, setWindowSupport, showPalette`

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, setBackground, 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, getBackground, 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

### CacheFileProperty

    public static final java.lang.String CacheFileProperty

See Also:
  Constant Field Values

### cacheURL

    protected java.net.URL cacheURL

  URL to read data from. This data will be in the form of a serialized stream of OMGraphics.

### omgraphics

    protected OMGraphicList omgraphics

  A list of graphics to be painted on the map.

Constructor Detail

### CacheLayer

    public CacheLayer()

  Construct a default CacheLayer.

Method Detail

### readGraphics

    public void readGraphics()
                      throws java.io.IOException

  Read a cache of OMGraphics

  Throws:
    `java.io.IOException`

### setProperties

    public void setProperties(java.lang.String prefix,
                              java.util.Properties props)

  Initializes this layer from the given properties.

  Specified by:
    `setProperties` in interface `PropertyConsumer`
  Overrides:
    `setProperties` in class `Layer`
  Parameters:
    `props` - the `Properties` holding settings for this layer
    `prefix` - the token to prefix the property names

### paint

    public void paint(java.awt.Graphics g)

  Renders the graphics list. It is important to make this routine as fast as possible since it is called frequently by Swing, and the User Interface blocks while painting is done.

### projectionChanged

    public void projectionChanged(ProjectionEvent e)

  Handler for `ProjectionEvent`s. This function is invoked when the `MapBean` projection changes. The graphics are reprojected and then the Layer is repainted.

  Specified by:
    `projectionChanged` in interface `ProjectionListener`
  Parameters:
    `e` - the projection event

### getGUI

    public java.awt.Component getGUI()

  Provides the palette widgets to control the options of showing maps, or attribute text.

  Overrides:
    `getGUI` in class `Layer`
  Returns:
    Component object representing the palette widgets.

### actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent e)

  The Action Listener method, that reacts to the palette widgets actions.

  Specified by:
    `actionPerformed` in interface `java.awt.event.ActionListener`
  Overrides:
    `actionPerformed` in class `Layer`

### getMouseModeServiceList

    public java.lang.String[] getMouseModeServiceList()

  Indicates which mouse modes should send events to this `Layer`.

  Specified by:
    `getMouseModeServiceList` in interface `MapMouseListener`
  Returns:
    An array mouse mode names
  See Also:
    `MapMouseListener`, `MouseDelegator`

### mousePressed

    public boolean mousePressed(java.awt.event.MouseEvent e)

  Called whenever the mouse is pressed by the user and one of the requested mouse modes is active.

  Specified by:
    `mousePressed` in interface `MapMouseListener`
  Parameters:
    `e` - the press event
  Returns:
    true if event was consumed (handled), false otherwise
  See Also:
    `getMouseModeServiceList()`

### mouseReleased

    public boolean mouseReleased(java.awt.event.MouseEvent e)

  Called whenever the mouse is released by the user and one of the requested mouse modes is active.

  Specified by:
    `mouseReleased` in interface `MapMouseListener`
  Parameters:
    `e` - the release event
  Returns:
    true if event was consumed (handled), false otherwise
  See Also:
    `getMouseModeServiceList()`

### mouseClicked

    public boolean mouseClicked(java.awt.event.MouseEvent e)

  Called whenever the mouse is clicked by the user and one of the requested mouse modes is active.

  Specified by:
    `mouseClicked` in interface `MapMouseListener`
  Parameters:
    `e` - the click event
  Returns:
    true if event was consumed (handled), false otherwise
  See Also:
    `getMouseModeServiceList()`

### mouseEntered

    public void mouseEntered(java.awt.event.MouseEvent e)

  Called whenever the mouse enters this layer and one of the requested mouse modes is active.

  Specified by:
    `mouseEntered` in interface `MapMouseListener`
  Parameters:
    `e` - the enter event
  See Also:
    `getMouseModeServiceList()`

### mouseExited

    public void mouseExited(java.awt.event.MouseEvent e)

  Called whenever the mouse exits this layer and one of the requested mouse modes is active.

  Specified by:
    `mouseExited` in interface `MapMouseListener`
  Parameters:
    `e` - the exit event
  See Also:
    `getMouseModeServiceList()`

### mouseDragged

    public boolean mouseDragged(java.awt.event.MouseEvent e)

  Called whenever the mouse is dragged on this layer and one of the requested mouse modes is active.

  Specified by:
    `mouseDragged` in interface `MapMouseListener`
  Parameters:
    `e` - the drag event
  Returns:
    true if event was consumed (handled), false otherwise
  See Also:
    `getMouseModeServiceList()`

### mouseMoved

    public boolean mouseMoved(java.awt.event.MouseEvent e)

  Called whenever the mouse is moved on this layer and one of the requested mouse modes is active.

  Tries to locate a graphic near the mouse, and if it is found, it is highlighted and the Layer is repainted to show the highlighting.

  Specified by:
    `mouseMoved` in interface `MapMouseListener`
  Parameters:
    `e` - the move event
  Returns:
    true if event was consumed (handled), false otherwise
  See Also:
    `getMouseModeServiceList()`

### mouseMoved

    public void mouseMoved()

  Called whenever the mouse is moved on this layer and one of the requested mouse modes is active, and the gesture is consumed by another active layer. We need to deselect anything that may be selected.

  Specified by:
    `mouseMoved` in interface `MapMouseListener`
  See Also:
    `getMouseModeServiceList()`

### getMapMouseListener

    public MapMouseListener getMapMouseListener()

  Returns self as the `MapMouseListener` in order to receive `MapMouseEvent`s. If the implementation would prefer to delegate `MapMouseEvent`s, it could return the delegate from this method instead.

  Overrides:
    `getMapMouseListener` in class `Layer`
  Returns:
    The object to receive `MapMouseEvent` s or null if this layer isn't interested in `MapMouseEvent` s

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