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.CacheEntry<T>
           
 
Field Summary
protected  AreaMeasurer areaMeasurer
           
protected  long areaMeasurerLastModifiedTime
           
protected static int DEFAULT_CACHE_CAPACITY
           
protected static int DEFAULT_MAX_EDGE_INTERVALS
           
protected static int DEFAULT_MIN_EDGE_INTERVALS
           
protected static String DEFAULT_PATH_TYPE
           
protected static int DEFAULT_TEXELS_PER_EDGE_INTERVAL
           
protected  BoundedHashMap<Object,AbstractSurfaceShape.CacheEntry<List<LatLon>>> drawLocationCache
           
protected  int maxEdgeIntervals
           
protected  int minEdgeIntervals
           
protected  String pathType
           
protected  TiledSurfaceObjectRenderer renderer
           
protected  BoundedHashMap<Object,AbstractSurfaceShape.CacheEntry<Iterable<? extends Sector>>> sectorCache
           
protected  boolean showBoundingSectors
           
protected  double texelsPerEdgeInterval
           
protected  List<Vec4> vertices
           
 
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 assembleShapeVertices(DrawContext dc, Sector sector, int x, int y, int width, int height, List<Vec4> vertices)
           
protected  void beginRenderToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void bindShapeData(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected abstract  void computeDrawLocations(Globe globe, double edgeIntervalsPerDegree, List<LatLon> locations)
           
protected  double computeEdgeIntervalsPerDegree(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected abstract  void computeLocations(Globe globe, List<LatLon> locations)
           
protected  void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  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 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, Sector sector, int x, int y, int width, int height)
           
 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 the rendering attributes associated with this SurfaceShape.
protected  List<? extends LatLon> getDrawLocations(DrawContext dc, double edgeIntervalsPerDegree)
           
protected  List<? extends LatLon> getDrawLocations(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.
 Iterable<? extends LatLon> getLocations(Globe globe)
          Returns the shape's locations as they appear on the specified globe.
 int[] getMinAndMaxEdgeIntervals()
          Returns the minimum and maximum number of interpolated intervals that may be added to each shape edge.
 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()
           
 String getRestorableState()
          Returns an XML document string describing the object’s state.
 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  String pathTypeFromString(String s)
           
 void preRender(DrawContext dc)
           
 void render(DrawContext dc)
          Causes this Renderable to render itself using the DrawContext provided.
protected  void renderBoundingSectors(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void renderInteriorToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void renderOutlineToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
 void restoreState(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(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.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

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

drawLocationCache

protected BoundedHashMap<Object,AbstractSurfaceShape.CacheEntry<List<LatLon>>> drawLocationCache

maxEdgeIntervals

protected int maxEdgeIntervals

minEdgeIntervals

protected int minEdgeIntervals

pathType

protected String pathType

renderer

protected TiledSurfaceObjectRenderer renderer

sectorCache

protected BoundedHashMap<Object,AbstractSurfaceShape.CacheEntry<Iterable<? extends Sector>>> sectorCache

showBoundingSectors

protected boolean showBoundingSectors

texelsPerEdgeInterval

protected double texelsPerEdgeInterval

vertices

protected List<Vec4> vertices
Constructor Detail

AbstractSurfaceShape

public AbstractSurfaceShape()

AbstractSurfaceShape

public AbstractSurfaceShape(ShapeAttributes attributes)
Method Detail

assembleShapeVertices

protected void assembleShapeVertices(DrawContext dc,
                                     Sector sector,
                                     int x,
                                     int y,
                                     int width,
                                     int height,
                                     List<Vec4> vertices)

beginRenderToRegion

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

bindShapeData

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

computeDrawLocations

protected abstract void computeDrawLocations(Globe globe,
                                             double edgeIntervalsPerDegree,
                                             List<LatLon> locations)

computeEdgeIntervalsPerDegree

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

computeLocations

protected abstract void computeLocations(Globe globe,
                                         List<LatLon> locations)

doGetRestorableState

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

doGetSectors

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

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,
                                 Sector sector,
                                 int x,
                                 int y,
                                 int width,
                                 int height)

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 the rendering attributes associated with this SurfaceShape.

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

getDrawLocations

protected List<? extends LatLon> getDrawLocations(DrawContext dc,
                                                  double edgeIntervalsPerDegree)

getDrawLocations

protected List<? extends LatLon> getDrawLocations(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

public Iterable<? extends LatLon> getLocations(Globe globe)
Description copied from interface: SurfaceShape
Returns the shape's locations as they appear on the specified globe.

Specified by:
getLocations in interface SurfaceShape
Parameters:
globe - the globe the shape is related to.
Returns:
the shapes locations on the globe.

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 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 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 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 String pathTypeFromString(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

renderBoundingSectors

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

renderInteriorToRegion

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

renderOutlineToRegion

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

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.

setAttributes

public void setAttributes(ShapeAttributes attributes)
Description copied from interface: SurfaceShape
Sets the rendering attributes associated with this SurfaceShape.

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(String pathType)
Description copied from interface: SurfaceShape
Sets the path type used to interpolate between locations on this SurfaceShape. This should be one of
  • gov.nasa.worldwind.avlist.AVKey.GREAT_CIRCLE
  • gov.nasa.worldwind.avlist.AVKey.LINEAR
  • gov.nasa.worldwind.avlist.AVKey.LOXODROME
  • gov.nasa.worldwind.avlist.AVKey.RHUMB

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

Hosted by docs.bugaco.com