Package org.mapsforge.map.layer
Class TileLayer<T extends Job>
- java.lang.Object
-
- org.mapsforge.map.layer.Layer
-
- org.mapsforge.map.layer.TileLayer<T>
-
- Direct Known Subclasses:
TileDownloadLayer,TileRendererLayer,TileStoreLayer
public abstract class TileLayer<T extends Job> extends Layer
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanhasJobQueueprotected booleanisTransparentprotected JobQueue<T>jobQueueprotected TileCachetileCache-
Fields inherited from class org.mapsforge.map.layer.Layer
displayModel
-
-
Constructor Summary
Constructors Constructor Description TileLayer(TileCache tileCache, IMapViewPosition mapViewPosition, org.mapsforge.core.graphics.Matrix matrix, boolean isTransparent)TileLayer(TileCache tileCache, IMapViewPosition mapViewPosition, org.mapsforge.core.graphics.Matrix matrix, boolean isTransparent, boolean hasJobQueue)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TcreateJob(org.mapsforge.core.model.Tile tile)voiddraw(org.mapsforge.core.model.BoundingBox boundingBox, byte zoomLevel, org.mapsforge.core.graphics.Canvas canvas, org.mapsforge.core.model.Point topLeftPoint)Draws thisLayeron the given canvas.floatgetAlpha()TileCachegetTileCache()protected abstract booleanisTileStale(org.mapsforge.core.model.Tile tile, org.mapsforge.core.graphics.TileBitmap bitmap)Whether the tile is stale and should be refreshed.protected voidretrieveLabelsOnly(T job)voidsetAlpha(float alpha)voidsetDisplayModel(DisplayModel displayModel)The DisplayModel comes from a MapView, so is generally not known when the layer itself is created.voidsetParentTilesRendering(org.mapsforge.core.util.Parameters.ParentTilesRendering parentTilesRendering)-
Methods inherited from class org.mapsforge.map.layer.Layer
getDisplayModel, getPosition, isVisible, onAdd, onDestroy, onLongPress, onRemove, onScroll, onTap, requestRedraw, setVisible, setVisible
-
-
-
-
Constructor Detail
-
TileLayer
public TileLayer(TileCache tileCache, IMapViewPosition mapViewPosition, org.mapsforge.core.graphics.Matrix matrix, boolean isTransparent)
-
TileLayer
public TileLayer(TileCache tileCache, IMapViewPosition mapViewPosition, org.mapsforge.core.graphics.Matrix matrix, boolean isTransparent, boolean hasJobQueue)
-
-
Method Detail
-
draw
public void draw(org.mapsforge.core.model.BoundingBox boundingBox, byte zoomLevel, org.mapsforge.core.graphics.Canvas canvas, org.mapsforge.core.model.Point topLeftPoint)Description copied from class:LayerDraws thisLayeron the given canvas.- Specified by:
drawin classLayer- Parameters:
boundingBox- the geographical area which should be drawn.zoomLevel- the zoom level at which thisLayershould draw itself.canvas- the canvas on which thisLayershould draw itself.topLeftPoint- the top-left pixel position of the canvas relative to the top-left map position.
-
setDisplayModel
public void setDisplayModel(DisplayModel displayModel)
Description copied from class:LayerThe DisplayModel comes from a MapView, so is generally not known when the layer itself is created. Maybe a better way would be to have a MapView as a parameter when creating a layer.- Overrides:
setDisplayModelin classLayer- Parameters:
displayModel- the displayModel to use.
-
createJob
protected abstract T createJob(org.mapsforge.core.model.Tile tile)
-
isTileStale
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. This method is called fromdraw(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. Returnfalseto use the cached copy without attempting to refresh it. Returntrueto cause the layer to attempt to obtain a fresh copy of the tile. The layer will first display the tile referenced bybitmapand 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.- Parameters:
tile- A tile.bitmap- The bitmap fortilecurrently held in the layer's cache.
-
retrieveLabelsOnly
protected void retrieveLabelsOnly(T job)
-
getAlpha
public float getAlpha()
-
getTileCache
public TileCache getTileCache()
-
setAlpha
public void setAlpha(float alpha)
-
setParentTilesRendering
public void setParentTilesRendering(org.mapsforge.core.util.Parameters.ParentTilesRendering parentTilesRendering)
-
-