Class AbstractSurfaceObject

    • Field Detail

      • visible

        protected boolean visible
      • uniqueId

        protected final long uniqueId
      • lastModifiedTime

        protected long lastModifiedTime
      • delegateOwner

        protected java.lang.Object delegateOwner
      • enableBatchPicking

        protected boolean enableBatchPicking
      • drawBoundingSectors

        protected boolean drawBoundingSectors
      • pickLayer

        protected Layer pickLayer
      • pickTileBuilder

        protected SurfaceObjectTileBuilder pickTileBuilder
        Support class used to build surface tiles used to draw the pick representation.
      • nextUniqueId

        protected static long nextUniqueId
    • Constructor Detail

      • AbstractSurfaceObject

        public AbstractSurfaceObject()
        Creates a new AbstractSurfaceObject, assigning it a unique ID and initializing its last modified time to the current system time.
      • AbstractSurfaceObject

        public AbstractSurfaceObject​(AbstractSurfaceObject source)
        Creates a shallow copy of the specified source shape.
        Parameters:
        source - the shape to copy.
    • Method Detail

      • nextUniqueId

        protected static long nextUniqueId()
        Returns the next unique integer associated with an AbstractSurfaceObject. This method is synchronized to ensure that two threads calling simultaneously receive different values. Since this method is called from AbstractSurfaceObject's constructor, this is critical to ensure that AbstractSurfaceObject can be safely constructed on separate threads.
        Returns:
        the next unique integer.
      • isVisible

        public boolean isVisible()
        Indicates whether the surface object should be drawn during rendering.
        Specified by:
        isVisible in interface SurfaceObject
        Returns:
        true if the object is to be drawn, otherwise false.
      • setVisible

        public void setVisible​(boolean visible)
        Specifies whether the surface object should be drawn during rendering.
        Specified by:
        setVisible in interface SurfaceObject
        Parameters:
        visible - true if the object is to be drawn, otherwise false.
      • getStateKey

        public java.lang.Object getStateKey​(DrawContext dc)
        Returns an object that uniquely identifies this renderable's state for the specified draw context.

        Callers can perform an equality test on two state keys using Object.equals(Object) in order to determine whether or not a renderable has changed. The returned object is guaranteed to be globally unique with respect to other SurfaceRenderable state keys; an equality test with a state key from another renderable always returns false.

        Specified by:
        getStateKey in interface SurfaceRenderable
        Parameters:
        dc - the draw context for which to determine this renderable's current state.
        Returns:
        an object representing this renderable's current state.
      • getDistanceFromEye

        public double getDistanceFromEye()
        Returns zero to indicate that the surface object's distance from the eye is unknown. SurfaceObjects are processed on the DrawContext's ordered surface renderable queue. Ordered surface renderables do not utilize the renderable's distance from the eye to determine draw order.
        Specified by:
        getDistanceFromEye in interface OrderedRenderable
        Specified by:
        getDistanceFromEye in interface SurfaceObject
        Returns:
        zero, to indicate that the object's distance from the eye is unknown.
      • getDelegateOwner

        public java.lang.Object getDelegateOwner()
        Returns the delegate owner of the surface object. If non-null, the returned object replaces the surface object as the pickable object returned during picking. If null, the surface object itself is the pickable object returned during picking.
        Specified by:
        getDelegateOwner in interface SurfaceObject
        Returns:
        the object used as the pickable object returned during picking, or null to indicate the the surface object is returned during picking.
      • setDelegateOwner

        public void setDelegateOwner​(java.lang.Object owner)
        Specifies the delegate owner of the surface object. If non-null, the delegate owner replaces the surface object as the pickable object returned during picking. If null, the surface object itself is the pickable object returned during picking.
        Specified by:
        setDelegateOwner in interface SurfaceObject
        Parameters:
        owner - the object to use as the pickable object returned during picking, or null to return the surface object.
      • isDrawBoundingSectors

        public boolean isDrawBoundingSectors()
        Indicates whether the SurfaceObject draws its bounding sector.
        Returns:
        true if the shape draws its outline; false otherwise.
        See Also:
        setDrawBoundingSectors(boolean)
      • setDrawBoundingSectors

        public void setDrawBoundingSectors​(boolean draw)
        Specifies if the SurfaceObject should draw its bounding sector. If true, the SurfaceObject draws an outline of its bounding sector in green on top of its shape. The default value is false.
        Parameters:
        draw - true to draw the shape's outline; false otherwise.
      • setEnableBatchPicking

        public void setEnableBatchPicking​(boolean enable)
        Specifies whether adjacent SurfaceObjects in the DrawContext's ordered surface renderable list may be rendered together during picking if they are contained in the same layer. This increases performance and there is seldom a reason to disable it.
        Specified by:
        setEnableBatchPicking in interface SurfaceObject
        Parameters:
        enable - true to enable batch picking; false otherwise.
      • getExtent

        public Extent getExtent​(DrawContext dc)
        Returns the surface object's enclosing volume as an Extent in model coordinates, given a specified DrawContext.
        Specified by:
        getExtent in interface SurfaceObject
        Parameters:
        dc - the current draw context.
        Returns:
        the surface object's Extent in model coordinates.
      • preRender

        public void preRender​(DrawContext dc)
        Causes the surface object to prepare a representation of itself which can be drawn on the surface terrain, using the provided draw context.
        Specified by:
        preRender in interface PreRenderable
        Specified by:
        preRender in interface SurfaceObject
        Parameters:
        dc - the current draw context.
      • pick

        public void pick​(DrawContext dc,
                         java.awt.Point pickPoint)
        Causes the surface object to draw a pickable representation of itself on the surface terrain, using the provided draw context.
        Specified by:
        pick in interface OrderedRenderable
        Specified by:
        pick in interface SurfaceObject
        Parameters:
        dc - the current draw context.
        pickPoint - the pick point.
      • render

        public void render​(DrawContext dc)
        Causes this Renderable to render itself using the provided draw context.
        Specified by:
        render in interface Renderable
        Parameters:
        dc - the DrawContext to be used
        See Also:
        DrawContext
      • getUniqueId

        protected long getUniqueId()
        Returns an integer number uniquely identifying the surface object. This number is unique relative to other instances of SurfaceObject, but is not necessarily globally unique.
        Returns:
        the surface object's unique identifier.
      • updateModifiedTime

        protected void updateModifiedTime()
        Sets the SurfaceObject's modified time to the current system time. This causes cached representations of this SurfaceObject to be refreshed.
      • clearCaches

        protected void clearCaches()
        Clears this SurfaceObject's internal extent cache.
      • onShapeChanged

        protected void onShapeChanged()
      • computeExtent

        protected Extent computeExtent​(DrawContext dc)
        Computes the surface object's extent. Uses the sector list returned by SurfaceRenderable.getSectors(DrawContext) to compute the extent bounding this object's sectors on the draw context's surface. This returns null if the surface object has no sectors.
        Parameters:
        dc - the draw context the extent relates to.
        Returns:
        the surface object's extent. Returns null if the surface object has no sectors.
      • computeExtent

        protected Extent computeExtent​(Globe globe,
                                       double verticalExaggeration,
                                       java.util.List<Sector> sectors)
        Computes an extent bounding the the specified sectors on the specified Globe's surface. If the list contains a single sector this returns a box created by calling Sector.computeBoundingBox(gov.nasa.worldwind.globes.Globe, double, gov.nasa.worldwind.geom.Sector). If the list contains more than one sector this returns a Box containing the corners of the boxes bounding each sector. This returns null if the sector list is empty.
        Parameters:
        globe - the globe the extent relates to.
        verticalExaggeration - the globe's vertical surface exaggeration.
        sectors - the sectors to bound.
        Returns:
        an extent for the specified sectors on the specified Globe.
      • intersectsFrustum

        protected boolean intersectsFrustum​(DrawContext dc)
        Test if this SurfaceObject intersects the specified draw context's frustum. During picking mode, this tests intersection against all of the draw context's pick frustums. During rendering mode, this tests intersection against the draw context's viewing frustum.
        Parameters:
        dc - the draw context the SurfaceObject is related to.
        Returns:
        true if this SurfaceObject intersects the draw context's frustum; false otherwise.
      • intersectsPickFrustum

        protected boolean intersectsPickFrustum​(DrawContext dc)
        Test if this SurfaceObject intersects the specified draw context's pick frustums.
        Parameters:
        dc - the draw context the SurfaceObject is related to.
        Returns:
        true if this SurfaceObject intersects any of the draw context's pick frustums; false otherwise.
      • intersectsVisibleSector

        protected boolean intersectsVisibleSector​(DrawContext dc)
        Test if this SurfaceObject intersects the specified draw context's visible sector. This returns false if the draw context's visible sector is null.
        Parameters:
        dc - draw context the SurfaceObject is related to.
        Returns:
        true if this SurfaceObject intersects the draw context's visible sector; false otherwise.
      • makeOrderedPreRenderable

        protected void makeOrderedPreRenderable​(DrawContext dc)
        Prepares the SurfaceObject as an OrderedRenderable and adds it to the DrawContext's ordered surface renderable list. Additionally, this prepares the SurfaceObject's pickable representation if the SurfaceObject's containing layer is enabled for picking and the SurfaceObject intersects one of the DrawContext's picking frustums.

        During ordered preRendering, the SceneController builds a composite representation of this SurfaceObject and any other SurfaceObject on the DrawContext's ordered surface renderable list. The SceneController causes each SurfaceObject's to draw itself into the composite representation by calling its render(DrawContext) method in ordered rendering mode.

        Parameters:
        dc - the DrawContext to add to.
      • makeOrderedRenderable

        protected void makeOrderedRenderable​(DrawContext dc)
        Prepares the SurfaceObject as an OrderedRenderable and adds it to the DrawContext's ordered surface renderable list. We ignore this call during rendering mode to suppress calls to render(DrawContext) during ordered rendering mode. The SceneController already invokes render during ordered picking mode to build a composite representation of the SurfaceObjects.

        During ordered picking, the SceneController invokes the SurfaceObject's pick(DrawContext, java.awt.Point) method.

        Parameters:
        dc - the DrawContext to add to.
      • pickOrderedRenderable

        protected void pickOrderedRenderable​(DrawContext dc,
                                             PickSupport pickSupport)
        Causes the SurfaceObject to draw itself in a unique pick color, and add itself as a pickable object to the specified pickSupport.
        Parameters:
        dc - the current DrawContext.
        pickSupport - the PickSupport to add the SurfaceObject to.
      • createPickedObject

        protected PickedObject createPickedObject​(DrawContext dc,
                                                  java.awt.Color pickColor)
        Create a PickedObject for this surface object. The PickedObject created by this method will be added to the pick list to represent the current surface object.
        Parameters:
        dc - Active draw context.
        pickColor - Unique color for this PickedObject.
        Returns:
        A new picked object.
      • pickBatched

        protected void pickBatched​(DrawContext dc,
                                   PickSupport pickSupport)
        Causes adjacent SurfaceObjects in the DrawContext's ordered surface renderable list to draw themselves in in a unique pick color, and adds themselves as pickable objects to the specified pickSupport. Adjacent SurfaceObjects are removed from the DrawContext's list and processed until one is encountered that has a different containing layer or is not enabled for batch picking.
        Parameters:
        dc - the current DrawContext.
        pickSupport - the PickSupport to add the SurfaceObject to.
      • drawGeographic

        protected abstract void drawGeographic​(DrawContext dc,
                                               SurfaceTileDrawContext sdc)
        Causes the SurfaceObject to render itself to the specified region in geographic coordinates. The specified viewport denotes the geographic region and its corresponding screen viewport.
        Parameters:
        dc - the current draw context.
        sdc - the context containing a geographic region and screen viewport corresponding to a surface tile.
      • buildPickRepresentation

        protected void buildPickRepresentation​(DrawContext dc)
        Builds this AbstractSurfaceObject's pickable representation. This method is called during the preRender phase, and is therefore free to modify the framebuffer contents to create the pickable representation.
        Parameters:
        dc - the draw context to build a representation for.
      • drawPickRepresentation

        protected void drawPickRepresentation​(DrawContext dc)
        Causes this SurfaceObject to draw a representation of itself suitable for use during picking.
        Parameters:
        dc - the current DrawContext.
      • createPickTileBuilder

        protected SurfaceObjectTileBuilder createPickTileBuilder()
        Returns a SurfaceObjectTileBuilder appropriate for building and drawing the surface object's pickable representation. The returned SurfaceObjectTileBuilder's is configured to create textures with the GL_ALPHA8 format, and to use GL_NEAREST filtering. This reduces a surface object's pick texture resources by a factor of 4, and ensures that linear texture filtering and mip-mapping is disabled while drawing the pick tiles.
        Returns:
        a SurfaceObjectTileBuilder used for building and drawing the surface object's pickable representation.
      • drawBoundingSectors

        protected void drawBoundingSectors​(DrawContext dc,
                                           SurfaceTileDrawContext sdc)
        Causes this SurfaceObject to render its bounding sectors to the specified region in geographic coordinates. The specified viewport denotes the geographic region and its corresponding screen viewport.

        The bounding sectors are rendered as a 1 pixel wide green outline.

        Parameters:
        dc - the current DrawContext.
        sdc - the context containing a geographic region and screen viewport corresponding to a surface tile.
        See Also:
        SurfaceRenderable.getSectors(DrawContext)