NASA World Wind

gov.nasa.worldwind.render
Class AbstractSurfaceShape

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

public abstract class AbstractSurfaceShape
extends AbstractSurfaceObject
implements SurfaceShape, Movable


Field Summary
protected  AreaMeasurer areaMeasurer
           
protected  long areaMeasurerLastModifiedTime
           
protected  List<LatLon> drawLocations
           
protected  long drawLocationsLastModifiedTime
           
protected  int edgeIntervalsPerDegree
           
protected  String pathType
           
protected  TiledSurfaceObjectRenderer renderer
           
 
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
lastModifiedTime, visible
 
Constructor Summary
AbstractSurfaceShape()
           
AbstractSurfaceShape(ShapeAttributes attributes)
           
 
Method Summary
protected abstract  void computeLocations(Globe globe, List<LatLon> locations)
           
protected  void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected abstract  void doMoveTo(Position oldReferencePosition, Position newReferencePosition)
           
protected  void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
           
 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)
           
 int getEdgeIntervalsPerDegree()
          Returns the number of edge intervals that will be added between shape locations, er degree of latitude and longitude.
 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.
 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)
           
protected static SurfaceShapeSupport getSurfaceShapeSupport()
           
 double getWidth(Globe globe)
          Returns the longitudinal length of the object in meters.
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.
 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 setEdgeIntervalsPerDegree(int numIntervals)
          Sets the number of edge intervals to add between shape locations, per degree of latitude and longitude.
 void setPathType(String pathType)
          Sets the path type used to interpolate between locations on this SurfaceShape.
protected  AreaMeasurer setupAreaMeasurer(Globe globe)
           
 
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
doRenderToRegion, getLastModifiedTime, isVisible, renderToRegion, setVisible, updateModifiedTime
 
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
 

Field Detail

areaMeasurer

protected AreaMeasurer areaMeasurer

areaMeasurerLastModifiedTime

protected long areaMeasurerLastModifiedTime

drawLocations

protected List<LatLon> drawLocations

drawLocationsLastModifiedTime

protected long drawLocationsLastModifiedTime

edgeIntervalsPerDegree

protected int edgeIntervalsPerDegree

pathType

protected String pathType

renderer

protected TiledSurfaceObjectRenderer renderer
Constructor Detail

AbstractSurfaceShape

public AbstractSurfaceShape()

AbstractSurfaceShape

public AbstractSurfaceShape(ShapeAttributes attributes)
Method Detail

computeLocations

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

doGetRestorableState

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

doMoveTo

protected abstract void doMoveTo(Position oldReferencePosition,
                                 Position newReferencePosition)

doRestoreState

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

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)

getEdgeIntervalsPerDegree

public int getEdgeIntervalsPerDegree()
Description copied from interface: SurfaceShape
Returns the number of edge intervals that will be added between shape locations, er degree of latitude and longitude.

Specified by:
getEdgeIntervalsPerDegree in interface SurfaceShape
Returns:
number of edge intervals between locations, per degree.

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.

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)
Specified by:
getSectors in interface SurfaceObject

getSurfaceShapeSupport

protected static SurfaceShapeSupport getSurfaceShapeSupport()

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.

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

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.

setEdgeIntervalsPerDegree

public void setEdgeIntervalsPerDegree(int numIntervals)
Description copied from interface: SurfaceShape
Sets the number of edge intervals to add between shape locations, per degree of latitude and longitude.

Specified by:
setEdgeIntervalsPerDegree in interface SurfaceShape
Parameters:
numIntervals - number of edge intervals between locations, per degree.

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

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

setupAreaMeasurer

protected AreaMeasurer setupAreaMeasurer(Globe globe)

NASA World Wind