NASA World Wind

gov.nasa.worldwind.render
Class IconRenderer

java.lang.Object
  extended by gov.nasa.worldwind.render.IconRenderer

public class IconRenderer
extends Object

IconRenderer processes collections of WWIcon 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 to true. 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:

KeyDescription
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
protected  class IconRenderer.OrderedIcon
           
protected  class IconRenderer.OrderedText
           
 
Field Summary
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
IconRenderer()
           
 
Method Summary
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, 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, 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 a SelectEvent 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, Iterable<? extends WWIcon> icons, Point pickPoint, Layer layer)
           
protected  void pickIconsInBatch(DrawContext dc, IconRenderer.OrderedIcon uIcon)
           
protected  void recordFeedback(DrawContext dc, WWIcon icon, Vec4 modelPoint, 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, 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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

allowBatchPicking

protected boolean allowBatchPicking

alwaysUseAbsoluteElevation

protected boolean alwaysUseAbsoluteElevation

horizonClippingEnabled

protected boolean horizonClippingEnabled

oglStackHandler

protected OGLStackHandler oglStackHandler

pedestal

protected Pedestal pedestal

pickFrustumClippingEnabled

protected boolean pickFrustumClippingEnabled

pickSupport

protected PickSupport pickSupport

viewClippingEnabled

protected boolean viewClippingEnabled
Constructor Detail

IconRenderer

public IconRenderer()
Method Detail

addToolTip

protected void addToolTip(DrawContext dc,
                          WWIcon icon,
                          Vec4 iconPoint)

applyBackground

protected void applyBackground(DrawContext dc,
                               WWIcon icon,
                               Vec4 screenPoint,
                               double width,
                               double height,
                               double pedestalSpacing,
                               double pedestalScale)

beginDrawIcons

protected void beginDrawIcons(DrawContext dc)

doRecordFeedback

protected void doRecordFeedback(DrawContext dc,
                                WWIcon icon,
                                Vec4 modelPoint,
                                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.

drawIcon

protected Vec4 drawIcon(DrawContext dc,
                        IconRenderer.OrderedIcon uIcon)

drawIconsInBatch

protected void drawIconsInBatch(DrawContext dc,
                                IconRenderer.OrderedIcon uIcon)

drawMany

protected void drawMany(DrawContext dc,
                        Iterable<? extends WWIcon> icons,
                        Layer layer)

endDrawIcons

protected void endDrawIcons(DrawContext dc)

getPedestal

public Pedestal getPedestal()

isAllowBatchPicking

public boolean isAllowBatchPicking()
Indicates whether icons are picked as a batch and therefore a SelectEvent 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)

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.

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.

isHorizonClippingEnabled

public boolean isHorizonClippingEnabled()
Indicates whether horizon clipping is performed.

Returns:
true if horizon clipping is performed, otherwise false.
See Also:
setHorizonClippingEnabled(boolean)

isIconValid

protected static boolean isIconValid(WWIcon icon,
                                     boolean checkPosition)

isPickFrustumClippingEnabled

public boolean isPickFrustumClippingEnabled()
Indicates whether picking volume clipping is performed.

Returns:
true if picking volume clipping is performed, otherwise false.
See Also:
setPickFrustumClippingEnabled(boolean)

isViewClippingEnabled

public boolean isViewClippingEnabled()
Indicates whether view volume clipping is performed.

Returns:
true if view volume clipping is performed, otherwise false.
See Also:
setViewClippingEnabled(boolean)

pick

public void pick(DrawContext dc,
                 Iterable<? extends WWIcon> icons,
                 Point pickPoint,
                 Layer layer)

pickIconsInBatch

protected void pickIconsInBatch(DrawContext dc,
                                IconRenderer.OrderedIcon uIcon)

recordFeedback

protected void recordFeedback(DrawContext dc,
                              WWIcon icon,
                              Vec4 modelPoint,
                              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.

render

public void render(DrawContext dc,
                   Iterable<? extends WWIcon> icons)

setAllowBatchPicking

public void setAllowBatchPicking(boolean allowBatchPicking)
Specifies whether batch picking is allowed. If so, a SelectEvent 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.

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 to true 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.

setDepthFunc

protected void setDepthFunc(DrawContext dc,
                            IconRenderer.OrderedIcon uIcon,
                            Vec4 screenPoint)

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 is false, horizon clipping is not performed.

Parameters:
horizonClippingEnabled - true if horizon clipping should be performed, otherwise false.
See Also:
setViewClippingEnabled(boolean)

setPedestal

public void setPedestal(Pedestal pedestal)

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 is false, picking volume clipping is not performed.

Parameters:
pickFrustumClippingEnabled - true if picking clipping should be performed, otherwise false.

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 is false, view volume clipping is not performed.

Parameters:
viewClippingEnabled - true if view clipping should be performed, otherwise false.
See Also:
setHorizonClippingEnabled(boolean)

toString

public String toString()
Overrides:
toString in class Object

NASA World Wind