X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosMap.java;h=d68cff7a6f99028791c1225336a6a8f7a2fae66a;hb=6ecd75a7abb5fcee440f7672082013088634680b;hp=adf52ab9469d0be1405a4295a201b92fe7dca718;hpb=e0c318cdd32b3c3fed5099c754aea3ebc6186a0f;p=fw%2Faltos diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index adf52ab9..d68cff7a 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -131,6 +131,10 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { return (System.currentTimeMillis() - user_input_time) < auto_scroll_delay; } + public boolean has_centre() { + return centre != null; + } + public boolean far_from_centre(AltosLatLon lat_lon) { if (centre == null || transform == null) @@ -391,6 +395,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 +406,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 +423,17 @@ 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) { + if (transform == null) { + debug("Transform not set in stop\n"); + return; + } + map_interface.select_object (transform.screen_lat_lon(new AltosPointInt(x,y))); + } } private void line_start(int x, int y) { @@ -442,6 +466,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);