altoslib: Don't try to drag lines around until map is loaded
authorKeith Packard <keithp@keithp.com>
Fri, 22 Apr 2016 23:15:51 +0000 (19:15 -0400)
committerKeith Packard <keithp@keithp.com>
Fri, 22 Apr 2016 23:15:51 +0000 (19:15 -0400)
When the transform is null, it's hard to draw lines.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosMap.java

index 9fbb94a6e1f5870f6ba13646ed19000fbb0c6d8f..26851e961453e985169e990939e5b92da4137646 100644 (file)
@@ -421,10 +421,8 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {
                if (distance > drag_far)
                        dragged = true;
 
-               if (transform == null) {
-                       debug("Transform not set in drag\n");
+               if (transform == null)
                        return;
-               }
 
                AltosLatLon new_centre = transform.screen_lat_lon(new AltosPointInt(width() / 2 - dx, height() / 2 - dy));
                centre(new_centre);
@@ -439,7 +437,6 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {
        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)));
@@ -447,14 +444,14 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {
        }
 
        private void line_start(int x, int y) {
-               if (line != null) {
+               if (line != null && transform != null) {
                        line.pressed(new AltosPointInt(x, y), transform);
                        repaint();
                }
        }
 
        private void line(int x, int y) {
-               if (line != null) {
+               if (line != null && transform != null) {
                        line.dragged(new AltosPointInt(x, y), transform);
                        repaint();
                }