NASA World Wind

gov.nasa.worldwind.render
Class SurfaceObjectTileBuilder.SurfaceObjectTile

java.lang.Object
  extended by gov.nasa.worldwind.util.Tile
      extended by gov.nasa.worldwind.layers.TextureTile
          extended by gov.nasa.worldwind.render.SurfaceObjectTileBuilder.SurfaceObjectTile
All Implemented Interfaces:
Cacheable, SurfaceTile, Comparable<Tile>
Enclosing class:
SurfaceObjectTileBuilder

protected static class SurfaceObjectTileBuilder.SurfaceObjectTile
extends TextureTile

Represents a TextureTile who's contents is constructed by a set of surface objects. The tile maintains a collection of surface objects that intersect the tile, and provides methods for to modify and retrieve that collection. Additionally, the method getStateKey(DrawContext) provides a mechanism to uniquely identify the tile's current state, including the state of each intersecting surface object.


Field Summary
protected  List<SurfaceObject> intersectingObjects
          List of surface objects intersecting the tile.
protected  Object lastUpdateStateKey
          The state key that was valid when the tile was last updated.
protected  Sector objectSector
          The sector that bounds the surface objects intersecting the tile.
 
Fields inherited from class gov.nasa.worldwind.layers.TextureTile
hasMipmapData, updateTime
 
Constructor Summary
SurfaceObjectTileBuilder.SurfaceObjectTile(Sector sector, Level level, int row, int column, String cacheName)
          Constructs a tile for a given sector, level, row and column of the tile's containing tile set.
 
Method Summary
 void addAllSurfaceObjects(List<SurfaceObject> c, Sector sector)
          Adds the specified collection of surface objects to the tile's list of intersecting objects.
 void addSurfaceObject(SurfaceObject so, Sector sector)
          Adds the specified surface object to the tile's list of intersecting objects.
 void clearObjectList()
          Clears the tile's list of intersecting objects.
protected  TextureTile createSubTile(Sector sector, Level level, int row, int col)
          Creates a sub tile of this texture tile with the specified Sector, Level, row, and column.
protected  TileKey createSubTileKey(Level level, int row, int col)
          Returns a key for a sub tile of this texture tile with the specified Level, row, and column.
 List<SurfaceObject> getObjectList()
          Returns a list of surface objects intersecting the tile.
 Sector getObjectSector()
          Returns a sector that bounds the surface objects intersecting the tile.
 long getSizeInBytes()
          Returns the tile's size in bytes.
 Object getStateKey(DrawContext dc)
          Returns an object that uniquely identifies the tile's state on the specified draw context.
 boolean hasObjects()
          Returns whether list of surface objects intersecting this tile has elements.
 
Methods inherited from class gov.nasa.worldwind.layers.TextureTile
applyInternalTransform, applyResourceTextureTransform, bind, createSubTiles, equals, getCentroidPoint, getCorners, getExtent, getFallbackTile, getMemoryCache, getTexture, getTextureData, getTileFromMemoryCache, getUpdateTime, hashCode, initializeTexture, isTextureExpired, isTextureExpired, isTextureInMemory, setFallbackTile, setTexture, setTextureData, setTextureParameters, toString, updateMemoryCache
 
Methods inherited from class gov.nasa.worldwind.util.Tile
compareTo, computeColumn, computeColumnLongitude, computeRow, computeRowLatitude, getCacheName, getColumn, getFormatSuffix, getHeight, getLabel, getLevel, getLevelName, getLevelNumber, getPath, getPathBase, getPriority, getResourceURL, getResourceURL, getRow, getSector, getTileKey, getWidth, setPriority
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.render.SurfaceTile
getSector
 

Field Detail

intersectingObjects

protected List<SurfaceObject> intersectingObjects
List of surface objects intersecting the tile.


lastUpdateStateKey

protected Object lastUpdateStateKey
The state key that was valid when the tile was last updated.


objectSector

protected Sector objectSector
The sector that bounds the surface objects intersecting the tile.

Constructor Detail

SurfaceObjectTileBuilder.SurfaceObjectTile

public SurfaceObjectTileBuilder.SurfaceObjectTile(Sector sector,
                                                  Level level,
                                                  int row,
                                                  int column,
                                                  String cacheName)
Constructs a tile for a given sector, level, row and column of the tile's containing tile set.

Parameters:
sector - The sector corresponding with the tile.
level - The tile's level within a containing level set.
row - The row index (0 origin) of the tile within the indicated level.
column - The column index (0 origin) of the tile within the indicated level.
cacheName - The tile's cache name. Overrides the Level's cache name to associates the tile with it's tile builder in a global cache.
Throws:
IllegalArgumentException - if any of the sector, level, or cacheName are null.
Method Detail

addAllSurfaceObjects

public void addAllSurfaceObjects(List<SurfaceObject> c,
                                 Sector sector)
Adds the specified collection of surface objects to the tile's list of intersecting objects.

Parameters:
c - the collection of surface objects to add.
sector - the sector bounding the specified surface object collection.

addSurfaceObject

public void addSurfaceObject(SurfaceObject so,
                             Sector sector)
Adds the specified surface object to the tile's list of intersecting objects.

Parameters:
so - the surface object to add.
sector - the sector bounding the specified surface object.

clearObjectList

public void clearObjectList()
Clears the tile's list of intersecting objects. getObjectSector() returns null after calling this method.


createSubTile

protected TextureTile createSubTile(Sector sector,
                                    Level level,
                                    int row,
                                    int col)
Creates a sub tile of this texture tile with the specified Sector, Level, row, and column. This is called by TextureTile.createSubTiles(gov.nasa.worldwind.util.Level), to construct a sub tile for each quadrant of this tile. Subclasses must override this method to return an instance of the derived version.

Overridden to return a new SurfaceObjectTile. The returned tile is created with the same cache name as this tile.

Overrides:
createSubTile in class TextureTile
Parameters:
sector - the sub tile's sector.
level - the sub tile's level.
row - the sub tile's row.
col - the sub tile's column.
Returns:
a sub tile of this texture tile.

createSubTileKey

protected TileKey createSubTileKey(Level level,
                                   int row,
                                   int col)
Returns a key for a sub tile of this texture tile with the specified Level, row, and column. This is called by TextureTile.createSubTiles(gov.nasa.worldwind.util.Level), to create a sub tile key for each quadrant of this tile.

Overridden to return a TileKey with the same cache name as this tile.

Overrides:
createSubTileKey in class TextureTile
Parameters:
level - the sub tile's level.
row - the sub tile's row.
col - the sub tile's column.
Returns:
a sub tile of this texture tile.

getObjectList

public List<SurfaceObject> getObjectList()
Returns a list of surface objects intersecting the tile.

Returns:
a tile's intersecting objects.

getObjectSector

public Sector getObjectSector()
Returns a sector that bounds the surface objects intersecting the tile. This returns null if no surface objects intersect the tile.

Returns:
a sector bounding the tile's intersecting objects.

getSizeInBytes

public long getSizeInBytes()
Returns the tile's size in bytes. Overridden to append the size of the Tile.cacheName and the lastUpdateStateKey to the superclass' computed size.

Specified by:
getSizeInBytes in interface Cacheable
Overrides:
getSizeInBytes in class TextureTile
Returns:
The tile's size in bytes.

getStateKey

public Object getStateKey(DrawContext dc)
Returns an object that uniquely identifies the tile's state on the specified draw context. This object is guaranteed to be globally unique; an equality test with a state key from another always returns false.

Parameters:
dc - the draw context the state key relates to.
Returns:
an object representing surface object's current state.

hasObjects

public boolean hasObjects()
Returns whether list of surface objects intersecting this tile has elements.

Returns:
true if the list of surface objects intersecting this tile has elements, and false otherwise.

NASA World Wind