Class LayerManagerLayer
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.layers.AbstractLayer
-
- gov.nasa.worldwind.layers.RenderableLayer
-
- gov.nasa.worldwindx.examples.util.LayerManagerLayer
-
- All Implemented Interfaces:
AVList,Disposable,MessageListener,SelectListener,Layer,Restorable,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
public class LayerManagerLayer extends RenderableLayer implements SelectListener
Displays the layer list in a heads-up display in the viewport. Layers can be turned on and off by clicking the check box next to the layer name. The order of layers in the list can be changed by dragging the layer names.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.ColordragColorprotected booleandraggingComponentprotected booleandraggingLayerprotected java.awt.PointdragRefCursorPointprotected intdragRefIndexprotected java.awt.PointdragRefPointprotected java.awt.Dimensionsizeprotected booleanupdateprotected WorldWindowwwd-
Fields inherited from class gov.nasa.worldwind.layers.RenderableLayer
pickSupport, renderables, renderablesOverride
-
-
Constructor Summary
Constructors Constructor Description LayerManagerLayer(WorldWindow wwd)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.PointcomputeLocation(java.awt.Rectangle viewport)Compute the draw frame south-west corner screen location according to it's position - seesetPosition(String), location offset - seesetLocationOffset(Vec4), or location center - seesetLocationCenter(Vec4), and border distance from the viewport edges - seesetBorderWidth(int).protected voiddrag(SelectEvent event)protected static java.lang.StringencodeHTMLColor(java.awt.Color c)ScreenAnnotationgetAnnotation()Get theScreenAnnotationused to display the layer list.intgetBorderWidth()Get the layer manager frame offset from the viewport borders.java.awt.ColorgetColor()Get theColorused to draw the layer names and the frame border when they are not highlighted.java.awt.FontgetFont()Get theFontused to draw the layer list text.java.awt.ColorgetHighlightColor()Get theColorused to draw the layer names and the frame border when they are highlighted.chargetLayerDisabledSymbol()Get the character used to denote a disabled layer.chargetLayerEnabledSymbol()Get the character used to denote an enabled layer.Vec4getLocationCenter()Returns the current layer manager location.Vec4getLocationOffset()Returns the current location offset.doublegetMaxOpacity()Get the opacity applied to the layer list when the cursor is inside it's frame.doublegetMinOpacity()Get the opacity applied to the layer list when the cursor is outside it's frame.java.lang.StringgetPosition()Returns the current relative layer manager frame position.intgetSelectedIndex()Get the selected layer index number in the currentModellayer list.protected voidhighlight(boolean highlighted)Change the annotation appearance according to the given highlighted state.protected voidinitialize()booleanisComponentDragEnabled()Determines whether the layer list can be moved or dragged with the mouse cursor.booleanisEnabled()Indicates whether the layer is enabled for rendering and selection.booleanisLayerDragEnabled()Determines whether a layer can be moved or dragged within the list with the mouse cursor.booleanisMinimized()Determines whether the layer list frame is minimized.booleanisSnapToCorners()Determines whether the layer list snaps to the viewport sides and corners while being dragged.protected java.lang.StringmakeAnnotationText(LayerList layers)Compose the annotation text from the givenLayerList.protected voidmoveTo(java.awt.Point targetPoint)voidrender(DrawContext dc)Cause the layer to draw its representation.voidselected(SelectEvent event)SelectListenerimplementation.voidsetBorderWidth(int borderWidth)Sets the layer manager frame offset from the viewport borders.voidsetColor(java.awt.Color color)Set theColorused to draw the layer names and the frame border when they are not highlighted.voidsetComponentDragEnabled(boolean enabled)Sets whether the layer list can be moved or dragged with the mouse cursor.voidsetEnabled(boolean enabled)Controls whether the layer is enabled for rendering and selection.voidsetFont(java.awt.Font font)Set theFontused to draw the layer list text.voidsetHighlightColor(java.awt.Color color)Set theColorused to draw the layer names and the frame border when they are highlighted.voidsetLayerDisabledSymbol(char c)Set the character used to denote a disabled layer.voidsetLayerDragEnabled(boolean enabled)Sets whether a layer can be moved or dragged within the list with the mouse cursor.voidsetLayerEnabledSymbol(char c)Set the character used to denote an enabled layer.voidsetLocationCenter(Vec4 locationCenter)Specifies the screen location of the layer manager, relative to it's frame center.voidsetLocationOffset(Vec4 locationOffset)Specifies a placement offset from the layer manager frame position on the screen.voidsetMaxOpacity(double opacity)Set the opacity applied to the layer list when the cursor is inside it's frame - zero to one, one is fully opaque.voidsetMinimized(boolean minimized)Set the layer list frame to be minimized.voidsetMinOpacity(double opacity)Set the opacity applied to the layer list when the cursor is outside it's frame - zero to one, one is fully opaque.voidsetPosition(java.lang.String position)Sets the relative viewport location to display the layer manager.voidsetSelectedIndex(int index)Set the selected layer index number.voidsetSnapToCorners(boolean enabled)Sets whether the layer list snaps to the viewport sides and corners while being dragged.protected voidsnapToCorners()java.lang.StringtoString()voidupdate()Schedule the layer list for redrawing before the next render pass.voidupdateNow(DrawContext dc)Force the layer list to redraw itself from the currentModelwith the current highlighted state and selected layer colors and opacity.-
Methods inherited from class gov.nasa.worldwind.layers.RenderableLayer
addRenderable, addRenderable, addRenderables, clearRenderables, dispose, disposeRenderables, doPick, doPick, doPreRender, doPreRender, doRender, doRender, getActiveRenderables, getNumRenderables, getOpacity, getRenderables, onMessage, removeAllRenderables, removeRenderable, setOpacity, setRenderables
-
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
createLayerConfigElements, getDataFileStore, getExpiryTime, getLayerConfigParams, getMaxActiveAltitude, getMaxEffectiveAltitude, getMinActiveAltitude, getMinEffectiveAltitude, getName, getRestorableState, getScale, getScreenCredit, isAtMaxResolution, isLayerActive, isLayerConfigDocument, isLayerInView, isMultiResolution, isNetworkRetrievalEnabled, isPickEnabled, pick, preRender, restoreState, setDataFileStore, 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, 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
-
-
-
-
Field Detail
-
wwd
protected WorldWindow wwd
-
update
protected boolean update
-
size
protected java.awt.Dimension size
-
draggingComponent
protected boolean draggingComponent
-
draggingLayer
protected boolean draggingLayer
-
dragRefCursorPoint
protected java.awt.Point dragRefCursorPoint
-
dragRefPoint
protected java.awt.Point dragRefPoint
-
dragRefIndex
protected int dragRefIndex
-
dragColor
protected java.awt.Color dragColor
-
-
Constructor Detail
-
LayerManagerLayer
public LayerManagerLayer(WorldWindow wwd)
-
-
Method Detail
-
initialize
protected void initialize()
-
getAnnotation
public ScreenAnnotation getAnnotation()
Get theScreenAnnotationused to display the layer list.- Returns:
- the
ScreenAnnotationused to display the layer list.
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:LayerControls whether the layer is enabled for rendering and selection.- Specified by:
setEnabledin interfaceLayer- Overrides:
setEnabledin classAbstractLayer- Parameters:
enabled-trueif the layer is enabled, elsefalse.
-
isEnabled
public boolean isEnabled()
Description copied from interface:LayerIndicates whether the layer is enabled for rendering and selection.- Specified by:
isEnabledin interfaceLayer- Overrides:
isEnabledin classAbstractLayer- Returns:
- true if the layer is enabled, else false.
-
getFont
public java.awt.Font getFont()
Get theFontused to draw the layer list text.- Returns:
- the
Fontused to draw the layer list text.
-
setFont
public void setFont(java.awt.Font font)
Set theFontused to draw the layer list text.- Parameters:
font- theFontused to draw the layer list text.
-
getColor
public java.awt.Color getColor()
Get theColorused to draw the layer names and the frame border when they are not highlighted.- Returns:
- the
Colorused to draw the layer names and the frame border when they are not highlighted.
-
setColor
public void setColor(java.awt.Color color)
Set theColorused to draw the layer names and the frame border when they are not highlighted.- Parameters:
color- theColorused to draw the layer names and the frame border when they are not highlighted.
-
getHighlightColor
public java.awt.Color getHighlightColor()
Get theColorused to draw the layer names and the frame border when they are highlighted.- Returns:
- the
Colorused to draw the layer names and the frame border when they are highlighted.
-
setHighlightColor
public void setHighlightColor(java.awt.Color color)
Set theColorused to draw the layer names and the frame border when they are highlighted.- Parameters:
color- theColorused to draw the layer names and the frame border when they are highlighted.
-
getMinOpacity
public double getMinOpacity()
Get the opacity applied to the layer list when the cursor is outside it's frame.- Returns:
- the opacity applied to the layer list when the cursor is outside it's frame.
-
setMinOpacity
public void setMinOpacity(double opacity)
Set the opacity applied to the layer list when the cursor is outside it's frame - zero to one, one is fully opaque.- Parameters:
opacity- the opacity applied to the layer list when the cursor is outside it's frame.
-
getMaxOpacity
public double getMaxOpacity()
Get the opacity applied to the layer list when the cursor is inside it's frame.- Returns:
- the opacity applied to the layer list when the cursor is inside it's frame.
-
setMaxOpacity
public void setMaxOpacity(double opacity)
Set the opacity applied to the layer list when the cursor is inside it's frame - zero to one, one is fully opaque.- Parameters:
opacity- the opacity applied to the layer list when the cursor is inside it's frame.
-
getLayerEnabledSymbol
public char getLayerEnabledSymbol()
Get the character used to denote an enabled layer.- Returns:
- the character used to denote an enabled layer.
-
setLayerEnabledSymbol
public void setLayerEnabledSymbol(char c)
Set the character used to denote an enabled layer.- Parameters:
c- the character used to denote an enabled layer.
-
getLayerDisabledSymbol
public char getLayerDisabledSymbol()
Get the character used to denote a disabled layer.- Returns:
- the character used to denote a disabled layer.
-
setLayerDisabledSymbol
public void setLayerDisabledSymbol(char c)
Set the character used to denote a disabled layer.- Parameters:
c- the character used to denote a disabled layer.
-
getBorderWidth
public int getBorderWidth()
Get the layer manager frame offset from the viewport borders.- Returns:
- the number of pixels to offset the layer manager frame from the borders indicated by
setPosition(String).
-
setBorderWidth
public void setBorderWidth(int borderWidth)
Sets the layer manager frame offset from the viewport borders.- Parameters:
borderWidth- the number of pixels to offset the layer manager frame from the borders indicated bysetPosition(String).
-
getPosition
public java.lang.String getPosition()
Returns the current relative layer manager frame position.- Returns:
- the current layer manager frame position
-
setPosition
public void setPosition(java.lang.String position)
Sets the relative viewport location to display the layer manager. Can be one ofAVKey.NORTHEAST(the default),AVKey.NORTHWEST,AVKey.SOUTHEAST, orAVKey.SOUTHWEST. These indicate the corner of the viewport to place the frame.- Parameters:
position- the desired layer manager position
-
getLocationCenter
public Vec4 getLocationCenter()
Returns the current layer manager location.- Returns:
- the current location center. May be null.
-
setLocationCenter
public void setLocationCenter(Vec4 locationCenter)
Specifies the screen location of the layer manager, relative to it's frame 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 frame location will be affected by the currently specified location offset if a non-null location offset has been specified (seesetLocationOffset(Vec4)).- Parameters:
locationCenter- the location center. May be null.- See Also:
setPosition(String),setLocationOffset(gov.nasa.worldwind.geom.Vec4)
-
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 layer manager frame position on the screen.- Parameters:
locationOffset- the number of pixels to shift the layer manager frame from its specified screen position. A positive X value shifts the frame to the right. A positive Y value shifts the frame up. If null, no offset is applied. The default offset is null.- See Also:
setLocationCenter(gov.nasa.worldwind.geom.Vec4),setPosition(String)
-
isMinimized
public boolean isMinimized()
Determines whether the layer list frame is minimized. When minimized, the layer list only contains itself as the only item, and thus shrinks toward it's corner position.- Returns:
trueif the layer list frame is minimized.
-
setMinimized
public void setMinimized(boolean minimized)
Set the layer list frame to be minimized. When minimized, the layer list only contains itself as the only item, and thus shrinks toward it's corner position.- Parameters:
minimized-trueif the layer list frame sould be minimized.
-
isComponentDragEnabled
public boolean isComponentDragEnabled()
Determines whether the layer list can be moved or dragged with the mouse cursor.If enabled, dragging the frame will result in a change to it's location offset -
setLocationOffset(Vec4). If the list is also set to snap to corners -setSnapToCorners(boolean), the frame position may change so as to be attached to the nearest corner - seesetPosition(String).- Returns:
trueif the layer list can be moved or dragged with the mouse cursor.
-
setComponentDragEnabled
public void setComponentDragEnabled(boolean enabled)
Sets whether the layer list can be moved or dragged with the mouse cursor.If enabled, dragging the frame will result in a change to it's location offset -
setLocationOffset(Vec4). If the list is also set to snap to corners -setSnapToCorners(boolean), the frame position may change so as to be attached to the nearest corner - seesetPosition(String).- Parameters:
enabled-trueif the layer list can be moved or dragged with the mouse cursor.
-
isLayerDragEnabled
public boolean isLayerDragEnabled()
Determines whether a layer can be moved or dragged within the list with the mouse cursor. If enabled, layers can be moved up and down the list.- Returns:
trueif a layer can be moved or dragged within the list.
-
setLayerDragEnabled
public void setLayerDragEnabled(boolean enabled)
Sets whether a layer can be moved or dragged within the list with the mouse cursor. If enabled, layers can be moved up and down the list.- Parameters:
enabled-trueif a layer can be moved or dragged within the list.
-
isSnapToCorners
public boolean isSnapToCorners()
Determines whether the layer list snaps to the viewport sides and corners while being dragged.Dragging the layer list frame will result in a change to it's location offset -
setLocationOffset(Vec4). If the list is also set to snap to corners -setSnapToCorners(boolean), the frame position may change so as to be attached to the nearest corner - seesetPosition(String).- Returns:
trueif the layer list snaps to the viewport sides and corners while being dragged.
-
setSnapToCorners
public void setSnapToCorners(boolean enabled)
Sets whether the layer list snaps to the viewport sides and corners while being dragged.Dragging the layer list frame will result in a change to it's location offset -
setLocationOffset(Vec4). If the list is also set to snap to corners the frame position may change so as to be attached to the nearest corner - seesetPosition(String).- Parameters:
enabled-trueif the layer list should snaps to the viewport sides and corners while being dragged.
-
getSelectedIndex
public int getSelectedIndex()
Get the selected layer index number in the currentModellayer list. A layer is selected when the cursor is over it in the list. Returns -1 if no layer is currently selected.- Returns:
- the selected layer index number or -1 if none is selected.
-
setSelectedIndex
public void setSelectedIndex(int index)
Set the selected layer index number. When selected a layer is highlighted in the list - this usually happens when the cursor is over it.- Parameters:
index- the selected layer index number.
-
selected
public void selected(SelectEvent event)
SelectListenerimplementation.- Specified by:
selectedin interfaceSelectListener- Parameters:
event- the currentSelectEvent
-
drag
protected void drag(SelectEvent event)
-
moveTo
protected void moveTo(java.awt.Point targetPoint)
-
snapToCorners
protected void snapToCorners()
-
update
public void update()
Schedule the layer list for redrawing before the next render pass.
-
updateNow
public void updateNow(DrawContext dc)
Force the layer list to redraw itself from the currentModelwith the current highlighted state and selected layer colors and opacity.- Parameters:
dc- the currentDrawContext.- See Also:
setMinOpacity(double),setMaxOpacity(double),setColor(java.awt.Color),setHighlightColor(java.awt.Color)
-
highlight
protected void highlight(boolean highlighted)
Change the annotation appearance according to the given highlighted state.- Parameters:
highlighted-trueif the annotation should appear highlighted.
-
makeAnnotationText
protected java.lang.String makeAnnotationText(LayerList layers)
Compose the annotation text from the givenLayerList.- Parameters:
layers- theLayerListto draw names from.- Returns:
- the annotation text to be displayed.
-
encodeHTMLColor
protected static java.lang.String encodeHTMLColor(java.awt.Color c)
-
render
public void render(DrawContext dc)
Description copied from interface:LayerCause the layer to draw its representation.- Specified by:
renderin interfaceLayer- Overrides:
renderin classAbstractLayer- Parameters:
dc- the current draw context
-
computeLocation
protected java.awt.Point computeLocation(java.awt.Rectangle viewport)
Compute the draw frame south-west corner screen location according to it's position - seesetPosition(String), location offset - seesetLocationOffset(Vec4), or location center - seesetLocationCenter(Vec4), and border distance from the viewport edges - seesetBorderWidth(int).- Parameters:
viewport- the currentViewportrectangle.- Returns:
- the draw frame south-west corner screen location.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classRenderableLayer
-
-