altoslib/altosui/telegps: Change log size configuration
[fw/altos] / telegps / TeleGPS.java
index 5a707547d480e131ee16332d1de2bd731cd23def..c61b245e006c80d7e16ae353df4cd093ccc19a63 100644 (file)
@@ -51,7 +51,7 @@ public class TeleGPS
        }
 
        AltosFlightReader       reader;
-       AltosDisplayThread      thread;
+       TeleGPSDisplayThread    thread;
 
        JMenuBar                menu_bar;
 
@@ -349,20 +349,28 @@ public class TeleGPS
 
        public void set_reader(AltosFlightReader reader) {
                setTitle(String.format("TeleGPS %s", reader.name));
-               thread = new AltosDisplayThread(this, voice(), this, reader);
+               thread = new TeleGPSDisplayThread(this, voice(), this, reader);
                thread.start();
        }
 
        static int      number_of_windows;
 
+       static public void add_window() {
+               ++number_of_windows;
+       }
+
+       static public void subtract_window() {
+               --number_of_windows;
+               if (number_of_windows == 0)
+                       System.exit(0);
+       }
+
        private void close() {
                AltosUIPreferences.unregister_font_listener(this);
                AltosPreferences.unregister_units_listener(this);
                setVisible(false);
                dispose();
-               --number_of_windows;
-               if (number_of_windows == 0)
-                       System.exit(0);
+               subtract_window();
        }
 
        private void add_menu(JMenu menu, String label, String action) {
@@ -457,7 +465,7 @@ public class TeleGPS
                pack();
                setVisible(true);
 
-               ++number_of_windows;
+               add_window();
 
                status_update = new TeleGPSStatusUpdate(telegps_status);
 
@@ -495,6 +503,18 @@ public class TeleGPS
                return new AltosReplayReader(states.iterator(), file);
        }
 
+       static boolean process_graph(File file) {
+               AltosStateIterable states = record_iterable(file);
+               if (states == null)
+                       return false;
+               try {
+                       new TeleGPSGraphUI(states, file);
+               } catch (Exception e) {
+                       return false;
+               }
+               return true;
+       }
+
        static boolean process_replay(File file) {
                AltosReplayReader new_reader = replay_file(file);
                if (new_reader == null)
@@ -578,10 +598,11 @@ public class TeleGPS
                        else {
                                File file = new File(args[i]);
                                switch (process) {
+                               case process_none:
                                case process_graph:
-                                       ++errors;
+                                       if (!process_graph(file))
+                                               ++errors;
                                        break;
-                               case process_none:
                                case process_replay:
                                        if (!process_replay(file))
                                                ++errors;
@@ -603,14 +624,14 @@ public class TeleGPS
                }
                if (errors != 0)
                        System.exit(errors);
-               if (!any_created) {
+               if (number_of_windows == 0) {
                        java.util.List<AltosDevice> devices = AltosUSBDevice.list(AltosLib.product_basestation);
                        if (devices != null)
                                for (AltosDevice device : devices) {
                                        new TeleGPS(device);
                                        any_created = true;
                                }
-                       if (!any_created)
+                       if (number_of_windows == 0)
                                new TeleGPS();
                }
        }