Class AbstractShape
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.render.AbstractShape
-
- All Implemented Interfaces:
AVList
,Draggable
,MessageListener
,Exportable
,ExtentHolder
,Movable
,Movable2
,Attributable
,GeographicExtent
,Highlightable
,OrderedRenderable
,PreRenderable
,Renderable
,Restorable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
AbstractGeneralShape
,AntennaAxes
,AntennaModel
,ExtrudedPolygon
,Path
,Polygon
,RadarVolume
,RigidShape
public abstract class AbstractShape extends WWObjectImpl implements Highlightable, OrderedRenderable, Movable, Movable2, ExtentHolder, GeographicExtent, Exportable, Restorable, PreRenderable, Attributable, Draggable
Provides a base class form several geometricRenderable
s. Implements common attribute handling and rendering flow for outlined shapes. Provides common defaults and common export code.In order to support simultaneous use of this shape with multiple globes (windows), this shape maintains a cache of data computed relative to each globe. During rendering, the data for the currently active globe, as indicated in the draw context, is made current. Subsequently called methods rely on the existence of this current data cache entry.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractShape.AbstractShapeData
Holds the globe-dependent data captured in this shape's data cache.
-
Field Summary
Fields Modifier and Type Field Description protected ShapeAttributes
activeAttributes
The attributes active for a particular pick and render pass.protected int
altitudeMode
protected OGLStackHandler
BEogsh
protected AbstractShape.AbstractShapeData
currentData
Identifies the active globe-dependent data for the current invocation ofrender(DrawContext)
.protected static int
DEFAULT_ALTITUDE_MODE
The default altitude mode.protected static int
DEFAULT_GEOMETRY_GENERATION_INTERVAL
The default geometry regeneration interval.protected static Material
DEFAULT_HIGHLIGHT_MATERIAL
The default highlight color.protected static Material
DEFAULT_INTERIOR_MATERIAL
The default interior color.protected static Material
DEFAULT_OUTLINE_MATERIAL
The default outline color.protected static int
DEFAULT_OUTLINE_PICK_WIDTH
The default outline pick width.protected static ShapeAttributes
defaultAttributes
The attributes used if attributes are not specified.protected java.lang.Object
delegateOwner
protected boolean
dragEnabled
protected DraggableSupport
draggableSupport
protected boolean
enableBatchPicking
protected boolean
enableBatchRendering
protected boolean
enableDepthOffset
protected ShapeAttributes
highlightAttrs
This shape's highlighted attributes.protected boolean
highlighted
protected long
maxExpiryTime
protected long
minExpiryTime
protected ShapeAttributes
normalAttrs
This shape's normal, non-highlighted attributes.protected int
outlinePickWidth
protected OutlinedShape
outlineShapeRenderer
Outlined shapes are drawn asOutlinedShape
s.protected Layer
pickLayer
protected PickSupport
pickSupport
protected Position
referencePosition
protected Sector
sector
protected ShapeDataCache
shapeDataCache
Holds globe-dependent computed data.protected SurfaceShape
surfaceShape
protected static int
VBO_THRESHOLD
Indicates the number of vertices that must be present in order for VBOs to be used to render this shape.protected boolean
viewDistanceExpiration
protected boolean
visible
-
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractShape()
Invokesinitialize()
during construction and sets the data cache's expiration time to a default value.protected
AbstractShape(AbstractShape source)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addOrderedRenderable(DrawContext dc)
Adds this shape to the draw context's ordered renderable list.protected OGLStackHandler
beginDrawing(DrawContext dc, int attrMask)
Establish the OpenGL state needed to draw this shape.protected void
checkViewDistanceExpiration(DrawContext dc)
Determines whether this shape's geometry should be invalidated because the view distance changed, and if so, invalidates the geometry.protected void
clearCachedVbos(DrawContext dc)
Removes from the GPU resource cache the entry for the current data cache entry's VBOs.protected Extent
computeExtentFromPositions(Globe globe, double verticalExaggeration, java.lang.Iterable<? extends LatLon> positions)
Computes this shape's approximate extent from its positions.protected Vec4
computePoint(DrawContext dc, Terrain terrain, Position position)
Computes a model-coordinate point from a position, applying this shape's altitude mode, and usingCLAMP_TO_GROUND
if the current globe is 2D.protected Vec4
computePoint(Terrain terrain, Position position)
Computes a model-coordinate point from a position, applying this shape's altitude mode.protected int
countTriangleVertices(java.util.List<java.util.List<java.lang.Integer>> prims, java.util.List<java.lang.Integer> primTypes)
protected abstract AbstractShape.AbstractShapeData
createCacheEntry(DrawContext dc)
Creates and returns a new cache entry specific to the subclass.protected PickedObject
createPickedObject(int colorCode)
Creates aPickedObject
for this shape and the specified unique pick color code.protected SurfaceShape
createSurfaceShape()
Returns aSurfaceShape
that corresponds to this Path and is used for drawing on 2D globes.protected void
determineActiveAttributes()
Determines which attributes -- normal, highlight or default -- to use each frame.protected void
doDrag(DragContext dragContext)
protected abstract void
doDrawInterior(DrawContext dc)
Draws this shape's interior.protected void
doDrawOrderedRenderable(DrawContext dc, PickSupport pickCandidates)
Draw this shape as an ordered renderable.protected abstract void
doDrawOutline(DrawContext dc)
Draws this shape's outline.protected abstract void
doExportAsKML(javax.xml.stream.XMLStreamWriter xmlWriter)
Exports shape-specific fields.protected void
doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
protected abstract boolean
doMakeOrderedRenderable(DrawContext dc)
Produces the geometry and other state necessary to represent this shape as an ordered renderable.protected void
doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
void
drag(DragContext dragContext)
Drag the object given the providedDragContext
.protected void
drawBatched(DrawContext dc)
Draws this ordered renderable and all subsequent Path ordered renderables in the ordered renderable list.protected void
drawInterior(DrawContext dc)
Draws this shape's interior.protected void
drawOrderedRenderable(DrawContext dc)
Draws this shape as an ordered renderable.protected void
drawOutline(DrawContext dc)
Draws this shape's outline.protected void
endDrawing(DrawContext dc)
Pop the state set inbeginDrawing(DrawContext, int)
.void
export(java.lang.String mimeType, java.lang.Object output)
Exports the object to a format.protected void
exportAsKML(java.lang.Object output)
Export the placemark to KML as a<Placemark>
element.protected abstract void
fillVBO(DrawContext dc)
Fill this shape's vertex buffer objects.ShapeAttributes
getActiveAttributes()
Returns this shape's currently active attributes, as determined during the most recent call todetermineActiveAttributes()
.int
getAltitudeMode()
Returns this shape's altitude mode.ShapeAttributes
getAttributes()
Returns this shape's normal (as opposed to highlight) attributes.protected AbstractShape.AbstractShapeData
getCurrentData()
Returns the data cache entry for the current rendering.java.lang.Object
getDelegateOwner()
double
getDistanceFromEye()
Returns the ordered renderable's distance from the current view's eye point.Extent
getExtent()
Returns this shape's extent in model coordinates.Extent
getExtent(Globe globe, double verticalExaggeration)
Returns the objects enclosing volume as anExtent
in model coordinates, given a specifiedGlobe
and vertical exaggeration (seeSceneController.getVerticalExaggeration()
.long
getGeometryRegenerationInterval()
Indicates the maximum length of time between geometry regenerations.ShapeAttributes
getHighlightAttributes()
Returns this shape's highlight attributes.int
getOutlinePickWidth()
Indicates the outline line width to use during picking.Vec4
getReferencePoint()
Returns the Cartesian coordinates of this shape's reference position as computed during the most recent rendering.java.lang.String
getRestorableState()
Returns an XML document string describing the object's state.protected int[]
getVboIds(DrawContext dc)
Get or create OpenGL resource IDs for the current data cache entry.protected abstract void
initialize()
Called during construction to establish any subclass-specific state such as different default values than those set by this class.abstract java.util.List<Intersection>
intersect(Line line, Terrain terrain)
Compute the intersections of a specified line with this shape.protected boolean
intersectsFrustum(DrawContext dc)
Determines whether this shape intersects the view frustum.boolean
isDragEnabled()
Indicates whether the object is enabled for dragging.boolean
isEnableBatchPicking()
Indicates whether batch picking is enabled.boolean
isEnableBatchRendering()
Indicates whether batch rendering is enabled for the concrete shape type of this shape.boolean
isEnableDepthOffset()
Indicates whether the filled sides of this shape should be offset towards the viewer to help eliminate artifacts when two or more faces of this or other filled shapes are coincident.java.lang.String
isExportFormatSupported(java.lang.String mimeType)
Does this object support a certain export format?boolean
isHighlighted()
Indicates whether to highlight the shape.protected abstract boolean
isOrderedRenderableValid(DrawContext dc)
Determines whether this shape's ordered renderable state is valid and can be rendered.protected boolean
isTerrainDependent()
Indicates whether this shape's geometry depends on the terrain.boolean
isViewDistanceExpiration()
Indicates whether this shape's terrain-dependent geometry is continually computed as its distance from the eye point changes.boolean
isVisible()
Indicates whether this shape is drawn during rendering.protected void
makeOrderedRenderable(DrawContext dc)
Determines whether to add this shape to the draw context's ordered renderable list.protected WWTexture
makeTexture(java.lang.Object imageSource)
Creates aWWTexture
for a specified image source.void
move(Position delta)
Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.void
moveTo(Globe globe, Position position)
Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.protected boolean
mustApplyLighting(DrawContext dc)
Indicates whether standard lighting must be applied by consulting the current active attributes.protected boolean
mustApplyLighting(DrawContext dc, ShapeAttributes activeAttrs)
Indicates whether standard lighting must be applied by consulting either the specified active attributes or the current active attributes.protected abstract boolean
mustApplyTexture(DrawContext dc)
Indicates whether texture should be applied to this shape.protected boolean
mustCreateNormals(DrawContext dc)
Indicates whether normal vectors must be computed by consulting the current active attributes.protected boolean
mustCreateNormals(DrawContext dc, ShapeAttributes activeAttrs)
Indicates whether normal vectors must be computed by consulting either the specified active attributes or the current active attributes.protected boolean
mustDrawInterior()
Indicates whether this shape's interior must be drawn.protected boolean
mustDrawOutline()
Indicates whether this shape's outline must be drawn.protected boolean
mustRegenerateGeometry(DrawContext dc)
Indicates whether this shape's renderable geometry must be recomputed, either as a result of an attribute or property change or the expiration of the geometry regeneration interval.void
pick(DrawContext dc, java.awt.Point pickPoint)
Executes a pick of the ordered renderable.protected void
prepareToDrawInterior(DrawContext dc, ShapeAttributes activeAttrs, ShapeAttributes defaultAttrs)
Establishes OpenGL state for drawing the interior, including setting the color/material.protected void
prepareToDrawOutline(DrawContext dc, ShapeAttributes activeAttrs, ShapeAttributes defaultAttrs)
Establishes OpenGL state for drawing the outline, including setting the color/material, line smoothing, line width and stipple.void
preRender(DrawContext dc)
void
render(DrawContext dc)
Causes thisRenderable
to render itself using the provided draw context.protected void
reset()
Invalidates computed values.void
restoreState(java.lang.String stateInXml)
Restores the object's state to what is described in the specified XML document string.void
setAltitudeMode(int altitudeMode)
Specifies this shape's altitude mode, one ofWorldWind.ABSOLUTE
,WorldWind.RELATIVE_TO_GROUND
orWorldWind.CLAMP_TO_GROUND
.void
setAttributes(ShapeAttributes normalAttrs)
Specifies this shape's normal (as opposed to highlight) attributes.void
setDelegateOwner(java.lang.Object delegateOwner)
void
setDragEnabled(boolean enabled)
Controls whether the object is enabled for dragging.void
setEnableBatchPicking(boolean enableBatchPicking)
Specifies whether adjacent shapes of this shape's concrete type in the ordered renderable list may be pick-tested together if they are contained in the same layer.void
setEnableBatchRendering(boolean enableBatchRendering)
Specifies whether adjacent shapes of this shape's concrete type in the ordered renderable list may be rendered together if they are contained in the same layer.void
setEnableDepthOffset(boolean enableDepthOffset)
Specifies whether the filled sides of this shape should be offset towards the viewer to help eliminate artifacts when two or more faces of this or other filled shapes are coincident.void
setGeometryRegenerationInterval(int geometryRegenerationInterval)
Specifies the maximum length of time between geometry regenerations.void
setHighlightAttributes(ShapeAttributes highlightAttrs)
Specifies this shape's highlight attributes.void
setHighlighted(boolean highlighted)
Specifies whether to highlight the shape.void
setOutlinePickWidth(int outlinePickWidth)
Specifies the outline line width to use during picking.void
setReferencePosition(Position referencePosition)
Specifies the position to use as a reference position for computed geometry.void
setViewDistanceExpiration(boolean viewDistanceExpiration)
Specifies whether this shape's terrain-dependent geometry is continually computed as its distance from the eye point changes.void
setVisible(boolean visible)
Specifies whether this shape is drawn during rendering.protected boolean
shouldUseVBOs(DrawContext dc)
Indicates whether this shape should use OpenGL vertex buffer objects.protected void
updateSurfaceShape()
Sets surface shape parameters prior to picking and rendering the 2D shape used to represent this shape on 2D globes.-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
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
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from interface gov.nasa.worldwind.render.GeographicExtent
getSector
-
Methods inherited from interface gov.nasa.worldwind.Movable
getReferencePosition, moveTo
-
Methods inherited from interface gov.nasa.worldwind.Movable2
getReferencePosition
-
-
-
-
Field Detail
-
DEFAULT_INTERIOR_MATERIAL
protected static final Material DEFAULT_INTERIOR_MATERIAL
The default interior color.
-
DEFAULT_OUTLINE_MATERIAL
protected static final Material DEFAULT_OUTLINE_MATERIAL
The default outline color.
-
DEFAULT_HIGHLIGHT_MATERIAL
protected static final Material DEFAULT_HIGHLIGHT_MATERIAL
The default highlight color.
-
DEFAULT_ALTITUDE_MODE
protected static final int DEFAULT_ALTITUDE_MODE
The default altitude mode.- See Also:
- Constant Field Values
-
DEFAULT_OUTLINE_PICK_WIDTH
protected static final int DEFAULT_OUTLINE_PICK_WIDTH
The default outline pick width.- See Also:
- Constant Field Values
-
DEFAULT_GEOMETRY_GENERATION_INTERVAL
protected static final int DEFAULT_GEOMETRY_GENERATION_INTERVAL
The default geometry regeneration interval.- See Also:
- Constant Field Values
-
VBO_THRESHOLD
protected static final int VBO_THRESHOLD
Indicates the number of vertices that must be present in order for VBOs to be used to render this shape.
-
defaultAttributes
protected static ShapeAttributes defaultAttributes
The attributes used if attributes are not specified.
-
normalAttrs
protected ShapeAttributes normalAttrs
This shape's normal, non-highlighted attributes.
-
highlightAttrs
protected ShapeAttributes highlightAttrs
This shape's highlighted attributes.
-
activeAttributes
protected ShapeAttributes activeAttributes
The attributes active for a particular pick and render pass. These are determined according to the highlighting mode.
-
highlighted
protected boolean highlighted
-
dragEnabled
protected boolean dragEnabled
-
visible
protected boolean visible
-
altitudeMode
protected int altitudeMode
-
enableBatchRendering
protected boolean enableBatchRendering
-
enableBatchPicking
protected boolean enableBatchPicking
-
enableDepthOffset
protected boolean enableDepthOffset
-
outlinePickWidth
protected int outlinePickWidth
-
sector
protected Sector sector
-
referencePosition
protected Position referencePosition
-
delegateOwner
protected java.lang.Object delegateOwner
-
maxExpiryTime
protected long maxExpiryTime
-
minExpiryTime
protected long minExpiryTime
-
viewDistanceExpiration
protected boolean viewDistanceExpiration
-
surfaceShape
protected SurfaceShape surfaceShape
-
BEogsh
protected OGLStackHandler BEogsh
-
pickLayer
protected Layer pickLayer
-
pickSupport
protected PickSupport pickSupport
-
shapeDataCache
protected ShapeDataCache shapeDataCache
Holds globe-dependent computed data. One entry per globe encountered duringrender(DrawContext)
.
-
draggableSupport
protected DraggableSupport draggableSupport
-
currentData
protected AbstractShape.AbstractShapeData currentData
Identifies the active globe-dependent data for the current invocation ofrender(DrawContext)
. The active data is drawn from this shape's data cache at the beginning of therender
method.
-
outlineShapeRenderer
protected OutlinedShape outlineShapeRenderer
Outlined shapes are drawn asOutlinedShape
s.
-
-
Constructor Detail
-
AbstractShape
protected AbstractShape()
Invokesinitialize()
during construction and sets the data cache's expiration time to a default value.
-
AbstractShape
protected AbstractShape(AbstractShape source)
-
-
Method Detail
-
intersect
public abstract java.util.List<Intersection> intersect(Line line, Terrain terrain) throws java.lang.InterruptedException
Compute the intersections of a specified line with this shape. If the shape's altitude mode is other thanWorldWind.ABSOLUTE
, the shape's geometry is created relative to the specified terrain rather than the terrain used during rendering, which may be at lower level of detail than required for accurate intersection determination.- Parameters:
line
- the line to intersect.terrain
- theTerrain
to use when computing the shape's geometry.- Returns:
- a list of intersections identifying where the line intersects the shape, or null if the line does not intersect the shape.
- Throws:
java.lang.InterruptedException
- if the operation is interrupted.- See Also:
Terrain
-
initialize
protected abstract void initialize()
Called during construction to establish any subclass-specific state such as different default values than those set by this class.
-
mustApplyTexture
protected abstract boolean mustApplyTexture(DrawContext dc)
Indicates whether texture should be applied to this shape. Called during rendering to determine whether texture state should be established during preparation for interior drawing.Note: This method always returns false during the pick pass.
- Parameters:
dc
- the current draw context- Returns:
- true if texture should be applied, otherwise false.
-
doMakeOrderedRenderable
protected abstract boolean doMakeOrderedRenderable(DrawContext dc)
Produces the geometry and other state necessary to represent this shape as an ordered renderable. Places this shape on the draw context's ordered renderable list for subsequent rendering. This method is called duringpick(DrawContext, java.awt.Point)
andrender(DrawContext)
when it's been determined that the shape is likely to be visible.- Parameters:
dc
- the current draw context.- Returns:
- true if the ordered renderable state was successfully computed, otherwise false, in which case the current pick or render pass is terminated for this shape. Subclasses should return false if it is not possible to create the ordered renderable state.
- See Also:
pick(DrawContext, java.awt.Point)
,render(DrawContext)
-
isOrderedRenderableValid
protected abstract boolean isOrderedRenderableValid(DrawContext dc)
Determines whether this shape's ordered renderable state is valid and can be rendered. Called bymakeOrderedRenderable(DrawContext)
just prior to adding the shape to the ordered renderable list.- Parameters:
dc
- the current draw context.- Returns:
- true if this shape is ready to be rendered as an ordered renderable.
-
doDrawOutline
protected abstract void doDrawOutline(DrawContext dc)
Draws this shape's outline. Called immediately after callingprepareToDrawOutline(DrawContext, ShapeAttributes, ShapeAttributes)
, which establishes OpenGL state for lighting, blending, pick color and line attributes. Subclasses should execute the drawing commands specific to the type of shape.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
doDrawInterior
protected abstract void doDrawInterior(DrawContext dc)
Draws this shape's interior. Called immediately after callingprepareToDrawInterior(DrawContext, ShapeAttributes, ShapeAttributes)
, which establishes OpenGL state for lighting, blending, pick color and interior attributes. Subclasses should execute the drawing commands specific to the type of shape.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
fillVBO
protected abstract void fillVBO(DrawContext dc)
Fill this shape's vertex buffer objects. If the vertex buffer object resource IDs don't yet exist, create them.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
doExportAsKML
protected abstract void doExportAsKML(javax.xml.stream.XMLStreamWriter xmlWriter) throws java.io.IOException, javax.xml.stream.XMLStreamException
Exports shape-specific fields.- Parameters:
xmlWriter
- the export writer to write to.- Throws:
java.io.IOException
- if an IO error occurs while writing to the output destination.javax.xml.stream.XMLStreamException
- if an exception occurs converting this shape's fields to XML.
-
createCacheEntry
protected abstract AbstractShape.AbstractShapeData createCacheEntry(DrawContext dc)
Creates and returns a new cache entry specific to the subclass.- Parameters:
dc
- the current draw context.- Returns:
- a data cache entry for the state in the specified draw context.
-
getCurrentData
protected AbstractShape.AbstractShapeData getCurrentData()
Returns the data cache entry for the current rendering.- Returns:
- the data cache entry for the current rendering.
-
reset
protected void reset()
Invalidates computed values. Called when this shape's contents or certain attributes change.
-
getAttributes
public ShapeAttributes getAttributes()
Returns this shape's normal (as opposed to highlight) attributes.- Specified by:
getAttributes
in interfaceAttributable
- Returns:
- this shape's normal attributes. May be null.
-
setAttributes
public void setAttributes(ShapeAttributes normalAttrs)
Specifies this shape's normal (as opposed to highlight) attributes.- Specified by:
setAttributes
in interfaceAttributable
- Parameters:
normalAttrs
- the normal attributes. May be null, in which case default attributes are used.
-
getHighlightAttributes
public ShapeAttributes getHighlightAttributes()
Returns this shape's highlight attributes.- Specified by:
getHighlightAttributes
in interfaceAttributable
- Returns:
- this shape's highlight attributes. May be null.
-
setHighlightAttributes
public void setHighlightAttributes(ShapeAttributes highlightAttrs)
Specifies this shape's highlight attributes.- Specified by:
setHighlightAttributes
in interfaceAttributable
- Parameters:
highlightAttrs
- the highlight attributes. May be null, in which case default attributes are used.
-
isHighlighted
public boolean isHighlighted()
Description copied from interface:Highlightable
Indicates whether to highlight the shape.- Specified by:
isHighlighted
in interfaceHighlightable
- Returns:
- true to highlight the shape, otherwise false.
-
setHighlighted
public void setHighlighted(boolean highlighted)
Description copied from interface:Highlightable
Specifies whether to highlight the shape.- Specified by:
setHighlighted
in interfaceHighlightable
- Parameters:
highlighted
- true to highlight the shape, otherwise false.
-
isVisible
public boolean isVisible()
Indicates whether this shape is drawn during rendering.- Returns:
- true if this shape is drawn, otherwise false.
- See Also:
setVisible(boolean)
-
setVisible
public void setVisible(boolean visible)
Specifies whether this shape is drawn during rendering.- Parameters:
visible
- true to draw this shape, otherwise false. The default value is true.- See Also:
setAttributes(ShapeAttributes)
-
getAltitudeMode
public int getAltitudeMode()
Returns this shape's altitude mode.- Returns:
- this shape's altitude mode.
- See Also:
setAltitudeMode(int)
-
setAltitudeMode
public void setAltitudeMode(int altitudeMode)
Specifies this shape's altitude mode, one ofWorldWind.ABSOLUTE
,WorldWind.RELATIVE_TO_GROUND
orWorldWind.CLAMP_TO_GROUND
.Note: If the altitude mode is unrecognized,
WorldWind.ABSOLUTE
is used.Note: Subclasses may recognize additional altitude modes or may not recognize the ones described above.
- Parameters:
altitudeMode
- the altitude mode. The default value isWorldWind.ABSOLUTE
.
-
getDistanceFromEye
public double getDistanceFromEye()
Description copied from interface:OrderedRenderable
Returns the ordered renderable's distance from the current view's eye point. Intended to be used only to sort a list of ordered renderables according to eye distance, and only during frame generation when a view is active.- Specified by:
getDistanceFromEye
in interfaceOrderedRenderable
- Returns:
- the distance of the ordered renderable from the current view's eye point.
-
isEnableBatchRendering
public boolean isEnableBatchRendering()
Indicates whether batch rendering is enabled for the concrete shape type of this shape.- Returns:
- true if batch rendering is enabled, otherwise false.
- See Also:
setEnableBatchRendering(boolean)
-
setEnableBatchRendering
public void setEnableBatchRendering(boolean enableBatchRendering)
Specifies whether adjacent shapes of this shape's concrete type in the ordered renderable list may be rendered together if they are contained in the same layer. This increases performance. There is seldom a reason to disable it.- Parameters:
enableBatchRendering
- true to enable batch rendering, otherwise false.
-
isEnableBatchPicking
public boolean isEnableBatchPicking()
Indicates whether batch picking is enabled.- Returns:
- true if batch rendering is enabled, otherwise false.
- See Also:
setEnableBatchPicking(boolean)
-
setEnableBatchPicking
public void setEnableBatchPicking(boolean enableBatchPicking)
Specifies whether adjacent shapes of this shape's concrete type in the ordered renderable list may be pick-tested together if they are contained in the same layer. This increases performance but allows only the top-most of the polygons to be reported in aSelectEvent
even if several of the polygons are at the pick position.Batch rendering (
setEnableBatchRendering(boolean)
) must be enabled in order for batch picking to occur.- Parameters:
enableBatchPicking
- true to enable batch rendering, otherwise false.
-
getOutlinePickWidth
public int getOutlinePickWidth()
Indicates the outline line width to use during picking. A larger width than normal typically makes the outline easier to pick.- Returns:
- the outline line width used during picking.
-
setOutlinePickWidth
public void setOutlinePickWidth(int outlinePickWidth)
Specifies the outline line width to use during picking. A larger width than normal typically makes the outline easier to pick.Note that the size of the pick aperture also affects the precision necessary to pick.
- Parameters:
outlinePickWidth
- the outline pick width. The default is 10.- Throws:
java.lang.IllegalArgumentException
- if the width is less than 0.
-
isEnableDepthOffset
public boolean isEnableDepthOffset()
Indicates whether the filled sides of this shape should be offset towards the viewer to help eliminate artifacts when two or more faces of this or other filled shapes are coincident.- Returns:
- true if depth offset is applied, otherwise false.
-
setEnableDepthOffset
public void setEnableDepthOffset(boolean enableDepthOffset)
Specifies whether the filled sides of this shape should be offset towards the viewer to help eliminate artifacts when two or more faces of this or other filled shapes are coincident. SeeOffset
.- Parameters:
enableDepthOffset
- true if depth offset is applied, otherwise false.
-
getGeometryRegenerationInterval
public long getGeometryRegenerationInterval()
Indicates the maximum length of time between geometry regenerations. SeesetGeometryRegenerationInterval(int)
for the regeneration-interval's description.- Returns:
- the geometry regeneration interval, in milliseconds.
- See Also:
setGeometryRegenerationInterval(int)
-
setGeometryRegenerationInterval
public void setGeometryRegenerationInterval(int geometryRegenerationInterval)
Specifies the maximum length of time between geometry regenerations. The geometry is regenerated when this shape's altitude mode isWorldWind.CLAMP_TO_GROUND
orWorldWind.RELATIVE_TO_GROUND
in order to capture changes to the terrain. (The terrain changes when its resolution changes or when new elevation data is returned from a server.) Decreasing this value causes the geometry to more quickly track terrain changes but at the cost of performance. Increasing this value often does not have much effect because there are limiting factors other than geometry regeneration.- Parameters:
geometryRegenerationInterval
- the geometry regeneration interval, in milliseconds. The default is two seconds.
-
setReferencePosition
public void setReferencePosition(Position referencePosition)
Specifies the position to use as a reference position for computed geometry. This value should typically left to the default value of the first position in the polygon's outer boundary.- Parameters:
referencePosition
- the reference position. May be null, in which case the first position of the outer boundary is the reference position.
-
getDelegateOwner
public java.lang.Object getDelegateOwner()
-
setDelegateOwner
public void setDelegateOwner(java.lang.Object delegateOwner)
-
getExtent
public Extent getExtent()
Returns this shape's extent in model coordinates.- Returns:
- this shape's extent, or null if an extent has not been computed.
-
getReferencePoint
public Vec4 getReferencePoint()
Returns the Cartesian coordinates of this shape's reference position as computed during the most recent rendering.- Returns:
- the Cartesian coordinates corresponding to this shape's reference position, or null if the point has not been computed.
-
getExtent
public Extent getExtent(Globe globe, double verticalExaggeration)
Description copied from interface:ExtentHolder
Returns the objects enclosing volume as anExtent
in model coordinates, given a specifiedGlobe
and vertical exaggeration (seeSceneController.getVerticalExaggeration()
.- Specified by:
getExtent
in interfaceExtentHolder
- Parameters:
globe
- the Globe the object is related to.verticalExaggeration
- the vertical exaggeration of the scene containing this object.- Returns:
- the object's Extent in model coordinates.
-
determineActiveAttributes
protected void determineActiveAttributes()
Determines which attributes -- normal, highlight or default -- to use each frame. Places the result in this shape's current active attributes.- See Also:
getActiveAttributes()
-
getActiveAttributes
public ShapeAttributes getActiveAttributes()
Returns this shape's currently active attributes, as determined during the most recent call todetermineActiveAttributes()
. The active attributes are either the normal or highlight attributes, depending on this shape's highlight flag, and incorporates default attributes for those not specified in the applicable attribute set.- Returns:
- this shape's currently active attributes.
-
mustRegenerateGeometry
protected boolean mustRegenerateGeometry(DrawContext dc)
Indicates whether this shape's renderable geometry must be recomputed, either as a result of an attribute or property change or the expiration of the geometry regeneration interval.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.- Returns:
- true if this shape's geometry must be regenerated, otherwise false.
-
shouldUseVBOs
protected boolean shouldUseVBOs(DrawContext dc)
Indicates whether this shape should use OpenGL vertex buffer objects.- Parameters:
dc
- the current draw context.- Returns:
- true if this shape should use vertex buffer objects, otherwise false.
-
mustDrawInterior
protected boolean mustDrawInterior()
Indicates whether this shape's interior must be drawn.- Returns:
- true if an interior must be drawn, otherwise false.
-
mustDrawOutline
protected boolean mustDrawOutline()
Indicates whether this shape's outline must be drawn.- Returns:
- true if the outline should be drawn, otherwise false.
-
mustApplyLighting
protected boolean mustApplyLighting(DrawContext dc)
Indicates whether standard lighting must be applied by consulting the current active attributes. CallsmustApplyLighting(DrawContext, ShapeAttributes)
, specifying null for the activeAttrs.- Parameters:
dc
- the current draw context- Returns:
- true if lighting must be applied, otherwise false.
-
mustApplyLighting
protected boolean mustApplyLighting(DrawContext dc, ShapeAttributes activeAttrs)
Indicates whether standard lighting must be applied by consulting either the specified active attributes or the current active attributes.- Parameters:
dc
- the current draw contextactiveAttrs
- the attribute bundle to consider when determining whether lighting is applied. May be null, in which case the current active attributes are used.- Returns:
- true if lighting must be applied, otherwise false.
-
mustCreateNormals
protected boolean mustCreateNormals(DrawContext dc)
Indicates whether normal vectors must be computed by consulting the current active attributes. CallsmustCreateNormals(DrawContext, ShapeAttributes)
, specifying null for the activeAttrs.- Parameters:
dc
- the current draw context- Returns:
- true if normal vectors must be computed, otherwise false.
-
mustCreateNormals
protected boolean mustCreateNormals(DrawContext dc, ShapeAttributes activeAttrs)
Indicates whether normal vectors must be computed by consulting either the specified active attributes or the current active attributes. CallsmustApplyLighting(DrawContext, ShapeAttributes)
, passing the specified active attrs.- Parameters:
dc
- the current draw contextactiveAttrs
- the attribute bundle to consider when determining whether normals should be computed. May be null, in which case the current active attributes are used.- Returns:
- true if normal vectors must be computed, otherwise false.
-
makeTexture
protected WWTexture makeTexture(java.lang.Object imageSource)
Creates aWWTexture
for a specified image source.- Parameters:
imageSource
- the image source for which to create the texture.- Returns:
- the new
WWTexture
. - Throws:
java.lang.IllegalArgumentException
- if the image source is null.
-
preRender
public void preRender(DrawContext dc)
- Specified by:
preRender
in interfacePreRenderable
-
createSurfaceShape
protected SurfaceShape createSurfaceShape()
Returns aSurfaceShape
that corresponds to this Path and is used for drawing on 2D globes.- Returns:
- The surface shape to represent this Path on a 2D globe.
-
updateSurfaceShape
protected void updateSurfaceShape()
Sets surface shape parameters prior to picking and rendering the 2D shape used to represent this shape on 2D globes. Subclasses should override this method if they need to update more than the highlighted state, visibility state and delegate owner.
-
pick
public void pick(DrawContext dc, java.awt.Point pickPoint)
Description copied from interface:OrderedRenderable
Executes a pick of the ordered renderable.- Specified by:
pick
in interfaceOrderedRenderable
- Parameters:
dc
- the current draw context.pickPoint
- the pick point.
-
render
public void render(DrawContext dc)
Description copied from interface:Renderable
Causes thisRenderable
to render itself using the provided draw context.- Specified by:
render
in interfaceRenderable
- Parameters:
dc
- theDrawContext
to be used- See Also:
DrawContext
-
makeOrderedRenderable
protected void makeOrderedRenderable(DrawContext dc)
Determines whether to add this shape to the draw context's ordered renderable list. Creates this shapes renderable geometry.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
addOrderedRenderable
protected void addOrderedRenderable(DrawContext dc)
Adds this shape to the draw context's ordered renderable list.- Parameters:
dc
- the current draw context.
-
isTerrainDependent
protected boolean isTerrainDependent()
Indicates whether this shape's geometry depends on the terrain.- Returns:
- true if this shape's geometry depends on the terrain, otherwise false.
-
isViewDistanceExpiration
public boolean isViewDistanceExpiration()
Indicates whether this shape's terrain-dependent geometry is continually computed as its distance from the eye point changes. This is often necessary to ensure that the shape is updated as the terrain precision changes. But it's often not necessary as well, and can be disabled.- Returns:
- true if the terrain dependent geometry is updated as the eye distance changes, otherwise false. The default is true.
-
setViewDistanceExpiration
public void setViewDistanceExpiration(boolean viewDistanceExpiration)
Specifies whether this shape's terrain-dependent geometry is continually computed as its distance from the eye point changes. This is often necessary to ensure that the shape is updated as the terrain precision changes. But it's often not necessary as well, and can be disabled.- Parameters:
viewDistanceExpiration
- true to enable view distance expiration, otherwise false.
-
checkViewDistanceExpiration
protected void checkViewDistanceExpiration(DrawContext dc)
Determines whether this shape's geometry should be invalidated because the view distance changed, and if so, invalidates the geometry.- Parameters:
dc
- the current draw context.
-
intersectsFrustum
protected boolean intersectsFrustum(DrawContext dc)
Determines whether this shape intersects the view frustum.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.- Returns:
- true if this shape intersects the frustum, otherwise false.
-
drawOrderedRenderable
protected void drawOrderedRenderable(DrawContext dc)
Draws this shape as an ordered renderable.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
drawBatched
protected void drawBatched(DrawContext dc)
Draws this ordered renderable and all subsequent Path ordered renderables in the ordered renderable list. If the current pick mode is true, only shapes within the same layer are drawn as a batch.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
doDrawOrderedRenderable
protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickCandidates)
Draw this shape as an ordered renderable. If in picking mode, add it to the picked object list of specifiedPickSupport
. ThePickSupport
may not be the one associated with this instance. During batch picking thePickSupport
of the instance initiating the batch picking is used so that all shapes rendered in batch are added to the same pick list.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.pickCandidates
- a pick support holding the picked object list to add this shape to.
-
createPickedObject
protected PickedObject createPickedObject(int colorCode)
Creates aPickedObject
for this shape and the specified unique pick color code. The PickedObject returned by this method will be added to the pick list to represent the current shape.- Parameters:
colorCode
- the unique color code for this shape.- Returns:
- a new picked object.
-
beginDrawing
protected OGLStackHandler beginDrawing(DrawContext dc, int attrMask)
Establish the OpenGL state needed to draw this shape.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.attrMask
- an attribute mask indicating state the caller will set. This base class implementation setsGL_CURRENT_BIT, GL_LINE_BIT, GL_HINT_BIT, GL_POLYGON_BIT, GL_COLOR_BUFFER_BIT, and GL_TRANSFORM_BIT
.- Returns:
- the stack handler used to set the OpenGL state. Callers should use this to set additional state, especially state indicated in the attribute mask argument.
-
endDrawing
protected void endDrawing(DrawContext dc)
Pop the state set inbeginDrawing(DrawContext, int)
.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
drawOutline
protected void drawOutline(DrawContext dc)
Draws this shape's outline.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
prepareToDrawOutline
protected void prepareToDrawOutline(DrawContext dc, ShapeAttributes activeAttrs, ShapeAttributes defaultAttrs)
Establishes OpenGL state for drawing the outline, including setting the color/material, line smoothing, line width and stipple. Disables texture.- Parameters:
dc
- the current draw context.activeAttrs
- the attributes indicating the state value to set.defaultAttrs
- the attributes to use ifactiveAttrs
does not contain a necessary value.
-
drawInterior
protected void drawInterior(DrawContext dc)
Draws this shape's interior.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
prepareToDrawInterior
protected void prepareToDrawInterior(DrawContext dc, ShapeAttributes activeAttrs, ShapeAttributes defaultAttrs)
Establishes OpenGL state for drawing the interior, including setting the color/material. Enabling texture is left to the subclass.- Parameters:
dc
- the current draw context.activeAttrs
- the attributes indicating the state value to set.defaultAttrs
- the attributes to use ifactiveAttrs
does not contain a necessary value.
-
computePoint
protected Vec4 computePoint(Terrain terrain, Position position)
Computes a model-coordinate point from a position, applying this shape's altitude mode.- Parameters:
terrain
- the terrain to compute a point relative to the globe's surface.position
- the position to compute a point for.- Returns:
- the model-coordinate point corresponding to the position and this shape's shape type.
-
computePoint
protected Vec4 computePoint(DrawContext dc, Terrain terrain, Position position)
Computes a model-coordinate point from a position, applying this shape's altitude mode, and usingCLAMP_TO_GROUND
if the current globe is 2D.- Parameters:
dc
- the current draw context.terrain
- the terrain to compute a point relative to the globe's surface.position
- the position to compute a point for.- Returns:
- the model-coordinate point corresponding to the position and this shape's shape type.
-
computeExtentFromPositions
protected Extent computeExtentFromPositions(Globe globe, double verticalExaggeration, java.lang.Iterable<? extends LatLon> positions)
Computes this shape's approximate extent from its positions.- Parameters:
globe
- the globe to use to compute the extent.verticalExaggeration
- the vertical exaggeration to apply to computed terrain points.positions
- the positions to compute the extent for.- Returns:
- the extent, or null if an extent cannot be computed. Null is returned if either
globe
orpositions
is null.
-
getVboIds
protected int[] getVboIds(DrawContext dc)
Get or create OpenGL resource IDs for the current data cache entry.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.- Returns:
- an array containing the coordinate vertex buffer ID in the first position and the index vertex buffer ID in the second position.
-
clearCachedVbos
protected void clearCachedVbos(DrawContext dc)
Removes from the GPU resource cache the entry for the current data cache entry's VBOs.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Parameters:
dc
- the current draw context.
-
countTriangleVertices
protected int countTriangleVertices(java.util.List<java.util.List<java.lang.Integer>> prims, java.util.List<java.lang.Integer> primTypes)
-
move
public void move(Position delta)
Description copied from interface:Movable
Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
-
moveTo
public void moveTo(Globe globe, Position position)
Description copied from interface:Movable2
Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
-
isDragEnabled
public boolean isDragEnabled()
Description copied from interface:Draggable
Indicates whether the object is enabled for dragging.- Specified by:
isDragEnabled
in interfaceDraggable
- Returns:
- true if the object is enabled, else false.
-
setDragEnabled
public void setDragEnabled(boolean enabled)
Description copied from interface:Draggable
Controls whether the object is enabled for dragging.- Specified by:
setDragEnabled
in interfaceDraggable
- Parameters:
enabled
-true
if the object is enabled, elsefalse
.
-
drag
public void drag(DragContext dragContext)
Description copied from interface:Draggable
Drag the object given the providedDragContext
.- Specified by:
drag
in interfaceDraggable
- Parameters:
dragContext
- theDragContext
of this dragging event.
-
doDrag
protected void doDrag(DragContext dragContext)
-
isExportFormatSupported
public java.lang.String isExportFormatSupported(java.lang.String mimeType)
Description copied from interface:Exportable
Does this object support a certain export format?- Specified by:
isExportFormatSupported
in interfaceExportable
- Parameters:
mimeType
- Desired export format.- Returns:
- One of
Exportable.FORMAT_SUPPORTED
,Exportable.FORMAT_NOT_SUPPORTED
, orExportable.FORMAT_PARTIALLY_SUPPORTED
. - See Also:
Exportable.export(String, Object)
-
export
public void export(java.lang.String mimeType, java.lang.Object output) throws java.io.IOException, java.lang.UnsupportedOperationException
Description copied from interface:Exportable
Exports the object to a format.- Specified by:
export
in interfaceExportable
- Parameters:
mimeType
- Desired export format. CallExportable.isExportFormatSupported(String)
to make sure that the object supports the format before trying to export, or be prepared to handleUnsupportedOperationException
.output
- Object that will receive the exported data. The type of this object depends on the export format. All formats should supportjava.io.OutputStream
. Text based format (for example, XML formats) should also supportjava.io.Writer
. Certain formats may also support other object types.- Throws:
java.io.IOException
- if an exception occurs while exporting the data.java.lang.UnsupportedOperationException
- if the format is not supported by this object, or if theoutput
argument is not of a supported type.- See Also:
Exportable.isExportFormatSupported(String)
-
exportAsKML
protected void exportAsKML(java.lang.Object output) throws java.io.IOException, javax.xml.stream.XMLStreamException
Export the placemark to KML as a<Placemark>
element. Theoutput
object will receive the data. This object must be one of: java.io.Writer java.io.OutputStream javax.xml.stream.XMLStreamWriter- Parameters:
output
- Object to receive the generated KML.- Throws:
javax.xml.stream.XMLStreamException
- If an exception occurs while writing the KMLjava.io.IOException
- if an exception occurs while exporting the data.- See Also:
export(String, Object)
-
getRestorableState
public java.lang.String getRestorableState()
Description copied from interface:Restorable
Returns an XML document string describing the object's state. This state can be restored later by callingrestoreState
and passing the XML document.- Specified by:
getRestorableState
in interfaceRestorable
- Returns:
- an XML document string describing the object's state.
-
doGetRestorableState
protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
-
restoreState
public void restoreState(java.lang.String stateInXml)
Description copied from interface:Restorable
Restores the object's state to what is described in the specified XML document string.- Specified by:
restoreState
in interfaceRestorable
- Parameters:
stateInXml
- an XML document string describing an object's state.
-
doRestoreState
protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
-
-