NASA World Wind

gov.nasa.worldwind.layers
Class ViewControlsLayer

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.layers.AbstractLayer
              extended by gov.nasa.worldwind.layers.RenderableLayer
                  extended by gov.nasa.worldwind.layers.ViewControlsLayer
All Implemented Interfaces:
AVList, Disposable, MessageListener, Layer, Restorable, WWObject, PropertyChangeListener, EventListener

public class ViewControlsLayer
extends RenderableLayer

This layer displays onscreen view controls. Controls are available for pan, zoom, heading, pitch, tilt, field-of-view and vertical exaggeration. Each of the controls can be enabled or disabled independently.

An instance of this class depends on an instance of ViewControlsSelectListener to control it. The select listener must be registered as such via WorldWindow.addSelectListener(gov.nasa.worldwind.event.SelectListener).

ViewControlsLayer instances are not sharable among WorldWindows.

See Also:
ViewControlsSelectListener

Field Summary
protected  int borderWidth
           
protected  int buttonSize
           
protected  ScreenAnnotation controlFovNarrow
           
protected  ScreenAnnotation controlFovWide
           
protected  ScreenAnnotation controlHeadingLeft
           
protected  ScreenAnnotation controlHeadingRight
           
protected  ScreenAnnotation controlLook
           
protected  ScreenAnnotation controlPan
           
protected  ScreenAnnotation controlPitchDown
           
protected  ScreenAnnotation controlPitchUp
           
protected  ScreenAnnotation controlVeDown
           
protected  ScreenAnnotation controlVeUp
           
protected  ScreenAnnotation controlZoomIn
           
protected  ScreenAnnotation controlZoomOut
           
protected  ScreenAnnotation currentControl
           
protected static String IMAGE_FOV_NARROW
           
protected static String IMAGE_FOV_WIDE
           
protected static String IMAGE_HEADING_LEFT
           
protected static String IMAGE_HEADING_RIGHT
           
protected static String IMAGE_LOOK
           
protected static String IMAGE_PAN
           
protected static String IMAGE_PITCH_DOWN
           
protected static String IMAGE_PITCH_UP
           
protected static String IMAGE_VE_DOWN
           
protected static String IMAGE_VE_UP
           
protected static String IMAGE_ZOOM_IN
           
protected static String IMAGE_ZOOM_OUT
           
protected  boolean initialized
           
protected  String layout
           
protected  Vec4 locationCenter
           
protected  Vec4 locationOffset
           
protected  int panSize
           
protected  String position
           
protected  Rectangle referenceViewport
           
protected  double scale
           
protected  boolean showFovControls
           
protected  boolean showHeadingControls
           
protected  boolean showLookControls
           
protected  boolean showPanControls
           
protected  boolean showPitchControls
           
protected  boolean showVeControls
           
protected  boolean showZoomControls
           
 
Fields inherited from class gov.nasa.worldwind.layers.RenderableLayer
pickSupport, renderables, renderablesOverride
 
Constructor Summary
ViewControlsLayer()
           
 
Method Summary
protected  void clearControls()
           
protected  Point computeLocation(Rectangle viewport, Rectangle controls)
          Compute the screen location of the controls overall rectangle bottom right corner according to either the location center if not null, or the screen position.
 void doRender(DrawContext dc)
           
 int getBorderWidth()
           
protected  int getButtonSize()
           
 String getControlType(Object control)
          Get the control type associated with the given object or null if unknown.
 Object getHighlightedObject()
          Indicates the currently highlighted control, if any.
protected  Object getImageSource(String control)
          Get a control image source.
 String getLayout()
          Returns the current layout.
 Vec4 getLocationCenter()
          Returns the current layer image location.
 Vec4 getLocationOffset()
          Returns the current location offset.
 double getOpacity()
          Returns the layer's opacity value, which is ignored by this layer.
protected  int getPanSize()
           
 String getPosition()
          Returns the current relative view controls position.
 double getScale()
          Get the controls display scale.
 void highlight(Object control)
          Specifies the control to highlight.
protected  void initialize(DrawContext dc)
           
protected  boolean isInitialized()
           
 boolean isShowFovControls()
           
 boolean isShowHeadingControls()
           
 boolean isShowLookControls()
           
 boolean isShowPanControls()
           
 boolean isShowPitchControls()
           
 boolean isShowVeControls()
           
 boolean isShowZoomControls()
           
 void setBorderWidth(int borderWidth)
          Sets the view controls offset from the viewport border.
protected  void setButtonSize(int buttonSize)
           
 void setLayout(String layout)
          Sets the desired layout.
 void setLocationCenter(Vec4 locationCenter)
          Specifies the screen location of the layer, relative to the image's center.
 void setLocationOffset(Vec4 locationOffset)
          Specifies a placement offset from the layer position on the screen.
 void setOpacity(double opacity)
          Layer opacity is not applied to layers of this type.
protected  void setPanSize(int panSize)
           
 void setPosition(String position)
          Sets the relative viewport location to display the view controls.
 void setScale(double scale)
          Set the controls display scale.
 void setShowFovControls(boolean state)
           
 void setShowHeadingControls(boolean state)
           
 void setShowLookControls(boolean state)
           
 void setShowPanControls(boolean state)
           
 void setShowPitchControls(boolean state)
           
 void setShowVeControls(boolean state)
           
 void setShowZoomControls(boolean state)
           
 String toString()
           
protected  void updatePositions(DrawContext dc)
           
 
Methods inherited from class gov.nasa.worldwind.layers.RenderableLayer
addRenderable, addRenderables, clearRenderables, dispose, disposeRenderables, doPick, doPick, doPreRender, doPreRender, doRender, getActiveRenderables, getNumRenderables, getRenderables, onMessage, removeAllRenderables, removeRenderable, setRenderables
 
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
createLayerConfigElements, getDataFileStore, getExpiryTime, getLayerConfigParams, getMaxActiveAltitude, getMaxEffectiveAltitude, getMinActiveAltitude, getMinEffectiveAltitude, getName, getRestorableState, getScreenCredit, isAtMaxResolution, isEnabled, isLayerActive, isLayerConfigDocument, isLayerInView, isMultiResolution, isNetworkRetrievalEnabled, isPickEnabled, pick, preRender, render, restoreState, setDataFileStore, setEnabled, setExpiryTime, setMaxActiveAltitude, setMinActiveAltitude, setName, setNetworkRetrievalEnabled, setPickEnabled, setScreenCredit
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 

Field Detail

borderWidth

protected int borderWidth

buttonSize

protected int buttonSize

controlFovNarrow

protected ScreenAnnotation controlFovNarrow

controlFovWide

protected ScreenAnnotation controlFovWide

controlHeadingLeft

protected ScreenAnnotation controlHeadingLeft

controlHeadingRight

protected ScreenAnnotation controlHeadingRight

controlLook

protected ScreenAnnotation controlLook

controlPan

protected ScreenAnnotation controlPan

controlPitchDown

protected ScreenAnnotation controlPitchDown

controlPitchUp

protected ScreenAnnotation controlPitchUp

controlVeDown

protected ScreenAnnotation controlVeDown

controlVeUp

protected ScreenAnnotation controlVeUp

controlZoomIn

protected ScreenAnnotation controlZoomIn

controlZoomOut

protected ScreenAnnotation controlZoomOut

currentControl

protected ScreenAnnotation currentControl

IMAGE_FOV_NARROW

protected static final String IMAGE_FOV_NARROW
See Also:
Constant Field Values

IMAGE_FOV_WIDE

protected static final String IMAGE_FOV_WIDE
See Also:
Constant Field Values

IMAGE_HEADING_LEFT

protected static final String IMAGE_HEADING_LEFT
See Also:
Constant Field Values

IMAGE_HEADING_RIGHT

protected static final String IMAGE_HEADING_RIGHT
See Also:
Constant Field Values

IMAGE_LOOK

protected static final String IMAGE_LOOK
See Also:
Constant Field Values

IMAGE_PAN

protected static final String IMAGE_PAN
See Also:
Constant Field Values

IMAGE_PITCH_DOWN

protected static final String IMAGE_PITCH_DOWN
See Also:
Constant Field Values

IMAGE_PITCH_UP

protected static final String IMAGE_PITCH_UP
See Also:
Constant Field Values

IMAGE_VE_DOWN

protected static final String IMAGE_VE_DOWN
See Also:
Constant Field Values

IMAGE_VE_UP

protected static final String IMAGE_VE_UP
See Also:
Constant Field Values

IMAGE_ZOOM_IN

protected static final String IMAGE_ZOOM_IN
See Also:
Constant Field Values

IMAGE_ZOOM_OUT

protected static final String IMAGE_ZOOM_OUT
See Also:
Constant Field Values

initialized

protected boolean initialized

layout

protected String layout

locationCenter

protected Vec4 locationCenter

locationOffset

protected Vec4 locationOffset

panSize

protected int panSize

position

protected String position

referenceViewport

protected Rectangle referenceViewport

scale

protected double scale

showFovControls

protected boolean showFovControls

showHeadingControls

protected boolean showHeadingControls

showLookControls

protected boolean showLookControls

showPanControls

protected boolean showPanControls

showPitchControls

protected boolean showPitchControls

showVeControls

protected boolean showVeControls

showZoomControls

protected boolean showZoomControls
Constructor Detail

ViewControlsLayer

public ViewControlsLayer()
Method Detail

clearControls

protected void clearControls()

computeLocation

protected Point computeLocation(Rectangle viewport,
                                Rectangle controls)
Compute the screen location of the controls overall rectangle bottom right corner according to either the location center if not null, or the screen position.

Parameters:
viewport - the current viewport rectangle.
controls - the overall controls rectangle
Returns:
the screen location of the bottom left corner - south west corner.

doRender

public void doRender(DrawContext dc)
Overrides:
doRender in class RenderableLayer

getBorderWidth

public int getBorderWidth()

getButtonSize

protected int getButtonSize()

getControlType

public String getControlType(Object control)
Get the control type associated with the given object or null if unknown.

Parameters:
control - the control object
Returns:
the control type. Can be one of AVKey.VIEW_PAN, AVKey.VIEW_LOOK, AVKey.VIEW_HEADING_LEFT, AVKey.VIEW_HEADING_RIGHT, AVKey.VIEW_ZOOM_IN, AVKey.VIEW_ZOOM_OUT, AVKey.VIEW_PITCH_UP, AVKey.VIEW_PITCH_DOWN, AVKey.VIEW_FOV_NARROW or AVKey.VIEW_FOV_WIDE.

Returns null if the object is not a view control associated with this layer.


getHighlightedObject

public Object getHighlightedObject()
Indicates the currently highlighted control, if any.

Returns:
the currently highlighted control, or null if no control is highlighted.

getImageSource

protected Object getImageSource(String control)
Get a control image source.

Parameters:
control - the control type. Can be one of AVKey.VIEW_PAN, AVKey.VIEW_LOOK, AVKey.VIEW_HEADING_LEFT, AVKey.VIEW_HEADING_RIGHT, AVKey.VIEW_ZOOM_IN, AVKey.VIEW_ZOOM_OUT, AVKey.VIEW_PITCH_UP, AVKey.VIEW_PITCH_DOWN, AVKey.VIEW_FOV_NARROW or AVKey.VIEW_FOV_WIDE.
Returns:
the image source associated with the given control type.

getLayout

public String getLayout()
Returns the current layout. Can be one of AVKey.HORIZONTAL or AVKey.VERTICAL.

Returns:
the current layout.

getLocationCenter

public Vec4 getLocationCenter()
Returns the current layer image location.

Returns:
the current location center. May be null.

getLocationOffset

public Vec4 getLocationOffset()
Returns the current location offset. See #setLocationOffset for a description of the offset and its values.

Returns:
the location offset. Will be null if no offset has been specified.

getOpacity

public double getOpacity()
Returns the layer's opacity value, which is ignored by this layer. Opacity is controlled by the alpha values of the operation images.

Specified by:
getOpacity in interface Layer
Overrides:
getOpacity in class RenderableLayer
Returns:
The layer opacity, a value between 0 and 1.

getPanSize

protected int getPanSize()

getPosition

public String getPosition()
Returns the current relative view controls position.

Returns:
the current view controls position.

getScale

public double getScale()
Get the controls display scale.

Specified by:
getScale in interface Layer
Overrides:
getScale in class AbstractLayer
Returns:
the controls display scale.

highlight

public void highlight(Object control)
Specifies the control to highlight. Any currently highlighted control is un-highlighted.

Parameters:
control - the control to highlight.

initialize

protected void initialize(DrawContext dc)

isInitialized

protected boolean isInitialized()

isShowFovControls

public boolean isShowFovControls()

isShowHeadingControls

public boolean isShowHeadingControls()

isShowLookControls

public boolean isShowLookControls()

isShowPanControls

public boolean isShowPanControls()

isShowPitchControls

public boolean isShowPitchControls()

isShowVeControls

public boolean isShowVeControls()

isShowZoomControls

public boolean isShowZoomControls()

setBorderWidth

public void setBorderWidth(int borderWidth)
Sets the view controls offset from the viewport border.

Parameters:
borderWidth - the number of pixels to offset the view controls from the borders indicated by setPosition(String).

setButtonSize

protected void setButtonSize(int buttonSize)

setLayout

public void setLayout(String layout)
Sets the desired layout. Can be one of AVKey.HORIZONTAL or AVKey.VERTICAL.

Parameters:
layout - the desired layout.

setLocationCenter

public void setLocationCenter(Vec4 locationCenter)
Specifies the screen location of the layer, relative to the image's center. May be null. If this value is non-null, it overrides the position specified by setPosition(String). The location is specified in pixels. The origin is the window's lower left corner. Positive X values are to the right of the origin, positive Y values are upwards from the origin. The final image location will be affected by the currently specified location offset if a non-null location offset has been specified (see setLocationOffset(gov.nasa.worldwind.geom.Vec4) )}.

Parameters:
locationCenter - the location center. May be null.
See Also:
setPosition(String), setLocationOffset(gov.nasa.worldwind.geom.Vec4)

setLocationOffset

public void setLocationOffset(Vec4 locationOffset)
Specifies a placement offset from the layer position on the screen.

Parameters:
locationOffset - the number of pixels to shift the layer image from its specified screen position. A positive X value shifts the image to the right. A positive Y value shifts the image up. If null, no offset is applied. The default offset is null.
See Also:
setLocationCenter(gov.nasa.worldwind.geom.Vec4), setPosition(String)

setOpacity

public void setOpacity(double opacity)
Layer opacity is not applied to layers of this type. Opacity is controlled by the alpha values of the operation images.

Specified by:
setOpacity in interface Layer
Overrides:
setOpacity in class RenderableLayer
Parameters:
opacity - the current opacity value, which is ignored by this layer.

setPanSize

protected void setPanSize(int panSize)

setPosition

public void setPosition(String position)
Sets the relative viewport location to display the view controls. Can be one of AVKey.NORTHEAST, AVKey.NORTHWEST, AVKey.SOUTHEAST, or AVKey.SOUTHWEST (the default). These indicate the corner of the viewport to place view controls.

Parameters:
position - the desired view controls position, in screen coordinates.

setScale

public void setScale(double scale)
Set the controls display scale.

Parameters:
scale - the controls display scale.

setShowFovControls

public void setShowFovControls(boolean state)

setShowHeadingControls

public void setShowHeadingControls(boolean state)

setShowLookControls

public void setShowLookControls(boolean state)

setShowPanControls

public void setShowPanControls(boolean state)

setShowPitchControls

public void setShowPitchControls(boolean state)

setShowVeControls

public void setShowVeControls(boolean state)

setShowZoomControls

public void setShowZoomControls(boolean state)

toString

public String toString()
Overrides:
toString in class RenderableLayer

updatePositions

protected void updatePositions(DrawContext dc)

NASA World Wind