Package gov.nasa.worldwind.render
Class IconRenderer
- java.lang.Object
-
- gov.nasa.worldwind.render.IconRenderer
-
public class IconRenderer extends java.lang.Object
IconRenderer processes collections ofWWIcon
instances 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_ENABLED
set 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_POINT
The icon's reference point in model coordinates. AVKey.FEEDBACK_SCREEN_BOUNDS
The icon's bounding rectangle in screen coordinates.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
IconRenderer.OrderedIcon
protected class
IconRenderer.OrderedText
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allowBatchPicking
protected boolean
alwaysUseAbsoluteElevation
protected boolean
horizonClippingEnabled
protected OGLStackHandler
oglStackHandler
protected Pedestal
pedestal
protected boolean
pickFrustumClippingEnabled
protected PickSupport
pickSupport
protected boolean
viewClippingEnabled
-
Constructor Summary
Constructors Constructor Description IconRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addToolTip(DrawContext dc, WWIcon icon, Vec4 iconPoint)
protected void
applyBackground(DrawContext dc, WWIcon icon, Vec4 screenPoint, double width, double height, double pedestalSpacing, double pedestalScale)
protected void
beginDrawIcons(DrawContext dc)
protected void
doRecordFeedback(DrawContext dc, WWIcon icon, Vec4 modelPoint, java.awt.Rectangle screenRect)
Records feedback about how the specified WWIcon has been processed.protected Vec4
drawIcon(DrawContext dc, IconRenderer.OrderedIcon uIcon)
protected void
drawIconsInBatch(DrawContext dc, IconRenderer.OrderedIcon uIcon)
protected void
drawMany(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons, Layer layer)
protected void
endDrawIcons(DrawContext dc)
Pedestal
getPedestal()
boolean
isAllowBatchPicking()
Indicates whether icons are picked as a batch and therefore aSelectEvent
will contain only one icon from a given layer.boolean
isAlwaysUseAbsoluteElevation()
Indicates whether an icon's elevation is treated as an offset from the terrain or an absolute elevation above sea level.protected boolean
isFeedbackEnabled(DrawContext dc, WWIcon icon)
Returns true if the IconRenderer should record feedback about how the specified WWIcon has been processed.boolean
isHorizonClippingEnabled()
Indicates whether horizon clipping is performed.protected static boolean
isIconValid(WWIcon icon, boolean checkPosition)
boolean
isPickFrustumClippingEnabled()
Indicates whether picking volume clipping is performed.boolean
isViewClippingEnabled()
Indicates whether view volume clipping is performed.void
pick(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons, java.awt.Point pickPoint, Layer layer)
protected void
pickIconsInBatch(DrawContext dc, IconRenderer.OrderedIcon uIcon)
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.void
render(DrawContext dc, java.lang.Iterable<? extends WWIcon> icons)
void
setAllowBatchPicking(boolean allowBatchPicking)
Specifies whether batch picking is allowed.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.protected void
setDepthFunc(DrawContext dc, IconRenderer.OrderedIcon uIcon, Vec4 screenPoint)
void
setHorizonClippingEnabled(boolean horizonClippingEnabled)
Indicates whether to render icons beyond the horizon.void
setPedestal(Pedestal pedestal)
void
setPickFrustumClippingEnabled(boolean pickFrustumClippingEnabled)
Indicates whether to render icons outside the picking volume when in pick mode.void
setViewClippingEnabled(boolean viewClippingEnabled)
Indicates whether to render icons outside the view volume.java.lang.String
toString()
-
-
-
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:
true
if 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
-true
if horizon clipping should be performed, otherwisefalse
.- See Also:
setViewClippingEnabled(boolean)
-
isViewClippingEnabled
public boolean isViewClippingEnabled()
Indicates whether view volume clipping is performed.- Returns:
true
if 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
-true
if view clipping should be performed, otherwisefalse
.- See Also:
setHorizonClippingEnabled(boolean)
-
isPickFrustumClippingEnabled
public boolean isPickFrustumClippingEnabled()
Indicates whether picking volume clipping is performed.- Returns:
true
if 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
-true
if 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:
true
if icon elevations are treated as absolute,false
if 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 totrue
causes the elevation to be treated as an absolute elevation above sea level.- Parameters:
alwaysUseAbsoluteElevation
-true
to treat icon elevations as absolute,false
to treat them as offsets from the terrain.
-
isAllowBatchPicking
public boolean isAllowBatchPicking()
Indicates whether icons are picked as a batch and therefore aSelectEvent
will 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, aSelectEvent
from 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:
toString
in 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.
-
-