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 voidcompileRenderTheme()protected RendererJobcreateJob(org.mapsforge.core.model.Tile tile)LabelStoregetLabelStore()Labels can be stored in a LabelStore for rendering on a separate Layer.MapDataStoregetMapDataStore()RenderThemeFuturegetRenderThemeFuture()floatgetTextScale()protected booleanisTileStale(org.mapsforge.core.model.Tile tile, org.mapsforge.core.graphics.TileBitmap bitmap)Whether the tile is stale and should be refreshed.protected voidonAdd()Called each time thisLayeris added to aLayerslist.voidonChange()Called whenever the observed object has been changed.voidonDestroy()protected voidonRemove()Called each time thisLayeris removed from aLayerslist.protected voidretrieveLabelsOnly(RendererJob job)voidsetDisplayModel(DisplayModel displayModel)The DisplayModel comes from a MapView, so is generally not known when the layer itself is created.voidsetTextScale(float textScale)voidsetXmlRenderTheme(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: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 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:
createJobin 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'smapDataStoreis more recent than thebitmap'sTileBitmap.getTimestamp(). When a tile has become stale, 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 for whatever reason, the stale tile will continue to be used until another#draw(BoundingBox, byte, Canvas, Point)operation requests it again.- Specified by:
isTileStalein classTileLayer<RendererJob>- Parameters:
tile- A tile.bitmap- The bitmap fortilecurrently held in the layer's cache.
-
onAdd
protected void onAdd()
Description copied from class:LayerCalled each time thisLayeris added to aLayerslist.
-
onRemove
protected void onRemove()
Description copied from class:LayerCalled each time thisLayeris removed from aLayerslist.
-
retrieveLabelsOnly
protected void retrieveLabelsOnly(RendererJob job)
- Overrides:
retrieveLabelsOnlyin classTileLayer<RendererJob>
-
-