Class MapScaleBar

java.lang.Object
org.oscim.scalebar.MapScaleBar
Direct Known Subclasses:
DefaultMapScaleBar

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

    • distanceUnitAdapter

      protected DistanceUnitAdapter distanceUnitAdapter
    • map

      protected final Map map
    • mapScaleBitmap

      protected Bitmap mapScaleBitmap
    • mapScaleCanvas

      protected Canvas mapScaleCanvas
    • prevMapPosition

      protected final MapPosition prevMapPosition
    • redrawNeeded

      protected boolean redrawNeeded
    • scale

      protected final float scale
    • scaleBarPosition

      protected MapScaleBar.ScaleBarPosition scaleBarPosition
  • Constructor Details

    • MapScaleBar

      public MapScaleBar(Map map, int width, int height, float scale)
  • Method Details

    • 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
    • getDistanceUnitAdapter

      public DistanceUnitAdapter getDistanceUnitAdapter()
      Returns:
      the DistanceUnitAdapter in use by this MapScaleBar
    • setDistanceUnitAdapter

      public void setDistanceUnitAdapter(DistanceUnitAdapter distanceUnitAdapter)
      Set the DistanceUnitAdapter for the MapScaleBar
      Parameters:
      distanceUnitAdapter - The DistanceUnitAdapter to be used by this MapScaleBar
    • getMarginHorizontal

      public int getMarginHorizontal()
    • setMarginHorizontal

      public void setMarginHorizontal(int marginHorizontal)
    • getMarginVertical

      public int getMarginVertical()
    • setMarginVertical

      public void setMarginVertical(int marginVertical)
    • getScaleBarPosition

      public MapScaleBar.ScaleBarPosition getScaleBarPosition()
    • setScaleBarPosition

      public void setScaleBarPosition(MapScaleBar.ScaleBarPosition scaleBarPosition)
    • calculateScaleBarLengthAndValue

      protected MapScaleBar.ScaleBarLengthAndValue calculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter)
      Calculates the required length and value of the scalebar
      Parameters:
      unitAdapter - the DistanceUnitAdapter to calculate for
      Returns:
      a MapScaleBar.ScaleBarLengthAndValue object containing the required scaleBarLength and scaleBarValue
    • calculateScaleBarLengthAndValue

      protected MapScaleBar.ScaleBarLengthAndValue calculateScaleBarLengthAndValue()
      Calculates the required length and value of the scalebar using the current DistanceUnitAdapter
      Returns:
      a MapScaleBar.ScaleBarLengthAndValue object containing the required scaleBarLength and scaleBarValue
    • draw

      public void draw(Canvas canvas)
      Parameters:
      canvas - The canvas 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(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