diff options
author | Keith Packard <keithp@keithp.com> | 2014-06-07 11:52:28 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-06-07 12:34:15 -0700 |
commit | d550c3b3eccbb0283c588b5df69edb2e9b44b4cc (patch) | |
tree | 838eccb03fc795a361268395048c98d59284b74f /telegps/TeleGPS.java | |
parent | 9f2189e0b99aa32b788ecb4576dcb9bcc926f4e2 (diff) |
telegps: Track graph windows as one of the TeleGPS windows
TeleGPS exits when the number of windows goes to zero; track graphing
windows in addition to the usual flight monitoring windows.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'telegps/TeleGPS.java')
-rw-r--r-- | telegps/TeleGPS.java | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 5a707547..71174436 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -355,14 +355,22 @@ public class TeleGPS 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(); } } |