Package gov.nasa.worldwind.layers
Class WorldMapLayer
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.layers.AbstractLayer
-
- gov.nasa.worldwind.layers.WorldMapLayer
-
- All Implemented Interfaces:
AVList,Disposable,MessageListener,Layer,Restorable,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
public class WorldMapLayer extends AbstractLayer
Displays a world map overlay with a current-position crosshair in a screen corner.A
ClickAndGoSelectListenercan be used in conjunction with this layer to move the view to a selected location when that location is clicked within the layer's map. SpecifyWorldMapLayer.classwhen constructing theClickAndGoSelectListener.Note: This layer may not be shared among multiple
WorldWindows.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classWorldMapLayer.OrderedIcon
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.ColorbackColorprotected intborderWidthprotected java.awt.Colorcolorprotected java.util.ArrayList<? extends LatLon>footPrintPositionsprotected longframeStampForDrawingprotected longframeStampForPickingprotected java.lang.StringiconFilePathprotected inticonHeightprotected doubleiconScaleprotected inticonWidthprotected Vec4locationCenterprotected Vec4locationOffsetprotected WorldMapLayer.OrderedIconorderedImageprotected PickSupportpickSupportprotected java.lang.Stringpositionprotected java.lang.StringresizeBehaviorprotected booleanshowFootprintprotected doubletoViewportScale
-
Constructor Summary
Constructors Constructor Description WorldMapLayer()Displays a world map overlay with a current position crosshair in a screen cornerWorldMapLayer(java.lang.String iconFilePath)Displays a world map overlay with a current position crosshair in a screen corner
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PositioncomputeGroundPosition(DrawContext dc, View view)Compute the lat/lon position of the view centerprotected Vec4computeLocation(java.awt.Rectangle viewport, double scale)protected PositioncomputePickPosition(DrawContext dc, Vec4 locationSW, java.awt.Dimension mapSize)Computes the lat/lon of the pickPoint over the world mapprotected doublecomputeScale(java.awt.Rectangle viewport)protected java.util.ArrayList<LatLon>computeViewFootPrint(DrawContext dc, int steps)Compute the view range footprint on the globe.voiddoPick(DrawContext dc, java.awt.Point pickPoint)voiddoRender(DrawContext dc)protected voiddrawIcon(DrawContext dc)java.awt.ColorgetBackgrounColor()intgetBorderWidth()java.util.List<? extends LatLon>getFootPrintPositions()Get the current view footprint position list.java.lang.StringgetIconFilePath()Returns the layer's current icon file path.doublegetIconScale()Returns the icon scale factor.Vec4getLocationCenter()Returns the current worldmap image location.Vec4getLocationOffset()Returns the current location offset.java.lang.StringgetPosition()Returns the current relative world map icon position.java.lang.StringgetResizeBehavior()Returns the world map icon's resize behavior.protected doublegetScaledIconHeight()protected doublegetScaledIconWidth()booleangetShowFootprint()doublegetToViewportScale()Returns the layer's world map-to-viewport scale factor.protected voidinitializeTexture(DrawContext dc)voidsetBackgroundColor(java.awt.Color color)voidsetBorderWidth(int borderWidth)Sets the world map icon offset from the viewport border.voidsetIconFilePath(java.lang.String iconFilePath)Sets the world map icon's image location.voidsetIconScale(double iconScale)Sets the scale factor defining the displayed size of the world map icon relative to the icon's width and height in its image file.voidsetLocationCenter(Vec4 locationCenter)Specifies the screen location of the worldmap image, relative to the image's center.voidsetLocationOffset(Vec4 locationOffset)Specifies a placement offset from the worldmap's position on the screen.voidsetPosition(java.lang.String position)Sets the relative viewport location to display the world map icon.voidsetResizeBehavior(java.lang.String resizeBehavior)Sets the behavior the layer uses to size the world map icon when the viewport size changes, typically when the WorldWind window is resized.voidsetShowFootprint(boolean state)voidsetToViewportScale(double toViewportScale)Sets the scale factor applied to the viewport size to determine the displayed size of the world map icon.java.lang.StringtoString()-
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
createLayerConfigElements, dispose, 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
-
-
-
-
Field Detail
-
iconFilePath
protected java.lang.String iconFilePath
-
toViewportScale
protected double toViewportScale
-
iconScale
protected double iconScale
-
borderWidth
protected int borderWidth
-
position
protected java.lang.String position
-
resizeBehavior
protected java.lang.String resizeBehavior
-
iconWidth
protected int iconWidth
-
iconHeight
protected int iconHeight
-
locationCenter
protected Vec4 locationCenter
-
locationOffset
protected Vec4 locationOffset
-
color
protected java.awt.Color color
-
backColor
protected java.awt.Color backColor
-
showFootprint
protected boolean showFootprint
-
footPrintPositions
protected java.util.ArrayList<? extends LatLon> footPrintPositions
-
pickSupport
protected PickSupport pickSupport
-
frameStampForPicking
protected long frameStampForPicking
-
frameStampForDrawing
protected long frameStampForDrawing
-
orderedImage
protected WorldMapLayer.OrderedIcon orderedImage
-
-
Constructor Detail
-
WorldMapLayer
public WorldMapLayer()
Displays a world map overlay with a current position crosshair in a screen corner
-
WorldMapLayer
public WorldMapLayer(java.lang.String iconFilePath)
Displays a world map overlay with a current position crosshair in a screen corner- Parameters:
iconFilePath- the world map image path and filename
-
-
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 world map 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 world map-to-viewport scale factor.- Returns:
- the world map-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 world map 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 world map image's native aspect ratio.- Parameters:
toViewportScale- the world map 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 world map 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 world map 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 world map 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 world map-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
-
getBorderWidth
public int getBorderWidth()
-
setBorderWidth
public void setBorderWidth(int borderWidth)
Sets the world map icon offset from the viewport border.- Parameters:
borderWidth- the number of pixels to offset the world map icon from the borders indicated bysetPosition(String).
-
getPosition
public java.lang.String getPosition()
Returns the current relative world map icon position.- Returns:
- the current world map position
-
setPosition
public void setPosition(java.lang.String position)
Sets the relative viewport location to display the world map icon. Can be one of AVKey.NORTHEAST, AVKey.NORTHWEST (the default), AVKey.SOUTHEAST, or SOUTHWEST. These indicate the corner of the viewport to place the icon.- Parameters:
position- the desired world map position
-
getLocationCenter
public Vec4 getLocationCenter()
Returns the current worldmap image location.- Returns:
- the current location center. May be null.
-
setLocationCenter
public void setLocationCenter(Vec4 locationCenter)
Specifies the screen location of the worldmap image, relative to the image's center. May be null. If this value is non-null, it overrides the position specified by #setPosition. 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).- Parameters:
locationCenter- the location center. May be null.- See Also:
the screen location at which to place the map.
-
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.
-
setLocationOffset
public void setLocationOffset(Vec4 locationOffset)
Specifies a placement offset from the worldmap's position on the screen.- Parameters:
locationOffset- the number of pixels to shift the worldmap 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)
-
getBackgrounColor
public java.awt.Color getBackgrounColor()
-
setBackgroundColor
public void setBackgroundColor(java.awt.Color color)
-
getShowFootprint
public boolean getShowFootprint()
-
setShowFootprint
public void setShowFootprint(boolean state)
-
getFootPrintPositions
public java.util.List<? extends LatLon> getFootPrintPositions()
Get the current view footprint position list. May be null if no footprint is displayed or none has been computed.- Returns:
- the current view footprint position list - may be null.
-
doRender
public void doRender(DrawContext dc)
- Specified by:
doRenderin classAbstractLayer
-
doPick
public void doPick(DrawContext dc, java.awt.Point pickPoint)
- Overrides:
doPickin classAbstractLayer
-
drawIcon
protected void drawIcon(DrawContext dc)
-
computeScale
protected double computeScale(java.awt.Rectangle viewport)
-
getScaledIconWidth
protected double getScaledIconWidth()
-
getScaledIconHeight
protected double getScaledIconHeight()
-
computeLocation
protected Vec4 computeLocation(java.awt.Rectangle viewport, double scale)
-
initializeTexture
protected void initializeTexture(DrawContext dc)
-
computeGroundPosition
protected Position computeGroundPosition(DrawContext dc, View view)
Compute the lat/lon position of the view center- Parameters:
dc- the current DrawContextview- the current View- Returns:
- the ground position of the view center or null
-
computePickPosition
protected Position computePickPosition(DrawContext dc, Vec4 locationSW, java.awt.Dimension mapSize)
Computes the lat/lon of the pickPoint over the world map- Parameters:
dc- the currentDrawContextlocationSW- the screen location of the bottom left corner of the mapmapSize- the world map screen dimension in pixels- Returns:
- the picked Position
-
computeViewFootPrint
protected java.util.ArrayList<LatLon> computeViewFootPrint(DrawContext dc, int steps)
Compute the view range footprint on the globe.- Parameters:
dc- the currentDrawContextsteps- the number of steps.- Returns:
- an array list of
LatLonforming a closed shape.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractLayer
-
-