Package gov.nasa.worldwind.render
Class SurfacePolygon
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.render.AbstractSurfaceObject
-
- gov.nasa.worldwind.render.AbstractSurfaceShape
-
- gov.nasa.worldwind.render.SurfacePolygon
-
- All Implemented Interfaces:
AVList,Draggable,MessageListener,Exportable,ExtentHolder,MeasurableArea,MeasurableLength,Movable,Movable2,Attributable,Highlightable,OrderedRenderable,PreRenderable,Renderable,SurfaceObject,SurfaceRenderable,SurfaceShape,Restorable,Combinable,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
KMLSurfacePolygonImpl
public class SurfacePolygon extends AbstractSurfaceShape implements Exportable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSurfacePolygon.ShapeDataprotected static classSurfacePolygon.Vertex-
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractSurfaceShape
AbstractSurfaceShape.GeometryKey, AbstractSurfaceShape.SurfaceShapeStateKey
-
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
AbstractSurfaceObject.CacheEntry, AbstractSurfaceObject.SurfaceObjectStateKey
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.Iterable<? extends LatLon>>boundariesprotected WWTextureexplicitTextureIf an image source was specified, this is the WWTexture form.protected float[]explicitTextureCoordsThis shape's texture coordinates.protected java.util.Map<java.lang.Object,SurfacePolygon.ShapeData>shapeDataCacheprotected static com.jogamp.opengl.glu.GLUtessellatortessprotected static GLUTessellatorSupport.CollectPrimitivesCallbacktessCallback-
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceShape
activeAttrs, activeGeometry, activeOutlineGeometry, areaMeasurer, areaMeasurerLastModifiedTime, DEFAULT_HIGHLIGHT_MATERIAL, DEFAULT_INTERIOR_MATERIAL, DEFAULT_MAX_EDGE_INTERVALS, DEFAULT_MIN_EDGE_INTERVALS, DEFAULT_OUTLINE_MATERIAL, DEFAULT_PATH_TYPE, DEFAULT_TEXELS_PER_EDGE_INTERVAL, defaultAttrs, dragEnabled, draggableSupport, geometryCache, highlightAttrs, highlighted, maxEdgeIntervals, minEdgeIntervals, normalAttrs, pathType, sectorCache, stackHandler, texelsPerEdgeInterval, texture, vertexBuffer
-
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
delegateOwner, drawBoundingSectors, enableBatchPicking, extentCache, lastModifiedTime, nextUniqueId, pickLayer, pickSupport, pickTileBuilder, uniqueId, visible
-
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
-
-
Constructor Summary
Constructors Constructor Description SurfacePolygon()Constructs a new surface polygon with the default attributes and no locations.SurfacePolygon(ShapeAttributes normalAttrs)Constructs a new surface polygon with the specified normal (as opposed to highlight) attributes and no locations.SurfacePolygon(ShapeAttributes normalAttrs, java.lang.Iterable<? extends LatLon> iterable)Constructs a new surface polygon with the specified normal (as opposed to highlight) attributes and the specified iterable of locations.SurfacePolygon(SurfacePolygon source)Creates a shallow copy of the specified source shape.SurfacePolygon(java.lang.Iterable<? extends LatLon> iterable)Constructs a new surface polygon with the default attributes and the specified iterable of locations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInnerBoundary(java.lang.Iterable<? extends LatLon> iterable)protected voidapplyInteriorState(DrawContext dc, SurfaceTileDrawContext sdc, ShapeAttributes attributes, WWTexture texture, LatLon refLocation)protected java.util.List<java.util.List<SurfacePolygon.Vertex>>assembleContours(Angle maxEdgeLength)protected voidclearCaches()Clears this SurfaceObject's internal extent cache.protected java.util.List<java.util.List<SurfacePolygon.Vertex>>clipWithDateline(java.util.List<SurfacePolygon.Vertex> contour)protected java.util.List<SurfacePolygon.Vertex>clipWithPole(java.util.List<SurfacePolygon.Vertex> contour, java.lang.String pole, Angle maxEdgeLength)protected voidcloseContour(java.util.List<SurfacePolygon.Vertex> contour)protected java.util.List<java.util.List<LatLon>>createGeometry(Globe globe, double edgeIntervalsPerDegree)protected voiddoDrawGeographic(DrawContext dc, SurfaceTileDrawContext sdc)protected voiddoGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)protected voiddoMoveTo(Position oldReferencePosition, Position newReferencePosition)protected voiddoMoveTo(Globe globe, Position oldReferencePosition, Position newReferencePosition)protected voiddoRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)protected voidexportAsKML(java.lang.Object output)Export the polygon to KML as a<Placemark>element.java.util.List<java.lang.Iterable<? extends LatLon>>getBoundaries()java.lang.Iterable<? extends LatLon>getLocations()java.lang.Iterable<? extends LatLon>getLocations(Globe globe)Returns the shape's locations as they appear on the specifiedglobe, or null if the shape has no locations.java.lang.Iterable<? extends LatLon>getOuterBoundary()PositiongetReferencePosition()A position associated with the object that indicates its aggregate geographic position.float[]getTextureCoords()Returns the texture coordinates for this polygon.java.lang.ObjectgetTextureImageSource()Returns this polygon's texture image source.protected voidhandleUnsuccessfulInteriorTessellation(DrawContext dc)Overridden to clear the polygon's locations iterable upon an unsuccessful tessellation attempt.protected voidlegacyRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)Restores state values from previous versions of the SurfaceShape state XML.voidsetLocations(java.lang.Iterable<? extends LatLon> iterable)voidsetOuterBoundary(java.lang.Iterable<? extends LatLon> iterable)voidsetTextureImageSource(java.lang.Object imageSource, float[] texCoords, int texCoordCount)Specifies the texture to apply to this polygon.protected voidsubdivideContour(java.util.List<SurfacePolygon.Vertex> contour, Angle maxEdgeLength)protected voidsubdivideEdge(SurfacePolygon.Vertex begin, SurfacePolygon.Vertex end, Angle maxEdgeLength, java.util.List<SurfacePolygon.Vertex> result)protected SurfacePolygon.ShapeDatatessellateContours(java.util.List<java.util.List<SurfacePolygon.Vertex>> contours)protected double[]uvWeightedAverage(java.util.List<SurfacePolygon.Vertex> contour, SurfacePolygon.Vertex vertex)-
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceShape
addIntermediateLocations, applyInteriorTextureState, applyModelviewTransform, applyOutlineState, beginDrawing, canContainPole, combine, combineBounds, combineContours, computeEdgeIntervalsPerDegree, computeEdgeIntervalsPerDegree, computeSectors, computeSectors, containsPole, createActiveAttributes, createGeometry, createGeometryKey, cutAlongDateLine, determineActiveAttributes, determineActiveGeometry, doCombineContour, doCombineContours, doDrag, doTessellateInterior, drag, drawGeographic, drawInterior, drawLineStrip, drawOutline, endDrawing, export, generateIntermediateLocations, getActiveAttributes, getActiveGeometry, getArea, getArea, getAttributes, getCachedGeometry, getExtent, getHeight, getHighlightAttributes, getInteriorTexture, getLength, getMinAndMaxEdgeIntervals, getPathType, getPerimeter, getRestorableState, getSectors, getStateKey, getTexelsPerEdgeInterval, getWidth, isDragEnabled, isExportFormatSupported, isHighlighted, isSectorEmpty, makeOrderedPreRenderable, move, moveTo, moveTo, pathTypeFromString, repeatAroundDateline, restoreState, setAttributes, setDragEnabled, setHighlightAttributes, setHighlighted, setMinAndMaxEdgeIntervals, setPathType, setTexelsPerEdgeInterval, setupAreaMeasurer, tessellateInterior, tessellateInteriorVertices
-
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
buildPickRepresentation, computeExtent, computeExtent, createPickedObject, createPickTileBuilder, drawBoundingSectors, drawOrderedRenderable, drawPickRepresentation, getDelegateOwner, getDistanceFromEye, getExtent, getUniqueId, intersectsFrustum, intersectsPickFrustum, intersectsVisibleSector, isDrawBoundingSectors, isEnableBatchPicking, isVisible, makeOrderedRenderable, nextUniqueId, onShapeChanged, pick, pickBatched, pickOrderedRenderable, preRender, render, setDelegateOwner, setDrawBoundingSectors, setEnableBatchPicking, setVisible, updateModifiedTime
-
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.Exportable
export, isExportFormatSupported
-
Methods inherited from interface gov.nasa.worldwind.render.Renderable
render
-
Methods inherited from interface gov.nasa.worldwind.render.SurfaceObject
getDelegateOwner, getDistanceFromEye, getExtent, isEnableBatchPicking, isVisible, pick, preRender, setDelegateOwner, setEnableBatchPicking, setVisible
-
-
-
-
Field Detail
-
boundaries
protected java.util.List<java.lang.Iterable<? extends LatLon>> boundaries
-
explicitTexture
protected WWTexture explicitTexture
If an image source was specified, this is the WWTexture form.
-
explicitTextureCoords
protected float[] explicitTextureCoords
This shape's texture coordinates.
-
shapeDataCache
protected java.util.Map<java.lang.Object,SurfacePolygon.ShapeData> shapeDataCache
-
tess
protected static com.jogamp.opengl.glu.GLUtessellator tess
-
tessCallback
protected static GLUTessellatorSupport.CollectPrimitivesCallback tessCallback
-
-
Constructor Detail
-
SurfacePolygon
public SurfacePolygon()
Constructs a new surface polygon with the default attributes and no locations.
-
SurfacePolygon
public SurfacePolygon(SurfacePolygon source)
Creates a shallow copy of the specified source shape.- Parameters:
source- the shape to copy.
-
SurfacePolygon
public SurfacePolygon(ShapeAttributes normalAttrs)
Constructs a new surface polygon with the specified normal (as opposed to highlight) attributes and no locations. Modifying the attribute reference after calling this constructor causes this shape's appearance to change accordingly.- Parameters:
normalAttrs- the normal attributes. May be null, in which case default attributes are used.
-
SurfacePolygon
public SurfacePolygon(java.lang.Iterable<? extends LatLon> iterable)
Constructs a new surface polygon with the default attributes and the specified iterable of locations.Note: If fewer than three locations is specified, no polygon is drawn.
- Parameters:
iterable- the polygon locations.- Throws:
java.lang.IllegalArgumentException- if the locations iterable is null.
-
SurfacePolygon
public SurfacePolygon(ShapeAttributes normalAttrs, java.lang.Iterable<? extends LatLon> iterable)
Constructs a new surface polygon with the specified normal (as opposed to highlight) attributes and the specified iterable of locations. Modifying the attribute reference after calling this constructor causes this shape's appearance to change accordingly.Note: If fewer than three locations is specified, no polygon is drawn.
- Parameters:
normalAttrs- the normal attributes. May be null, in which case default attributes are used.iterable- the polygon locations.- Throws:
java.lang.IllegalArgumentException- if the locations iterable is null.
-
-
Method Detail
-
getLocations
public java.lang.Iterable<? extends LatLon> getLocations(Globe globe)
Description copied from interface:SurfaceShapeReturns the shape's locations as they appear on the specifiedglobe, or null if the shape has no locations.- Specified by:
getLocationsin interfaceSurfaceShape- Parameters:
globe- the globe the shape is related to.- Returns:
- the shapes locations on the globe, or null if the shape has no locations.
-
getLocations
public java.lang.Iterable<? extends LatLon> getLocations()
-
getBoundaries
public java.util.List<java.lang.Iterable<? extends LatLon>> getBoundaries()
-
setLocations
public void setLocations(java.lang.Iterable<? extends LatLon> iterable)
-
getOuterBoundary
public java.lang.Iterable<? extends LatLon> getOuterBoundary()
-
setOuterBoundary
public void setOuterBoundary(java.lang.Iterable<? extends LatLon> iterable)
-
addInnerBoundary
public void addInnerBoundary(java.lang.Iterable<? extends LatLon> iterable)
-
getTextureImageSource
public java.lang.Object getTextureImageSource()
Returns this polygon's texture image source.- Returns:
- the texture image source, or null if no source has been specified.
-
getTextureCoords
public float[] getTextureCoords()
Returns the texture coordinates for this polygon.- Returns:
- the texture coordinates, or null if no texture coordinates have been specified.
-
setTextureImageSource
public void setTextureImageSource(java.lang.Object imageSource, float[] texCoords, int texCoordCount)Specifies the texture to apply to this polygon.- Parameters:
imageSource- the texture image source. May be aStringidentifying a file path or URL, aFile, or aURL.texCoords- the (s, t) texture coordinates aligning the image to the polygon. There must be one texture coordinate pair, (s, t), for each polygon location in the polygon's outer boundary.texCoordCount- the number of texture coordinates, (s, v) pairs, specified.- Throws:
java.lang.IllegalArgumentException- if the image source is not null and either the texture coordinates are null or inconsistent with the specified texture-coordinate count, or there are fewer than three texture coordinate pairs.
-
getReferencePosition
public Position getReferencePosition()
Description copied from interface:MovableA position associated with the object that indicates its aggregate geographic position. The chosen position varies among implementers of this interface. For objects defined by a list of positions, the reference position is typically the first position in the list. For symmetric objects the reference position is often the center of the object. In many cases the object's reference position may be explicitly specified by the application.- Specified by:
getReferencePositionin interfaceMovable- Specified by:
getReferencePositionin interfaceMovable2- Specified by:
getReferencePositionin classAbstractSurfaceShape- Returns:
- the object's reference position, or null if no reference position is available.
-
clearCaches
protected void clearCaches()
Description copied from class:AbstractSurfaceShapeClears this SurfaceObject's internal extent cache.Overridden to clear this SurfaceShape's internal sector and geometry caches.
- Overrides:
clearCachesin classAbstractSurfaceShape
-
doDrawGeographic
protected void doDrawGeographic(DrawContext dc, SurfaceTileDrawContext sdc)
- Overrides:
doDrawGeographicin classAbstractSurfaceShape
-
applyInteriorState
protected void applyInteriorState(DrawContext dc, SurfaceTileDrawContext sdc, ShapeAttributes attributes, WWTexture texture, LatLon refLocation)
- Overrides:
applyInteriorStatein classAbstractSurfaceShape
-
assembleContours
protected java.util.List<java.util.List<SurfacePolygon.Vertex>> assembleContours(Angle maxEdgeLength)
-
closeContour
protected void closeContour(java.util.List<SurfacePolygon.Vertex> contour)
-
subdivideContour
protected void subdivideContour(java.util.List<SurfacePolygon.Vertex> contour, Angle maxEdgeLength)
-
subdivideEdge
protected void subdivideEdge(SurfacePolygon.Vertex begin, SurfacePolygon.Vertex end, Angle maxEdgeLength, java.util.List<SurfacePolygon.Vertex> result)
-
clipWithPole
protected java.util.List<SurfacePolygon.Vertex> clipWithPole(java.util.List<SurfacePolygon.Vertex> contour, java.lang.String pole, Angle maxEdgeLength)
-
uvWeightedAverage
protected double[] uvWeightedAverage(java.util.List<SurfacePolygon.Vertex> contour, SurfacePolygon.Vertex vertex)
-
clipWithDateline
protected java.util.List<java.util.List<SurfacePolygon.Vertex>> clipWithDateline(java.util.List<SurfacePolygon.Vertex> contour)
-
tessellateContours
protected SurfacePolygon.ShapeData tessellateContours(java.util.List<java.util.List<SurfacePolygon.Vertex>> contours)
-
createGeometry
protected java.util.List<java.util.List<LatLon>> createGeometry(Globe globe, double edgeIntervalsPerDegree)
- Specified by:
createGeometryin classAbstractSurfaceShape
-
doMoveTo
protected void doMoveTo(Position oldReferencePosition, Position newReferencePosition)
- Specified by:
doMoveToin classAbstractSurfaceShape
-
doMoveTo
protected void doMoveTo(Globe globe, Position oldReferencePosition, Position newReferencePosition)
- Specified by:
doMoveToin classAbstractSurfaceShape
-
handleUnsuccessfulInteriorTessellation
protected void handleUnsuccessfulInteriorTessellation(DrawContext dc)
Overridden to clear the polygon's locations iterable upon an unsuccessful tessellation attempt. This ensures the polygon won't attempt to re-tessellate itself each frame.- Overrides:
handleUnsuccessfulInteriorTessellationin classAbstractSurfaceShape- Parameters:
dc- the current DrawContext.
-
doGetRestorableState
protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
- Overrides:
doGetRestorableStatein classAbstractSurfaceShape
-
doRestoreState
protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
- Overrides:
doRestoreStatein classAbstractSurfaceShape
-
legacyRestoreState
protected void legacyRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
Description copied from class:AbstractSurfaceShapeRestores state values from previous versions of the SurfaceShape state XML. These values are stored or named differently than the current implementation. Those values which have not changed are ignored here, and will restored inAbstractSurfaceShape.doRestoreState(gov.nasa.worldwind.util.RestorableSupport, gov.nasa.worldwind.util.RestorableSupport.StateObject).- Overrides:
legacyRestoreStatein classAbstractSurfaceShape- Parameters:
rs- RestorableSupport object which contains the state value properties.context- active context in the RestorableSupport to read state from.
-
exportAsKML
protected void exportAsKML(java.lang.Object output) throws java.io.IOException, javax.xml.stream.XMLStreamExceptionExport the polygon to KML as a<Placemark>element. Theoutputobject will receive the data. This object must be one of: java.io.Writer java.io.OutputStream javax.xml.stream.XMLStreamWriter- Overrides:
exportAsKMLin classAbstractSurfaceShape- 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:
AbstractSurfaceShape.export(String, Object)
-
-