altoslib: Require 'debug' hook in AltosMapInterface
authorKeith Packard <keithp@keithp.com>
Fri, 29 May 2015 16:49:30 +0000 (09:49 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 29 May 2015 16:49:30 +0000 (09:49 -0700)
This lets the map users redirect debug messages as appropriate

Signed-off-by: Keith Packard <keithp@keithp.com>
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java
altoslib/AltosMap.java
altoslib/AltosMapInterface.java
altosuilib/AltosUIMapNew.java

index cc1acd6798ab339c4a226b9984daa8fc639812f4..f1f1b6de853e6996034d23d305b8b51a909fb2a4 100644 (file)
@@ -57,6 +57,7 @@ public abstract class AltosDroidTab extends Fragment implements AltosUnitsListen
 
        public void set_visible(boolean visible) {
                FragmentTransaction     ft = AltosDroid.fm.beginTransaction();
+               AltosDebug.debug("set visible %b %s\n", visible, tab_name());
                if (visible) {
                        AltosState              state = last_state;
                        AltosGreatCircle        from_receiver = last_from_receiver;
index 85f95eef9cfdf3af49cae55224b6d1b165dd9ae5..d99730b4cf12510ce8d77fa038c92a1fd54ba30e 100644 (file)
@@ -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);
index 195574e9b7950fb15f1eccaec7a678291ca874c4..e6cb5971931773f860c8cf604b814c8cb1716821 100644 (file)
@@ -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);
 }
index 05f47b53d552d292b414048d0ab46917356ebf7c..3efffb00ddb37316ab8e5518924172d0d168a279 100644 (file)
@@ -369,6 +369,10 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt
                zoom_label.setText(label);
        }
 
+       public void debug(String format, Object ... arguments) {
+               System.out.printf(format, arguments);
+       }
+
        /* AltosFlightDisplay interface */
 
        public void set_font() {