Class MapScaleBar

  • Direct Known Subclasses:
    DefaultMapScaleBar

    public abstract class MapScaleBar
    extends java.lang.Object
    A MapScaleBar displays the ratio of a distance on the map to the corresponding distance on the ground.
    • Field Detail

      • graphicFactory

        protected final org.mapsforge.core.graphics.GraphicFactory graphicFactory
      • mapScaleBitmap

        protected final org.mapsforge.core.graphics.Bitmap mapScaleBitmap
      • mapScaleCanvas

        protected final org.mapsforge.core.graphics.Canvas mapScaleCanvas
      • prevMapPosition

        protected org.mapsforge.core.model.MapPosition prevMapPosition
      • redrawNeeded

        protected boolean redrawNeeded
      • scale

        protected final float scale
    • Constructor Detail

      • MapScaleBar

        public MapScaleBar​(IMapViewPosition mapViewPosition,
                           MapViewDimension mapViewDimension,
                           DisplayModel displayModel,
                           org.mapsforge.core.graphics.GraphicFactory graphicFactory,
                           int width,
                           int height,
                           float scale)
    • Method Detail

      • destroy

        public void destroy()
        Free all resources
      • isVisible

        public boolean isVisible()
        Returns:
        true if this MapScaleBar is visible
      • setVisible

        public void setVisible​(boolean visible)
        Set the visibility of this MapScaleBar
        Parameters:
        visible - true if the MapScaleBar should be visible, false otherwise
      • getMarginHorizontal

        public int getMarginHorizontal()
      • setMarginHorizontal

        public void setMarginHorizontal​(int marginHorizontal)
      • getMarginVertical

        public int getMarginVertical()
      • setMarginVertical

        public void setMarginVertical​(int marginVertical)
      • draw

        public void draw​(org.mapsforge.core.graphics.GraphicContext graphicContext)
        Called from MapView
        Parameters:
        graphicContext - The graphicContext to use to draw the MapScaleBar
      • drawScaleBar

        public void drawScaleBar()
        The scalebar is redrawn now.
      • redrawScaleBar

        public void redrawScaleBar()
        The scalebar will be redrawn on the next draw()
      • isRedrawNecessary

        protected boolean isRedrawNecessary()
        Determines if a redraw is necessary or not
        Returns:
        true if redraw is necessary, false otherwise
      • redraw

        protected abstract void redraw​(org.mapsforge.core.graphics.Canvas canvas)
        Redraw the map scale bar. Make sure you always apply scale factor to all coordinates and dimensions.
        Parameters:
        canvas - The canvas to draw on