public abstract class AbstractSurfaceObject extends WWObjectImpl implements SurfaceObject
SceneController
's bulk
rendering of SurfaceObjects. The SceneControllers bulk renders all SurfaceObjects added to the DrawContext
's ordered surface renderable queue during the preRendering pass. While
building the composite representation the SceneController invokes render(DrawContext)
in ordered rendering
mode. To avoid overloading the purpose of the render method, AbstractSurfaceObject does not add itself to the
DrawContext's ordered surface renderable queue during rendering.
Subclasses that do not wish to participate in this composite representation can override this behavior as follows:
makeOrderedPreRenderable(DrawContext)
; do not add this object to the draw context's
ordered renderable queue. Perform any preRender processing necessary for the subclass to pick and render itself.pickOrderedRenderable(DrawContext, PickSupport)
; draw the custom pick representation.makeOrderedRenderable(DrawContext)
; add this object to the draw context's ordered renderable
queue. AbstractSurfaceObject does not add itself to this queue during rendering. render() is called from the
SceneController while building the composite representation because AbstractSurfaceObject adds itself to the ordered
surface renderable queue during preRendering.drawOrderedRenderable(DrawContext)
; draw the
custom representation. Unlike AbstractSurfaceObject subclasses should assume the modelview and projection matrices
are consistent with the current View
.Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractSurfaceObject.CacheEntry
Represents a globe dependent cache entry.
|
protected static class |
AbstractSurfaceObject.SurfaceObjectStateKey
Represents a surface object's current state.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
delegateOwner |
protected boolean |
drawBoundingSectors |
protected boolean |
enableBatchPicking |
protected java.util.Map<java.lang.Object,AbstractSurfaceObject.CacheEntry> |
extentCache |
protected long |
lastModifiedTime |
protected static long |
nextUniqueId |
protected Layer |
pickLayer |
protected PickSupport |
pickSupport |
protected SurfaceObjectTileBuilder |
pickTileBuilder
Support class used to build surface tiles used to draw the pick representation.
|
protected long |
uniqueId |
protected boolean |
visible |
Constructor and Description |
---|
AbstractSurfaceObject()
Creates a new AbstractSurfaceObject, assigning it a unique ID and initializing its last modified time to the
current system time.
|
AbstractSurfaceObject(AbstractSurfaceObject source)
Creates a shallow copy of the specified source shape.
|
Modifier and Type | Method and Description |
---|---|
protected void |
buildPickRepresentation(DrawContext dc)
Builds this AbstractSurfaceObject's pickable representation.
|
protected void |
clearCaches()
Clears this SurfaceObject's internal extent cache.
|
protected Extent |
computeExtent(DrawContext dc)
Computes the surface object's extent.
|
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.
|
protected PickedObject |
createPickedObject(DrawContext dc,
java.awt.Color pickColor)
Create a
PickedObject for this surface object. |
protected SurfaceObjectTileBuilder |
createPickTileBuilder()
Returns a
SurfaceObjectTileBuilder appropriate for building and drawing the surface object's pickable
representation. |
protected void |
drawBoundingSectors(DrawContext dc,
SurfaceTileDrawContext sdc)
Causes this SurfaceObject to render its bounding sectors to the specified region in geographic coordinates.
|
protected abstract void |
drawGeographic(DrawContext dc,
SurfaceTileDrawContext sdc)
Causes the SurfaceObject to render itself to the specified region in geographic coordinates.
|
protected void |
drawOrderedRenderable(DrawContext dc)
Causes the SurfaceObject to render itself.
|
protected void |
drawPickRepresentation(DrawContext dc)
Causes this SurfaceObject to draw a representation of itself suitable for use during picking.
|
java.lang.Object |
getDelegateOwner()
Returns the delegate owner of the surface object.
|
double |
getDistanceFromEye()
Returns zero to indicate that the surface object's distance from the eye is unknown.
|
Extent |
getExtent(DrawContext dc)
Returns the surface object's enclosing volume as an
Extent in model coordinates,
given a specified DrawContext . |
java.lang.Object |
getStateKey(DrawContext dc)
Returns an object that uniquely identifies this renderable's state for the specified draw context.
|
protected long |
getUniqueId()
Returns an integer number uniquely identifying the surface object.
|
protected boolean |
intersectsFrustum(DrawContext dc)
Test if this SurfaceObject intersects the specified draw context's frustum.
|
protected boolean |
intersectsPickFrustum(DrawContext dc)
Test if this SurfaceObject intersects the specified draw context's pick frustums.
|
protected boolean |
intersectsVisibleSector(DrawContext dc)
Test if this SurfaceObject intersects the specified draw context's visible sector.
|
boolean |
isDrawBoundingSectors()
Indicates whether the SurfaceObject draws its bounding sector.
|
boolean |
isEnableBatchPicking()
Indicates whether batch picking is enabled.
|
boolean |
isVisible()
Indicates whether the surface object should be drawn during rendering.
|
protected void |
makeOrderedPreRenderable(DrawContext dc)
Prepares the SurfaceObject as an
OrderedRenderable and adds it to the
DrawContext's ordered surface renderable list. |
protected void |
makeOrderedRenderable(DrawContext dc)
Prepares the SurfaceObject as an
OrderedRenderable and adds it to the
DrawContext's ordered surface renderable list. |
protected static long |
nextUniqueId()
Returns the next unique integer associated with an AbstractSurfaceObject.
|
protected void |
onShapeChanged() |
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.
|
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.
|
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.
|
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.
|
void |
render(DrawContext dc)
Causes this
Renderable to render itself using the provided draw context. |
void |
setDelegateOwner(java.lang.Object owner)
Specifies the delegate owner of the surface object.
|
void |
setDrawBoundingSectors(boolean draw)
Specifies if the SurfaceObject should draw its bounding sector.
|
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.
|
void |
setVisible(boolean visible)
Specifies whether the surface object should be drawn during rendering.
|
protected void |
updateModifiedTime()
Sets the SurfaceObject's modified time to the current system time.
|
onMessage, propertyChange
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSectors
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
protected java.lang.Object delegateOwner
protected boolean drawBoundingSectors
protected boolean enableBatchPicking
protected java.util.Map<java.lang.Object,AbstractSurfaceObject.CacheEntry> extentCache
protected long lastModifiedTime
protected static long nextUniqueId
protected Layer pickLayer
protected PickSupport pickSupport
protected SurfaceObjectTileBuilder pickTileBuilder
protected final long uniqueId
protected boolean visible
public AbstractSurfaceObject()
public AbstractSurfaceObject(AbstractSurfaceObject source)
source
- the shape to copy.protected void buildPickRepresentation(DrawContext dc)
dc
- the draw context to build a representation for.protected void clearCaches()
protected Extent computeExtent(DrawContext dc)
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.dc
- the draw context the extent relates to.protected Extent computeExtent(Globe globe, double verticalExaggeration, java.util.List<Sector> sectors)
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.globe
- the globe the extent relates to.verticalExaggeration
- the globe's vertical surface exaggeration.sectors
- the sectors to bound.protected PickedObject createPickedObject(DrawContext dc, java.awt.Color pickColor)
PickedObject
for this surface object. The PickedObject created by this
method will be added to the pick list to represent the current surface object.dc
- Active draw context.pickColor
- Unique color for this PickedObject.protected SurfaceObjectTileBuilder createPickTileBuilder()
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.protected void drawBoundingSectors(DrawContext dc, SurfaceTileDrawContext sdc)
dc
- the current DrawContext.sdc
- the context containing a geographic region and screen viewport corresponding to a surface tile.SurfaceRenderable.getSectors(DrawContext)
protected abstract void drawGeographic(DrawContext dc, SurfaceTileDrawContext sdc)
dc
- the current draw context.sdc
- the context containing a geographic region and screen viewport corresponding to a surface tile.protected void drawOrderedRenderable(DrawContext dc)
SurfaceTileDrawContext
from the
DrawContext's AVList by querying the key AVKey.SURFACE_TILE_DRAW_CONTEXT
. If
the DrawContext has a SurfaceTileDrawContext attached under that key, this calls drawGeographic(DrawContext, gov.nasa.worldwind.util.SurfaceTileDrawContext)
with the SurfaceTileDrawContext.
Otherwise this logs a warning and returns.dc
- the current DrawContext.protected void drawPickRepresentation(DrawContext dc)
dc
- the current DrawContext.public java.lang.Object getDelegateOwner()
getDelegateOwner
in interface SurfaceObject
public double getDistanceFromEye()
getDistanceFromEye
in interface OrderedRenderable
getDistanceFromEye
in interface SurfaceObject
public Extent getExtent(DrawContext dc)
Extent
in model coordinates,
given a specified DrawContext
.getExtent
in interface SurfaceObject
dc
- the current draw context.public java.lang.Object getStateKey(DrawContext dc)
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.getStateKey
in interface SurfaceRenderable
dc
- the draw context for which to determine this renderable's current state.protected long getUniqueId()
protected boolean intersectsFrustum(DrawContext dc)
dc
- the draw context the SurfaceObject is related to.protected boolean intersectsPickFrustum(DrawContext dc)
dc
- the draw context the SurfaceObject is related to.protected boolean intersectsVisibleSector(DrawContext dc)
dc
- draw context the SurfaceObject is related to.public boolean isDrawBoundingSectors()
true
if the shape draws its outline; false
otherwise.setDrawBoundingSectors(boolean)
public boolean isEnableBatchPicking()
isEnableBatchPicking
in interface SurfaceObject
true
to enable batch picking; false
otherwise.SurfaceObject.setEnableBatchPicking(boolean)
public boolean isVisible()
isVisible
in interface SurfaceObject
protected void makeOrderedPreRenderable(DrawContext dc)
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.dc
- the DrawContext to add to.protected void makeOrderedRenderable(DrawContext dc)
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.dc
- the DrawContext to add to.protected static long nextUniqueId()
protected void onShapeChanged()
public void pick(DrawContext dc, java.awt.Point pickPoint)
pick
in interface OrderedRenderable
pick
in interface SurfaceObject
dc
- the current draw context.pickPoint
- the pick point.protected void pickBatched(DrawContext dc, PickSupport pickSupport)
dc
- the current DrawContext.pickSupport
- the PickSupport to add the SurfaceObject to.protected void pickOrderedRenderable(DrawContext dc, PickSupport pickSupport)
dc
- the current DrawContext.pickSupport
- the PickSupport to add the SurfaceObject to.public void preRender(DrawContext dc)
preRender
in interface PreRenderable
preRender
in interface SurfaceObject
dc
- the current draw context.public void render(DrawContext dc)
Renderable
to render itself using the provided draw context.render
in interface Renderable
dc
- the DrawContext
to be usedDrawContext
public void setDelegateOwner(java.lang.Object owner)
setDelegateOwner
in interface SurfaceObject
owner
- the object to use as the pickable object returned during picking, or null to return the surface
object.public void setDrawBoundingSectors(boolean draw)
true
, the SurfaceObject draws an
outline of its bounding sector in green on top of its shape. The default value is false
.draw
- true
to draw the shape's outline; false
otherwise.public void setEnableBatchPicking(boolean enable)
setEnableBatchPicking
in interface SurfaceObject
enable
- true
to enable batch picking; false
otherwise.public void setVisible(boolean visible)
setVisible
in interface SurfaceObject
visible
- true if the object is to be drawn, otherwise false.protected void updateModifiedTime()