Package org.mapsforge.map.layer.renderer
Class TileRendererLayer
- java.lang.Object
-
- org.mapsforge.map.layer.Layer
-
- org.mapsforge.map.layer.TileLayer<RendererJob>
-
- org.mapsforge.map.layer.renderer.TileRendererLayer
-
- All Implemented Interfaces:
Observer
public class TileRendererLayer extends TileLayer<RendererJob> implements Observer
-
-
Field Summary
-
Fields inherited from class org.mapsforge.map.layer.TileLayer
hasJobQueue, isTransparent, jobQueue, tileCache
-
Fields inherited from class org.mapsforge.map.layer.Layer
displayModel
-
-
Constructor Summary
Constructors Constructor Description TileRendererLayer(TileCache tileCache, MapDataStore mapDataStore, IMapViewPosition mapViewPosition, boolean isTransparent, boolean renderLabels, boolean cacheLabels, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
Creates a TileRendererLayer (without hillshading).TileRendererLayer(TileCache tileCache, MapDataStore mapDataStore, IMapViewPosition mapViewPosition, boolean isTransparent, boolean renderLabels, boolean cacheLabels, org.mapsforge.core.graphics.GraphicFactory graphicFactory, HillsRenderConfig hillsRenderConfig)
Creates a TileRendererLayer.TileRendererLayer(TileCache tileCache, MapDataStore mapDataStore, IMapViewPosition mapViewPosition, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
Creates a TileRendererLayer (without hillshading).
- Tiles will not have alpha/transparency
- Labels will be rendered onto tiles
- Labels will not be cached in a LabelStore
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
compileRenderTheme()
protected RendererJob
createJob(org.mapsforge.core.model.Tile tile)
LabelStore
getLabelStore()
Labels can be stored in a LabelStore for rendering on a separate Layer.MapDataStore
getMapDataStore()
RenderThemeFuture
getRenderThemeFuture()
float
getTextScale()
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 thisLayer
is added to aLayers
list.void
onChange()
Called whenever the observed object has been changed.void
onDestroy()
protected void
onRemove()
Called each time thisLayer
is removed from aLayers
list.protected void
retrieveLabelsOnly(RendererJob job)
void
setDisplayModel(DisplayModel displayModel)
The DisplayModel comes from a MapView, so is generally not known when the layer itself is created.void
setTextScale(float textScale)
void
setXmlRenderTheme(XmlRenderTheme xmlRenderTheme)
-
Methods inherited from class org.mapsforge.map.layer.TileLayer
draw, getAlpha, getTileCache, setAlpha, setParentTilesRendering
-
Methods inherited from class org.mapsforge.map.layer.Layer
getDisplayModel, getPosition, isVisible, onLongPress, onScroll, onTap, requestRedraw, setVisible, setVisible
-
-
-
-
Constructor Detail
-
TileRendererLayer
public TileRendererLayer(TileCache tileCache, MapDataStore mapDataStore, IMapViewPosition mapViewPosition, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
Creates a TileRendererLayer (without hillshading).
- Tiles will not have alpha/transparency
- Labels will be rendered onto tiles
- Labels will not be cached in a LabelStore- Parameters:
tileCache
- cache where tiles are storedmapDataStore
- the mapsforge map filemapViewPosition
- the mapViewPosition to know which tiles to rendergraphicFactory
- the graphicFactory to carry out platform specific operations
-
TileRendererLayer
public TileRendererLayer(TileCache tileCache, MapDataStore mapDataStore, IMapViewPosition mapViewPosition, boolean isTransparent, boolean renderLabels, boolean cacheLabels, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
Creates a TileRendererLayer (without hillshading).- Parameters:
tileCache
- cache where tiles are storedmapDataStore
- the mapsforge map filemapViewPosition
- the mapViewPosition to know which tiles to renderisTransparent
- true if the tile should have an alpha/transparencyrenderLabels
- true if labels should be rendered onto tilescacheLabels
- true if labels should be cached in a LabelStoregraphicFactory
- the graphicFactory to carry out platform specific operations
-
TileRendererLayer
public TileRendererLayer(TileCache tileCache, MapDataStore mapDataStore, IMapViewPosition mapViewPosition, boolean isTransparent, boolean renderLabels, boolean cacheLabels, org.mapsforge.core.graphics.GraphicFactory graphicFactory, HillsRenderConfig hillsRenderConfig)
Creates a TileRendererLayer.- Parameters:
tileCache
- cache where tiles are storedmapDataStore
- the mapsforge map filemapViewPosition
- the mapViewPosition to know which tiles to renderisTransparent
- true if the tile should have an alpha/transparencyrenderLabels
- true if labels should be rendered onto tilescacheLabels
- true if labels should be cached in a LabelStoregraphicFactory
- the graphicFactory to carry out platform specific operationshillsRenderConfig
- the hillshading setup to be used (can be null)
-
-
Method Detail
-
getLabelStore
public LabelStore getLabelStore()
Labels can be stored in a LabelStore for rendering on a separate Layer.- Returns:
- the LabelStore used for storing labels, null otherwise.
-
getMapDataStore
public MapDataStore getMapDataStore()
-
getTextScale
public float getTextScale()
-
setDisplayModel
public void setDisplayModel(DisplayModel displayModel)
Description copied from class:Layer
The 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:
setDisplayModel
in classTileLayer<RendererJob>
- Parameters:
displayModel
- the displayModel to use.
-
setTextScale
public void setTextScale(float textScale)
-
setXmlRenderTheme
public void setXmlRenderTheme(XmlRenderTheme xmlRenderTheme)
-
compileRenderTheme
protected void compileRenderTheme()
-
getRenderThemeFuture
public RenderThemeFuture getRenderThemeFuture()
-
createJob
protected RendererJob createJob(org.mapsforge.core.model.Tile tile)
- Specified by:
createJob
in classTileLayer<RendererJob>
-
isTileStale
protected 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 fromTileLayer.draw(org.mapsforge.core.model.BoundingBox, byte, org.mapsforge.core.graphics.Canvas, org.mapsforge.core.model.Point)
to determine whether the tile needs to be refreshed. A tile is considered stale if the timestamp of the layer'smapDataStore
is more recent than thebitmap
'sTileBitmap.getTimestamp()
. When a tile has become stale, the layer will first display the tile referenced bybitmap
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 for whatever reason, the stale tile will continue to be used until another#draw(BoundingBox, byte, Canvas, Point)
operation requests it again.- Specified by:
isTileStale
in classTileLayer<RendererJob>
- Parameters:
tile
- A tile.bitmap
- The bitmap fortile
currently held in the layer's cache.
-
onAdd
protected void onAdd()
Description copied from class:Layer
Called each time thisLayer
is added to aLayers
list.
-
onRemove
protected void onRemove()
Description copied from class:Layer
Called each time thisLayer
is removed from aLayers
list.
-
retrieveLabelsOnly
protected void retrieveLabelsOnly(RendererJob job)
- Overrides:
retrieveLabelsOnly
in classTileLayer<RendererJob>
-
-