Package org.mapsforge.map.model
Class MapViewPosition
- java.lang.Object
-
- org.mapsforge.map.model.common.Observable
-
- org.mapsforge.map.model.MapViewPosition
-
- All Implemented Interfaces:
ObservableInterface,Persistable,IMapViewPosition
public class MapViewPosition extends Observable implements IMapViewPosition, Persistable
-
-
Constructor Summary
Constructors Constructor Description MapViewPosition(DisplayModel displayModel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanimateTo(org.mapsforge.core.model.LatLong latLong)Animate the map towards the given position.booleananimationInProgress()voiddestroy()Destroys the class.org.mapsforge.core.model.LatLonggetCenter()Returns the current center position of the map.org.mapsforge.core.model.BoundingBoxgetMapLimit()org.mapsforge.core.model.MapPositiongetMapPosition()Returns a newly instantiated object representing the current position and zoomlevel.org.mapsforge.core.model.LatLonggetPivot()The pivot point is the point the map zooms around.org.mapsforge.core.model.PointgetPivotXY(byte zoomLevel)The pivot point is the point the map zooms around.doublegetScaleFactor()Gets the current scale factor.bytegetZoomLevel()bytegetZoomLevelMax()bytegetZoomLevelMin()voidinit(PreferencesFacade preferencesFacade)Initializes the class.voidmoveCenter(double moveHorizontal, double moveVertical)Animates the center position of the map by the given amount of pixels.voidmoveCenter(double moveHorizontal, double moveVertical, boolean animated)Moves the center position of the map by the given amount of pixels.voidmoveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff)Animates the center position of the map by the given amount of pixels.voidmoveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff, boolean animated)Moves the center position of the map by the given amount of pixels.voidsave(PreferencesFacade preferencesFacade)Saves the current state.voidsetCenter(org.mapsforge.core.model.LatLong latLong)Sets the new center position of the map.voidsetMapLimit(org.mapsforge.core.model.BoundingBox mapLimit)Sets the new limit of the map (might be null).voidsetMapPosition(org.mapsforge.core.model.MapPosition mapPosition)Sets the new center position and zoom level of the map.voidsetMapPosition(org.mapsforge.core.model.MapPosition mapPosition, boolean animated)Sets the new center position and zoom level of the map.voidsetPivot(org.mapsforge.core.model.LatLong pivot)The pivot point is the point the map is scaled around when zooming.voidsetScaleFactor(double scaleFactor)Sets the new scale factor to be applied.voidsetScaleFactorAdjustment(double adjustment)voidsetZoomLevel(byte zoomLevel)Sets the new zoom level of the map.voidsetZoomLevel(byte zoomLevel, boolean animated)Sets the new zoom level of the mapvoidsetZoomLevelMax(byte zoomLevelMax)voidsetZoomLevelMin(byte zoomLevelMin)voidzoom(byte zoomLevelDiff)Changes the current zoom level by the given value if possible.voidzoom(byte zoomLevelDiff, boolean animated)Changes the current zoom level by the given value if possible.voidzoomIn()Increases the current zoom level by one if possible.voidzoomIn(boolean animated)Increases the current zoom level by one if possible.voidzoomOut()Decreases the current zoom level by one if possible.voidzoomOut(boolean animated)Decreases the current zoom level by one if possible.-
Methods inherited from class org.mapsforge.map.model.common.Observable
addObserver, notifyObservers, removeObserver
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.mapsforge.map.model.IMapViewPosition
addObserver, removeObserver
-
-
-
-
Constructor Detail
-
MapViewPosition
public MapViewPosition(DisplayModel displayModel)
-
-
Method Detail
-
animateTo
public void animateTo(org.mapsforge.core.model.LatLong latLong)
Animate the map towards the given position.- Specified by:
animateToin interfaceIMapViewPosition
-
animationInProgress
public boolean animationInProgress()
- Specified by:
animationInProgressin interfaceIMapViewPosition- Returns:
- true if animation is in progress or animation is in the queue for being processed.
-
destroy
public void destroy()
Description copied from interface:IMapViewPositionDestroys the class.- Specified by:
destroyin interfaceIMapViewPosition
-
getCenter
public org.mapsforge.core.model.LatLong getCenter()
Description copied from interface:IMapViewPositionReturns the current center position of the map. The position may change rapidly if an animation is in progress. If you are using animation consider keeping the positions and zoom factors in your code and not using this getter.- Specified by:
getCenterin interfaceIMapViewPosition- Returns:
- the current center position of the map.
-
getMapLimit
public org.mapsforge.core.model.BoundingBox getMapLimit()
- Specified by:
getMapLimitin interfaceIMapViewPosition- Returns:
- the current limit of the map (might be null).
-
getMapPosition
public org.mapsforge.core.model.MapPosition getMapPosition()
Description copied from interface:IMapViewPositionReturns a newly instantiated object representing the current position and zoomlevel. Note that the position or zoomlevel may change rapidly if an animation is in progress.- Specified by:
getMapPositionin interfaceIMapViewPosition- Returns:
- the current center position and zoom level of the map.
-
getPivot
public org.mapsforge.core.model.LatLong getPivot()
The pivot point is the point the map zooms around.- Specified by:
getPivotin interfaceIMapViewPosition- Returns:
- the lat/long coordinates of the map pivot point if set or null otherwise.
-
getPivotXY
public org.mapsforge.core.model.Point getPivotXY(byte zoomLevel)
The pivot point is the point the map zooms around. If the map zooms around its center null is returned, otherwise the zoom-specific x/y pixel coordinates for the MercatorProjection (note: not the x/y coordinates for the map view or the frame buffer, the MapViewPosition knows nothing about them).- Parameters:
zoomLevel- the zoomlevel to compute the x/y coordinates for- Returns:
- the x/y coordinates of the map pivot point if set or null otherwise.
-
getScaleFactor
public double getScaleFactor()
Description copied from interface:IMapViewPositionGets the current scale factor. The scale factor is normally 2^zoomLevel but it may differ if in between a zoom-animation or in between a pinch-to-zoom process.Needed by mapsforge core classes.
- Specified by:
getScaleFactorin interfaceIMapViewPosition
-
getZoomLevel
public byte getZoomLevel()
- Specified by:
getZoomLevelin interfaceIMapViewPosition- Returns:
- the current zoom level of the map.
-
getZoomLevelMax
public byte getZoomLevelMax()
- Specified by:
getZoomLevelMaxin interfaceIMapViewPosition
-
getZoomLevelMin
public byte getZoomLevelMin()
- Specified by:
getZoomLevelMinin interfaceIMapViewPosition
-
init
public void init(PreferencesFacade preferencesFacade)
Description copied from interface:IMapViewPositionInitializes the class.Needed by mapsforge core classes.
- Specified by:
initin interfaceIMapViewPosition- Specified by:
initin interfacePersistable
-
moveCenter
public void moveCenter(double moveHorizontal, double moveVertical)Animates the center position of the map by the given amount of pixels.- Specified by:
moveCenterin interfaceIMapViewPosition- Parameters:
moveHorizontal- the amount of pixels to move this MapViewPosition horizontally.moveVertical- the amount of pixels to move this MapViewPosition vertically.
-
moveCenter
public void moveCenter(double moveHorizontal, double moveVertical, boolean animated)Moves the center position of the map by the given amount of pixels.- Specified by:
moveCenterin interfaceIMapViewPosition- Parameters:
moveHorizontal- the amount of pixels to move this MapViewPosition horizontally.moveVertical- the amount of pixels to move this MapViewPosition vertically.animated- whether the move should be animated.
-
moveCenterAndZoom
public void moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff)Animates the center position of the map by the given amount of pixels.- Specified by:
moveCenterAndZoomin interfaceIMapViewPosition- Parameters:
moveHorizontal- the amount of pixels to move this MapViewPosition horizontally.moveVertical- the amount of pixels to move this MapViewPosition vertically.zoomLevelDiff- the difference in desired zoom level.
-
moveCenterAndZoom
public void moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff, boolean animated)Moves the center position of the map by the given amount of pixels.- Parameters:
moveHorizontal- the amount of pixels to move this MapViewPosition horizontally.moveVertical- the amount of pixels to move this MapViewPosition vertically.zoomLevelDiff- the difference in desired zoom level.animated- whether the move should be animated.
-
save
public void save(PreferencesFacade preferencesFacade)
Description copied from interface:IMapViewPositionSaves the current state.Needed by mapsforge core classes.
- Specified by:
savein interfaceIMapViewPosition- Specified by:
savein interfacePersistable
-
setCenter
public void setCenter(org.mapsforge.core.model.LatLong latLong)
Sets the new center position of the map.- Specified by:
setCenterin interfaceIMapViewPosition
-
setMapLimit
public void setMapLimit(org.mapsforge.core.model.BoundingBox mapLimit)
Sets the new limit of the map (might be null).- Specified by:
setMapLimitin interfaceIMapViewPosition
-
setMapPosition
public void setMapPosition(org.mapsforge.core.model.MapPosition mapPosition)
Sets the new center position and zoom level of the map. Note: The default zoom level changes are animated.- Specified by:
setMapPositionin interfaceIMapViewPosition
-
setMapPosition
public void setMapPosition(org.mapsforge.core.model.MapPosition mapPosition, boolean animated)Sets the new center position and zoom level of the map.- Specified by:
setMapPositionin interfaceIMapViewPosition
-
setPivot
public void setPivot(org.mapsforge.core.model.LatLong pivot)
The pivot point is the point the map is scaled around when zooming. In normal mode the pivot point is whatever the view center is (this is indicated by setting the pivot to null), but when hand-zooming the pivot point can be any point on the map. It is stored as lat/long and retrieved as an x/y coordinate depending on the current zoom level.- Specified by:
setPivotin interfaceIMapViewPosition- Parameters:
pivot- lat/long of pivot point, null for map center
-
setScaleFactor
public void setScaleFactor(double scaleFactor)
Sets the new scale factor to be applied.
-
setScaleFactorAdjustment
public void setScaleFactorAdjustment(double adjustment)
- Specified by:
setScaleFactorAdjustmentin interfaceIMapViewPosition
-
setZoomLevel
public void setZoomLevel(byte zoomLevel)
Sets the new zoom level of the map. Note: The default zoom level changes are animated.- Specified by:
setZoomLevelin interfaceIMapViewPosition- Parameters:
zoomLevel- new zoom level.- Throws:
java.lang.IllegalArgumentException- if the zoom level is negative.
-
setZoomLevel
public void setZoomLevel(byte zoomLevel, boolean animated)Sets the new zoom level of the map- Specified by:
setZoomLevelin interfaceIMapViewPosition- Parameters:
zoomLevel- desired zoom levelanimated- true if the transition should be animated, false otherwise- Throws:
java.lang.IllegalArgumentException- if the zoom level is negative.
-
setZoomLevelMax
public void setZoomLevelMax(byte zoomLevelMax)
- Specified by:
setZoomLevelMaxin interfaceIMapViewPosition
-
setZoomLevelMin
public void setZoomLevelMin(byte zoomLevelMin)
- Specified by:
setZoomLevelMinin interfaceIMapViewPosition
-
zoom
public void zoom(byte zoomLevelDiff)
Changes the current zoom level by the given value if possible. Note: The default zoom level changes are animated.- Specified by:
zoomin interfaceIMapViewPosition
-
zoom
public void zoom(byte zoomLevelDiff, boolean animated)Changes the current zoom level by the given value if possible.
-
zoomIn
public void zoomIn()
Increases the current zoom level by one if possible. Note: The default zoom level changes are animated.- Specified by:
zoomInin interfaceIMapViewPosition
-
zoomIn
public void zoomIn(boolean animated)
Increases the current zoom level by one if possible.- Specified by:
zoomInin interfaceIMapViewPosition
-
zoomOut
public void zoomOut()
Decreases the current zoom level by one if possible. Note: The default zoom level changes are animated.- Specified by:
zoomOutin interfaceIMapViewPosition
-
zoomOut
public void zoomOut(boolean animated)
Decreases the current zoom level by one if possible.- Specified by:
zoomOutin interfaceIMapViewPosition
-
-