X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=telegps%2FTeleGPS.java;h=bef0bbc69d5ab04c36c3653a943037a75090cd3e;hp=de2b4aa33f84d05c9ed1a8d658a39d5143613df8;hb=f80075be4ebb9c5fe00c24b8c7638fad23267424;hpb=8ba523cd793f2263bb1acd7a5a10f8964075bdc5 diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index de2b4aa3..bef0bbc6 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -26,7 +26,10 @@ import java.util.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener, ActionListener { +public class TeleGPS + extends AltosUIFrame + implements AltosFlightDisplay, AltosFontListener, AltosUnitsListener, ActionListener +{ static String[] telegps_icon_names = { "/telegps-16.png", @@ -50,16 +53,25 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo AltosFlightReader reader; AltosDisplayThread thread; - JTabbedPane pane; + JMenuBar menu_bar; - AltosSiteMap sitemap; - TeleGPSInfo gps_info; - boolean has_map; + JMenu file_menu; + JMenu monitor_menu; + JMenu device_menu; + AltosFreqList frequencies; + + Container bag; + + TeleGPSStatus telegps_status; + TeleGPSStatusUpdate status_update; + + JTabbedPane pane; + + AltosSiteMap sitemap; + TeleGPSInfo gps_info; + AltosInfoTable info_table; - JMenuBar menu_bar; - JMenu file_menu; - JMenu monitor_menu; - JMenu device_menu; + LinkedList displays; /* File menu */ final static String new_command = "new"; @@ -89,21 +101,19 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo /* Device menu */ final static String download_command = "download"; - final static String configure_command = "configure"; final static String export_command = "export"; final static String graph_command = "graph"; + final static String configure_command = "configure"; + final static String flash_command = "flash"; static final String[][] device_menu_entries = new String[][] { { "Download Data", download_command }, { "Configure Device", configure_command }, { "Export Data", export_command }, { "Graph Data", graph_command }, + { "Flash Device", flash_command }, }; -// private AltosInfoTable flightInfo; - - boolean exit_on_close = false; - void stop_display() { if (thread != null && thread.isAlive()) { thread.interrupt(); @@ -115,41 +125,39 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo } public void reset() { - sitemap.reset(); - gps_info.reset(); - } - - public void set_font() { - sitemap.set_font(); - gps_info.set_font(); + for (AltosFlightDisplay display : displays) + display.reset(); } public void font_size_changed(int font_size) { - set_font(); + for (AltosFlightDisplay display : displays) + display.font_size_changed(font_size); } - -// AltosFlightStatusUpdate status_update; + public void units_changed(boolean imperial_units) { + for (AltosFlightDisplay display : displays) + display.units_changed(imperial_units); + } public void show(AltosState state, AltosListenerState listener_state) { -// status_update.saved_state = state; + try { + status_update.saved_state = state; - if (state == null) - state = new AltosState(); + if (state == null) + state = new AltosState(); - sitemap.show(state, listener_state); - gps_info.show(state, listener_state); - telegps_status.show(state, listener_state); + int i = 0; + for (AltosFlightDisplay display : displays) { + display.show(state, listener_state); + i++; + } + } catch (Exception ex) { + System.out.printf("Exception %s\n", ex.toString()); + for (StackTraceElement e : ex.getStackTrace()) + System.out.printf("%s\n", e.toString()); + } } - Container bag; - AltosFreqList frequencies; - JLabel telemetry; - TeleGPSStatus telegps_status; - TeleGPSStatusUpdate status_update; - - ActionListener show_timer; - void new_window() { new TeleGPS(); } @@ -240,6 +248,10 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo void graph() { } + void flash() { + AltosFlashUI.show(this); + } + public void actionPerformed(ActionEvent ev) { /* File menu */ @@ -293,6 +305,10 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo graph(); return; } + if (flash_command.equals(ev.getActionCommand())) { + flash(); + return; + } } void add_frequency_menu(int serial, final AltosFlightReader reader) { @@ -331,6 +347,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo private void close() { AltosUIPreferences.unregister_font_listener(this); + AltosPreferences.unregister_units_listener(this); setVisible(false); dispose(); --number_of_windows; @@ -373,6 +390,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo file_menu = make_menu("File", file_menu_entries); monitor_menu = make_menu("Monitor", monitor_menu_entries); device_menu = make_menu("Device", device_menu_entries); + displays = new LinkedList(); int serial = -1; @@ -385,6 +403,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo c.gridwidth = 2; bag.add(telegps_status, c); c.gridwidth = 1; + displays.add(telegps_status); /* The rest of the window uses a tabbed pane to @@ -403,13 +422,20 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo sitemap = new AltosSiteMap(); pane.add("Site Map", sitemap); + displays.add(sitemap); gps_info = new TeleGPSInfo(); pane.add("Info", gps_info); + displays.add(gps_info); + + info_table = new AltosInfoTable(); + pane.add("Table", info_table); + displays.add(info_table); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); AltosUIPreferences.register_font_listener(this); + AltosPreferences.register_units_listener(this); addWindowListener(new WindowAdapter() { @Override