altoslib/altosui: Carry receiver status around in AltosListenerState
[fw/altos] / altosui / AltosSiteMap.java
index f111e62d45066d0d4dd6e6295a4fb44df955a0c8..5bf02e546179fbf936cdfb05c263617bb4054b84 100644 (file)
@@ -264,7 +264,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                initMaps(lat, lon);
                scrollRocketToVisible(pt(lat, lon));
        }
-       public void show(final AltosState state, final int crc_errors) {
+       public void show(final AltosState state, final AltosListenerState listener_state) {
                // if insufficient gps data, nothing to update
                if (!state.gps.locked && state.gps.nsat < 4)
                        return;
@@ -294,7 +294,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                        Point2D.Double ref, lref;
                        ref = translatePoint(pt, tileCoordOffset(offset));
                        lref = translatePoint(last_pt, tileCoordOffset(offset));
-                       tile.show(state, crc_errors, lref, ref);
+                       tile.show(state, listener_state, lref, ref);
                        if (0 <= ref.x && ref.x < px_size)
                                if (0 <= ref.y && ref.y < px_size)
                                        in_any = true;
@@ -307,7 +307,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                        lref = translatePoint(last_pt, tileCoordOffset(offset));
 
                        AltosSiteMapTile tile = createTile(offset);
-                       tile.show(state, crc_errors, lref, ref);
+                       tile.show(state, listener_state, lref, ref);
                        initMap(offset);
                        finishTileLater(tile, offset);
                }
@@ -322,6 +322,22 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                last_state = state.state;
        }
 
+       public void centre(Point2D.Double pt) {
+               Rectangle r = comp.getVisibleRect();
+               Point2D.Double copt = translatePoint(pt, tileCoordOffset(topleft));
+               int dx = (int)copt.x - r.width/2 - r.x;
+               int dy = (int)copt.y - r.height/2 - r.y;
+               r.x += dx;
+               r.y += dy;
+               comp.scrollRectToVisible(r);
+       }
+
+       public void centre(AltosState state) {
+               if (!state.gps.locked && state.gps.nsat < 4)
+                       return;
+               centre(pt(state.gps.lat, state.gps.lon));
+       }
+
        public void draw_circle(double lat, double lon) {
                final Point2D.Double pt = pt(lat, lon);