NASA World Wind

gov.nasa.worldwind.render.airspaces
Class AbstractAirspace

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.render.airspaces.AbstractAirspace
All Implemented Interfaces:
AVList, ExtentHolder, Movable, Airspace, Renderable, Restorable
Direct Known Subclasses:
Box, Cake, CappedCylinder, Curtain, Orbit, Polygon, SphereAirspace, TrackAirspace

public abstract class AbstractAirspace
extends AVListImpl
implements Airspace, Movable


Nested Class Summary
protected static class AbstractAirspace.AirspaceInfo
           
 
Field Summary
protected  HashMap<Globe,AbstractAirspace.AirspaceInfo> airspaceInfo
           
protected static String ARC_SLICES
           
protected static String DISABLE_TERRAIN_CONFORMANCE
           
protected static String EXPIRY_TIME
           
protected static String GEOMETRY_CACHE_KEY
           
protected static String GEOMETRY_CACHE_NAME
           
protected static String GLOBE_KEY
           
protected static String LENGTH_SLICES
           
protected static String LOOPS
           
protected static String PILLARS
           
protected static String SLICES
           
protected static String SPLIT_THRESHOLD
           
protected static String STACKS
           
protected static String SUBDIVISIONS
           
protected static String VERTICAL_EXAGGERATION
           
 
Fields inherited from interface gov.nasa.worldwind.render.airspaces.Airspace
DRAW_STYLE_FILL, DRAW_STYLE_OUTLINE
 
Constructor Summary
AbstractAirspace()
           
AbstractAirspace(AirspaceAttributes attributes)
           
 
Method Summary
protected  void addDetailLevels(Collection<DetailLevel> newDetailLevels)
           
protected  void adjustForGroundReference(DrawContext dc, boolean[] terrainConformant, double[] altitudes, LatLon groundRef)
           
protected  void clearElevationMap()
           
protected  DetailLevel computeDetailLevel(DrawContext dc)
           
protected  double computeElevationAt(DrawContext dc, Angle latitude, Angle longitude)
           
protected  Extent computeExtent(DrawContext dc)
           
protected abstract  Extent computeExtent(Globe globe, double verticalExaggeration)
           
protected  double computeEyeDistance(DrawContext dc)
           
protected  List<Vec4> computeMinimalGeometry(DrawContext dc)
           
protected abstract  List<Vec4> computeMinimalGeometry(Globe globe, double verticalExaggeration)
           
 Vec4 computePointFromPosition(DrawContext dc, Angle latitude, Angle longitude, double elevation, boolean terrainConformant)
           
protected  Position computeReferencePosition(List<? extends LatLon> locations, double[] altitudes)
           
protected  void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  void doMoveTo(Position oldRef, Position newRef)
           
protected  void doRender(DrawContext dc)
           
protected  void doRenderExtent(DrawContext dc)
           
protected abstract  void doRenderGeometry(DrawContext dc, String drawStyle)
           
protected  void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  AbstractAirspace.AirspaceInfo getAirspaceInfo(DrawContext dc)
           
 String[] getAltitudeDatum()
          Returns the current altitude datum of the airspace's lower and upper surfaces.
 double[] getAltitudes()
          Returns the current airspace surface altitudes.
protected  double[] getAltitudes(double verticalExaggeration)
           
 AirspaceAttributes getAttributes()
           
 Iterable<DetailLevel> getDetailLevels()
           
protected  long[] getExpiryRange()
           
protected  long getExpiryTime()
           
 Extent getExtent(DrawContext dc)
          Returns this Airspace's enclosing volume as an Extent in model coordinates, given a specified DrawContext.
 Extent getExtent(Globe globe, double verticalExaggeration)
          Returns this Airspace's enclosing volume as an Extent in model coordinates, given a specified Globe and vertical exaggeration (see SceneController.getVerticalExaggeration().
protected  GeometryBuilder getGeometryBuilder()
           
protected  MemoryCache getGeometryCache()
           
 LatLon getGroundReference()
          Returns the current ground reference location.
 AirspaceRenderer getRenderer()
           
 String getRestorableState()
          Returns an XML document string describing the object's state.
 boolean isAirspaceCollapsed()
           
 boolean isAirspaceVisible(DrawContext dc)
          Test if this airspace is visible in the specified draw context.
 boolean isEnableLevelOfDetail()
           
protected  boolean isExpired(DrawContext dc, Geometry geom)
           
 boolean[] isTerrainConforming()
          Returns the old-style indicators of the airspace's lower and upper surface datums.
 boolean isVisible()
           
protected  void makeExtremePoints(Globe globe, double verticalExaggeration, Iterable<? extends LatLon> locations, List<Vec4> extremePoints)
           
 void makeOrderedRenderable(DrawContext dc, AirspaceRenderer renderer)
           
 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  long nextExpiryTime(DrawContext dc, boolean[] terrainConformance)
           
 void render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
 void renderExtent(DrawContext dc)
           
 void renderGeometry(DrawContext dc, String drawStyle)
           
 void restoreState(String stateInXml)
          Restores the object's state to what is described in the specified XML document string.
 void setAltitude(double altitude)
          Sets the lower and upper airspace surface altitudes to the same value.
 void setAltitudeDatum(String lowerAltitudeDatum, String upperAltitudeDatum)
          Sets the altitude datum, which indicates whether airspace altitudes are relative to mean sea level, ground level or a single ground reference location.
 void setAltitudes(double lowerAltitude, double upperAltitude)
          Sets the lower and upper airspace surface altitudes.
 void setAttributes(AirspaceAttributes attributes)
           
 void setDetailLevels(Collection<DetailLevel> detailLevels)
           
 void setEnableLevelOfDetail(boolean enableLevelOfDetail)
           
protected  void setExpiryRange(long minTimeMillis, long maxTimeMillis)
           
protected  void setExpiryTime(long timeMillis)
           
protected  void setExtentOutOfDate()
           
protected  void setGeometryBuilder(GeometryBuilder gb)
           
 void setGroundReference(LatLon groundReference)
          Sets the reference location used to determine the elevation offset for airspace surfaces whose altitude datum is AVKey.ABOVE_GROUND_REFERENCE.
protected  void setRenderer(AirspaceRenderer renderer)
           
 void setTerrainConforming(boolean terrainConformant)
          Sets the altitude datum for both the lower and upper airspace surface to the same specified value.
 void setTerrainConforming(boolean lowerTerrainConformant, boolean upperTerrainConformant)
          Sets the altitude datum, which indicates whether airspace altitudes are relative to mean sea level, ground level or a single ground reference location.
 void setVisible(boolean visible)
           
protected  void updateExpiryCriteria(DrawContext dc, Geometry geom)
           
 
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.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.Movable
getReferencePosition
 

Field Detail

airspaceInfo

protected HashMap<Globe,AbstractAirspace.AirspaceInfo> airspaceInfo

ARC_SLICES

protected static final String ARC_SLICES
See Also:
Constant Field Values

DISABLE_TERRAIN_CONFORMANCE

protected static final String DISABLE_TERRAIN_CONFORMANCE
See Also:
Constant Field Values

EXPIRY_TIME

protected static final String EXPIRY_TIME
See Also:
Constant Field Values

GEOMETRY_CACHE_KEY

protected static final String GEOMETRY_CACHE_KEY

GEOMETRY_CACHE_NAME

protected static final String GEOMETRY_CACHE_NAME
See Also:
Constant Field Values

GLOBE_KEY

protected static final String GLOBE_KEY
See Also:
Constant Field Values

LENGTH_SLICES

protected static final String LENGTH_SLICES
See Also:
Constant Field Values

LOOPS

protected static final String LOOPS
See Also:
Constant Field Values

PILLARS

protected static final String PILLARS
See Also:
Constant Field Values

SLICES

protected static final String SLICES
See Also:
Constant Field Values

SPLIT_THRESHOLD

protected static final String SPLIT_THRESHOLD
See Also:
Constant Field Values

STACKS

protected static final String STACKS
See Also:
Constant Field Values

SUBDIVISIONS

protected static final String SUBDIVISIONS
See Also:
Constant Field Values

VERTICAL_EXAGGERATION

protected static final String VERTICAL_EXAGGERATION
See Also:
Constant Field Values
Constructor Detail

AbstractAirspace

public AbstractAirspace()

AbstractAirspace

public AbstractAirspace(AirspaceAttributes attributes)
Method Detail

addDetailLevels

protected void addDetailLevels(Collection<DetailLevel> newDetailLevels)

adjustForGroundReference

protected void adjustForGroundReference(DrawContext dc,
                                        boolean[] terrainConformant,
                                        double[] altitudes,
                                        LatLon groundRef)

clearElevationMap

protected void clearElevationMap()

computeDetailLevel

protected DetailLevel computeDetailLevel(DrawContext dc)

computeElevationAt

protected double computeElevationAt(DrawContext dc,
                                    Angle latitude,
                                    Angle longitude)

computeExtent

protected Extent computeExtent(DrawContext dc)

computeExtent

protected abstract Extent computeExtent(Globe globe,
                                        double verticalExaggeration)

computeEyeDistance

protected double computeEyeDistance(DrawContext dc)

computeMinimalGeometry

protected List<Vec4> computeMinimalGeometry(DrawContext dc)

computeMinimalGeometry

protected abstract List<Vec4> computeMinimalGeometry(Globe globe,
                                                     double verticalExaggeration)

computePointFromPosition

public Vec4 computePointFromPosition(DrawContext dc,
                                     Angle latitude,
                                     Angle longitude,
                                     double elevation,
                                     boolean terrainConformant)

computeReferencePosition

protected Position computeReferencePosition(List<? extends LatLon> locations,
                                            double[] altitudes)

doGetRestorableState

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

doMoveTo

protected void doMoveTo(Position oldRef,
                        Position newRef)

doRender

protected void doRender(DrawContext dc)

doRenderExtent

protected void doRenderExtent(DrawContext dc)

doRenderGeometry

protected abstract void doRenderGeometry(DrawContext dc,
                                         String drawStyle)

doRestoreState

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

getAirspaceInfo

protected AbstractAirspace.AirspaceInfo getAirspaceInfo(DrawContext dc)

getAltitudeDatum

public String[] getAltitudeDatum()
Description copied from interface: Airspace
Returns the current altitude datum of the airspace's lower and upper surfaces.

Specified by:
getAltitudeDatum in interface Airspace
Returns:
a two-element array containing at position 0 the lower altitude datum, and at position 1 the upper altitude datum.
See Also:
Airspace.setAltitudeDatum(String, String)

getAltitudes

public double[] getAltitudes()
Description copied from interface: Airspace
Returns the current airspace surface altitudes.

Specified by:
getAltitudes in interface Airspace
Returns:
a two-element array of double with element 0 containing the lower surface altitude, and element 1 containing the upper surface altitude.
See Also:
Airspace.setAltitudes(double, double), Airspace.setAltitudeDatum(java.lang.String, java.lang.String), Airspace.setGroundReference(gov.nasa.worldwind.geom.LatLon)

getAltitudes

protected double[] getAltitudes(double verticalExaggeration)

getAttributes

public AirspaceAttributes getAttributes()
Specified by:
getAttributes in interface Airspace

getDetailLevels

public Iterable<DetailLevel> getDetailLevels()
Specified by:
getDetailLevels in interface Airspace

getExpiryRange

protected long[] getExpiryRange()

getExpiryTime

protected long getExpiryTime()

getExtent

public Extent getExtent(DrawContext dc)
Description copied from interface: Airspace
Returns this Airspace's enclosing volume as an Extent in model coordinates, given a specified DrawContext. The returned Extent may be different than the Extent returned by calling Airspace.getExtent(gov.nasa.worldwind.globes.Globe, double) with the DrawContext's Globe and vertical exaggeration. Additionally, this may cache the computed extent and is therefore potentially faster than calling Airspace.getExtent(gov.nasa.worldwind.globes.Globe, double).

Specified by:
getExtent in interface Airspace
Parameters:
dc - the current DrawContext.
Returns:
this Airspace's Extent in model coordinates.

getExtent

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

Specified by:
getExtent in interface ExtentHolder
Specified by:
getExtent in interface Airspace
Parameters:
globe - the Globe this Airspace is related to.
verticalExaggeration - the vertical exaggeration of the scene containing this Airspace.
Returns:
this Airspace's Extent in model coordinates.

getGeometryBuilder

protected GeometryBuilder getGeometryBuilder()

getGeometryCache

protected MemoryCache getGeometryCache()

getGroundReference

public LatLon getGroundReference()
Description copied from interface: Airspace
Returns the current ground reference location.

Specified by:
getGroundReference in interface Airspace
Returns:
the current ground reference location.

getRenderer

public AirspaceRenderer 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.

isAirspaceCollapsed

public boolean isAirspaceCollapsed()

isAirspaceVisible

public boolean isAirspaceVisible(DrawContext dc)
Test if this airspace is visible in the specified draw context. During picking mode, this tests intersection against all of the draw context's pick frustums. During rendering mode, this tests intersection against the draw context's viewing frustum.

Specified by:
isAirspaceVisible in interface Airspace
Parameters:
dc - the draw context the airspace is related to.
Returns:
true if this airspace is visible; false otherwise.

isEnableLevelOfDetail

public boolean isEnableLevelOfDetail()
Specified by:
isEnableLevelOfDetail in interface Airspace

isExpired

protected boolean isExpired(DrawContext dc,
                            Geometry geom)

isTerrainConforming

public boolean[] isTerrainConforming()
Description copied from interface: Airspace
Returns the old-style indicators of the airspace's lower and upper surface datums.

Specified by:
isTerrainConforming in interface Airspace
Returns:
the lower and upper surface datums.

isVisible

public boolean isVisible()
Specified by:
isVisible in interface Airspace

makeExtremePoints

protected void makeExtremePoints(Globe globe,
                                 double verticalExaggeration,
                                 Iterable<? extends LatLon> locations,
                                 List<Vec4> extremePoints)

makeOrderedRenderable

public void makeOrderedRenderable(DrawContext dc,
                                  AirspaceRenderer renderer)
Specified by:
makeOrderedRenderable in interface Airspace

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.

nextExpiryTime

protected long nextExpiryTime(DrawContext dc,
                              boolean[] terrainConformance)

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

renderExtent

public void renderExtent(DrawContext dc)
Specified by:
renderExtent in interface Airspace

renderGeometry

public void renderGeometry(DrawContext dc,
                           String drawStyle)
Specified by:
renderGeometry in interface Airspace

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.

setAltitude

public void setAltitude(double altitude)
Description copied from interface: Airspace
Sets the lower and upper airspace surface altitudes to the same value. The lower and upper altitudes are interpreted according to the current altitude datum of the respective surface. See Airspace.setAltitudeDatum(String, String) for a description of the possible interpretations and the means to specify them.

Specified by:
setAltitude in interface Airspace
Parameters:
altitude - the lower surface altitude, in meters.
See Also:
Airspace.setAltitudes(double, double), Airspace.setAltitudeDatum(java.lang.String, java.lang.String), Airspace.setGroundReference(gov.nasa.worldwind.geom.LatLon)

setAltitudeDatum

public void setAltitudeDatum(String lowerAltitudeDatum,
                             String upperAltitudeDatum)
Description copied from interface: Airspace
Sets the altitude datum, which indicates whether airspace altitudes are relative to mean sea level, ground level or a single ground reference location.

A value of AVKey.ABOVE_MEAN_SEA_LEVEL, the default for both lower and upper datums, indicates a datum of mean sea level. The respective lower or upper surface of the airspace is drawn at the constant altitude specified by Airspace.setAltitude(double).

A datum of AVKey.ABOVE_GROUND_LEVEL indicates that each position of the respective airspace surface is offset vertically from the altitude specified to Airspace.setAltitude(double) by an amount equal to the terrain elevation at that position. For example, if the specified lower altitude is zero, the lower surface lies on and conforms to the terrain. If non-zero, the surface undulates in tandem with the terrain but relative to the specified altitude.

A datum of AVKey.ABOVE_GROUND_REFERENCE combines both of the above datums. It indicates that the respective surface is drawn at the altitude specified to Airspace.setAltitude(double) but offset vertically by an amount equal to the elevation at a single reference location on the ground. This is useful for displaying surfaces that are "flat" but are positioned relative to the ground. An example is the roof of a building, which maintains a constant altitude even as the base of its building may conform to varying terrain. One method of representing buildings is to specify a lower altitude of 0, a lower altitude datum of AVKey.ABOVE_GROUND_LEVEL, an upper altitude that's the building's height, and an upper altitude datum of AVKey.ABOVE_GROUND_REFERENCE, where the ground reference is a location at the building's base. The reference position is specifed by Airspace.setGroundReference(LatLon).

Specified by:
setAltitudeDatum in interface Airspace
Parameters:
lowerAltitudeDatum - the lower altitude datum.
upperAltitudeDatum - the upper altitude datum
See Also:
Airspace.setGroundReference(gov.nasa.worldwind.geom.LatLon), Airspace.setAltitudes(double, double)

setAltitudes

public void setAltitudes(double lowerAltitude,
                         double upperAltitude)
Description copied from interface: Airspace
Sets the lower and upper airspace surface altitudes. The altitudes are interpreted according to the current altitude datum of the respective surface. See Airspace.setAltitudeDatum(String, String) for a description of the possible interpretations and the means to specify them.

Specified by:
setAltitudes in interface Airspace
Parameters:
lowerAltitude - the lower surface altitude, in meters.
upperAltitude - the upper surface altitude, in meters.
See Also:
Airspace.setAltitudes(double, double), Airspace.setAltitudeDatum(java.lang.String, java.lang.String), Airspace.setGroundReference(gov.nasa.worldwind.geom.LatLon)

setAttributes

public void setAttributes(AirspaceAttributes attributes)
Specified by:
setAttributes in interface Airspace

setDetailLevels

public void setDetailLevels(Collection<DetailLevel> detailLevels)
Specified by:
setDetailLevels in interface Airspace

setEnableLevelOfDetail

public void setEnableLevelOfDetail(boolean enableLevelOfDetail)
Specified by:
setEnableLevelOfDetail in interface Airspace

setExpiryRange

protected void setExpiryRange(long minTimeMillis,
                              long maxTimeMillis)

setExpiryTime

protected void setExpiryTime(long timeMillis)

setExtentOutOfDate

protected void setExtentOutOfDate()

setGeometryBuilder

protected void setGeometryBuilder(GeometryBuilder gb)

setGroundReference

public void setGroundReference(LatLon groundReference)
Description copied from interface: Airspace
Sets the reference location used to determine the elevation offset for airspace surfaces whose altitude datum is AVKey.ABOVE_GROUND_REFERENCE. The reference location is unused if the altitude datum is a value other than this.

Specified by:
setGroundReference in interface Airspace
Parameters:
groundReference - the location at which to compute the terrain elevation used to offset an upper or lower airspace surface. The location need not be within the airspace's bounds. If null, an airspace-specific position is chosen from those defining the airspace. See the method descriptions for the individual airspaces to determine the position used.
See Also:
Airspace.setAltitudeDatum(String, String)

setRenderer

protected void setRenderer(AirspaceRenderer renderer)

setTerrainConforming

public void setTerrainConforming(boolean terrainConformant)
Description copied from interface: Airspace
Sets the altitude datum for both the lower and upper airspace surface to the same specified value. The datum is normally set via Airspace.setAltitudeDatum(String, String), but this method is provided for backwards compatibility with the means of originally setting the datum. See the argument descriptions for the mapping of the boolean values of this method to the altitude-datum values.

Specified by:
setTerrainConforming in interface Airspace
Parameters:
terrainConformant - the altitude datum. See Airspace.setTerrainConforming(boolean, boolean) for a description of the possible values.

setTerrainConforming

public void setTerrainConforming(boolean lowerTerrainConformant,
                                 boolean upperTerrainConformant)
Description copied from interface: Airspace
Sets the altitude datum, which indicates whether airspace altitudes are relative to mean sea level, ground level or a single ground reference location. The datum is normally set via Airspace.setAltitudeDatum(String, String), but this method is provided for backwards compatibility with the means of originally setting the datum. See the argument descriptions below for the mapping of the boolean values of this method to the altitude-datum values.

Specified by:
setTerrainConforming in interface Airspace
Parameters:
lowerTerrainConformant - the lower altitude datum. A value of true indicates a lower altitude datum of AVKey.ABOVE_GROUND_LEVEL (terrain conforming), a value of false indicates a lower altitude datum of {link AVKey#ABOVE_MEAN_SEA_LEVEL} (not terrain conforming). the terrain-conforming, a value of false indicates that it's not.
upperTerrainConformant - the upper altitude datum. A value of true indicates an upper altitude datum of AVKey.ABOVE_GROUND_LEVEL (terrain conforming), a value of false indicates an upper altitude datum of {link AVKey#ABOVE_MEAN_SEA_LEVEL} (not terrain conforming. the terrain-conforming, a value of false indicates that it's not.
See Also:
Airspace.setAltitudeDatum(String, String)

setVisible

public void setVisible(boolean visible)
Specified by:
setVisible in interface Airspace

updateExpiryCriteria

protected void updateExpiryCriteria(DrawContext dc,
                                    Geometry geom)

NASA World Wind