X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosIdleMonitorUI.java;h=88243c5d396150eb744758305053dae89f752c1c;hp=b5652df3cffb13d8909f3aa3141727a63f28d931;hb=2c4ebe9b4b392531cd1a5bbafc4ddc38a9391af5;hpb=71715337eb532a1fbe1a753240e7417d5223489f diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index b5652df3..88243c5d 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -24,18 +24,22 @@ import javax.swing.event.*; import java.io.*; import java.util.concurrent.*; import java.util.Arrays; -import org.altusmetrum.altoslib_4.*; -import org.altusmetrum.altosuilib_2.*; +import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altosuilib_6.*; -public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener, DocumentListener { +public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosIdleMonitorListener, DocumentListener { AltosDevice device; JTabbedPane pane; AltosPad pad; AltosInfoTable flightInfo; AltosFlightStatus flightStatus; + AltosIgnitor ignitor; AltosIdleMonitor thread; + AltosUIMap sitemap; int serial; boolean remote; + boolean has_ignitor; + boolean has_map; void stop_display() { if (thread != null) { @@ -56,23 +60,51 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl flightInfo.clear(); } - public void set_font() { - pad.set_font(); - flightInfo.set_font(); + public void font_size_changed(int font_size) { + pad.font_size_changed(font_size); + flightInfo.font_size_changed(font_size); } - public void font_size_changed(int font_size) { - set_font(); + public void units_changed(boolean imperial_units) { + pad.units_changed(imperial_units); + flightInfo.units_changed(imperial_units); } AltosFlightStatusUpdate status_update; public void show(AltosState state, AltosListenerState listener_state) { status_update.saved_state = state; + if (ignitor.should_show(state)) { + if (!has_ignitor) { + pane.add("Ignitor", ignitor); + has_ignitor = true; + } + } else { + if (has_ignitor) { + pane.remove(ignitor); + has_ignitor = false; + } + } + if (state.gps != null && state.gps.connected) { + if (!has_map) { + pane.add("Site Map", sitemap); + has_map = true; + } + } else { + if (has_map) { + pane.remove(sitemap); + has_map = false; + } + } + // try { pad.show(state, listener_state); flightStatus.show(state, listener_state); flightInfo.show(state, listener_state); + if (has_ignitor) + ignitor.show(state, listener_state); + if (has_map) + sitemap.show(state, listener_state); // } catch (Exception e) { // System.out.print("Show exception " + e); // } @@ -87,8 +119,17 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl SwingUtilities.invokeLater(r); } + public void failed() { + Runnable r = new Runnable() { + public void run() { + close(); + } + }; + SwingUtilities.invokeLater(r); + } + Container bag; - AltosFreqList frequencies; + AltosUIFreqList frequencies; JTextField callsign_value; /* DocumentListener interface methods */ @@ -159,6 +200,19 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl } } + private void close() { + try { + disconnect(); + } catch (Exception ex) { + System.out.printf("Exception %s\n", ex.toString()); + for (StackTraceElement el : ex.getStackTrace()) + System.out.printf("%s\n", el.toString()); + } + setVisible(false); + dispose(); + AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this); + } + public AltosIdleMonitorUI(JFrame in_owner) throws FileNotFoundException, TimeoutException, InterruptedException { @@ -169,9 +223,10 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl serial = device.getSerial(); - AltosLink link; + AltosSerial link; try { link = new AltosSerial(device); + link.set_frame(this); } catch (Exception ex) { idle_exception(in_owner, ex); return; @@ -185,7 +240,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl /* Stick frequency selector at top of table for telemetry monitoring */ if (remote && serial >= 0) { // Frequency menu - frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial)); + frequencies = new AltosUIFreqList(AltosUIPreferences.frequency(serial)); frequencies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { double frequency = frequencies.frequency(); @@ -221,6 +276,10 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl flightInfo = new AltosInfoTable(); pane.add("Table", new JScrollPane(flightInfo)); + ignitor = new AltosIgnitor(); + + sitemap = new AltosUIMap(); + /* Make the tabbed pane use the rest of the window space */ bag.add(pane, constraints(0, 3, GridBagConstraints.BOTH)); @@ -231,16 +290,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - try { - disconnect(); - } catch (Exception ex) { - System.out.printf("Exception %s\n", ex.toString()); - for (StackTraceElement e : ex.getStackTrace()) - System.out.printf("%s\n", e.toString()); - } - setVisible(false); - dispose(); - AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this); + close(); } });