public abstract class MapScaleBar
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
MapScaleBar.ScaleBarLengthAndValue
Internal class used by calculateScaleBarLengthAndValue
|
static class |
MapScaleBar.ScaleBarPosition |
Modifier and Type | Field and Description |
---|---|
protected DisplayModel |
displayModel |
protected DistanceUnitAdapter |
distanceUnitAdapter |
protected org.mapsforge.core.graphics.GraphicFactory |
graphicFactory |
protected org.mapsforge.core.graphics.Bitmap |
mapScaleBitmap |
protected org.mapsforge.core.graphics.Canvas |
mapScaleCanvas |
protected boolean |
redrawNeeded |
protected MapScaleBar.ScaleBarPosition |
scaleBarPosition |
Constructor and Description |
---|
MapScaleBar(MapViewPosition mapViewPosition,
MapViewDimension mapViewDimension,
DisplayModel displayModel,
org.mapsforge.core.graphics.GraphicFactory graphicFactory,
int width,
int height) |
Modifier and Type | Method and Description |
---|---|
protected MapScaleBar.ScaleBarLengthAndValue |
calculateScaleBarLengthAndValue()
Calculates the required length and value of the scalebar using the current
DistanceUnitAdapter |
protected MapScaleBar.ScaleBarLengthAndValue |
calculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter)
Calculates the required length and value of the scalebar
|
void |
destroy()
Free all resources
|
void |
draw(org.mapsforge.core.graphics.GraphicContext graphicContext)
Called from
MapView |
void |
drawScaleBar()
The scalebar is redrawn now.
|
DistanceUnitAdapter |
getDistanceUnitAdapter() |
int |
getMarginHorizontal() |
int |
getMarginVertical() |
MapScaleBar.ScaleBarPosition |
getScaleBarPosition() |
protected boolean |
isRedrawNecessary()
Determines if a redraw is necessary or not
|
boolean |
isVisible() |
protected abstract void |
redraw(org.mapsforge.core.graphics.Canvas canvas)
Redraw the map scale bar.
|
void |
redrawScaleBar()
The scalebar will be redrawn on the next draw()
|
void |
setDistanceUnitAdapter(DistanceUnitAdapter distanceUnitAdapter)
Set the
DistanceUnitAdapter for the MapScaleBar |
void |
setMarginHorizontal(int marginHorizontal) |
void |
setMarginVertical(int marginVertical) |
void |
setScaleBarPosition(MapScaleBar.ScaleBarPosition scaleBarPosition) |
void |
setVisible(boolean visible)
Set the visibility of this
MapScaleBar |
protected final DisplayModel displayModel
protected DistanceUnitAdapter distanceUnitAdapter
protected final org.mapsforge.core.graphics.GraphicFactory graphicFactory
protected final org.mapsforge.core.graphics.Bitmap mapScaleBitmap
protected final org.mapsforge.core.graphics.Canvas mapScaleCanvas
protected boolean redrawNeeded
protected MapScaleBar.ScaleBarPosition scaleBarPosition
public MapScaleBar(MapViewPosition mapViewPosition, MapViewDimension mapViewDimension, DisplayModel displayModel, org.mapsforge.core.graphics.GraphicFactory graphicFactory, int width, int height)
public void destroy()
public boolean isVisible()
MapScaleBar
is visiblepublic void setVisible(boolean visible)
MapScaleBar
visible
- true if the MapScaleBar should be visible, false otherwisepublic DistanceUnitAdapter getDistanceUnitAdapter()
DistanceUnitAdapter
in use by this MapScaleBarpublic void setDistanceUnitAdapter(DistanceUnitAdapter distanceUnitAdapter)
DistanceUnitAdapter
for the MapScaleBardistanceUnitAdapter
- The DistanceUnitAdapter
to be used by this MapScaleBar
public int getMarginHorizontal()
public void setMarginHorizontal(int marginHorizontal)
public int getMarginVertical()
public void setMarginVertical(int marginVertical)
public MapScaleBar.ScaleBarPosition getScaleBarPosition()
public void setScaleBarPosition(MapScaleBar.ScaleBarPosition scaleBarPosition)
protected MapScaleBar.ScaleBarLengthAndValue calculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter)
unitAdapter
- the DistanceUnitAdapter to calculate forMapScaleBar.ScaleBarLengthAndValue
object containing the required scaleBarLength and scaleBarValueprotected MapScaleBar.ScaleBarLengthAndValue calculateScaleBarLengthAndValue()
DistanceUnitAdapter
MapScaleBar.ScaleBarLengthAndValue
object containing the required scaleBarLength and scaleBarValuepublic void draw(org.mapsforge.core.graphics.GraphicContext graphicContext)
MapView
graphicContext
- The graphicContext to use to draw the MapScaleBarpublic void drawScaleBar()
public void redrawScaleBar()
protected boolean isRedrawNecessary()
protected abstract void redraw(org.mapsforge.core.graphics.Canvas canvas)
canvas
- The canvas to draw on