## com.bbn.openmap.layer.terrain
Class TerrainLayer

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  com.bbn.openmap.Layer
                      com.bbn.openmap.layer.OMGraphicHandlerLayer
                          com.bbn.openmap.layer.terrain.TerrainLayer

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

public class TerrainLayer
extends OMGraphicHandlerLayer
implements java.awt.event.ActionListener, MapMouseListener

The Terrain Layer is an example of creating a layer that acts as a tool that defines and area (via user gestures) and presents a result of the analysis of the data. In this case, Elevation data is used in two different ways. The Profile tool lets you draw a line on the map, and then uses DTED data to create a GIF image that shows the terrain profile along the drawn line. The LOS (line-of-sight) tool lets you define a circle, and then calculates the places on the ground that are within sight of the center of the circle. The result is shown with the visible points being colored green, and all other points being clear. The LOS tool lets you use a height slider on its palette to define additional height at the point, representing a tower, building, or location of an aircraft.

The tools require you to be in the gesture mode of OpenMap.

The TerrainLayer needs a DTEDFrameCache. It can be added to the layer programmatically, or the layer will find it if the DTEDFrameCache is added to the MapHandler. To do that in the OpenMap application, add the DTEDFrameCache to the openmap.components property in the openmap.properties file.

      #----------------------------------------------------------------------
      # Properties file for TerrainLayer
      #----------------------------------------------------------------------
      # The default tool to use for the terrain layer.  Can be PROFILE or
      LOS.  terrain.default.mode=PROFILE
      #----------------------------------------------------------------------
      # End of properties file for TerrainLayer
      #----------------------------------------------------------------------

See Also:
  `DTEDFrameCache`, 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` `clearCommand`
`static java.lang.String` `createCommand`
`TerrainTool` `currentTool` The current tool being used.
`static java.lang.String` `defaultModeProperty`
`DTEDFrameCache` `frameCache` The cache that knows how to handle DTED requests.
`static int` `LOS` The code number for the LOS tool.
`LOSGenerator` `LOSTool`
`protected int` `mode` Which tool is being used.
`protected javax.swing.Box` `palette` The user interface palette for the Terrain layer.
`static int` `PERSPECTIVE` The code number for the perspective tool (unimplemented).
`static int` `PROFILE` The code number for the profile tool.
`ProfileGenerator` `profileTool`

Fields inherited from class com.bbn.openmap.layer.OMGraphicHandlerLayer
`consumeEvents, ConsumeEventsProperty, filter, interruptable, InterruptableProperty, layerWorker, LAYERWORKER_LOCK, 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, DisplayPaletteCmd, DisplayPropertiesCmd, doHack, HidePaletteCmd, i18n, IDListeners, localHackList, lsListeners, maxScale, MaxScaleProperty, minScale, MinScaleProperty, 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
`TerrainLayer()` The default constructor for the Layer.

Method Summary
`void` `actionPerformed(java.awt.event.ActionEvent e)` The reaction handler for the buttons being pressed on the palette.
`void` `findAndInit(java.lang.Object someObj)` This method is called by the findAndInit(Iterator) method, once for every object inside the iterator.
`void` `findAndUndo(java.lang.Object someObj)` This is the method that does the opposite as the findAndInit(Object).
`DTEDFrameCache` `getFrameCache()`
`java.awt.Component` `getGUI()` Creates the interface palette.
`MapMouseListener` `getMapMouseListener()` Query asked from the MouseDelegator for interest in receiving MapMouseEvents.
`int` `getMode()`
`java.lang.String[]` `getMouseModeServiceList()` Tells the MouseDelegator which Mouse Modes we're interested in receiving events from.
`void` `init()` Creates new tools.
`boolean` `mouseClicked(java.awt.event.MouseEvent e)` Invoked when the mouse has been clicked on a component.
`boolean` `mouseDragged(java.awt.event.MouseEvent e)` Invoked when a mouse button is pressed on a component and then dragged.
`void` `mouseEntered(java.awt.event.MouseEvent e)` Invoked when the mouse enters a component.
`void` `mouseExited(java.awt.event.MouseEvent e)` Invoked when the mouse exits a component.
`void` `mouseMoved()` Handle a mouse cursor moving without the button being pressed.
`boolean` `mouseMoved(java.awt.event.MouseEvent e)` Invoked when the mouse button has been moved on a component (with no buttons down).
`boolean` `mousePressed(java.awt.event.MouseEvent e)` Invoked when a mouse button has been pressed on a component.
`boolean` `mouseReleased(java.awt.event.MouseEvent e)` Invoked when a mouse button has been released on a component.
`static int` `numPixelsBetween(int x1, int y1, int x2, int y2)` Little math utility that both tools use, that just implements the pathagorean theorem to do the number of pixels between two screen points.
`OMGraphicList` `prepare()` Prepares the graphics for the layer.
`protected void` `setDefaultValues()` Sets the default values for the variables, if the properties are not found, or are invalid.
`void` `setFrameCache(DTEDFrameCache dfc)`
`void` `setMode(int m)` Set the current tool to be used.
`void` `setProperties(java.lang.String prefix, java.util.Properties properties)` Set all the TerrainLayer properties from a proerties object

Methods inherited from class com.bbn.openmap.layer.OMGraphicHandlerLayer

`canSetList, copy, createLayerWorker, cut, deselect, doAction, doPrepare, filter, filter, filter, getConsumeEvents, getFilter, getInfoText, getItemsForMapMenu, getItemsForOMGraphicMenu, getLayerWorker, getList, getMouseEventInterpreter, getMouseModeIDsForEvents, getProjectionChangePolicy, getProperties, getPropertyInfo, getRenderPolicy, getSelected, getToolTipTextFor, getTransparency, getTransparencyAdjustmentPanel, highlight, interrupt, isCancelled, isHighlightable, isInterruptable, isSelectable, isWorking, leftClick, mouseOver, paint, paste, projectionChanged, receivesMapEvents, renderDataForProjection, resetFiltering, select, setCancelled, 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, finalize, findAndInit, 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, getPropertyPrefix, getWindowSupport, hasGUI, hidePalette, isAutoPalette, isProjectionOK, isRemovable, notifyHideHack, putAttribute, removeComponentListener, removeConfirmed, removed, removeInfoDisplayListener, removeLayerStatusListener, removeVetoableChangeListener, 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

### frameCache

    public DTEDFrameCache frameCache

  The cache that knows how to handle DTED requests.

### mode

    protected int mode

  Which tool is being used.

### PROFILE

    public static final int PROFILE

  The code number for the profile tool.

  See Also:
    Constant Field Values

### PERSPECTIVE

    public static final int PERSPECTIVE

  The code number for the perspective tool (unimplemented).

  See Also:
    Constant Field Values

### LOS

    public static final int LOS

  The code number for the LOS tool.

  See Also:
    Constant Field Values

### currentTool

    public TerrainTool currentTool

  The current tool being used.

### profileTool

    public ProfileGenerator profileTool

### LOSTool

    public LOSGenerator LOSTool

### defaultModeProperty

    public static final java.lang.String defaultModeProperty

See Also:
  Constant Field Values

### clearCommand

    public static final java.lang.String clearCommand

See Also:
  Constant Field Values

### createCommand

    public static final java.lang.String createCommand

See Also:
  Constant Field Values

### palette

    protected javax.swing.Box palette

  The user interface palette for the Terrain layer.

Constructor Detail

### TerrainLayer

    public TerrainLayer()

  The default constructor for the Layer. All of the attributes are set to their default values.

Method Detail

### init

    public void init()

  Creates new tools.

### setDefaultValues

    protected void setDefaultValues()

  Sets the default values for the variables, if the properties are not found, or are invalid. Usually not a good idea.

### setFrameCache

    public void setFrameCache(DTEDFrameCache dfc)

### getFrameCache

    public DTEDFrameCache getFrameCache()

### setProperties

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

  Set all the TerrainLayer properties from a proerties object

  Specified by:
    `setProperties` in interface `PropertyConsumer`
  Overrides:
    `setProperties` in class `OMGraphicHandlerLayer`
  Parameters:
    `prefix` - a string that gets set to indiviualize the properties to a specific layer.
    `properties` - the proerties object

### prepare

    public OMGraphicList prepare()

  Prepares the graphics for the layer. This is where the getRectangle() method call is made on the dted.

  Occasionally it is necessary to abort a prepare call. When this happens, the map will set the cancel bit in the LayerThread, (the thread that is running the prepare). If this Layer needs to do any cleanups during the abort, it should do so, but return out of the prepare asap.

  Overrides:
    `prepare` in class `OMGraphicHandlerLayer`

### getGUI

    public java.awt.Component getGUI()

  Creates the interface palette.

  Overrides:
    `getGUI` in class `Layer`
  Returns:
    java.awt.Component or null

### actionPerformed

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

  The reaction handler for the buttons being pressed on the palette.

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

### getMapMouseListener

    public MapMouseListener getMapMouseListener()

  Description copied from class: `OMGraphicHandlerLayer`
  Query asked from the MouseDelegator for interest in receiving MapMouseEvents. This returns a MapMouseInterpreter that has been told to listen for events from the MapMouseModes in setMouseModeIDsForEvents().

  Overrides:
    `getMapMouseListener` in class `OMGraphicHandlerLayer`

### getMouseModeServiceList

    public java.lang.String[] getMouseModeServiceList()

  Tells the MouseDelegator which Mouse Modes we're interested in receiving events from. In this case, just the "Gestures" mode.

  Specified by:
    `getMouseModeServiceList` in interface `MapMouseListener`
  Returns:
    String[] of modeID's
  See Also:
    `NavMouseMode.modeID`, `SelectMouseMode.modeID`, `NullMouseMode.modeID`

### mousePressed

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

  Description copied from interface: `MapMouseListener`
  Invoked when a mouse button has been pressed on a component.

  Specified by:
    `mousePressed` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    true if the listener was able to process the event.

### mouseReleased

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

  Description copied from interface: `MapMouseListener`
  Invoked when a mouse button has been released on a component.

  Specified by:
    `mouseReleased` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    true if the listener was able to process the event.

### mouseClicked

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

  Description copied from interface: `MapMouseListener`
  Invoked when the mouse has been clicked on a component. The listener will receive this event if it successfully processed `mousePressed()`, or if no other listener processes the event. If the listener successfully processes `mouseClicked()`, then it will receive the next `mouseClicked()` notifications that have a click count greater than one.

  NOTE: We have noticed that this method can sometimes be erroneously invoked. It seems to occur when a light-weight AWT component (like an internal window or menu) closes (removes itself from the window hierarchy). A specific OpenMap example is when you make a menu selection when the MenuItem you select is above the MapBean canvas. After making the selection, the mouseClicked() gets invoked on the MouseDelegator, which passes it to the appropriate listeners depending on the MouseMode. The best way to avoid this problem is to not implement anything crucial in this method. Use a combination of `mousePressed()` and `mouseReleased()` instead.

  Specified by:
    `mouseClicked` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    true if the listener was able to process the event.

### mouseEntered

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

  Description copied from interface: `MapMouseListener`
  Invoked when the mouse enters a component.

  Specified by:
    `mouseEntered` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent

### mouseExited

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

  Description copied from interface: `MapMouseListener`
  Invoked when the mouse exits a component.

  Specified by:
    `mouseExited` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent

### mouseDragged

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

  Description copied from interface: `MapMouseListener`
  Invoked when a mouse button is pressed on a component and then dragged. The listener will receive these events if it successfully processes mousePressed(), or if no other listener processes the event.

  Specified by:
    `mouseDragged` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    true if the listener was able to process the event.

### mouseMoved

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

  Description copied from interface: `MapMouseListener`
  Invoked when the mouse button has been moved on a component (with no buttons down).

  Specified by:
    `mouseMoved` in interface `MapMouseListener`
  Parameters:
    `e` - MouseEvent
  Returns:
    true if the listener was able to process the event.

### mouseMoved

    public void mouseMoved()

  Description copied from interface: `MapMouseListener`
  Handle a mouse cursor moving without the button being pressed. This event is intended to tell the listener that there was a mouse movement, but that the event was consumed by another layer. This will allow a mouse listener to clean up actions that might have happened because of another motion event response.

  Specified by:
    `mouseMoved` in interface `MapMouseListener`

### numPixelsBetween

    public static int numPixelsBetween(int x1,
                                       int y1,
                                       int x2,
                                       int y2)

  Little math utility that both tools use, that just implements the pathagorean theorem to do the number of pixels between two screen points.

### setMode

    public void setMode(int m)

  Set the current tool to be used.

### getMode

    public int getMode()

### findAndInit

    public void findAndInit(java.lang.Object someObj)

  Description copied from class: `Layer`
  This method is called by the findAndInit(Iterator) method, once for every object inside the iterator. It's here to allow subclasses a way to receive objects and still let the super classes have a shot at the object. So, you can override this method can call super.findAndInit(obj), or override the findAndInit(Iterator) method and call super.findAndInit(obj). Whatever.

  Overrides:
    `findAndInit` in class `Layer`

### findAndUndo

    public void findAndUndo(java.lang.Object someObj)

  Description copied from class: `Layer`
  This is the method that does the opposite as the findAndInit(Object). Lets you call super classes with objects that need to be removed.

  Overrides:
    `findAndUndo` in class `Layer`

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