Package gov.nasa.worldwind.layers
Class CrosshairLayer
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.layers.AbstractLayer
-
- gov.nasa.worldwind.layers.CrosshairLayer
-
- All Implemented Interfaces:
AVList
,Disposable
,MessageListener
,Layer
,Restorable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
public class CrosshairLayer extends AbstractLayer
Renders a crosshair icon in the viewport center or at a specified location.
-
-
Constructor Summary
Constructors Constructor Description CrosshairLayer()
CrosshairLayer(java.lang.String iconFilePath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doRender(DrawContext dc)
java.lang.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.java.lang.String
getResizeBehavior()
Returns the crosshair icon's resize behavior.double
getToViewportScale()
Returns the layer's compass-to-viewport scale factor.void
setIconFilePath(java.lang.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(java.lang.String resizeBehavior)
Sets the behavior the layer uses to size the crosshair icon when the viewport size changes, typically when the WorldWind 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.java.lang.String
toString()
-
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
createLayerConfigElements, dispose, doPick, doPreRender, getDataFileStore, getExpiryTime, getLayerConfigParams, getMaxActiveAltitude, getMaxEffectiveAltitude, getMinActiveAltitude, getMinEffectiveAltitude, getName, getOpacity, getRestorableState, getScale, getScreenCredit, isAtMaxResolution, isEnabled, isLayerActive, isLayerConfigDocument, isLayerInView, isMultiResolution, isNetworkRetrievalEnabled, isPickEnabled, pick, preRender, render, restoreState, setDataFileStore, setEnabled, setExpiryTime, setMaxActiveAltitude, setMinActiveAltitude, setName, setNetworkRetrievalEnabled, setOpacity, setPickEnabled, setScreenCredit
-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, 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, 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 gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Method Detail
-
getIconFilePath
public java.lang.String getIconFilePath()
Returns the layer's current icon file path.- Returns:
- the icon file path
-
setIconFilePath
public void setIconFilePath(java.lang.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
-
getToViewportScale
public double getToViewportScale()
Returns the layer's compass-to-viewport scale factor.- Returns:
- the crosshair-to-viewport scale factor
-
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 AVKey.RESIZE_STRETCH or AVKey.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
-
getIconScale
public double getIconScale()
Returns the icon scale factor. SeesetIconScale(double)
for a description of the scale factor.- Returns:
- the current icon scale
-
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 AVKey.RESIZE_KEEP_FIXED_SIZE, the icon's displayed sized is further affected by the value specified bysetToViewportScale(double)
and the current viewport size.- Parameters:
iconScale
- the icon scale factor
-
getResizeBehavior
public java.lang.String getResizeBehavior()
Returns the crosshair icon's resize behavior.- Returns:
- the icon's resize behavior
-
setResizeBehavior
public void setResizeBehavior(java.lang.String resizeBehavior)
Sets the behavior the layer uses to size the crosshair icon when the viewport size changes, typically when the WorldWind window is resized. If the value is AVKey.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 AVKey.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 AVKey.RESIZE_SHRINK_ONLY (the default), icon sizing behaves as for AVKey.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
-
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.
-
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.
-
doRender
protected void doRender(DrawContext dc)
- Specified by:
doRender
in classAbstractLayer
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractLayer
-
-