diff options
Diffstat (limited to 'altoslib')
| -rw-r--r-- | altoslib/AltosMap.java | 21 | ||||
| -rw-r--r-- | altoslib/AltosMapInterface.java | 2 | ||||
| -rw-r--r-- | altoslib/AltosMapTransform.java | 7 | 
3 files changed, 30 insertions, 0 deletions
diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index adf52ab9..8d12a180 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -391,6 +391,10 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {  	AltosPointInt	drag_start; +	boolean		dragged; + +	static final double drag_far = 20; +  	private void drag(int x, int y) {  		if (drag_start == null)  			return; @@ -398,6 +402,11 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {  		int dx = x - drag_start.x;  		int dy = y - drag_start.y; +		double distance = Math.hypot(dx, dy); + +		if (distance > drag_far) +			dragged = true; +  		if (transform == null) {  			debug("Transform not set in drag\n");  			return; @@ -410,6 +419,12 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {  	private void drag_start(int x, int y) {  		drag_start = new AltosPointInt(x, y); +		dragged = false; +	} + +	private void drag_stop(int x, int y) { +		if (!dragged) +			map_interface.select_object (transform.screen_lat_lon(new AltosPointInt(x,y)));  	}  	private void line_start(int x, int y) { @@ -442,6 +457,12 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {  			line(x, y);  	} +	public void touch_stop(int x, int y, boolean is_drag) { +		notice_user_input(); +		if (is_drag) +			drag_stop(x, y); +	} +  	public AltosMap(AltosMapInterface map_interface) {  		this.map_interface = map_interface;  		cache = new AltosMapCache(map_interface); diff --git a/altoslib/AltosMapInterface.java b/altoslib/AltosMapInterface.java index e6cb5971..7e8dd236 100644 --- a/altoslib/AltosMapInterface.java +++ b/altoslib/AltosMapInterface.java @@ -42,4 +42,6 @@ public interface AltosMapInterface {  	public abstract void set_zoom_label(String label);  	public abstract void debug(String format, Object ... arguments); + +	public abstract void select_object(AltosLatLon latlon);  } diff --git a/altoslib/AltosMapTransform.java b/altoslib/AltosMapTransform.java index 30994ecb..11ed4eb9 100644 --- a/altoslib/AltosMapTransform.java +++ b/altoslib/AltosMapTransform.java @@ -51,6 +51,13 @@ public class AltosMapTransform {  		return new AltosPointDouble(screen.x + offset_x, screen.y + offset_y);  	} +	public double hypot(AltosLatLon a, AltosLatLon b) { +		AltosPointDouble	a_pt = point(a); +		AltosPointDouble	b_pt = point(b); + +		return Math.hypot(a_pt.x - b_pt.x, a_pt.y - b_pt.y); +	} +  	public AltosLatLon screen_lat_lon(AltosPointInt screen) {  		return lat_lon(screen_point(screen));  	}  | 
