Class IconRenderer


  • public class IconRenderer
    extends java.lang.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:

    WWIcon Feedback Properties
    KeyDescription
    AVKey.FEEDBACK_REFERENCE_POINTThe icon's reference point in model coordinates.
    AVKey.FEEDBACK_SCREEN_BOUNDSThe icon's bounding rectangle in screen coordinates.
    • Field Detail

      • horizonClippingEnabled

        protected boolean horizonClippingEnabled
      • viewClippingEnabled

        protected boolean viewClippingEnabled
      • pickFrustumClippingEnabled

        protected boolean pickFrustumClippingEnabled
      • alwaysUseAbsoluteElevation

        protected boolean alwaysUseAbsoluteElevation
      • allowBatchPicking

        protected boolean allowBatchPicking
    • Constructor Detail

      • IconRenderer

        public IconRenderer()
    • 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, otherwise false.
        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 is false, horizon clipping is not performed.
        Parameters:
        horizonClippingEnabled - true if horizon clipping should be performed, otherwise false.
        See Also:
        setViewClippingEnabled(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)
      • 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 true, view volume clipping is not performed.
        Parameters:
        viewClippingEnabled - true if view clipping should be performed, otherwise false.
        See Also:
        setHorizonClippingEnabled(boolean)
      • 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)
      • 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.
      • 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 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.
      • 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)
      • 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.
      • 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)
      • beginDrawIcons

        protected void beginDrawIcons​(DrawContext dc)
      • endDrawIcons

        protected void endDrawIcons​(DrawContext dc)
      • applyBackground

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

        public java.lang.String toString()
        Overrides:
        toString in class java.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.