Class ReattachableTileRendererLayer
- All Implemented Interfaces:
org.mapsforge.map.model.common.Observer
TileRendererLayer that keeps rendering after it has been removed from and re-added to
the Layers of a map view.
Works around a mapsforge (0.30.0) bug, reported as mapsforge/mapsforge#1817: Layers.add(int, org.mapsforge.map.layer.Layer) calls setDisplayModel(org.mapsforge.map.model.DisplayModel) on every add,
and TileLayer.setDisplayModel(org.mapsforge.map.model.DisplayModel) replaces the layer's JobQueue with a fresh instance each
time, but TileRendererLayer.setDisplayModel(org.mapsforge.map.model.DisplayModel) creates its MapWorkerPool only once, bound
to the queue that existed on the first add. After a re-add, TileLayer.draw() queues tile jobs
into the new queue while the worker pool waits on the old one forever, so the layer never renders
another tile. This is what left the world map background blank (issue #376).
Keeping the first queue for the whole lifetime of the layer keeps draw() and the worker pool
on the same queue. The queue only captures the map view position and display model, which stay the
same objects for a map view, so reusing it is safe.
-
Field Summary
Fields inherited from class org.mapsforge.map.layer.TileLayer
hasJobQueue, isTransparent, jobQueue, tileCacheFields inherited from class org.mapsforge.map.layer.Layer
displayModel -
Constructor Summary
ConstructorsConstructorDescriptionReattachableTileRendererLayer(org.mapsforge.map.layer.cache.TileCache tileCache, org.mapsforge.map.datastore.MapDataStore mapDataStore, org.mapsforge.map.model.MapViewPosition mapViewPosition, boolean isTransparent, boolean renderLabels, boolean cacheLabels, org.mapsforge.core.graphics.GraphicFactory graphicFactory, org.mapsforge.map.layer.hills.HillsRenderConfig hillsRenderConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoidsetDisplayModel(org.mapsforge.map.model.DisplayModel displayModel) Methods inherited from class org.mapsforge.map.layer.renderer.TileRendererLayer
compileRenderTheme, createJob, getLabelStore, getMapDataStore, getRenderThemeFuture, getTextScale, isTileStale, onAdd, onChange, onDestroy, onRemove, retrieveLabelsOnly, setTextScale, setXmlRenderThemeMethods inherited from class org.mapsforge.map.layer.TileLayer
draw, getAlpha, getCacheTileMargin, getCacheZoomMinus, getCacheZoomPlus, getTileCache, setAlpha, setCacheTileMargin, setCacheZoomMinus, setCacheZoomPlus, setParentTilesRenderingMethods inherited from class org.mapsforge.map.layer.Layer
getDisplayModel, getPosition, isVisible, onLongPress, onScroll, onTap, requestRedraw, setVisible, setVisible
-
Constructor Details
-
ReattachableTileRendererLayer
public ReattachableTileRendererLayer(org.mapsforge.map.layer.cache.TileCache tileCache, org.mapsforge.map.datastore.MapDataStore mapDataStore, org.mapsforge.map.model.MapViewPosition mapViewPosition, boolean isTransparent, boolean renderLabels, boolean cacheLabels, org.mapsforge.core.graphics.GraphicFactory graphicFactory, org.mapsforge.map.layer.hills.HillsRenderConfig hillsRenderConfig)
-
-
Method Details
-
setDisplayModel
public void setDisplayModel(org.mapsforge.map.model.DisplayModel displayModel) - Overrides:
setDisplayModelin classorg.mapsforge.map.layer.renderer.TileRendererLayer
-