public class TileDownloadLayer extends TileLayer<DownloadJob> implements Observer
hasJobQueue, isTransparent, jobQueuedisplayModel| Constructor and Description |
|---|
TileDownloadLayer(TileCache tileCache,
MapViewPosition mapViewPosition,
TileSource tileSource,
org.mapsforge.core.graphics.GraphicFactory graphicFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected DownloadJob |
createJob(org.mapsforge.core.model.Tile tile) |
void |
draw(org.mapsforge.core.model.BoundingBox boundingBox,
byte zoomLevel,
org.mapsforge.core.graphics.Canvas canvas,
org.mapsforge.core.model.Point topLeftPoint)
Draws this
Layer on the given canvas. |
long |
getCacheTimeToLive()
Returns the time-to-live (TTL) for tiles in the cache, or 0 if not set.
|
protected boolean |
isTileStale(org.mapsforge.core.model.Tile tile,
org.mapsforge.core.graphics.TileBitmap bitmap)
Whether the tile is stale and should be refreshed.
|
protected void |
onAdd()
Called each time this
Layer is added to a Layers list. |
void |
onChange()
Called whenever the observed object has been changed.
|
void |
onDestroy() |
void |
onPause() |
protected void |
onRemove()
Called each time this
Layer is removed from a Layers list. |
void |
onResume() |
void |
setCacheTimeToLive(long ttl)
Sets the time-to-live (TTL) for tiles in the cache.
|
void |
setDisplayModel(DisplayModel displayModel)
The DisplayModel comes from a MapView, so is generally not known when the layer itself is created.
|
void |
start() |
getTileCache, retrieveLabelsOnlygetDisplayModel, getPosition, isVisible, onLongPress, onTap, requestRedraw, setVisible, setVisiblepublic TileDownloadLayer(TileCache tileCache, MapViewPosition mapViewPosition, TileSource tileSource, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
public void draw(org.mapsforge.core.model.BoundingBox boundingBox,
byte zoomLevel,
org.mapsforge.core.graphics.Canvas canvas,
org.mapsforge.core.model.Point topLeftPoint)
LayerLayer on the given canvas.draw in class TileLayer<DownloadJob>boundingBox - the geographical area which should be drawn.zoomLevel - the zoom level at which this Layer should draw itself.canvas - the canvas on which this Layer should draw itself.topLeftPoint - the top-left pixel position of the canvas relative to the top-left map position.public long getCacheTimeToLive()
isTileStale(Tile, TileBitmap) for information on how the TTL is enforced.public void onPause()
public void onResume()
public void setCacheTimeToLive(long ttl)
TileSource's
TileSource.getDefaultTimeToLive() ()} method. Refer to
isTileStale(Tile, TileBitmap) for information on how the TTL is enforced.ttl - The TTL. If set to 0, no TTL will be enforced.public void setDisplayModel(DisplayModel displayModel)
LayersetDisplayModel in class TileLayer<DownloadJob>displayModel - the displayModel to use.public void start()
protected DownloadJob createJob(org.mapsforge.core.model.Tile tile)
createJob in class TileLayer<DownloadJob>protected boolean isTileStale(org.mapsforge.core.model.Tile tile,
org.mapsforge.core.graphics.TileBitmap bitmap)
draw(BoundingBox, byte, Canvas, Point) to determine whether the tile needs to
be refreshed.
A tile is considered stale if one or more of the following two conditions apply:
bitmap's TileBitmap.isExpired() method returns True.getCacheTimeToLive() returns a nonzero value) and the sum of
the bitmap's TileBitmap.getTimestamp() and TTL is less than current
time (as returned by System.currentTimeMillis()).bitmap and attempt to
obtain a fresh copy in the background. When a fresh copy becomes available, the layer will replace it and update
the cache. If a fresh copy cannot be obtained (e.g. because the tile is obtained from an online source which
cannot be reached), the stale tile will continue to be used until another
#draw(BoundingBox, byte, Canvas, Point) operation requests it again.isTileStale in class TileLayer<DownloadJob>tile - A tile. This parameter is not used for a TileDownloadLayer and can be null.bitmap - The bitmap for tile currently held in the layer's cache.protected void onAdd()
LayerLayer is added to a Layers list.protected void onRemove()
LayerLayer is removed from a Layers list.