NASA World Wind

gov.nasa.worldwind.layers
Class CrosshairLayer

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.CrosshairLayer
All Implemented Interfaces:
AVList, Disposable, Layer, Restorable, WWObject, PropertyChangeListener, EventListener

public class CrosshairLayer
extends AbstractLayer

Renders a crosshair icon in the viewport center or at a specified location.


Field Summary
static String RESIZE_KEEP_FIXED_SIZE
          Does not modify the crosshair icon size when the window changes size.
static String RESIZE_SHRINK_ONLY
          On window resize, scales the crosshair icon to occupy a constant relative size of the viewport, but not larger than the icon's inherent size scaled by the layer's icon scale factor.
static String RESIZE_STRETCH
          On window resize, scales the crosshair icon to occupy a constant relative size of the viewport.
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
CrosshairLayer()
           
CrosshairLayer(String iconFilePath)
           
 
Method Summary
protected  void doRender(DrawContext dc)
           
 String getIconFilePath()
          Returns the layer's current icon file path.
 double getIconScale()
          Returns the icon scale factor.
 Vec4 getLocationCenter()
          Get the crosshair location inside the viewport.
 String getResizeBehavior()
          Returns the crosshair icon's resize behavior.
 double getToViewportScale()
          Returns the layer's compass-to-viewport scale factor.
 void setIconFilePath(String iconFilePath)
          Sets the crosshair icon's image location.
 void setIconScale(double iconScale)
          Sets the scale factor defining the displayed size of the crosshair icon relative to the icon's width and height in its image file.
 void setLocationCenter(Vec4 locationCenter)
          Set the crosshair location inside the viewport.
 void setResizeBehavior(String resizeBehavior)
          Sets the behavior the layer uses to size the crosshair icon when the viewport size changes, typically when the World Wind window is resized.
 void setToViewportScale(double toViewportScale)
          Sets the scale factor applied to the viewport size to determine the displayed size of the crosshair icon.
 String toString()
           
 
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
dispose, doPick, getMaxActiveAltitude, getMinActiveAltitude, getName, getOpacity, getRestorableState, getScale, isAtMaxResolution, isEnabled, isLayerActive, isLayerInView, isMultiResolution, isPickEnabled, pick, render, restoreState, setEnabled, setMaxActiveAltitude, setMinActiveAltitude, setName, setOpacity, setPickEnabled
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, 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

RESIZE_KEEP_FIXED_SIZE

public static final String RESIZE_KEEP_FIXED_SIZE
Does not modify the crosshair icon size when the window changes size.

See Also:
Constant Field Values

RESIZE_SHRINK_ONLY

public static final String RESIZE_SHRINK_ONLY
On window resize, scales the crosshair icon to occupy a constant relative size of the viewport, but not larger than the icon's inherent size scaled by the layer's icon scale factor.

See Also:
Constant Field Values

RESIZE_STRETCH

public static final String RESIZE_STRETCH
On window resize, scales the crosshair icon to occupy a constant relative size of the viewport.

See Also:
Constant Field Values
Constructor Detail

CrosshairLayer

public CrosshairLayer()

CrosshairLayer

public CrosshairLayer(String iconFilePath)
Method Detail

doRender

protected void doRender(DrawContext dc)
Specified by:
doRender in class AbstractLayer

getIconFilePath

public String getIconFilePath()
Returns the layer's current icon file path.

Returns:
the icon file path

getIconScale

public double getIconScale()
Returns the icon scale factor. See setIconScale(double) for a description of the scale factor.

Returns:
the current icon scale

getLocationCenter

public Vec4 getLocationCenter()
Get the crosshair location inside the viewport. If this location is null, the crosshair is drawn in the viewport center.

Returns:
the crosshair location inside the viewport.

getResizeBehavior

public String getResizeBehavior()
Returns the crosshair icon's resize behavior.

Returns:
the icon's resize behavior

getToViewportScale

public double getToViewportScale()
Returns the layer's compass-to-viewport scale factor.

Returns:
the crosshair-to-viewport scale factor

setIconFilePath

public void setIconFilePath(String iconFilePath)
Sets the crosshair icon's image location. The layer first searches for this location in the current Java classpath. If not found then the specified path is assumed to refer to the local file system. found there then the

Parameters:
iconFilePath - the path to the icon's image file

setIconScale

public void setIconScale(double iconScale)
Sets the scale factor defining the displayed size of the crosshair icon relative to the icon's width and height in its image file. Values greater than 1 magify the image, values less than one minify it. If the layer's resize behavior is other than RESIZE_KEEP_FIXED_SIZE, the icon's displayed sized is further affected by the value specified by setToViewportScale(double) and the current viewport size.

Parameters:
iconScale - the icon scale factor

setLocationCenter

public void setLocationCenter(Vec4 locationCenter)
Set the crosshair location inside the viewport. If this location is null, the crosshair will be drawn in the viewport center.

Parameters:
locationCenter - the crosshair location inside the viewport.

setResizeBehavior

public void setResizeBehavior(String resizeBehavior)
Sets the behavior the layer uses to size the crosshair icon when the viewport size changes, typically when the World Wind window is resized. If the value is RESIZE_KEEP_FIXED_SIZE, the icon size is kept to the size specified in its image file scaled by the layer's current icon scale. If the value is RESIZE_STRETCH, the icon is resized to have a constant size relative to the current viewport size. If the viewport shrinks the icon size decreases; if it expands then the icon file enlarges. The relative size is determined by the current crosshair-to-viewport scale and by the icon's image file size scaled by the current icon scale. If the value is RESIZE_SHRINK_ONLY (the default), icon sizing behaves as for RESIZE_STRETCH but the icon will not grow larger than the size specified in its image file scaled by the current icon scale.

Parameters:
resizeBehavior - the desired resize behavior

setToViewportScale

public void setToViewportScale(double toViewportScale)
Sets the scale factor applied to the viewport size to determine the displayed size of the crosshair icon. This scale factor is used only when the layer's resize behavior is RESIZE_STRETCH or RESIZE_SHRINK_ONLY. The icon's width is adjusted to occupy the proportion of the viewport's width indicated by this factor. The icon's height is adjusted to maintain the crosshair image's native aspect ratio.

Parameters:
toViewportScale - the compass to viewport scale factor

toString

public String toString()
Overrides:
toString in class AbstractLayer

NASA World Wind