NASA World Wind

gov.nasa.worldwind.render
Class AbstractShape

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.render.AbstractShape
All Implemented Interfaces:
AVList, MessageListener, Exportable, ExtentHolder, Movable, GeographicExtent, Highlightable, OrderedRenderable, Renderable, Restorable, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
AbstractGeneralShape, AntennaAxes, AntennaModel, ExtrudedPolygon, Path, Polygon, RigidShape

public abstract class AbstractShape
extends WWObjectImpl
implements Highlightable, OrderedRenderable, Movable, ExtentHolder, GeographicExtent, Exportable, Restorable

Provides a base class form several geometric Renderables. 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
protected static class AbstractShape.AbstractShapeData
          Holds the globe-dependent data captured in this shape's data cache.
 
Field Summary
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 of render(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  Object delegateOwner
           
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 as OutlinedShapes.
protected  Layer pickLayer
           
protected  PickSupport pickSupport
           
protected  Position referencePosition
           
protected  Sector sector
           
protected  ShapeDataCache shapeDataCache
          Holds globe-dependent computed data.
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
protected AbstractShape()
          Invokes initialize() during construction and sets the data cache's expiration time to a default value.
 
Method Summary
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, Iterable<? extends LatLon> positions)
          Computes this shape's approximate extent from its positions.
protected  Vec4 computePoint(Terrain terrain, Position position)
          Computes a model-coordinate point from a position, applying this shape's altitude mode.
protected  int countTriangleVertices(List<List<Integer>> prims, List<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 a PickedObject for this shape and the specified unique pick color code.
protected  void determineActiveAttributes()
          Determines which attributes -- normal, highlight or default -- to use each frame.
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(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)
           
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 in beginDrawing(DrawContext, int).
 void export(String mimeType, Object output)
          Exports the object to a format.
protected  void exportAsKML(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 to determineActiveAttributes().
 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.
 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 an Extent in model coordinates, given a specified Globe and vertical exaggeration (see SceneController.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.
 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  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 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.
 String isExportFormatSupported(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(Object imageSource)
          Creates a WWTexture 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.
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, 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 render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
protected  void reset()
          Invalidates computed values.
 void restoreState(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 of WorldWind.ABSOLUTE, WorldWind.RELATIVE_TO_GROUND or WorldWind.CLAMP_TO_GROUND.
 void setAttributes(ShapeAttributes normalAttrs)
          Specifies this shape's normal (as opposed to highlight) attributes.
 void setDelegateOwner(Object delegateOwner)
           
 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.
 
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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.Movable
getReferencePosition, moveTo
 
Methods inherited from interface gov.nasa.worldwind.render.GeographicExtent
getSector
 
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
 

Field Detail

activeAttributes

protected ShapeAttributes activeAttributes
The attributes active for a particular pick and render pass. These are determined according to the highlighting mode.


altitudeMode

protected int altitudeMode

BEogsh

protected OGLStackHandler BEogsh

currentData

protected AbstractShape.AbstractShapeData currentData
Identifies the active globe-dependent data for the current invocation of render(DrawContext). The active data is drawn from this shape's data cache at the beginning of the render method.


DEFAULT_ALTITUDE_MODE

protected static final int DEFAULT_ALTITUDE_MODE
The default altitude mode.

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

DEFAULT_HIGHLIGHT_MATERIAL

protected static final Material DEFAULT_HIGHLIGHT_MATERIAL
The default highlight color.


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_OUTLINE_PICK_WIDTH

protected static final int DEFAULT_OUTLINE_PICK_WIDTH
The default outline pick width.

See Also:
Constant Field Values

defaultAttributes

protected static ShapeAttributes defaultAttributes
The attributes used if attributes are not specified.


delegateOwner

protected Object delegateOwner

enableBatchPicking

protected boolean enableBatchPicking

enableBatchRendering

protected boolean enableBatchRendering

enableDepthOffset

protected boolean enableDepthOffset

highlightAttrs

protected ShapeAttributes highlightAttrs
This shape's highlighted attributes.


highlighted

protected boolean highlighted

maxExpiryTime

protected long maxExpiryTime

minExpiryTime

protected long minExpiryTime

normalAttrs

protected ShapeAttributes normalAttrs
This shape's normal, non-highlighted attributes.


outlinePickWidth

protected int outlinePickWidth

outlineShapeRenderer

protected OutlinedShape outlineShapeRenderer
Outlined shapes are drawn as OutlinedShapes.


pickLayer

protected Layer pickLayer

pickSupport

protected PickSupport pickSupport

referencePosition

protected Position referencePosition

sector

protected Sector sector

shapeDataCache

protected ShapeDataCache shapeDataCache
Holds globe-dependent computed data. One entry per globe encountered during render(DrawContext).


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.


viewDistanceExpiration

protected boolean viewDistanceExpiration

visible

protected boolean visible
Constructor Detail

AbstractShape

protected AbstractShape()
Invokes initialize() during construction and sets the data cache's expiration time to a default value.

Method Detail

addOrderedRenderable

protected void addOrderedRenderable(DrawContext dc)
Adds this shape to the draw context's ordered renderable list.

Parameters:
dc - the current draw context.

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 sets GL_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.

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.

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.

computeExtentFromPositions

protected Extent computeExtentFromPositions(Globe globe,
                                            double verticalExaggeration,
                                            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 or positions is null.

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.

countTriangleVertices

protected int countTriangleVertices(List<List<Integer>> prims,
                                    List<Integer> primTypes)

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.

createPickedObject

protected PickedObject createPickedObject(int colorCode)
Creates a PickedObject 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.

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()

doDrawInterior

protected abstract void doDrawInterior(DrawContext dc)
Draws this shape's interior. Called immediately after calling prepareToDrawInterior(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.

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 specified PickSupport. The PickSupport may not be the one associated with this instance. During batch picking the PickSupport 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.

doDrawOutline

protected abstract void doDrawOutline(DrawContext dc)
Draws this shape's outline. Called immediately after calling prepareToDrawOutline(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.

doExportAsKML

protected abstract void doExportAsKML(XMLStreamWriter xmlWriter)
                               throws IOException,
                                      XMLStreamException
Exports shape-specific fields.

Parameters:
xmlWriter - the export writer to write to.
Throws:
IOException - if an IO error occurs while writing to the output destination.
XMLStreamException - if an exception occurs converting this shape's fields to XML.

doGetRestorableState

protected void doGetRestorableState(RestorableSupport rs,
                                    RestorableSupport.StateObject context)

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 during pick(DrawContext, java.awt.Point) and render(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)

doRestoreState

protected void doRestoreState(RestorableSupport rs,
                              RestorableSupport.StateObject 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.

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.

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.

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.

endDrawing

protected void endDrawing(DrawContext dc)
Pop the state set in beginDrawing(DrawContext, int).

A AbstractShape.AbstractShapeData must be current when this method is called.

Parameters:
dc - the current draw context.

export

public void export(String mimeType,
                   Object output)
            throws IOException,
                   UnsupportedOperationException
Description copied from interface: Exportable
Exports the object to a format.

Specified by:
export in interface Exportable
Parameters:
mimeType - Desired export format. Call Exportable.isExportFormatSupported(String) to make sure that the object supports the format before trying to export, or be prepared to handle UnsupportedOperationException.
output - Object that will receive the exported data. The type of this object depends on the export format. All formats should support java.io.OutputStream. Text based format (for example, XML formats) should also support java.io.Writer. Certain formats may also support other object types.
Throws:
IOException - if an exception occurs while exporting the data.
UnsupportedOperationException - if the format is not supported by this object, or if the output argument is not of a supported type.
See Also:
Exportable.isExportFormatSupported(String)

exportAsKML

protected void exportAsKML(Object output)
                    throws IOException,
                           XMLStreamException
Export the placemark to KML as a <Placemark> element. The output 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:
XMLStreamException - If an exception occurs while writing the KML
IOException - if an exception occurs while exporting the data.
See Also:
export(String, Object)

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.

getActiveAttributes

public ShapeAttributes getActiveAttributes()
Returns this shape's currently active attributes, as determined during the most recent call to determineActiveAttributes(). 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.

getAltitudeMode

public int getAltitudeMode()
Returns this shape's altitude mode.

Returns:
this shape's altitude mode.
See Also:
setAltitudeMode(int)

getAttributes

public ShapeAttributes getAttributes()
Returns this shape's normal (as opposed to highlight) attributes.

Returns:
this shape's normal attributes. May be null.

getCurrentData

protected AbstractShape.AbstractShapeData getCurrentData()
Returns the data cache entry for the current rendering.

Returns:
the data cache entry for the current rendering.

getDelegateOwner

public Object getDelegateOwner()

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 interface OrderedRenderable
Returns:
the distance of the ordered renderable from the current view's eye point.

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.

getExtent

public Extent getExtent(Globe globe,
                        double verticalExaggeration)
Description copied from interface: ExtentHolder
Returns the objects enclosing volume as an Extent in model coordinates, given a specified Globe and vertical exaggeration (see SceneController.getVerticalExaggeration().

Specified by:
getExtent in interface ExtentHolder
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.

getGeometryRegenerationInterval

public long getGeometryRegenerationInterval()
Indicates the maximum length of time between geometry regenerations. See setGeometryRegenerationInterval(int) for the regeneration-interval's description.

Returns:
the geometry regeneration interval, in milliseconds.
See Also:
setGeometryRegenerationInterval(int)

getHighlightAttributes

public ShapeAttributes getHighlightAttributes()
Returns this shape's highlight attributes.

Returns:
this shape's highlight attributes. May be null.

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.

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.

getRestorableState

public String getRestorableState()
Description copied from interface: Restorable
Returns an XML document string describing the object's state. This state can be restored later by calling restoreState and passing the XML document.

Specified by:
getRestorableState in interface Restorable
Returns:
an XML document string describing the object's state.

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.

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.


intersect

public abstract List<Intersection> intersect(Line line,
                                             Terrain terrain)
                                      throws InterruptedException
Compute the intersections of a specified line with this shape. If the shape's altitude mode is other than WorldWind.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 - the Terrain 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:
InterruptedException - if the operation is interrupted.
See Also:
Terrain

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.

isEnableBatchPicking

public boolean isEnableBatchPicking()
Indicates whether batch picking is enabled.

Returns:
true if batch rendering is enabled, otherwise false.
See Also:
setEnableBatchPicking(boolean).

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).

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.

isExportFormatSupported

public String isExportFormatSupported(String mimeType)
Description copied from interface: Exportable
Does this object support a certain export format?

Specified by:
isExportFormatSupported in interface Exportable
Parameters:
mimeType - Desired export format.
Returns:
One of Exportable.FORMAT_SUPPORTED, Exportable.FORMAT_NOT_SUPPORTED, or Exportable.FORMAT_PARTIALLY_SUPPORTED.
See Also:
Exportable.export(String, Object)

isHighlighted

public boolean isHighlighted()
Description copied from interface: Highlightable
Indicates whether to highlight the shape.

Specified by:
isHighlighted in interface Highlightable
Returns:
true to highlight the shape, otherwise false.

isOrderedRenderableValid

protected abstract boolean isOrderedRenderableValid(DrawContext dc)
Determines whether this shape's ordered renderable state is valid and can be rendered. Called by makeOrderedRenderable(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.

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.

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)

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.

makeTexture

protected WWTexture makeTexture(Object imageSource)
Creates a WWTexture for a specified image source.

Parameters:
imageSource - the image source for which to create the texture.
Returns:
the new WWTexture.
Throws:
IllegalArgumentException - if the image source is null.

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.

Specified by:
move in interface Movable
Parameters:
delta - the latitude and longitude to add to the shape's reference position.

mustApplyLighting

protected boolean mustApplyLighting(DrawContext dc)
Indicates whether standard lighting must be applied by consulting the current active attributes. Calls mustApplyLighting(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 context
activeAttrs - 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.

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.

mustCreateNormals

protected boolean mustCreateNormals(DrawContext dc)
Indicates whether normal vectors must be computed by consulting the current active attributes. Calls mustCreateNormals(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. Calls mustApplyLighting(DrawContext, ShapeAttributes), passing the specified active attrs.

Parameters:
dc - the current draw context
activeAttrs - 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.

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.

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.

pick

public void pick(DrawContext dc,
                 Point pickPoint)
Description copied from interface: OrderedRenderable
Executes a pick of the ordered renderable.

Specified by:
pick in interface OrderedRenderable
Parameters:
dc - the current draw context.
pickPoint - the pick point.

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 if activeAttrs does not contain a necessary value.

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 if activeAttrs does not contain a necessary value.

render

public void render(DrawContext dc)
Description copied from interface: Renderable
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

reset

protected void reset()
Invalidates computed values. Called when this shape's contents or certain attributes change.


restoreState

public void restoreState(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 interface Restorable
Parameters:
stateInXml - an XML document string describing an object's state.

setAltitudeMode

public void setAltitudeMode(int altitudeMode)
Specifies this shape's altitude mode, one of WorldWind.ABSOLUTE, WorldWind.RELATIVE_TO_GROUND or WorldWind.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 is WorldWind.ABSOLUTE.

setAttributes

public void setAttributes(ShapeAttributes normalAttrs)
Specifies this shape's normal (as opposed to highlight) attributes.

Parameters:
normalAttrs - the normal attributes. May be null, in which case default attributes are used.

setDelegateOwner

public void setDelegateOwner(Object delegateOwner)

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 a SelectEvent 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.

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.

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. See Offset.

Parameters:
enableDepthOffset - true if depth offset is applied, otherwise false.

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 is WorldWind.CLAMP_TO_GROUND or WorldWind.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.

setHighlightAttributes

public void setHighlightAttributes(ShapeAttributes highlightAttrs)
Specifies this shape's highlight attributes.

Parameters:
highlightAttrs - the highlight attributes. May be null, in which case default attributes are used.

setHighlighted

public void setHighlighted(boolean highlighted)
Description copied from interface: Highlightable
Specifies whether to highlight the shape.

Specified by:
setHighlighted in interface Highlightable
Parameters:
highlighted - true to highlight the shape, otherwise false.

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:
IllegalArgumentException - if the width is less than 0.

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.

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.

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)

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.

NASA World Wind