diff options
author | Keith Packard <keithp@keithp.com> | 2015-05-29 09:49:30 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-05-29 09:49:30 -0700 |
commit | 0beb02f1848e34892cca6e34ba83d6ca836d6df2 (patch) | |
tree | 3ad6b436e7c1ac354ce65d9ad92d73fa6067ce64 /altoslib | |
parent | 4f1c4dddbce7b4e8673173f1690f79ba60e72ba2 (diff) |
altoslib: Require 'debug' hook in AltosMapInterface
This lets the map users redirect debug messages as appropriate
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r-- | altoslib/AltosMap.java | 10 | ||||
-rw-r--r-- | altoslib/AltosMapInterface.java | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index 85f95eef..d99730b4 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -109,6 +109,10 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { return map_interface.height(); } + public void debug(String format, Object ... arguments) { + map_interface.debug(format, arguments); + } + public AltosPointInt floor(AltosPointDouble point) { return new AltosPointInt ((int) Math.floor(point.x / AltosMap.px_size) * AltosMap.px_size, (int) Math.floor(point.y / AltosMap.px_size) * AltosMap.px_size); @@ -150,6 +154,7 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { } public void set_transform() { + debug("set_transform, centre is %s\n", centre); if (centre != null) { transform = new AltosMapTransform(width(), height(), zoom, centre); repaint(); @@ -376,6 +381,11 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { int dx = x - drag_start.x; int dy = y - drag_start.y; + if (transform == null) { + debug("Transform not set in drag\n"); + return; + } + AltosLatLon new_centre = transform.screen_lat_lon(new AltosPointInt(width() / 2 - dx, height() / 2 - dy)); centre(new_centre); drag_start = new AltosPointInt(x, y); diff --git a/altoslib/AltosMapInterface.java b/altoslib/AltosMapInterface.java index 195574e9..e6cb5971 100644 --- a/altoslib/AltosMapInterface.java +++ b/altoslib/AltosMapInterface.java @@ -40,4 +40,6 @@ public interface AltosMapInterface { public abstract void repaint(AltosRectangle damage); public abstract void set_zoom_label(String label); + + public abstract void debug(String format, Object ... arguments); } |