diff options
| author | Keith Packard <keithp@keithp.com> | 2015-06-21 09:34:29 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2015-06-22 21:04:43 -0700 | 
| commit | e0c318cdd32b3c3fed5099c754aea3ebc6186a0f (patch) | |
| tree | 8a166b6a1dbc2cfe8fbd4141341431869097c85f /altoslib/AltosMap.java | |
| parent | b8bdb432aacc1a273ee484a29a24b3768c274db6 (diff) | |
altoslib: Add set_zoom_centre to AltosMap
This zooms around a specific point, keeping it at the same place on
the screen.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosMap.java')
| -rw-r--r-- | altoslib/AltosMap.java | 24 | 
1 files changed, 24 insertions, 0 deletions
diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index 59420d4b..adf52ab9 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -166,6 +166,7 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {  	public boolean set_zoom(int zoom) { +		notice_user_input();  		if (AltosMap.min_zoom <= zoom && zoom <= AltosMap.max_zoom && zoom != this.zoom) {  			this.zoom = zoom;  			tiles.clear(); @@ -176,6 +177,29 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {  		return false;  	} +	public boolean set_zoom_centre(int zoom, AltosPointInt centre) { +		AltosLatLon	mouse_lat_lon = null; +		boolean		ret; + +		if (transform != null) +			mouse_lat_lon = transform.screen_lat_lon(centre); + +		ret = set_zoom(zoom); + +		if (ret && mouse_lat_lon != null) { +			AltosPointDouble	new_mouse = transform.screen(mouse_lat_lon); + +			double	dx = width()/2.0 - centre.x; +			double	dy = height()/2.0 - centre.y; + +			AltosLatLon	new_centre = transform.screen_lat_lon(new AltosPointDouble(new_mouse.x + dx, new_mouse.y + dy)); + +			centre(new_centre); +		} + +		return ret; +	} +  	public int get_zoom() {  		return zoom;  	}  | 
