NASA World Wind

gov.nasa.worldwind.render
Class AbstractSurfaceShape

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.render.AbstractSurfaceObject
          extended by gov.nasa.worldwind.render.AbstractSurfaceShape
All Implemented Interfaces:
AVList, MeasurableArea, MeasurableLength, Movable, PreRenderable, Renderable, SurfaceObject, SurfaceShape, Restorable
Direct Known Subclasses:
SurfaceConcaveShape, SurfacePolyline

public abstract class AbstractSurfaceShape
extends AbstractSurfaceObject
implements SurfaceShape, Movable


Nested Class Summary
protected static class AbstractSurfaceShape.CachedLocations
           
protected static class AbstractSurfaceShape.CachedSectors
           
protected static class AbstractSurfaceShape.CacheEntry<T>
           
 
Field Summary
protected  AreaMeasurer areaMeasurer
           
protected  long areaMeasurerLastModifiedTime
           
protected  ShapeAttributes attributes
           
protected static int DEFAULT_CACHE_CAPACITY
           
protected static int DEFAULT_MAX_EDGE_INTERVALS
           
protected static int DEFAULT_MIN_EDGE_INTERVALS
           
protected static java.lang.String DEFAULT_PATH_TYPE
           
protected static int DEFAULT_TEXELS_PER_EDGE_INTERVAL
           
protected  java.util.List<LatLon> drawLocations
           
protected  BoundedHashMap<java.lang.Object,AbstractSurfaceShape.CachedLocations> locationCache
           
protected  int maxEdgeIntervals
           
protected  int minEdgeIntervals
           
protected  java.lang.String pathType
           
protected  TiledSurfaceObjectRenderer renderer
           
protected  BoundedHashMap<java.lang.Object,AbstractSurfaceShape.CachedSectors> sectorCache
           
protected  boolean showBoundingSectors
           
protected  double texelsPerEdgeInterval
           
 
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
lastModifiedTime, visible
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
AbstractSurfaceShape()
           
AbstractSurfaceShape(ShapeAttributes attributes)
           
 
Method Summary
protected  void assembleRenderState(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void beginRenderToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  double computeEdgeIntervalsPerDegree(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  java.lang.Iterable<? extends Sector> doGetSectors(DrawContext dc, double texelSizeRadians)
           
protected abstract  void doMoveTo(Position oldReferencePosition, Position newReferencePosition)
           
protected  void doRenderBoundingSectors(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected abstract  void doRenderInteriorToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected abstract  void doRenderOutlineToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void doRenderShape(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void doRenderToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  void endRenderToRegion(DrawContext dc)
           
 double getArea(Globe globe)
          Returns the object's area in square meters.
 double getArea(Globe globe, boolean terrainConformant)
          Returns the shapes's area in square meters.
 ShapeAttributes getAttributes()
          Returns a copy of the rendering attributes associated with this SurfaceShape.
protected  java.lang.Iterable<? extends LatLon> getCachedLocations(DrawContext dc, double edgeIntervalsPerDegree)
           
protected  java.lang.Iterable<? extends LatLon> getCachedLocations(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
 double getHeight(Globe globe)
          Returns the latitudanl length of the object in meters.
 double getLength(Globe globe)
          Returns the object's length in meters.
protected abstract  java.lang.Iterable<? extends LatLon> getLocations(Globe globe, double edgeIntevalsPerDegree)
           
 int[] getMinAndMaxEdgeIntervals()
          Returns the minimum and maximum number of interpolated intervals that may be added to each shape edge.
 java.lang.String getPathType()
          Returns the path type used to interpolate between locations on this SurfaceShape.
 double getPerimeter(Globe globe)
          Returns the length of the object's perimeter in meters.
abstract  Position getReferencePosition()
           
protected  TiledSurfaceObjectRenderer getRenderer()
           
 java.lang.String getRestorableState()
          Returns an XML document string describing the object's state.
 java.lang.Iterable<? extends Sector> getSectors(DrawContext dc, double texelSizeRadians)
           
protected static SurfaceShapeSupport getSurfaceShapeSupport()
           
 double getTexelsPerEdgeInterval()
          Returns the number of texels per shape edge interval.
 double getWidth(Globe globe)
          Returns the longitudinal length of the object in meters.
 boolean isShowBoundingSectors()
           
protected  void legacyRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
          Restores state values from previous versions of the SurfaceShape state XML.
 void move(Position position)
          Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
 void moveTo(Position position)
          Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
protected  void onShapeChanged()
           
protected  java.lang.String pathTypeFromString(java.lang.String s)
           
 void preRender(DrawContext dc)
           
 void render(DrawContext dc)
          Causes this Renderable to render itself using the DrawContext provided.
 void restoreState(java.lang.String stateInXml)
          Restores the object's state to what is described in the specified XML document string.
 void setAttributes(ShapeAttributes attributes)
          Sets the rendering attributes associated with this SurfaceShape.
 void setMinAndMaxEdgeIntervals(int minEdgeIntervals, int maxEdgeIntervals)
          Sets the minimum and maximum number of interpolated intervals that may be added to each shape edge.
 void setPathType(java.lang.String pathType)
          Sets the path type used to interpolate between locations on this SurfaceShape.
 void setShowBoundingSectors(boolean showBoundingSectors)
           
 void setTexelsPerEdgeInterval(double texelsPerEdgeInterval)
          Sets the number of texels per shape edge interval.
protected  AreaMeasurer setupAreaMeasurer(Globe globe)
           
 
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
getLastModifiedTime, isVisible, renderToRegion, setVisible, updateModifiedTime
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, 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.render.SurfaceShape
getLocations
 
Methods inherited from interface gov.nasa.worldwind.render.SurfaceObject
getLastModifiedTime, isVisible, renderToRegion, setVisible
 
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

areaMeasurer

protected AreaMeasurer areaMeasurer

areaMeasurerLastModifiedTime

protected long areaMeasurerLastModifiedTime

attributes

protected ShapeAttributes attributes

DEFAULT_CACHE_CAPACITY

protected static final int DEFAULT_CACHE_CAPACITY
See Also:
Constant Field Values

DEFAULT_MAX_EDGE_INTERVALS

protected static final int DEFAULT_MAX_EDGE_INTERVALS
See Also:
Constant Field Values

DEFAULT_MIN_EDGE_INTERVALS

protected static final int DEFAULT_MIN_EDGE_INTERVALS
See Also:
Constant Field Values

DEFAULT_PATH_TYPE

protected static final java.lang.String DEFAULT_PATH_TYPE
See Also:
Constant Field Values

DEFAULT_TEXELS_PER_EDGE_INTERVAL

protected static final int DEFAULT_TEXELS_PER_EDGE_INTERVAL
See Also:
Constant Field Values

drawLocations

protected java.util.List<LatLon> drawLocations

locationCache

protected BoundedHashMap<java.lang.Object,AbstractSurfaceShape.CachedLocations> locationCache

maxEdgeIntervals

protected int maxEdgeIntervals

minEdgeIntervals

protected int minEdgeIntervals

pathType

protected java.lang.String pathType

renderer

protected TiledSurfaceObjectRenderer renderer

sectorCache

protected BoundedHashMap<java.lang.Object,AbstractSurfaceShape.CachedSectors> sectorCache

showBoundingSectors

protected boolean showBoundingSectors

texelsPerEdgeInterval

protected double texelsPerEdgeInterval
Constructor Detail

AbstractSurfaceShape

public AbstractSurfaceShape()

AbstractSurfaceShape

public AbstractSurfaceShape(ShapeAttributes attributes)
Method Detail

assembleRenderState

protected void assembleRenderState(DrawContext dc,
                                   Sector sector,
                                   int x,
                                   int y,
                                   int width,
                                   int height)

beginRenderToRegion

protected void beginRenderToRegion(DrawContext dc,
                                   Sector sector,
                                   int x,
                                   int y,
                                   int width,
                                   int height)

computeEdgeIntervalsPerDegree

protected double computeEdgeIntervalsPerDegree(DrawContext dc,
                                               Sector sector,
                                               int x,
                                               int y,
                                               int width,
                                               int height)

doGetRestorableState

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

doGetSectors

protected java.lang.Iterable<? extends Sector> doGetSectors(DrawContext dc,
                                                            double texelSizeRadians)

doMoveTo

protected abstract void doMoveTo(Position oldReferencePosition,
                                 Position newReferencePosition)

doRenderBoundingSectors

protected void doRenderBoundingSectors(DrawContext dc,
                                       Sector sector,
                                       int x,
                                       int y,
                                       int width,
                                       int height)

doRenderInteriorToRegion

protected abstract void doRenderInteriorToRegion(DrawContext dc,
                                                 Sector sector,
                                                 int x,
                                                 int y,
                                                 int width,
                                                 int height)

doRenderOutlineToRegion

protected abstract void doRenderOutlineToRegion(DrawContext dc,
                                                Sector sector,
                                                int x,
                                                int y,
                                                int width,
                                                int height)

doRenderShape

protected void doRenderShape(DrawContext dc,
                             Sector sector,
                             int x,
                             int y,
                             int width,
                             int height)

doRenderToRegion

protected void doRenderToRegion(DrawContext dc,
                                Sector sector,
                                int x,
                                int y,
                                int width,
                                int height)
Specified by:
doRenderToRegion in class AbstractSurfaceObject

doRestoreState

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

endRenderToRegion

protected void endRenderToRegion(DrawContext dc)

getArea

public double getArea(Globe globe)
Description copied from interface: MeasurableArea
Returns the object's area in square meters. If the object conforms to terrain, the area returned is the surface area of the terrain, including its hillsides and other undulations.

Specified by:
getArea in interface MeasurableArea
Parameters:
globe - The globe the object is related to.
Returns:
the object's area in square meters. Returns -1 if the object does not form an area due to an insufficient number of vertices or any other condition.

getArea

public double getArea(Globe globe,
                      boolean terrainConformant)
Description copied from interface: SurfaceShape
Returns the shapes's area in square meters. If terrainConformant is true, the area returned is the surface area of the terrain, including its hillsides and other undulations.

Specified by:
getArea in interface SurfaceShape
Parameters:
globe - the globe the shape is related to.
terrainConformant - whether or not the returned area should treat the shape as conforming to the terrain.
Returns:
the shape's area in square meters. Returns -1 if the object does not form an area due to an insufficient number of vertices or any other condition.

getAttributes

public ShapeAttributes getAttributes()
Description copied from interface: SurfaceShape
Returns a copy of the rendering attributes associated with this SurfaceShape. Modifying the contents of the returned reference has no effect on this shape. In order to make an attribute change take effect, invoke SurfaceShape.setAttributes(ShapeAttributes) with the modified attributes.

Specified by:
getAttributes in interface SurfaceShape
Returns:
a copy of this shape's rendering attributes.

getCachedLocations

protected java.lang.Iterable<? extends LatLon> getCachedLocations(DrawContext dc,
                                                                  double edgeIntervalsPerDegree)

getCachedLocations

protected java.lang.Iterable<? extends LatLon> getCachedLocations(DrawContext dc,
                                                                  Sector sector,
                                                                  int x,
                                                                  int y,
                                                                  int width,
                                                                  int height)

getHeight

public double getHeight(Globe globe)
Description copied from interface: MeasurableArea
Returns the latitudanl length of the object in meters. The length is the distance from the objects south-most point to its east-most position.

Specified by:
getHeight in interface MeasurableArea
Parameters:
globe - The globe the object is related to.
Returns:
the height of the object in meters.

getLength

public double getLength(Globe globe)
Description copied from interface: MeasurableLength
Returns the object's length in meters. If the object conforms to terrain, the length is that along the terrain, including its hillsides and other undulations.

Specified by:
getLength in interface MeasurableLength
Parameters:
globe - The globe the object is related to.
Returns:
the object's length in meters.

getLocations

protected abstract java.lang.Iterable<? extends LatLon> getLocations(Globe globe,
                                                                     double edgeIntevalsPerDegree)

getMinAndMaxEdgeIntervals

public int[] getMinAndMaxEdgeIntervals()
Description copied from interface: SurfaceShape
Returns the minimum and maximum number of interpolated intervals that may be added to each shape edge.

Specified by:
getMinAndMaxEdgeIntervals in interface SurfaceShape
Returns:
array of two elements, the first element is minEdgeIntervals, the second element is maxEdgeIntervals.
See Also:
SurfaceShape.setMinAndMaxEdgeIntervals(int, int)

getPathType

public java.lang.String getPathType()
Description copied from interface: SurfaceShape
Returns the path type used to interpolate between locations on this SurfaceShape.

Specified by:
getPathType in interface SurfaceShape
Returns:
path interpolation type.

getPerimeter

public double getPerimeter(Globe globe)
Description copied from interface: MeasurableArea
Returns the length of the object's perimeter in meters. If the object conforms to terrain, the perimeter is that along the terrain, including its hillsides and other undulations.

Specified by:
getPerimeter in interface MeasurableArea
Parameters:
globe - The globe the object is related to.
Returns:
the object's perimeter in meters. Returns -1 if the object does not form an area due to an insufficient number of vertices or any other condition.

getReferencePosition

public abstract Position getReferencePosition()
Specified by:
getReferencePosition in interface Movable

getRenderer

protected TiledSurfaceObjectRenderer getRenderer()

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 calling restoreState and passing the XML document.

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

getSectors

public java.lang.Iterable<? extends Sector> getSectors(DrawContext dc,
                                                       double texelSizeRadians)
Specified by:
getSectors in interface SurfaceObject

getSurfaceShapeSupport

protected static SurfaceShapeSupport getSurfaceShapeSupport()

getTexelsPerEdgeInterval

public double getTexelsPerEdgeInterval()
Description copied from interface: SurfaceShape
Returns the number of texels per shape edge interval.

Specified by:
getTexelsPerEdgeInterval in interface SurfaceShape
Returns:
texels per shape edge interval.
See Also:
SurfaceShape.setTexelsPerEdgeInterval(double)

getWidth

public double getWidth(Globe globe)
Description copied from interface: MeasurableArea
Returns the longitudinal length of the object in meters. The length is the distance from the object's west-most point to its east-most. If the object is terrain conforming then the

Specified by:
getWidth in interface MeasurableArea
Parameters:
globe - The globe the object is related to.
Returns:
the width of the object in meters.

isShowBoundingSectors

public boolean isShowBoundingSectors()

legacyRestoreState

protected void legacyRestoreState(RestorableSupport rs,
                                  RestorableSupport.StateObject context)
Restores 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 in {# doRestoreState }.

Parameters:
rs - RestorableSupport object which contains the state value properties.
context - active context in the RestorableSupport to read state from.

move

public void move(Position position)
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:
position - the latitude and longitude to add to the shape's reference position.

moveTo

public void moveTo(Position position)
Description copied from interface: Movable
Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.

Specified by:
moveTo in interface Movable
Parameters:
position - the new position of the shape's reference position.

onShapeChanged

protected void onShapeChanged()

pathTypeFromString

protected java.lang.String pathTypeFromString(java.lang.String s)

preRender

public void preRender(DrawContext dc)
Specified by:
preRender in interface PreRenderable

render

public void render(DrawContext dc)
Description copied from interface: Renderable
Causes this Renderable to render itself using the DrawContext provided. The DrawContext provides the elevation model, openGl instance, globe and other information required for drawing. It is recommended that the DrawContext is non-null as most implementations do not support null DrawContexts.

Specified by:
render in interface Renderable
Parameters:
dc - the DrawContext to be used
See Also:
DrawContext

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

setAttributes

public void setAttributes(ShapeAttributes attributes)
Description copied from interface: SurfaceShape
Sets the rendering attributes associated with this SurfaceShape. The caller cannot assume that modifying the attribute reference after calling setAttributes() will have any effect, as the implementation may defensively copy the attribute reference. In order to make an attribute change take effect, invoke setAttributes(ShapeAttributes) again with the modified attributes.

Specified by:
setAttributes in interface SurfaceShape
Parameters:
attributes - this shapes new rendering attributes.

setMinAndMaxEdgeIntervals

public void setMinAndMaxEdgeIntervals(int minEdgeIntervals,
                                      int maxEdgeIntervals)
Description copied from interface: SurfaceShape
Sets the minimum and maximum number of interpolated intervals that may be added to each shape edge. The minimum and maximum values may be 0, or any positive integer. Note that Setting either of minEdgeIntervals or maxEdgeIntervals too large may adversely impact surface shape rendering performance.

Specified by:
setMinAndMaxEdgeIntervals in interface SurfaceShape
Parameters:
minEdgeIntervals - the minimum number of interpolated edge intervals.
maxEdgeIntervals - the maximum number of interpolated edge intervals.
See Also:
SurfaceShape.setTexelsPerEdgeInterval(double)

setPathType

public void setPathType(java.lang.String pathType)
Description copied from interface: SurfaceShape
Sets the path type used to interpolate between locations on this SurfaceShape. This should be one of

Specified by:
setPathType in interface SurfaceShape
Parameters:
pathType - path interpolation type.

setShowBoundingSectors

public void setShowBoundingSectors(boolean showBoundingSectors)

setTexelsPerEdgeInterval

public void setTexelsPerEdgeInterval(double texelsPerEdgeInterval)
Description copied from interface: SurfaceShape
Sets the number of texels per shape edge interval. This value controls how many interpolated intervals will be added to each shape edge, depending on size of the original edge in texels. Each shape is responsible for defining what an edge is, though for most shapes it will simply be defined as the edge between implicit or caller-specified shape locations. The number of interpolated intervals is limited by the values set in a call to SurfaceShape.setMinAndMaxEdgeIntervals(int, int).

Specified by:
setTexelsPerEdgeInterval in interface SurfaceShape
Parameters:
texelsPerEdgeInterval - the size, in texels, of each interpolated edge interval.
See Also:
SurfaceShape.setMinAndMaxEdgeIntervals(int, int)

setupAreaMeasurer

protected AreaMeasurer setupAreaMeasurer(Globe globe)

NASA World Wind