Package org.oscim.scalebar
Class MapScaleBar
java.lang.Object
org.oscim.scalebar.MapScaleBar
- Direct Known Subclasses:
DefaultMapScaleBar
A MapScaleBar displays the ratio of a distance on the map to the corresponding distance on the ground.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classInternal class used by calculateScaleBarLengthAndValuestatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DistanceUnitAdapterprotected final Mapprotected Bitmapprotected Canvasprotected final MapPositionprotected booleanprotected final floatprotected MapScaleBar.ScaleBarPosition -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MapScaleBar.ScaleBarLengthAndValueCalculates the required length and value of the scalebar using the currentDistanceUnitAdapterprotected MapScaleBar.ScaleBarLengthAndValuecalculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter) Calculates the required length and value of the scalebarvoiddestroy()Free all resourcesvoidvoidThe scalebar is redrawn now.intintprotected booleanDetermines if a redraw is necessary or notbooleanprotected abstract voidRedraw the map scale bar.voidThe scalebar will be redrawn on the next draw()voidsetDistanceUnitAdapter(DistanceUnitAdapter distanceUnitAdapter) Set theDistanceUnitAdapterfor the MapScaleBarvoidsetMarginHorizontal(int marginHorizontal) voidsetMarginVertical(int marginVertical) voidsetScaleBarPosition(MapScaleBar.ScaleBarPosition scaleBarPosition) voidsetVisible(boolean visible) Set the visibility of thisMapScaleBar
-
Field Details
-
distanceUnitAdapter
-
map
-
mapScaleBitmap
-
mapScaleCanvas
-
prevMapPosition
-
redrawNeeded
protected boolean redrawNeeded -
scale
protected final float scale -
scaleBarPosition
-
-
Constructor Details
-
MapScaleBar
-
-
Method Details
-
destroy
public void destroy()Free all resources -
isVisible
public boolean isVisible()- Returns:
- true if this
MapScaleBaris visible
-
setVisible
public void setVisible(boolean visible) Set the visibility of thisMapScaleBar- Parameters:
visible- true if the MapScaleBar should be visible, false otherwise
-
getDistanceUnitAdapter
- Returns:
- the
DistanceUnitAdapterin use by this MapScaleBar
-
setDistanceUnitAdapter
Set theDistanceUnitAdapterfor the MapScaleBar- Parameters:
distanceUnitAdapter- TheDistanceUnitAdapterto be used by thisMapScaleBar
-
getMarginHorizontal
public int getMarginHorizontal() -
setMarginHorizontal
public void setMarginHorizontal(int marginHorizontal) -
getMarginVertical
public int getMarginVertical() -
setMarginVertical
public void setMarginVertical(int marginVertical) -
getScaleBarPosition
-
setScaleBarPosition
-
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.ScaleBarLengthAndValueobject containing the required scaleBarLength and scaleBarValue
-
calculateScaleBarLengthAndValue
Calculates the required length and value of the scalebar using the currentDistanceUnitAdapter- Returns:
- a
MapScaleBar.ScaleBarLengthAndValueobject containing the required scaleBarLength and scaleBarValue
-
draw
- 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
Redraw the map scale bar. Make sure you always apply scale factor to all coordinates and dimensions.- Parameters:
canvas- The canvas to draw on
-