Package gov.nasa.worldwind.render
Class IconRenderer
- java.lang.Object
-
- gov.nasa.worldwind.render.IconRenderer
-
public class IconRenderer extends java.lang.ObjectIconRenderer processes collections ofWWIconinstances for picking and rendering. IconRenderer applies batch processing techniques to improve the runtime performance of picking and rendering large collections of icons.During the draw pass, IconRenderer records feedback information for each WWIcon which has the property key
AVKey.FEEDBACK_ENABLEDset totrue. IconRenderer does not record any feedback information during the pick pass. When feedback is enabled, IconRenderer puts properties which describe how each WWIcon has been processed in key-value pairs attached to the WWIcon. Any of these properties may be null, indicating that processing of the WWIcon was terminated before this information became available. The feedback properties for WWIcon are as follows:WWIcon Feedback Properties Key Description AVKey.FEEDBACK_REFERENCE_POINTThe icon's reference point in model coordinates. AVKey.FEEDBACK_SCREEN_BOUNDSThe icon's bounding rectangle in screen coordinates.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classIconRenderer.OrderedIconprotected classIconRenderer.OrderedText
-
Field Summary
Fields Modifier and Type Field Description protected booleanallowBatchPickingprotected booleanalwaysUseAbsoluteElevationprotected booleanhorizonClippingEnabledprotected OGLStackHandleroglStackHandlerprotected Pedestalpedestalprotected booleanpickFrustumClippingEnabledprotected PickSupportpickSupportprotected booleanviewClippingEnabled
-
Constructor Summary
Constructors Constructor Description IconRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddToolTip(DrawContext dc, WWIcon icon, Vec4 iconPoint)protected voidapplyBackground(DrawContext dc, WWIcon icon, Vec4 screenPoint, double width, double height, double pedestalSpacing, double pedestalScale)protected voidbeginDrawIcons(DrawContext dc)protected voiddoRecordFeedback(DrawContext dc, WWIcon icon, Vec4 modelPoint, java.awt.Rectangle screenRect)Records feedback about how the specified WWIcon has been processed.protected Vec4drawIcon(DrawContext dc, IconRenderer.OrderedIcon uIcon)protected voiddrawIconsInBatch(DrawContext dc, IconRenderer.OrderedIcon uIcon)protected voiddrawMany(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons, Layer layer)protected voidendDrawIcons(DrawContext dc)PedestalgetPedestal()booleanisAllowBatchPicking()Indicates whether icons are picked as a batch and therefore aSelectEventwill contain only one icon from a given layer.booleanisAlwaysUseAbsoluteElevation()Indicates whether an icon's elevation is treated as an offset from the terrain or an absolute elevation above sea level.protected booleanisFeedbackEnabled(DrawContext dc, WWIcon icon)Returns true if the IconRenderer should record feedback about how the specified WWIcon has been processed.booleanisHorizonClippingEnabled()Indicates whether horizon clipping is performed.protected static booleanisIconValid(WWIcon icon, boolean checkPosition)booleanisPickFrustumClippingEnabled()Indicates whether picking volume clipping is performed.booleanisViewClippingEnabled()Indicates whether view volume clipping is performed.voidpick(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons, java.awt.Point pickPoint, Layer layer)protected voidpickIconsInBatch(DrawContext dc, IconRenderer.OrderedIcon uIcon)protected voidrecordFeedback(DrawContext dc, WWIcon icon, Vec4 modelPoint, java.awt.Rectangle screenRect)If feedback is enabled for the specified WWIcon, this method records feedback about how the specified WWIcon has been processed.voidrender(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons)voidsetAllowBatchPicking(boolean allowBatchPicking)Specifies whether batch picking is allowed.voidsetAlwaysUseAbsoluteElevation(boolean alwaysUseAbsoluteElevation)Normally, an icon's elevation is treated as an offset from the terrain when it is less than the globe's maximum elevation.protected voidsetDepthFunc(DrawContext dc, IconRenderer.OrderedIcon uIcon, Vec4 screenPoint)voidsetHorizonClippingEnabled(boolean horizonClippingEnabled)Indicates whether to render icons beyond the horizon.voidsetPedestal(Pedestal pedestal)voidsetPickFrustumClippingEnabled(boolean pickFrustumClippingEnabled)Indicates whether to render icons outside the picking volume when in pick mode.voidsetViewClippingEnabled(boolean viewClippingEnabled)Indicates whether to render icons outside the view volume.java.lang.StringtoString()
-
-
-
Field Detail
-
pedestal
protected Pedestal pedestal
-
horizonClippingEnabled
protected boolean horizonClippingEnabled
-
viewClippingEnabled
protected boolean viewClippingEnabled
-
pickFrustumClippingEnabled
protected boolean pickFrustumClippingEnabled
-
alwaysUseAbsoluteElevation
protected boolean alwaysUseAbsoluteElevation
-
oglStackHandler
protected OGLStackHandler oglStackHandler
-
allowBatchPicking
protected boolean allowBatchPicking
-
pickSupport
protected PickSupport pickSupport
-
-
Method Detail
-
getPedestal
public Pedestal getPedestal()
-
setPedestal
public void setPedestal(Pedestal pedestal)
-
isHorizonClippingEnabled
public boolean isHorizonClippingEnabled()
Indicates whether horizon clipping is performed.- Returns:
trueif horizon clipping is performed, otherwisefalse.- See Also:
setHorizonClippingEnabled(boolean)
-
setHorizonClippingEnabled
public void setHorizonClippingEnabled(boolean horizonClippingEnabled)
Indicates whether to render icons beyond the horizon. If view culling is enabled, the icon is also tested for view volume inclusion. The default isfalse, horizon clipping is not performed.- Parameters:
horizonClippingEnabled-trueif horizon clipping should be performed, otherwisefalse.- See Also:
setViewClippingEnabled(boolean)
-
isViewClippingEnabled
public boolean isViewClippingEnabled()
Indicates whether view volume clipping is performed.- Returns:
trueif view volume clipping is performed, otherwisefalse.- See Also:
setViewClippingEnabled(boolean)
-
setViewClippingEnabled
public void setViewClippingEnabled(boolean viewClippingEnabled)
Indicates whether to render icons outside the view volume. This is primarily to control icon visibility beyond the far view clipping plane. Some important use cases demand that clipping not be performed. If horizon clipping is enabled, the icon is also tested for horizon clipping. The default istrue, view volume clipping is not performed.- Parameters:
viewClippingEnabled-trueif view clipping should be performed, otherwisefalse.- See Also:
setHorizonClippingEnabled(boolean)
-
isPickFrustumClippingEnabled
public boolean isPickFrustumClippingEnabled()
Indicates whether picking volume clipping is performed.- Returns:
trueif picking volume clipping is performed, otherwisefalse.- See Also:
setPickFrustumClippingEnabled(boolean)
-
setPickFrustumClippingEnabled
public void setPickFrustumClippingEnabled(boolean pickFrustumClippingEnabled)
Indicates whether to render icons outside the picking volume when in pick mode. This increases performance by only drawing the icons within the picking volume when picking is enabled. Some important use cases demand that clipping not be performed. The default isfalse, picking volume clipping is not performed.- Parameters:
pickFrustumClippingEnabled-trueif picking clipping should be performed, otherwisefalse.
-
isIconValid
protected static boolean isIconValid(WWIcon icon, boolean checkPosition)
-
isAlwaysUseAbsoluteElevation
public boolean isAlwaysUseAbsoluteElevation()
Indicates whether an icon's elevation is treated as an offset from the terrain or an absolute elevation above sea level.- Returns:
trueif icon elevations are treated as absolute,falseif they're treated as offsets from the terrain.
-
setAlwaysUseAbsoluteElevation
public void setAlwaysUseAbsoluteElevation(boolean alwaysUseAbsoluteElevation)
Normally, an icon's elevation is treated as an offset from the terrain when it is less than the globe's maximum elevation. Setting #setAlwaysUseAbsoluteElevation totruecauses the elevation to be treated as an absolute elevation above sea level.- Parameters:
alwaysUseAbsoluteElevation-trueto treat icon elevations as absolute,falseto treat them as offsets from the terrain.
-
isAllowBatchPicking
public boolean isAllowBatchPicking()
Indicates whether icons are picked as a batch and therefore aSelectEventwill contain only one icon from a given layer. Batch picking is much faster than individual picking, so this attribute should be used judiciously.- Returns:
- true if batch picking is allowed, otherwise false.
- See Also:
setAllowBatchPicking(boolean)
-
setAllowBatchPicking
public void setAllowBatchPicking(boolean allowBatchPicking)
Specifies whether batch picking is allowed. If so, aSelectEventfrom a layer will contain only one icon even if several overlapping icons are at the pick point. Batch picking is much faster than individual picking so the default value is true.- Parameters:
allowBatchPicking- true if batch picking is allowed, otherwise false.
-
pick
public void pick(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons, java.awt.Point pickPoint, Layer layer)
-
render
public void render(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons)
-
drawMany
protected void drawMany(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons, Layer layer)
-
addToolTip
protected void addToolTip(DrawContext dc, WWIcon icon, Vec4 iconPoint)
-
beginDrawIcons
protected void beginDrawIcons(DrawContext dc)
-
endDrawIcons
protected void endDrawIcons(DrawContext dc)
-
drawIconsInBatch
protected void drawIconsInBatch(DrawContext dc, IconRenderer.OrderedIcon uIcon)
-
pickIconsInBatch
protected void pickIconsInBatch(DrawContext dc, IconRenderer.OrderedIcon uIcon)
-
drawIcon
protected Vec4 drawIcon(DrawContext dc, IconRenderer.OrderedIcon uIcon)
-
applyBackground
protected void applyBackground(DrawContext dc, WWIcon icon, Vec4 screenPoint, double width, double height, double pedestalSpacing, double pedestalScale)
-
setDepthFunc
protected void setDepthFunc(DrawContext dc, IconRenderer.OrderedIcon uIcon, Vec4 screenPoint)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isFeedbackEnabled
protected boolean isFeedbackEnabled(DrawContext dc, WWIcon icon)
Returns true if the IconRenderer should record feedback about how the specified WWIcon has been processed.- Parameters:
dc- the current DrawContext.icon- the WWIcon to record feedback information for.- Returns:
- true to record feedback; false otherwise.
-
recordFeedback
protected void recordFeedback(DrawContext dc, WWIcon icon, Vec4 modelPoint, java.awt.Rectangle screenRect)
If feedback is enabled for the specified WWIcon, this method records feedback about how the specified WWIcon has been processed.- Parameters:
dc- the current DrawContext.icon- the icon which the feedback information refers to.modelPoint- the icon's reference point in model coordinates.screenRect- the icon's bounding rectangle in screen coordinates.
-
doRecordFeedback
protected void doRecordFeedback(DrawContext dc, WWIcon icon, Vec4 modelPoint, java.awt.Rectangle screenRect)
Records feedback about how the specified WWIcon has been processed.- Parameters:
dc- the current DrawContext.icon- the icon which the feedback information refers to.modelPoint- the icon's reference point in model coordinates.screenRect- the icon's bounding rectangle in screen coordinates.
-
-