public abstract class TileLayer<T extends Job> extends Layer
Modifier and Type | Field and Description |
---|---|
protected boolean |
hasJobQueue |
protected boolean |
isTransparent |
protected JobQueue<T> |
jobQueue |
protected TileCache |
tileCache |
displayModel
Constructor and Description |
---|
TileLayer(TileCache tileCache,
MapViewPosition mapViewPosition,
org.mapsforge.core.graphics.Matrix matrix,
boolean isTransparent) |
TileLayer(TileCache tileCache,
MapViewPosition mapViewPosition,
org.mapsforge.core.graphics.Matrix matrix,
boolean isTransparent,
boolean hasJobQueue) |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
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. |
TileCache |
getTileCache() |
protected abstract 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 |
retrieveLabelsOnly(T job) |
void |
setDisplayModel(DisplayModel displayModel)
The DisplayModel comes from a MapView, so is generally not known when the layer itself is created.
|
getDisplayModel, getPosition, isVisible, onAdd, onDestroy, onLongPress, onRemove, onTap, requestRedraw, setVisible, setVisible
protected final boolean hasJobQueue
protected final boolean isTransparent
protected final TileCache tileCache
public TileLayer(TileCache tileCache, MapViewPosition mapViewPosition, org.mapsforge.core.graphics.Matrix matrix, boolean isTransparent)
public TileLayer(TileCache tileCache, MapViewPosition mapViewPosition, org.mapsforge.core.graphics.Matrix matrix, boolean isTransparent, boolean hasJobQueue)
public void draw(org.mapsforge.core.model.BoundingBox boundingBox, byte zoomLevel, org.mapsforge.core.graphics.Canvas canvas, org.mapsforge.core.model.Point topLeftPoint)
Layer
Layer
on the given canvas.draw
in class Layer
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 void setDisplayModel(DisplayModel displayModel)
Layer
setDisplayModel
in class Layer
displayModel
- the displayModel to use.protected abstract T createJob(org.mapsforge.core.model.Tile tile)
protected abstract 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. Subclasses must override this method and implement appropriate checks to determine when a tile is
stale.
Return false
to use the cached copy without attempting to refresh it.
Return true
to cause the layer to attempt to obtain a fresh copy of the tile. The layer will first
display the tile referenced by bitmap
and attempt to obtain a fresh copy in the background. When a fresh
copy becomes available, the layer will replace is 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.tile
- A tile.bitmap
- The bitmap for tile
currently held in the layer's cache.protected void retrieveLabelsOnly(T job)
public TileCache getTileCache()