import java.util.prefs.*;
import java.util.concurrent.*;
-public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
+class AltosFlightStatusUpdate implements ActionListener {
+
+ public AltosState saved_state;
+ AltosFlightStatus flightStatus;
+
+ public void actionPerformed (ActionEvent e) {
+ if (saved_state != null)
+ flightStatus.show(saved_state, 0);
+ }
+
+ public AltosFlightStatusUpdate (AltosFlightStatus in_flightStatus) {
+ flightStatus = in_flightStatus;
+ }
+}
+
+public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener {
AltosVoice voice;
AltosFlightReader reader;
AltosDisplayThread thread;
AltosAscent ascent;
AltosDescent descent;
AltosLanded landed;
+ AltosCompanionInfo companion;
AltosSiteMap sitemap;
boolean has_map;
+ boolean has_companion;
private AltosFlightStatus flightStatus;
private AltosInfoTable flightInfo;
sitemap.reset();
}
+ public void set_font() {
+ pad.set_font();
+ ascent.set_font();
+ descent.set_font();
+ landed.set_font();
+ flightStatus.set_font();
+ flightInfo.set_font();
+ sitemap.set_font();
+ companion.set_font();
+ }
+
+ public void font_size_changed(int font_size) {
+ set_font();
+ }
+
+
+ AltosFlightStatusUpdate status_update;
+
public void show(AltosState state, int crc_errors) {
+ status_update.saved_state = state;
JComponent tab = which_tab(state);
try {
pad.show(state, crc_errors);
}
flightStatus.show(state, crc_errors);
flightInfo.show(state, crc_errors);
- if (state.gps != null) {
+
+ if (state.data.companion != null) {
+ if (!has_companion) {
+ pane.add("Companion", companion);
+ has_companion= true;
+ }
+ companion.show(state, crc_errors);
+ } else {
+ if (has_companion) {
+ pane.remove(companion);
+ has_companion = false;
+ }
+ }
+ if (state.gps != null && state.gps.connected) {
if (!has_map) {
pane.add("Site Map", sitemap);
has_map = true;
AltosFreqList frequencies;
JComboBox telemetries;
+ ActionListener show_timer;
+
public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
AltosPreferences.set_component(this);
});
c.gridx = 0;
c.gridy = 0;
+ c.weightx = 0;
+ c.weighty = 0;
c.insets = new Insets(3, 3, 3, 3);
+ c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
bag.add (frequencies, c);
telemetry = Altos.ao_telemetry_standard;
telemetries.setSelectedIndex(telemetry - 1);
telemetries.setMaximumRowCount(Altos.ao_telemetry_max);
+ telemetries.setPreferredSize(null);
+ telemetries.revalidate();
telemetries.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int telemetry = telemetries.getSelectedIndex() + 1;
});
c.gridx = 1;
c.gridy = 0;
+ c.weightx = 0;
+ c.weighty = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
bag.add (telemetries, c);
flightInfo = new AltosInfoTable();
pane.add("Table", new JScrollPane(flightInfo));
+ companion = new AltosCompanionInfo();
+ has_companion = false;
+
sitemap = new AltosSiteMap();
has_map = false;
bag.add(pane, c);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+
+ AltosPreferences.register_font_listener(this);
+
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
disconnect();
setVisible(false);
dispose();
+ AltosPreferences.unregister_font_listener(AltosFlightUI.this);
if (exit_on_close)
System.exit(0);
}
thread = new AltosDisplayThread(this, voice, this, reader);
+ status_update = new AltosFlightStatusUpdate(flightStatus);
+
+ new javax.swing.Timer(100, status_update).start();
+
thread.start();
}