Merge branch 'master' into droid-gps
authorKeith Packard <keithp@keithp.com>
Wed, 17 Apr 2013 17:41:05 +0000 (10:41 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 17 Apr 2013 17:41:05 +0000 (10:41 -0700)
altosui/AltosConfigUI.java
altosui/AltosSiteMap.java
altosui/AltosSiteMapCache.java

index 4fd0647efa860a3d47f8d4732a479e69cea14314..11f405938ba385118eed7bbf57c6665f20d93b55 100644 (file)
@@ -719,6 +719,7 @@ public class AltosConfigUI
 
        public void set_main_deploy(int new_main_deploy) {
                main_deploy_value.setSelectedItem(Integer.toString(new_main_deploy));
+               main_deploy_value.setEnabled(new_main_deploy >= 0);
        }
 
        public int main_deploy() {
index 5bf02e546179fbf936cdfb05c263617bb4054b84..23085f3ec5e270645b8c44760c34fb9202d61271 100644 (file)
@@ -220,6 +220,16 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                return pngfile.toString();
        }
 
+       public void initAndFinishMapAsync (final AltosSiteMapTile tile, final Point offset) {
+               Thread thread = new Thread() {
+                               public void run() {
+                                       initMap(offset);
+                                       finishTileLater(tile, offset);
+                               }
+                       };
+               thread.start();
+       }
+
        public void setBaseLocation(double lat, double lng) {
                for (Point k : mapTiles.keySet()) {
                        AltosSiteMapTile tile = mapTiles.get(k);
@@ -308,8 +318,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
 
                        AltosSiteMapTile tile = createTile(offset);
                        tile.show(state, listener_state, lref, ref);
-                       initMap(offset);
-                       finishTileLater(tile, offset);
+                       initAndFinishMapAsync(tile, offset);
                }
 
                scrollRocketToVisible(pt);
@@ -370,8 +379,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                                if (mapTiles.containsKey(offset))
                                        continue;
                                AltosSiteMapTile tile = createTile(offset);
-                               initMap(offset);
-                               finishTileLater(tile, offset);
+                               initAndFinishMapAsync(tile, offset);
                        }
                }
        }
index 617ed4a9a3331193271b03f4dd4b56b6eb406eb3..40c8ff6bf0dc078beff6f8b5016f8910ffe2f4c4 100644 (file)
@@ -19,6 +19,7 @@ package altosui;
 
 import javax.swing.*;
 import javax.imageio.ImageIO;
+import java.awt.image.*;
 import java.io.*;
 import java.net.URL;
 import java.net.URLConnection;
@@ -87,7 +88,14 @@ public class AltosSiteMapCache extends JLabel {
                }
 
                try {
-                       return new ImageIcon(ImageIO.read(pngfile));
+                       BufferedImage   img;
+
+                       img = ImageIO.read(pngfile);
+                       if (img == null) {
+                               System.out.printf("# Can't read pngfile %s\n", pngfile);
+                               return null;
+                       }
+                       return new ImageIcon(img);
                } catch (IOException e) {
                        System.out.printf("# IO error trying to load %s\n", pngfile);
                        return null;