Class TileRendererLayer

    • 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 stored
        mapDataStore - the mapsforge map file
        mapViewPosition - the mapViewPosition to know which tiles to render
        graphicFactory - 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 stored
        mapDataStore - the mapsforge map file
        mapViewPosition - the mapViewPosition to know which tiles to render
        isTransparent - true if the tile should have an alpha/transparency
        renderLabels - true if labels should be rendered onto tiles
        cacheLabels - true if labels should be cached in a LabelStore
        graphicFactory - 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 stored
        mapDataStore - the mapsforge map file
        mapViewPosition - the mapViewPosition to know which tiles to render
        isTransparent - true if the tile should have an alpha/transparency
        renderLabels - true if labels should be rendered onto tiles
        cacheLabels - true if labels should be cached in a LabelStore
        graphicFactory - the graphicFactory to carry out platform specific operations
        hillsRenderConfig - 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.
      • getTextScale

        public float getTextScale()
      • onDestroy

        public void onDestroy()
        Overrides:
        onDestroy in class Layer
      • 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 class TileLayer<RendererJob>
        Parameters:
        displayModel - the displayModel to use.
      • setTextScale

        public void setTextScale​(float textScale)
      • setXmlRenderTheme

        public void setXmlRenderTheme​(XmlRenderTheme xmlRenderTheme)
      • compileRenderTheme

        protected void compileRenderTheme()
      • 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 from TileLayer.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's mapDataStore is more recent than the bitmap's TileBitmap.getTimestamp().

        When a tile has become stale, 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 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 class TileLayer<RendererJob>
        Parameters:
        tile - A tile.
        bitmap - The bitmap for tile currently held in the layer's cache.
      • onAdd

        protected void onAdd()
        Description copied from class: Layer
        Called each time this Layer is added to a Layers list.
        Overrides:
        onAdd in class Layer
      • onRemove

        protected void onRemove()
        Description copied from class: Layer
        Called each time this Layer is removed from a Layers list.
        Overrides:
        onRemove in class Layer
      • onChange

        public void onChange()
        Description copied from interface: Observer
        Called whenever the observed object has been changed.

        Time-consuming operations should be performed in a separate thread.

        Specified by:
        onChange in interface Observer