altosui: improve sitemap scrolling behaviour
[fw/altos] / ao-tools / altosui / AltosSiteMapTile.java
index fd4cf0bbd3b3097f1b5a0fe43fb5671d1a7f6767..8301f42b007e7fa9907991c3920543ce033e4946 100644 (file)
@@ -32,9 +32,6 @@ import java.awt.geom.Point2D;
 import java.awt.geom.Line2D;
 
 public class AltosSiteMapTile extends JLayeredPane {
-       Point2D.Double coord_pt;
-       Point2D.Double last_pt;
-
        JLabel mapLabel;
        JLabel draw;
        Graphics2D g2d;
@@ -55,35 +52,15 @@ public class AltosSiteMapTile extends JLayeredPane {
                Color.BLACK   // landed
        };
 
-       boolean drawn_landed_circle = false;
-       boolean drawn_boost_circle = false;
-       public void show(AltosState state, int crc_errors, Point2D.Double pt) {
-               if (last_pt == null) {
-                       // setLocation(state.pad_lat, state.pad_lon);
-                       // loadMap();
-                       last_pt = pt;
-               }
-
-               if (pt != last_pt) {
-                       if (0 <= state.state && state.state < stateColors.length) {
-                               g2d.setColor(stateColors[state.state]);
-                       }
-                       g2d.draw(new Line2D.Double(last_pt, pt));
-               }
-
-               int px_size = getWidth();
-               if (0 <= pt.x && pt.x < px_size) {
-                       if (0 <= pt.y && pt.y < px_size) {
-                               int dx = 500, dy = 250;
-                               if (state.state > 2) {
-                                       dx = Math.min(200, 20 + (int) Math.abs(last_pt.x - pt.x));
-                                       dy = Math.min(100, 10 + (int) Math.abs(last_pt.y - pt.y));
-                               }
-                               Rectangle r = new Rectangle((int)pt.x-dx, (int)pt.y-dy,
-                                                           dx*2, dy*2);
-                               scrollRectToVisible(r);
-                       }
+       private boolean drawn_landed_circle = false;
+       private boolean drawn_boost_circle = false;
+       public synchronized void show(AltosState state, int crc_errors,
+                                     Point2D.Double last_pt, Point2D.Double pt)
+       {
+               if (0 <= state.state && state.state < stateColors.length) {
+                       g2d.setColor(stateColors[state.state]);
                }
+               g2d.draw(new Line2D.Double(last_pt, pt));
 
                if (state.state == 3 && !drawn_boost_circle) {
                        drawn_boost_circle = true;
@@ -100,7 +77,6 @@ public class AltosSiteMapTile extends JLayeredPane {
                        g2d.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70);
                }
 
-               last_pt = pt;
                repaint();
        }