From 9cb10d73fee0e3f36c778fd2a9c9992b87669fe2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 5 Apr 2014 18:14:35 -0700 Subject: altosui: Add ignitor tab for TeleMega extra ignitors Show the current state of the additional ignitors in another tab; there's not really room in the 'Pad' tab. Signed-off-by: Keith Packard --- altosui/AltosFlightUI.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'altosui/AltosFlightUI.java') diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index e8cf7f08..aac4c9b0 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -32,6 +32,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A JTabbedPane pane; AltosPad pad; + AltosIgnitor ignitor; AltosAscent ascent; AltosDescent descent; AltosLanded landed; @@ -40,6 +41,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A boolean has_map; boolean has_companion; boolean has_state; + boolean has_ignitor; private AltosFlightStatus flightStatus; private AltosInfoTable flightInfo; @@ -73,6 +75,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A public void reset() { pad.reset(); + ignitor.reset(); ascent.reset(); descent.reset(); landed.reset(); @@ -82,6 +85,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A public void set_font() { pad.set_font(); + ignitor.set_font(); ascent.set_font(); descent.set_font(); landed.set_font(); @@ -130,6 +134,19 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A flightStatus.show(state, listener_state); flightInfo.show(state, listener_state); + if (ignitor.should_show(state)) { + if (!has_ignitor) { + pane.add("Ignitor", ignitor); + has_ignitor = true; + } + ignitor.show(state, listener_state); + } else { + if (has_ignitor) { + pane.remove(ignitor); + has_ignitor = false; + } + } + if (state.companion != null) { if (!has_companion) { pane.add("Companion", companion); @@ -274,6 +291,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A pad = new AltosPad(); pane.add("Status", pad); + ignitor = new AltosIgnitor(); ascent = new AltosAscent(); descent = new AltosDescent(); landed = new AltosLanded(reader); -- cgit v1.2.3 From 9e18c524fa2d1f648f265b3c3105f5ceacf06c10 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 11 Apr 2014 16:40:06 -0700 Subject: altoslib/altosui/altosuilib/libaltos: Remove trailing whitespace Just cleaning up the source code. Signed-off-by: Keith Packard --- altoslib/AltosEepromDownload.java | 2 +- altoslib/AltosEepromHeader.java | 4 ++-- altoslib/AltosEepromMega.java | 2 +- altoslib/AltosEepromMetrum2.java | 4 ++-- altoslib/AltosFile.java | 2 +- altoslib/AltosIdleFetch.java | 2 +- altoslib/AltosLib.java | 2 +- altoslib/AltosLink.java | 4 ++-- altoslib/AltosMag.java | 1 - altoslib/AltosMs5607.java | 4 ++-- altoslib/AltosPreferences.java | 4 ++-- altoslib/AltosPyro.java | 6 +++--- altoslib/AltosRomconfig.java | 2 +- altoslib/AltosSelfFlash.java | 4 ++-- altoslib/AltosSensorTM.java | 2 +- altoslib/AltosSensorTMini.java | 2 +- altoslib/AltosStateIterable.java | 2 +- altoslib/AltosTelemetry.java | 2 +- altoslib/AltosTelemetryFile.java | 2 +- altoslib/AltosTelemetryLegacy.java | 2 +- altoslib/AltosTelemetryMegaData.java | 6 +++--- altoslib/AltosTelemetryMegaSensor.java | 2 +- altoslib/AltosTelemetrySatellite.java | 2 +- altoslib/AltosUnits.java | 8 ++++---- altosui/AltosAscent.java | 4 ++-- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosConfigFreqUI.java | 10 +++++----- altosui/AltosConfigPyroUI.java | 14 +++++++------- altosui/AltosConfigTDUI.java | 4 ++-- altosui/AltosConfigureUI.java | 4 ++-- altosui/AltosDescent.java | 2 +- altosui/AltosDeviceUIDialog.java | 2 +- altosui/AltosDisplayThread.java | 2 +- altosui/AltosFlashUI.java | 4 ++-- altosui/AltosFlightStatsTable.java | 2 +- altosui/AltosFlightUI.java | 2 +- altosui/AltosFreqList.java | 6 +++--- altosui/AltosGraphDataPoint.java | 4 ++-- altosui/AltosGraphUI.java | 2 +- altosui/AltosIgniteUI.java | 2 +- altosui/AltosInfoTable.java | 2 +- altosui/AltosLanded.java | 2 +- altosui/AltosPad.java | 6 +++--- altosui/AltosScanUI.java | 16 ++++++++-------- altosui/AltosSiteMap.java | 2 +- altosui/AltosSiteMapPreload.java | 16 ++++++++-------- altosui/AltosUI.java | 6 +++--- altosui/AltosUIPreferencesBackend.java | 2 +- altosuilib/AltosDeviceDialog.java | 2 +- altosuilib/AltosUIAxis.java | 2 +- altosuilib/AltosUIEnable.java | 2 +- altosuilib/AltosUIFrame.java | 10 +++++----- altosuilib/AltosUIGraph.java | 4 ++-- altosuilib/AltosUIGrapher.java | 2 +- altosuilib/AltosUIMarker.java | 2 +- altosuilib/AltosUIPreferencesBackend.java | 2 +- altosuilib/AltosUISeries.java | 4 ++-- libaltos/libaltos.c | 10 +++++----- 58 files changed, 115 insertions(+), 116 deletions(-) (limited to 'altosui/AltosFlightUI.java') diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 04101079..163ffad9 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -132,7 +132,7 @@ public class AltosEepromDownload implements Runnable { CheckFile(false); } - + void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException, ParseException { int block, state_block = 0; int log_format = flights.config_data.log_format; diff --git a/altoslib/AltosEepromHeader.java b/altoslib/AltosEepromHeader.java index 6ce7ddd3..fe5bf6c3 100644 --- a/altoslib/AltosEepromHeader.java +++ b/altoslib/AltosEepromHeader.java @@ -162,7 +162,7 @@ public class AltosEepromHeader extends AltosEeprom { break; } } - + public AltosEepromHeader (String[] tokens) { last = false; valid = true; @@ -269,7 +269,7 @@ public class AltosEepromHeader extends AltosEeprom { for (AltosEepromHeader header : headers) { header.write(out); } - + } public AltosEepromHeader (String line) { diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index b8a1b9e8..35e87885 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -70,7 +70,7 @@ public class AltosEepromMega extends AltosEeprom { public int year() { return data8(14); } public int month() { return data8(15); } public int day() { return data8(16); } - + /* AO_LOG_GPS_SAT elements */ public int nsat() { return data16(0); } public int svid(int n) { return data8(2 + n * 2); } diff --git a/altoslib/AltosEepromMetrum2.java b/altoslib/AltosEepromMetrum2.java index f1bca6dc..d13aac42 100644 --- a/altoslib/AltosEepromMetrum2.java +++ b/altoslib/AltosEepromMetrum2.java @@ -59,7 +59,7 @@ public class AltosEepromMetrum2 extends AltosEeprom { public int year() { return data8(4); } public int month() { return data8(5); } public int day() { return data8(6); } - + /* AO_LOG_GPS_SAT elements */ public int nsat() { return data8(0); } public int more() { return data8(1); } @@ -161,7 +161,7 @@ public class AltosEepromMetrum2 extends AltosEeprom { break; try { AltosEepromMetrum2 metrum = new AltosEepromMetrum2(line); - + if (metrum.cmd != AltosLib.AO_LOG_INVALID) metrums.add(metrum); } catch (Exception e) { diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index 37bf7075..79f6f1c6 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_3; import java.io.File; import java.util.*; diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 02cb7a94..b0e45797 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -142,7 +142,7 @@ public class AltosIdleFetch implements AltosStateUpdate { state.set_received_time(System.currentTimeMillis()); } catch (TimeoutException te) { } - + } public AltosIdleFetch(AltosLink link) { diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 05f0af8d..3f25bc31 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -203,7 +203,7 @@ public class AltosLib { throw new IllegalArgumentException(String.format("Invalid telemetry %d", telemetry)); } - + private static String[] state_to_string = { "startup", "idle", diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 97fa7062..469b03c0 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -76,7 +76,7 @@ public abstract class AltosLink implements Runnable { return get_reply(5000); } - + public abstract boolean can_cancel_reply(); public abstract boolean show_reply_timeout(); public abstract void hide_reply_timeout(); @@ -215,7 +215,7 @@ public abstract class AltosLink implements Runnable { break; } } - + } finally { --in_reply; } diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index d2bb9da6..a3a0a74b 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -87,4 +87,3 @@ public class AltosMag implements Cloneable { } } } - \ No newline at end of file diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 97d08c3e..4a851524 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -44,7 +44,7 @@ public class AltosMs5607 { //int P; dT = raw_temp - ((int) tref << 8); - + TEMP = (int) (2000 + (((long) dT * (long) tempsens) >> 23)); if (ms5611) { @@ -55,7 +55,7 @@ public class AltosMs5607 { OFF = ((long) off << 17) + (((long) tco * (long) dT) >> 6); SENS = ((long) sens << 16) + (((long) tcs * (long) dT) >> 7); - } + } if (TEMP < 2000) { int T2 = (int) (((long) dT * (long) dT) >> 31); diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index b8920d26..484cb644 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -55,7 +55,7 @@ public class AltosPreferences { /* Launcher channel preference name */ public final static String launcherChannelPreference = "LAUNCHER-CHANNEL"; - + /* Default logdir is ~/TeleMetrum */ public final static String logdirName = "TeleMetrum"; @@ -349,7 +349,7 @@ public class AltosPreferences { return launcher_channel; } } - + public static AltosPreferencesBackend bt_devices() { synchronized (backend) { return backend.node("bt_devices"); diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index aefc6fbd..a1414123 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -105,7 +105,7 @@ public class AltosPyro { private static HashMap pyro_to_units = new HashMap(); private static HashMap pyro_to_scale = new HashMap(); - + private static void insert_map(int flag, String string, String name, AltosUnits units, double scale) { string_to_pyro.put(string, flag); pyro_to_string.put(flag, string); @@ -114,7 +114,7 @@ public class AltosPyro { pyro_to_units.put(flag, units); pyro_to_scale.put(flag, scale); } - + public static int string_to_pyro(String name) { if (string_to_pyro.containsKey(name)) return string_to_pyro.get(name); @@ -174,7 +174,7 @@ public class AltosPyro { insert_map(pyro_after_motor, pyro_after_motor_string, pyro_after_motor_name, null, 1.0); insert_map(pyro_delay, pyro_delay_string, pyro_delay_name, null, pyro_delay_scale); - + insert_map(pyro_state_less, pyro_state_less_string, pyro_state_less_name, null, 1.0); insert_map(pyro_state_greater_or_equal, pyro_state_greater_or_equal_string, pyro_state_greater_or_equal_name, null, 1.0); } diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index 1273fbc6..506c3961 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -144,7 +144,7 @@ public class AltosRomconfig { ao_romconfig_check, ao_serial_number }; - + private static boolean name_required(String name) { for (String required : required_names) if (name.equals(required)) diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index aae993eb..051aa766 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -47,7 +47,7 @@ public class AltosSelfFlash extends AltosProgrammer { for (int offset = 0; offset < len; offset += 0x100) { link.printf("R %x\n", addr + offset); byte[] reply = link.get_binary_reply(5000, 0x100); - + if (reply == null) throw new IOException("Read device memory timeout"); for (b = 0; b < len; b++) @@ -55,7 +55,7 @@ public class AltosSelfFlash extends AltosProgrammer { } return data; } - + void write_memory(long addr, byte[] data, int start, int len) { int b; link.printf("W %x\n", addr); diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index b8f54bcb..a5129783 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -40,7 +40,7 @@ public class AltosSensorTM { state.set_battery_voltage(AltosConvert.cc_battery_to_voltage(sensor_tm.batt)); state.set_apogee_voltage(AltosConvert.cc_ignitor_to_voltage(sensor_tm.drogue)); state.set_main_voltage(AltosConvert.cc_ignitor_to_voltage(sensor_tm.main)); - + } catch (TimeoutException te) { } } diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java index cc5718a0..bb60a794 100644 --- a/altoslib/AltosSensorTMini.java +++ b/altoslib/AltosSensorTMini.java @@ -34,7 +34,7 @@ public class AltosSensorTMini { state.set_battery_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.batt)); state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.apogee)); state.set_main_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.main)); - + } catch (TimeoutException te) { } } diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java index 5a919b66..7ea3041b 100644 --- a/altoslib/AltosStateIterable.java +++ b/altoslib/AltosStateIterable.java @@ -24,6 +24,6 @@ public abstract class AltosStateIterable implements Iterable { public void write_comments (PrintStream out) { } - + public abstract void write(PrintStream out); } diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 01bedd5e..1c4ce7bc 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -67,7 +67,7 @@ public abstract class AltosTelemetry implements AltosStateUpdate { final static int packet_type_metrum_sensor = 0x0a; final static int packet_type_metrum_data = 0x0b; final static int packet_type_mini = 0x10; - + static AltosTelemetry parse_hex(String hex) throws ParseException, AltosCRCException { AltosTelemetry telem = null; diff --git a/altoslib/AltosTelemetryFile.java b/altoslib/AltosTelemetryFile.java index 09d7d3f8..f6643134 100644 --- a/altoslib/AltosTelemetryFile.java +++ b/altoslib/AltosTelemetryFile.java @@ -62,7 +62,7 @@ public class AltosTelemetryFile extends AltosStateIterable { } public void write(PrintStream out) { - + } public AltosTelemetryFile(FileInputStream input) { diff --git a/altoslib/AltosTelemetryLegacy.java b/altoslib/AltosTelemetryLegacy.java index d302addd..da9296e4 100644 --- a/altoslib/AltosTelemetryLegacy.java +++ b/altoslib/AltosTelemetryLegacy.java @@ -470,7 +470,7 @@ public class AltosTelemetryLegacy extends AltosTelemetry { batt = int16(29); apogee = int16(31); main = int16(33); - + ground_accel = int16(7); ground_pres = int16(15); accel_plus_g = int16(17); diff --git a/altoslib/AltosTelemetryMegaData.java b/altoslib/AltosTelemetryMegaData.java index a4df70be..ffd82546 100644 --- a/altoslib/AltosTelemetryMegaData.java +++ b/altoslib/AltosTelemetryMegaData.java @@ -19,7 +19,7 @@ package org.altusmetrum.altoslib_3; public class AltosTelemetryMegaData extends AltosTelemetryStandard { int state; - + int v_batt; int v_pyro; int sense[]; @@ -41,7 +41,7 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { v_batt = int16(6); v_pyro = int16(8); - sense = new int[6]; + sense = new int[6]; for (int i = 0; i < 6; i++) { sense[i] = int8(10 + i) << 4; @@ -62,7 +62,7 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { super.update_state(state); state.set_state(this.state); - + state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt)); state.set_pyro_voltage(AltosConvert.mega_pyro_voltage(v_pyro)); diff --git a/altoslib/AltosTelemetryMegaSensor.java b/altoslib/AltosTelemetryMegaSensor.java index d1a463c0..d9fd7fde 100644 --- a/altoslib/AltosTelemetryMegaSensor.java +++ b/altoslib/AltosTelemetryMegaSensor.java @@ -67,7 +67,7 @@ public class AltosTelemetryMegaSensor extends AltosTelemetryStandard { state.set_orient(orient); AltosIMU imu = new AltosIMU(); - + imu.accel_x = AltosIMU.convert_accel(accel_x); imu.accel_y = AltosIMU.convert_accel(accel_y); imu.accel_z = AltosIMU.convert_accel(accel_z); diff --git a/altoslib/AltosTelemetrySatellite.java b/altoslib/AltosTelemetrySatellite.java index 01252bde..24777b28 100644 --- a/altoslib/AltosTelemetrySatellite.java +++ b/altoslib/AltosTelemetrySatellite.java @@ -43,7 +43,7 @@ public class AltosTelemetrySatellite extends AltosTelemetryStandard { super.update_state(state); AltosGPS gps = state.make_temp_gps(true); - + gps.cc_gps_sat = sats; state.set_temp_gps(); } diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index e573a43b..82f102e4 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -41,7 +41,7 @@ public abstract class AltosUnits { public double value(double v) { return value(v, AltosConvert.imperial_units); } - + public double inverse(double v) { return inverse(v, AltosConvert.imperial_units); } @@ -49,15 +49,15 @@ public abstract class AltosUnits { public String show_units() { return show_units(AltosConvert.imperial_units); } - + public String say_units() { return say_units(AltosConvert.imperial_units); } - + public int show_fraction(int width) { return show_fraction(width, AltosConvert.imperial_units); } - + int say_fraction(boolean imperial_units) { return 0; } diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 36871dd6..81b08d2c 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -48,7 +48,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { show(); value.setText(s); } - + void show(AltosUnits units, double v) { show(units.show(8, v)); } @@ -122,7 +122,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { show(); value.setText(s); } - + void show(AltosUnits units, double v) { show(units.show(8, v)); } diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 4cc6c462..b90240fb 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -82,7 +82,7 @@ public class AltosCompanionInfo extends JTable { return String.format("%02x\n", companion.board_id); } } - + public void show(AltosState state, AltosListenerState listener_state) { if (state == null) return; diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index e9923a32..58778057 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -71,7 +71,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets (4,4,4,4); - + c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.gridx = 0; @@ -126,7 +126,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { c.weightx = 0; c.weighty = 0; pane.add(ok_button, c); - + cancel_button = new JButton("Cancel"); cancel_button.setActionCommand("cancel"); cancel_button.addActionListener(this); @@ -139,7 +139,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { c.weightx = 0; c.weighty = 0; pane.add(cancel_button, c); - + if (existing == null) setTitle("Add New Frequency"); else { @@ -151,7 +151,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { pack(); setLocationRelativeTo(frame); - + } public AltosEditFreqUI(Frame in_frame) { @@ -290,7 +290,7 @@ public class AltosConfigFreqUI extends AltosUIDialog implements ActionListener { public AltosFrequency[] frequencies() { return frequencies.frequencies(); } - + public AltosConfigFreqUI(Frame in_frame, AltosFrequency[] in_frequencies) { super(in_frame, "Manage Frequencies", true); diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index b14c39ab..b667b15a 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -63,22 +63,22 @@ public class AltosConfigPyroUI public void itemStateChanged(ItemEvent e) { set_enable(enable.isSelected()); - if (!setting) + if (!setting) ui.set_dirty(); } public void changedUpdate(DocumentEvent e) { - if (!setting) + if (!setting) ui.set_dirty(); } public void insertUpdate(DocumentEvent e) { - if (!setting) + if (!setting) ui.set_dirty(); } public void removeUpdate(DocumentEvent e) { - if (!setting) + if (!setting) ui.set_dirty(); } @@ -149,7 +149,7 @@ public class AltosConfigPyroUI enable = new JCheckBox(); enable.addItemListener(this); pane.add(enable, c); - + if ((flag & AltosPyro.pyro_no_value) == 0) { c = new GridBagConstraints(); c.gridx = x+1; c.gridy = y; @@ -224,7 +224,7 @@ public class AltosConfigPyroUI items = new PyroItem[nrow]; int row = 0; - + GridBagConstraints c; c = new GridBagConstraints(); c.gridx = x; c.gridy = y; @@ -371,7 +371,7 @@ public class AltosConfigPyroUI pane.add(close, c); close.addActionListener(this); close.setActionCommand("Close"); - + addWindowListener(new ConfigListener(this, owner)); AltosPreferences.register_units_listener(this); } diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index 3ce0d98c..55d6aed9 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -311,7 +311,7 @@ public class AltosConfigTDUI int i; for (i = 0; i < radio_frequency_value.getItemCount(); i++) { AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i); - + if (f.close(new_radio_frequency)) { radio_frequency_value.setSelectedIndex(i); return; @@ -319,7 +319,7 @@ public class AltosConfigTDUI } for (i = 0; i < radio_frequency_value.getItemCount(); i++) { AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i); - + if (new_radio_frequency < f.frequency) break; } diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index 5e42f430..631c188d 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -123,10 +123,10 @@ public class AltosConfigureUI "Bottom", "Bottom right", }; - + public void add_position() { pane.add(new JLabel ("Menu position"), constraints(0, 1)); - + position_value = new JComboBox (position_names); position_value.setMaximumRowCount(position_names.length); int position = AltosUIPreferences.position(); diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index d1379083..cd993a75 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -318,7 +318,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { } Distance distance; - + class Apogee extends DescentStatus { void show (AltosState state, AltosListenerState listener_state) { diff --git a/altosui/AltosDeviceUIDialog.java b/altosui/AltosDeviceUIDialog.java index ceabe843..ca34357e 100644 --- a/altosui/AltosDeviceUIDialog.java +++ b/altosui/AltosDeviceUIDialog.java @@ -46,7 +46,7 @@ public class AltosDeviceUIDialog extends AltosDeviceDialog { buttonPane.add(manage_bluetooth_button); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); } - + public void actionPerformed(ActionEvent e) { super.actionPerformed(e); if ("manage".equals(e.getActionCommand())) { diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index 2a33f996..ab85607d 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -155,7 +155,7 @@ public class AltosDisplayThread extends Thread { wait(sleep_time); } } - + report(false); } } catch (InterruptedException ie) { diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index 793a8af3..ff9cb95d 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -231,7 +231,7 @@ public class AltosFlashUI javax.swing.filechooser.FileFilter ihx_filter = new FileNameExtensionFilter("Flash Image", "ihx"); hexfile_chooser.addChoosableFileFilter(ihx_filter); hexfile_chooser.setFileFilter(ihx_filter); - + if (!is_pair_programmed() && !device.matchProduct(AltosLib.product_altusmetrum)) { for (int i = 0; i < filters.length; i++) { if (device != null && device.matchProduct(filters[i].product)) @@ -247,7 +247,7 @@ public class AltosFlashUI if (file == null) return false; AltosUIPreferences.set_firmwaredir(file.getParentFile()); - + return true; } diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index cb0c1562..da71154e 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -140,5 +140,5 @@ public class AltosFlightStatsTable extends JComponent { pos(stats.lon,"E","W")); } } - + } \ No newline at end of file diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index aac4c9b0..0d21d296 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -226,7 +226,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A // Telemetry format menu if (reader.supports_telemetry(Altos.ao_telemetry_standard)) { telemetries = new JComboBox(); - for (int i = 1; i <= Altos.ao_telemetry_max; i++) + for (int i = 1; i <= Altos.ao_telemetry_max; i++) telemetries.addItem(Altos.telemetry_name(i)); int telemetry = AltosPreferences.telemetry(serial); if (telemetry <= Altos.ao_telemetry_off || diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java index 039b5f22..525e5ce5 100644 --- a/altosui/AltosFreqList.java +++ b/altosui/AltosFreqList.java @@ -37,7 +37,7 @@ public class AltosFreqList extends JComboBox { for (i = 0; i < getItemCount(); i++) { AltosFrequency f = (AltosFrequency) getItemAt(i); - + if (f.close(new_frequency)) { setSelectedIndex(i); return; @@ -45,7 +45,7 @@ public class AltosFreqList extends JComboBox { } for (i = 0; i < getItemCount(); i++) { AltosFrequency f = (AltosFrequency) getItemAt(i); - + if (new_frequency < f.frequency) break; } @@ -59,7 +59,7 @@ public class AltosFreqList extends JComboBox { public void set_product(String new_product) { product = new_product; } - + public void set_serial(int new_serial) { serial = new_serial; } diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java index 61a1a227..e672d1bf 100644 --- a/altosui/AltosGraphDataPoint.java +++ b/altosui/AltosGraphDataPoint.java @@ -87,7 +87,7 @@ public class AltosGraphDataPoint implements AltosUIDataPoint { break; case data_gps_height: y = state.gps_height; - break; + break; case data_gps_nsat_solution: if (state.gps != null) y = state.gps.nsat; @@ -109,7 +109,7 @@ public class AltosGraphDataPoint implements AltosUIDataPoint { case data_pressure: y = state.pressure(); break; - + case data_accel_x: case data_accel_y: case data_accel_z: diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 40d2f7f4..92b9b94a 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -16,7 +16,7 @@ import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.ui.RefineryUtilities; -public class AltosGraphUI extends AltosUIFrame +public class AltosGraphUI extends AltosUIFrame { JTabbedPane pane; AltosGraph graph; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 2e69249f..3028bb9c 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -486,7 +486,7 @@ public class AltosIgniteUI pane.add(close, c); close.addActionListener(this); close.setActionCommand("close"); - + pack(); setLocationRelativeTo(owner); diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 158b61f0..3242d652 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -205,7 +205,7 @@ public class AltosInfoTable extends JTable { info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W'); info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt); } - if (state.gps.year != AltosLib.MISSING) + if (state.gps.year != AltosLib.MISSING) info_add_row(1, "GPS date", "%04d-%02d-%02d", state.gps.year, state.gps.month, diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 74177753..25d768ad 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -44,7 +44,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio show(); value.setText(s); } - + void show(AltosUnits units, double v) { show(units.show(8, v)); } diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 7baf0eb2..2844b32c 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -69,7 +69,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public void set_label(String text) { label.setText(text); } - + public LaunchStatus (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -142,7 +142,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public void set_label(String text) { label.setText(text); } - + void reset() { value.setText(""); } @@ -414,7 +414,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { pad_lon.set_font(); pad_alt.set_font(); } - + public void show(AltosState state, AltosListenerState listener_state) { battery.show(state, listener_state); apogee.show(state, listener_state); diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index e4a93362..419fe957 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -34,9 +34,9 @@ class AltosScanResult { int flight; AltosFrequency frequency; int telemetry; - + boolean interrupted = false; - + public String toString() { return String.format("%-9.9s serial %-4d flight %-4d (%s %s)", callsign, serial, flight, frequency.toShortString(), Altos.telemetry_name(telemetry)); @@ -76,7 +76,7 @@ class AltosScanResult { } class AltosScanResults extends LinkedList implements ListModel { - + LinkedList listeners = new LinkedList(); void changed(ListDataEvent de) { @@ -107,7 +107,7 @@ class AltosScanResults extends LinkedList implements ListModel public void addListDataListener(ListDataListener l) { listeners.add(l); } - + public void removeListDataListener(ListDataListener l) { listeners.remove(l); } @@ -221,12 +221,12 @@ public class AltosScanUI void set_telemetry() { reader.set_telemetry(telemetry); } - + void set_frequency() throws InterruptedException, TimeoutException { reader.set_frequency(frequencies[frequency_index].frequency); reader.reset(); } - + void next() throws InterruptedException, TimeoutException { reader.set_monitor(false); Thread.sleep(100); @@ -402,7 +402,7 @@ public class AltosScanUI scanning_label = new JLabel("Scanning:"); frequency_label = new JLabel(""); telemetry_label = new JLabel(""); - + set_label(); c.fill = GridBagConstraints.HORIZONTAL; @@ -434,7 +434,7 @@ public class AltosScanUI } int y_offset = 3 + (Altos.ao_telemetry_max - Altos.ao_telemetry_min + 1); - + list = new JList(results) { //Subclass JList to workaround bug 4832765, which can cause the //scroll pane to not let the user easily scroll up to the beginning diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index 105afade..643417b5 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -237,7 +237,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { AltosSiteMapTile tile = mapTiles.get(k); tile.clearMap(); } - + centre = getBaseLocation(lat, lng); scrollRocketToVisible(pt(lat,lng)); } diff --git a/altosui/AltosSiteMapPreload.java b/altosui/AltosSiteMapPreload.java index 66399557..8380b967 100644 --- a/altosui/AltosSiteMapPreload.java +++ b/altosui/AltosSiteMapPreload.java @@ -178,7 +178,7 @@ class AltosSites extends Thread { try { URLConnection uc = url.openConnection(); //int length = uc.getContentLength(); - + InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), Altos.unicode_set); BufferedReader in = new BufferedReader(in_stream); @@ -222,7 +222,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener AltosSites sites; JLabel site_list_label; JComboBox site_list; - + JToggleButton load_button; boolean loading; JButton close_button; @@ -347,7 +347,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener pbar.setValue(0); pbar.setString(""); pbar.setStringPainted(true); - + c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = i; @@ -373,7 +373,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener c.gridwidth = 1; pane.add(site_list_label, c); - + site_list = new JComboBox(new String[] { "Site List" }); site_list.addItemListener(this); @@ -390,7 +390,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener c.gridwidth = 1; pane.add(site_list, c); - + lat = new AltosMapPos(owner, "Latitude:", lat_hemi_names, @@ -407,7 +407,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener c.anchor = GridBagConstraints.CENTER; pane.add(lat, c); - + lon = new AltosMapPos(owner, "Longitude:", lon_hemi_names, @@ -429,7 +429,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener load_button = new JToggleButton("Load Map"); load_button.addActionListener(this); load_button.setActionCommand("load"); - + c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; c.insets = i; @@ -446,7 +446,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener close_button = new JButton("Close"); close_button.addActionListener(this); close_button.setActionCommand("close"); - + c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; c.insets = i; diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 5d459947..a1bc83bf 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -233,7 +233,7 @@ public class AltosUI extends AltosUIFrame { }); setLocationByPlatform(false); - + /* Insets aren't set before the window is visible */ setVisible(true); } @@ -468,7 +468,7 @@ public class AltosUI extends AltosUIFrame { } return false; } - + static boolean process_summary(File file) { AltosStateIterable states = record_iterable(file); if (states == null) @@ -547,7 +547,7 @@ public class AltosUI extends AltosUIFrame { System.out.printf(" --kml\tgenerate KML output for use with Google Earth\n"); System.exit(code); } - + public static void main(final String[] args) { int errors = 0; load_library(null); diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java index 697d9902..f85735e8 100644 --- a/altosui/AltosUIPreferencesBackend.java +++ b/altosui/AltosUIPreferencesBackend.java @@ -25,7 +25,7 @@ import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { private Preferences _preferences = null; - + public AltosUIPreferencesBackend() { _preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); } diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index 73bc0b2f..0a3ddb7b 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -30,7 +30,7 @@ public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionL public Frame frame; public int product; public JPanel buttonPane; - + public AltosDevice getValue() { return value; } diff --git a/altosuilib/AltosUIAxis.java b/altosuilib/AltosUIAxis.java index 1638ea29..7bc2def9 100644 --- a/altosuilib/AltosUIAxis.java +++ b/altosuilib/AltosUIAxis.java @@ -50,7 +50,7 @@ public class AltosUIAxis extends NumberAxis { public void set_units() { setLabel(String.format("%s (%s)", label, units.show_units())); } - + public void set_enable(boolean enable) { if (enable) { visible++; diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java index ea4bd00a..40b5f087 100644 --- a/altosuilib/AltosUIEnable.java +++ b/altosuilib/AltosUIEnable.java @@ -56,7 +56,7 @@ public class AltosUIEnable extends Container { this.name = name; this.grapher = grapher; enable = new JRadioButton(name, enabled); - grapher.set_enable(enabled); + grapher.set_enable(enabled); enable.addActionListener(this); } } diff --git a/altosuilib/AltosUIFrame.java b/altosuilib/AltosUIFrame.java index 3fc99910..3dc2a0ad 100644 --- a/altosuilib/AltosUIFrame.java +++ b/altosuilib/AltosUIFrame.java @@ -45,7 +45,7 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi }; static public String[] icon_names; - + static public void set_icon_names(String[] new_icon_names) { icon_names = new_icon_names; } public String[] icon_names() { @@ -57,7 +57,7 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi public void set_icon() { ArrayList icons = new ArrayList(); String[] icon_names = icon_names(); - + for (int i = 0; i < icon_names.length; i++) { java.net.URL imgURL = AltosUIFrame.class.getResource(icon_names[i]); if (imgURL != null) @@ -65,14 +65,14 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi } setIconImages(icons); } - + private boolean location_by_platform = true; public void setLocationByPlatform(boolean lbp) { location_by_platform = lbp; super.setLocationByPlatform(lbp); } - + public void setSize() { /* Smash sizes around so that the window comes up in the right shape */ Insets i = getInsets(); @@ -153,7 +153,7 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi setPosition(position); } } - + void init() { AltosUIPreferences.register_ui_listener(this); AltosUIPreferences.register_position_listener(this); diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index 061a7629..21e13cf6 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -82,7 +82,7 @@ public class AltosUIGraph implements AltosUnitsListener { public void addSeries(String label, int fetch, AltosUnits units, Color color) { addSeries(label, fetch, units, color, true, newAxis(label, units, color)); } - + public void addMarker(String label, int fetch, Color color) { AltosUIMarker marker = new AltosUIMarker(fetch, color, plot); if (enable != null) @@ -131,7 +131,7 @@ public class AltosUIGraph implements AltosUnitsListener { this.axis_index = 0; xAxis = new NumberAxis("Time (s)"); - + xAxis.setAutoRangeIncludesZero(true); plot = new XYPlot(); diff --git a/altosuilib/AltosUIGrapher.java b/altosuilib/AltosUIGrapher.java index 23e7d9f0..54f8d5a9 100644 --- a/altosuilib/AltosUIGrapher.java +++ b/altosuilib/AltosUIGrapher.java @@ -37,7 +37,7 @@ import org.jfree.data.*; interface AltosUIGrapher { public abstract void set_units(); - + public abstract void clear(); public abstract void add(AltosUIDataPoint dataPoint); diff --git a/altosuilib/AltosUIMarker.java b/altosuilib/AltosUIMarker.java index ae8eb034..efd27921 100644 --- a/altosuilib/AltosUIMarker.java +++ b/altosuilib/AltosUIMarker.java @@ -41,7 +41,7 @@ public class AltosUIMarker implements AltosUIGrapher { boolean enabled; int fetch; Color color; - + private void remove_markers() { for (ValueMarker marker : markers) plot.removeDomainMarker(marker); diff --git a/altosuilib/AltosUIPreferencesBackend.java b/altosuilib/AltosUIPreferencesBackend.java index 64d3e3df..d6575717 100644 --- a/altosuilib/AltosUIPreferencesBackend.java +++ b/altosuilib/AltosUIPreferencesBackend.java @@ -25,7 +25,7 @@ import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { private Preferences _preferences = null; - + public AltosUIPreferencesBackend() { _preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); } diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java index 1f2a1c3f..c17175e4 100644 --- a/altosuilib/AltosUISeries.java +++ b/altosuilib/AltosUISeries.java @@ -38,7 +38,7 @@ class AltosUITime extends AltosUnits { public double value(double v, boolean imperial_units) { return v; } public double inverse(double v, boolean imperial_unis) { return v; } - + public String show_units(boolean imperial_units) { return "s"; } public String say_units(boolean imperial_units) { return "seconds"; } @@ -60,7 +60,7 @@ public class AltosUISeries extends XYSeries implements AltosUIGrapher { XYItemRenderer renderer; int fetch; boolean enable; - + public void set_units() { axis.set_units(); StandardXYToolTipGenerator ttg; diff --git a/libaltos/libaltos.c b/libaltos/libaltos.c index a623d5ae..b7ec98fc 100644 --- a/libaltos/libaltos.c +++ b/libaltos/libaltos.c @@ -817,7 +817,7 @@ get_string(io_object_t object, CFStringRef entry, char *result, int result_len) got_string = CFStringGetCString(entry_as_string, result, result_len, kCFStringEncodingASCII); - + CFRelease(entry_as_string); if (got_string) return 1; @@ -830,7 +830,7 @@ get_number(io_object_t object, CFStringRef entry, int *result) { CFTypeRef entry_as_number; Boolean got_number; - + entry_as_number = IORegistryEntrySearchCFProperty (object, kIOServicePlane, entry, @@ -885,7 +885,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device) object = IOIteratorNext(list->iterator); if (!object) return 0; - + if (!get_number (object, CFSTR(kUSBVendorID), &device->vendor) || !get_number (object, CFSTR(kUSBProductID), &device->product)) continue; @@ -989,7 +989,7 @@ log_message(char *fmt, ...) if (log) { SYSTEMTIME time; GetLocalTime(&time); - fprintf (log, "%4d-%02d-%02d %2d:%02d:%02d. ", + fprintf (log, "%4d-%02d-%02d %2d:%02d:%02d. ", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond); va_start(a, fmt); @@ -1340,7 +1340,7 @@ altos_open(struct altos_device *device) altos_set_last_windows_error(); Sleep(100); } - + if (file->handle == INVALID_HANDLE_VALUE) { free(file); return NULL; -- cgit v1.2.3 From 4ac7797d3efb9cc2d9fae88519f55e40b1050224 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 25 May 2014 20:47:49 -0700 Subject: altosui/altosuilib: Cleanup -Xlint:unchecked warnings Add parametric types to avoid unchecked warnings. Signed-off-by: Keith Packard --- altosui/AltosBTManage.java | 14 ++--- altosui/AltosCSVUI.java | 4 +- altosui/AltosChannelMenu.java | 2 +- altosui/AltosConfigFreqUI.java | 6 +- altosui/AltosConfigPyroUI.java | 4 +- altosui/AltosConfigUI.java | 124 +++++++++++++++++++------------------- altosui/AltosConfigureUI.java | 4 +- altosui/AltosFlightUI.java | 4 +- altosui/AltosScanUI.java | 8 +-- altosuilib/AltosDeviceDialog.java | 16 ++--- altosuilib/AltosUIConfigure.java | 19 +++--- 11 files changed, 101 insertions(+), 104 deletions(-) (limited to 'altosui/AltosFlightUI.java') diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java index 1015f7c3..ad1c28b6 100644 --- a/altosui/AltosBTManage.java +++ b/altosui/AltosBTManage.java @@ -31,9 +31,9 @@ public class AltosBTManage extends AltosUIDialog implements ActionListener, Iter LinkedList listeners; AltosBTKnown bt_known; - class DeviceList extends JList implements Iterable { - LinkedList devices; - DefaultListModel list_model; + class DeviceList extends JList implements Iterable { + LinkedList devices; + DefaultListModel list_model; public void add (AltosBTDevice device) { if (!devices.contains(device)) { @@ -86,16 +86,12 @@ public class AltosBTManage extends AltosUIDialog implements ActionListener, Iter } public java.util.List selected_list() throws InterruptedException { - java.util.LinkedList l = new java.util.LinkedList(); - Object[] a = getSelectedValues(); - for (int i = 0; i < a.length; i++) - l.add((AltosBTDevice)a[i]); - return l; + return getSelectedValuesList(); } public DeviceList() { devices = new LinkedList(); - list_model = new DefaultListModel(); + list_model = new DefaultListModel(); setModel(list_model); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); setLayoutOrientation(JList.HORIZONTAL_WRAP); diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index 05cabcdf..95a8aeea 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -30,7 +30,7 @@ public class AltosCSVUI { JFileChooser csv_chooser; JPanel accessory; - JComboBox combo_box; + JComboBox combo_box; Iterable states; AltosWriter writer; @@ -73,7 +73,7 @@ public class AltosCSVUI c.gridy = 0; accessory.add(accessory_label, c); - combo_box = new JComboBox(combo_box_items); + combo_box = new JComboBox(combo_box_items); combo_box.addActionListener(this); c.gridx = 0; c.gridy = 1; diff --git a/altosui/AltosChannelMenu.java b/altosui/AltosChannelMenu.java index f90a11c0..382b6ae4 100644 --- a/altosui/AltosChannelMenu.java +++ b/altosui/AltosChannelMenu.java @@ -20,7 +20,7 @@ package altosui; import java.awt.event.*; import javax.swing.*; -public class AltosChannelMenu extends JComboBox implements ActionListener { +public class AltosChannelMenu extends JComboBox implements ActionListener { int channel; public AltosChannelMenu(int current_channel) { diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index 58778057..663782f0 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -164,8 +164,8 @@ public class AltosConfigFreqUI extends AltosUIDialog implements ActionListener { Frame frame; LinkedList listeners; - class FrequencyList extends JList { - DefaultListModel list_model; + class FrequencyList extends JList { + DefaultListModel list_model; public void add(AltosFrequency frequency) { int i; @@ -226,7 +226,7 @@ public class AltosConfigFreqUI extends AltosUIDialog implements ActionListener { } public FrequencyList(AltosFrequency[] in_frequencies) { - list_model = new DefaultListModel(); + list_model = new DefaultListModel(); setModel(list_model); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); setLayoutOrientation(JList.HORIZONTAL_WRAP); diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index b667b15a..cd42a3b0 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -50,7 +50,7 @@ public class AltosConfigPyroUI public int flag; public JCheckBox enable; public JTextField value; - public JComboBox combo; + public JComboBox combo; AltosConfigPyroUI ui; boolean setting; @@ -159,7 +159,7 @@ public class AltosConfigPyroUI c.insets = il; if ((flag & AltosPyro.pyro_state_value) != 0) { make_state_names(); - combo = new JComboBox(state_names); + combo = new JComboBox(state_names); combo.addItemListener(this); pane.add(combo, c); } else { diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 6292f778..7f4e1eb0 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -29,98 +29,98 @@ public class AltosConfigUI implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener { - Container pane; - JLabel product_label; - JLabel version_label; - JLabel serial_label; - JLabel main_deploy_label; - JLabel apogee_delay_label; - JLabel apogee_lockout_label; - JLabel frequency_label; - JLabel radio_calibration_label; - JLabel radio_frequency_label; - JLabel radio_enable_label; - JLabel aprs_interval_label; - JLabel flight_log_max_label; - JLabel ignite_mode_label; - JLabel pad_orientation_label; - JLabel callsign_label; - JLabel beep_label; + Container pane; + JLabel product_label; + JLabel version_label; + JLabel serial_label; + JLabel main_deploy_label; + JLabel apogee_delay_label; + JLabel apogee_lockout_label; + JLabel frequency_label; + JLabel radio_calibration_label; + JLabel radio_frequency_label; + JLabel radio_enable_label; + JLabel aprs_interval_label; + JLabel flight_log_max_label; + JLabel ignite_mode_label; + JLabel pad_orientation_label; + JLabel callsign_label; + JLabel beep_label; public boolean dirty; - JFrame owner; - JLabel product_value; - JLabel version_value; - JLabel serial_value; - JComboBox main_deploy_value; - JComboBox apogee_delay_value; - JComboBox apogee_lockout_value; - AltosFreqList radio_frequency_value; - JTextField radio_calibration_value; - JRadioButton radio_enable_value; - JComboBox aprs_interval_value; - JComboBox flight_log_max_value; - JComboBox ignite_mode_value; - JComboBox pad_orientation_value; - JTextField callsign_value; - JComboBox beep_value; - - JButton pyro; - - JButton save; - JButton reset; - JButton reboot; - JButton close; - - AltosPyro[] pyros; - - ActionListener listener; - - static String[] main_deploy_values_m = { + JFrame owner; + JLabel product_value; + JLabel version_value; + JLabel serial_value; + JComboBox main_deploy_value; + JComboBox apogee_delay_value; + JComboBox apogee_lockout_value; + AltosFreqList radio_frequency_value; + JTextField radio_calibration_value; + JRadioButton radio_enable_value; + JComboBox aprs_interval_value; + JComboBox flight_log_max_value; + JComboBox ignite_mode_value; + JComboBox pad_orientation_value; + JTextField callsign_value; + JComboBox beep_value; + + JButton pyro; + + JButton save; + JButton reset; + JButton reboot; + JButton close; + + AltosPyro[] pyros; + + ActionListener listener; + + static String[] main_deploy_values_m = { "100", "150", "200", "250", "300", "350", "400", "450", "500" }; - static String[] main_deploy_values_ft = { + static String[] main_deploy_values_ft = { "250", "500", "750", "1000", "1250", "1500", "1750", "2000" }; - static String[] apogee_delay_values = { + static String[] apogee_delay_values = { "0", "1", "2", "3", "4", "5" }; - static String[] apogee_lockout_values = { + static String[] apogee_lockout_values = { "0", "5", "10", "15", "20" }; - static String[] flight_log_max_values = { + static String[] flight_log_max_values = { "64", "128", "192", "256", "320", "384", "448", "512", "576", "640", "704", "768", "832", "896", "960", }; - static String[] ignite_mode_values = { + static String[] ignite_mode_values = { "Dual Deploy", "Redundant Apogee", "Redundant Main", }; - static String[] aprs_interval_values = { + static String[] aprs_interval_values = { "Disabled", "2", "5", "10" }; - static String[] beep_values = { + static String[] beep_values = { "3750", "4000", "4250", }; - static String[] pad_orientation_values = { + static String[] pad_orientation_values = { "Antenna Up", "Antenna Down", }; @@ -319,7 +319,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - main_deploy_value = new JComboBox(main_deploy_values()); + main_deploy_value = new JComboBox(main_deploy_values()); main_deploy_value.setEditable(true); main_deploy_value.addItemListener(this); pane.add(main_deploy_value, c); @@ -345,7 +345,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - apogee_delay_value = new JComboBox(apogee_delay_values); + apogee_delay_value = new JComboBox(apogee_delay_values); apogee_delay_value.setEditable(true); apogee_delay_value.addItemListener(this); pane.add(apogee_delay_value, c); @@ -371,7 +371,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - apogee_lockout_value = new JComboBox(apogee_lockout_values); + apogee_lockout_value = new JComboBox(apogee_lockout_values); apogee_lockout_value.setEditable(true); apogee_lockout_value.addItemListener(this); pane.add(apogee_lockout_value, c); @@ -474,7 +474,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - aprs_interval_value = new JComboBox(aprs_interval_values); + aprs_interval_value = new JComboBox(aprs_interval_values); aprs_interval_value.setEditable(true); aprs_interval_value.addItemListener(this); pane.add(aprs_interval_value, c); @@ -525,7 +525,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - flight_log_max_value = new JComboBox(flight_log_max_values); + flight_log_max_value = new JComboBox(flight_log_max_values); flight_log_max_value.setEditable(true); flight_log_max_value.addItemListener(this); pane.add(flight_log_max_value, c); @@ -551,7 +551,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - ignite_mode_value = new JComboBox(ignite_mode_values); + ignite_mode_value = new JComboBox(ignite_mode_values); ignite_mode_value.setEditable(false); ignite_mode_value.addItemListener(this); pane.add(ignite_mode_value, c); @@ -577,7 +577,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - pad_orientation_value = new JComboBox(pad_orientation_values); + pad_orientation_value = new JComboBox(pad_orientation_values); pad_orientation_value.setEditable(false); pad_orientation_value.addItemListener(this); pane.add(pad_orientation_value, c); @@ -603,7 +603,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - beep_value = new JComboBox(beep_values); + beep_value = new JComboBox(beep_values); beep_value.setEditable(true); beep_value.addItemListener(this); pane.add(beep_value, c); diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index 631c188d..80876959 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -31,7 +31,7 @@ public class AltosConfigureUI AltosVoice voice; public JTextField callsign_value; - public JComboBox position_value; + public JComboBox position_value; /* DocumentListener interface methods */ public void insertUpdate(DocumentEvent e) { @@ -127,7 +127,7 @@ public class AltosConfigureUI public void add_position() { pane.add(new JLabel ("Menu position"), constraints(0, 1)); - position_value = new JComboBox (position_names); + position_value = new JComboBox(position_names); position_value.setMaximumRowCount(position_names.length); int position = AltosUIPreferences.position(); position_value.setSelectedIndex(position); diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 0d21d296..b31de12c 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -179,7 +179,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A Container bag; AltosFreqList frequencies; - JComboBox telemetries; + JComboBox telemetries; JLabel telemetry; ActionListener show_timer; @@ -225,7 +225,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A // Telemetry format menu if (reader.supports_telemetry(Altos.ao_telemetry_standard)) { - telemetries = new JComboBox(); + telemetries = new JComboBox(); for (int i = 1; i <= Altos.ao_telemetry_max; i++) telemetries.addItem(Altos.telemetry_name(i)); int telemetry = AltosPreferences.telemetry(serial); diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 419fe957..5cc74a77 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -75,7 +75,7 @@ class AltosScanResult { } } -class AltosScanResults extends LinkedList implements ListModel { +class AltosScanResults extends LinkedList implements ListModel { LinkedList listeners = new LinkedList(); @@ -129,7 +129,7 @@ public class AltosScanUI AltosDevice device; AltosConfigData config_data; AltosTelemetryReader reader; - private JList list; + private JList list; private JLabel scanning_label; private JLabel frequency_label; private JLabel telemetry_label; @@ -435,7 +435,7 @@ public class AltosScanUI int y_offset = 3 + (Altos.ao_telemetry_max - Altos.ao_telemetry_min + 1); - list = new JList(results) { + list = new JList(results) { //Subclass JList to workaround bug 4832765, which can cause the //scroll pane to not let the user easily scroll up to the beginning //of the list. An alternative would be to set the unitIncrement @@ -548,4 +548,4 @@ public class AltosScanUI setVisible(true); } -} \ No newline at end of file +} diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index 0a3ddb7b..7fb23e13 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -23,13 +23,13 @@ import java.awt.event.*; public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionListener { - private AltosDevice value; - private JList list; - private JButton cancel_button; - private JButton select_button; - public Frame frame; - public int product; - public JPanel buttonPane; + private AltosDevice value; + private JList list; + private JButton cancel_button; + private JButton select_button; + public Frame frame; + public int product; + public JPanel buttonPane; public AltosDevice getValue() { return value; @@ -65,7 +65,7 @@ public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionL select_button.setEnabled(false); getRootPane().setDefaultButton(select_button); - list = new JList(devices) { + list = new JList(devices) { //Subclass JList to workaround bug 4832765, which can cause the //scroll pane to not let the user easily scroll up to the beginning //of the list. An alternative would be to set the unitIncrement diff --git a/altosuilib/AltosUIConfigure.java b/altosuilib/AltosUIConfigure.java index 9e72e403..153eb8ee 100644 --- a/altosuilib/AltosUIConfigure.java +++ b/altosuilib/AltosUIConfigure.java @@ -23,10 +23,10 @@ import java.beans.*; import javax.swing.*; import javax.swing.event.*; -class DelegatingRenderer implements ListCellRenderer { +class DelegatingRenderer implements ListCellRenderer { // ... - public static void install(JComboBox comboBox) { + public static void install(JComboBox comboBox) { DelegatingRenderer renderer = new DelegatingRenderer(comboBox); renderer.initialise(); comboBox.setRenderer(renderer); @@ -36,7 +36,7 @@ class DelegatingRenderer implements ListCellRenderer { private final JComboBox comboBox; // ... - private ListCellRenderer delegate; + private ListCellRenderer delegate; // ... private DelegatingRenderer(JComboBox comboBox) { @@ -45,21 +45,22 @@ class DelegatingRenderer implements ListCellRenderer { // ... private void initialise() { - delegate = new JComboBox().getRenderer(); + JComboBox c = new JComboBox(); + delegate = c.getRenderer(); comboBox.addPropertyChangeListener("UI", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { - delegate = new JComboBox().getRenderer(); + delegate = new JComboBox().getRenderer(); } }); } // ... - public Component getListCellRendererComponent(JList list, + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return delegate.getListCellRendererComponent(list, - ((UIManager.LookAndFeelInfo) value).getName(), + ((UIManager.LookAndFeelInfo)value).getName(), index, isSelected, cellHasFocus); } } @@ -139,7 +140,7 @@ public class AltosUIConfigure /* Font size setting */ pane.add(new JLabel("Font size"), constraints(0, 1)); - final JComboBox font_size_value = new JComboBox(font_size_names); + final JComboBox font_size_value = new JComboBox(font_size_names); int font_size = AltosUIPreferences.font_size(); font_size_value.setSelectedIndex(font_size - AltosUILib.font_size_small); font_size_value.addActionListener(new ActionListener() { @@ -181,7 +182,7 @@ public class AltosUIConfigure final UIManager.LookAndFeelInfo[] look_and_feels = UIManager.getInstalledLookAndFeels(); - final JComboBox look_and_feel_value = new JComboBox(look_and_feels); + final JComboBox look_and_feel_value = new JComboBox(look_and_feels); DelegatingRenderer.install(look_and_feel_value); -- cgit v1.2.3 From f0216d721ed13f4d3dc608bb6ad8f83732b27c0a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 25 May 2014 21:01:38 -0700 Subject: altoslib/altosuilib: Change versions to altoslib:4, altosuilib:2 API has changed for these libraries, time to bump the file versions Signed-off-by: Keith Packard --- altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java | 2 +- altoslib/AltosAccel.java | 2 +- altoslib/AltosCRCException.java | 2 +- altoslib/AltosCSV.java | 2 +- altoslib/AltosCompanion.java | 2 +- altoslib/AltosConfigData.java | 2 +- altoslib/AltosConfigValues.java | 2 +- altoslib/AltosConvert.java | 2 +- altoslib/AltosDebug.java | 2 +- altoslib/AltosDistance.java | 2 +- altoslib/AltosEeprom.java | 2 +- altoslib/AltosEepromChunk.java | 2 +- altoslib/AltosEepromDownload.java | 2 +- altoslib/AltosEepromFile.java | 2 +- altoslib/AltosEepromHeader.java | 2 +- altoslib/AltosEepromIterable.java | 2 +- altoslib/AltosEepromList.java | 2 +- altoslib/AltosEepromLog.java | 2 +- altoslib/AltosEepromMega.java | 2 +- altoslib/AltosEepromMetrum2.java | 2 +- altoslib/AltosEepromMini.java | 2 +- altoslib/AltosEepromMonitor.java | 2 +- altoslib/AltosEepromTM.java | 2 +- altoslib/AltosEepromTm.java | 2 +- altoslib/AltosFile.java | 2 +- altoslib/AltosFlash.java | 2 +- altoslib/AltosFlashListener.java | 2 +- altoslib/AltosFlightReader.java | 2 +- altoslib/AltosFrequency.java | 2 +- altoslib/AltosGPS.java | 2 +- altoslib/AltosGPSSat.java | 2 +- altoslib/AltosGreatCircle.java | 2 +- altoslib/AltosHeight.java | 2 +- altoslib/AltosHexfile.java | 2 +- altoslib/AltosHexsym.java | 2 +- altoslib/AltosIMU.java | 2 +- altoslib/AltosIdle.java | 2 +- altoslib/AltosIdleFetch.java | 2 +- altoslib/AltosIdleMonitor.java | 2 +- altoslib/AltosIdleMonitorListener.java | 2 +- altoslib/AltosIgnite.java | 2 +- altoslib/AltosKML.java | 2 +- altoslib/AltosLib.java | 2 +- altoslib/AltosLine.java | 2 +- altoslib/AltosLink.java | 2 +- altoslib/AltosListenerState.java | 2 +- altoslib/AltosLog.java | 2 +- altoslib/AltosMag.java | 2 +- altoslib/AltosMma655x.java | 2 +- altoslib/AltosMs5607.java | 2 +- altoslib/AltosNoSymbol.java | 2 +- altoslib/AltosOrient.java | 2 +- altoslib/AltosParse.java | 2 +- altoslib/AltosPreferences.java | 2 +- altoslib/AltosPreferencesBackend.java | 2 +- altoslib/AltosProgrammer.java | 2 +- altoslib/AltosPyro.java | 2 +- altoslib/AltosReplayReader.java | 2 +- altoslib/AltosRomconfig.java | 2 +- altoslib/AltosSelfFlash.java | 2 +- altoslib/AltosSensorEMini.java | 2 +- altoslib/AltosSensorMM.java | 2 +- altoslib/AltosSensorMega.java | 2 +- altoslib/AltosSensorMetrum.java | 2 +- altoslib/AltosSensorTM.java | 2 +- altoslib/AltosSensorTMini.java | 2 +- altoslib/AltosSpeed.java | 2 +- altoslib/AltosState.java | 2 +- altoslib/AltosStateIterable.java | 2 +- altoslib/AltosStateUpdate.java | 2 +- altoslib/AltosTelemetry.java | 2 +- altoslib/AltosTelemetryConfiguration.java | 2 +- altoslib/AltosTelemetryFile.java | 2 +- altoslib/AltosTelemetryIterable.java | 2 +- altoslib/AltosTelemetryLegacy.java | 2 +- altoslib/AltosTelemetryLocation.java | 2 +- altoslib/AltosTelemetryMap.java | 2 +- altoslib/AltosTelemetryMegaData.java | 2 +- altoslib/AltosTelemetryMegaSensor.java | 2 +- altoslib/AltosTelemetryMetrumData.java | 2 +- altoslib/AltosTelemetryMetrumSensor.java | 2 +- altoslib/AltosTelemetryMini.java | 2 +- altoslib/AltosTelemetryRaw.java | 2 +- altoslib/AltosTelemetryReader.java | 2 +- altoslib/AltosTelemetrySatellite.java | 2 +- altoslib/AltosTelemetrySensor.java | 2 +- altoslib/AltosTelemetryStandard.java | 2 +- altoslib/AltosTemperature.java | 2 +- altoslib/AltosUnits.java | 2 +- altoslib/AltosUnitsListener.java | 2 +- altoslib/AltosWriter.java | 2 +- altosui/Altos.java | 4 ++-- altosui/AltosAscent.java | 3 ++- altosui/AltosBTDevice.java | 2 +- altosui/AltosBTKnown.java | 4 ++-- altosui/AltosBTManage.java | 2 +- altosui/AltosCSVUI.java | 4 ++-- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosConfig.java | 4 ++-- altosui/AltosConfigFreqUI.java | 4 ++-- altosui/AltosConfigPyroUI.java | 4 ++-- altosui/AltosConfigTD.java | 4 ++-- altosui/AltosConfigTDUI.java | 4 ++-- altosui/AltosConfigUI.java | 4 ++-- altosui/AltosConfigureUI.java | 2 +- altosui/AltosDataChooser.java | 4 ++-- altosui/AltosDescent.java | 3 ++- altosui/AltosDeviceUIDialog.java | 2 +- altosui/AltosEepromDelete.java | 2 +- altosui/AltosEepromManage.java | 4 ++-- altosui/AltosEepromMonitor.java | 2 +- altosui/AltosEepromMonitorUI.java | 4 ++-- altosui/AltosEepromSelect.java | 4 ++-- altosui/AltosFlashUI.java | 4 ++-- altosui/AltosFlightStatsTable.java | 2 +- altosui/AltosFlightStatus.java | 3 ++- altosui/AltosFlightStatusTableModel.java | 2 +- altosui/AltosFlightStatusUpdate.java | 2 +- altosui/AltosFlightUI.java | 4 ++-- altosui/AltosGraph.java | 4 ++-- altosui/AltosGraphDataPoint.java | 4 ++-- altosui/AltosGraphDataSet.java | 4 ++-- altosui/AltosGraphUI.java | 4 ++-- altosui/AltosIdleMonitorUI.java | 4 ++-- altosui/AltosIgniteUI.java | 4 ++-- altosui/AltosIgnitor.java | 3 ++- altosui/AltosInfoTable.java | 2 +- altosui/AltosLanded.java | 3 ++- altosui/AltosLaunch.java | 2 +- altosui/AltosLaunchUI.java | 2 +- altosui/AltosPad.java | 3 ++- altosui/AltosRomconfigUI.java | 4 ++-- altosui/AltosScanUI.java | 4 ++-- altosui/AltosSerial.java | 4 ++-- altosui/AltosSerialInUseException.java | 2 +- altosui/AltosUI.java | 4 ++-- altosui/AltosUIPreferencesBackend.java | 2 +- altosuilib/AltosDevice.java | 2 +- altosuilib/AltosDeviceDialog.java | 2 +- altosuilib/AltosFontListener.java | 2 +- altosuilib/AltosPositionListener.java | 2 +- altosuilib/AltosUIAxis.java | 4 ++-- altosuilib/AltosUIConfigure.java | 2 +- altosuilib/AltosUIDataMissing.java | 2 +- altosuilib/AltosUIDataPoint.java | 2 +- altosuilib/AltosUIDataSet.java | 2 +- altosuilib/AltosUIDialog.java | 2 +- altosuilib/AltosUIEnable.java | 4 ++-- altosuilib/AltosUIFrame.java | 2 +- altosuilib/AltosUIGraph.java | 4 ++-- altosuilib/AltosUIGrapher.java | 4 ++-- altosuilib/AltosUILib.java | 4 ++-- altosuilib/AltosUIListener.java | 2 +- altosuilib/AltosUIMarker.java | 4 ++-- altosuilib/AltosUIPreferences.java | 4 ++-- altosuilib/AltosUIPreferencesBackend.java | 4 ++-- altosuilib/AltosUISeries.java | 4 ++-- altosuilib/AltosUIVersion.java.in | 2 +- altosuilib/AltosUSBDevice.java | 2 +- configure.ac | 4 ++-- micropeak/MicroData.java | 4 ++-- micropeak/MicroDataPoint.java | 2 +- micropeak/MicroDeviceDialog.java | 2 +- micropeak/MicroDownload.java | 4 ++-- micropeak/MicroExport.java | 4 ++-- micropeak/MicroFile.java | 4 ++-- micropeak/MicroFileChooser.java | 4 ++-- micropeak/MicroFrame.java | 2 +- micropeak/MicroGraph.java | 4 ++-- micropeak/MicroPeak.java | 4 ++-- micropeak/MicroRaw.java | 4 ++-- micropeak/MicroSave.java | 4 ++-- micropeak/MicroSerial.java | 2 +- micropeak/MicroSerialLog.java | 2 +- micropeak/MicroStats.java | 4 ++-- micropeak/MicroStatsTable.java | 4 ++-- micropeak/MicroUSB.java | 2 +- 189 files changed, 241 insertions(+), 235 deletions(-) (limited to 'altosui/AltosFlightUI.java') diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index 634769cc..1b4d45ed 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -31,7 +31,7 @@ import android.os.Handler; //import android.os.Message; import android.util.Log; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosBluetooth extends AltosLink { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 9125d56b..f61baf1e 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -49,7 +49,7 @@ import android.widget.Toast; import android.app.AlertDialog; import android.location.Location; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosDroid extends FragmentActivity { // Debugging diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java index 067cb620..f6e6881d 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java @@ -23,7 +23,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Environment; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosDroidPreferences implements AltosPreferencesBackend { public final static String NAME = "org.altusmetrum.AltosDroid"; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java index 9d155385..fac4b8d4 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.location.Location; public interface AltosDroidTab { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java index b50cab22..77d4ba38 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java @@ -21,7 +21,7 @@ package org.altusmetrum.AltosDroid; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosVoice { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java index edfd8245..e4a815eb 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java index cc070b0d..cbbe4d44 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java index 5a703978..b2e6fd20 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java index 5fe88f51..38922771 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java @@ -19,7 +19,7 @@ package org.altusmetrum.AltosDroid; import java.util.Arrays; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java index 3f0a1887..10bb3bd9 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java index c8c61838..4215a330 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java @@ -1,6 +1,6 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.content.BroadcastReceiver; import android.content.Context; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java index 2a2cc404..5bc4b90d 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java @@ -25,7 +25,7 @@ import java.util.concurrent.*; import android.util.Log; import android.os.Handler; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class TelemetryReader extends Thread { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index 96cedad8..da5e044f 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -44,7 +44,7 @@ import android.location.LocationManager; import android.location.LocationListener; import android.location.Criteria; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class TelemetryService extends Service implements LocationListener { diff --git a/altoslib/AltosAccel.java b/altoslib/AltosAccel.java index 43dc20bd..3d340e5d 100644 --- a/altoslib/AltosAccel.java +++ b/altoslib/AltosAccel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosAccel extends AltosUnits { diff --git a/altoslib/AltosCRCException.java b/altoslib/AltosCRCException.java index 94962731..253ca435 100644 --- a/altoslib/AltosCRCException.java +++ b/altoslib/AltosCRCException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosCRCException extends Exception { public int rssi; diff --git a/altoslib/AltosCSV.java b/altoslib/AltosCSV.java index 8176d21b..27e1fade 100644 --- a/altoslib/AltosCSV.java +++ b/altoslib/AltosCSV.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosCompanion.java b/altoslib/AltosCompanion.java index 47ca328e..09bfe9f3 100644 --- a/altoslib/AltosCompanion.java +++ b/altoslib/AltosCompanion.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosCompanion { public final static int board_id_telescience = 0x0a; diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 213d8f13..e5c546ff 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.*; import java.text.*; diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 1a9fddbf..b7c0c6ed 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosConfigValues { /* set and get all of the dialog values */ diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 4ed45c68..484f6213 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -18,7 +18,7 @@ /* * Sensor data conversion functions */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosConvert { /* diff --git a/altoslib/AltosDebug.java b/altoslib/AltosDebug.java index 4dfb31e5..b0e52fc1 100644 --- a/altoslib/AltosDebug.java +++ b/altoslib/AltosDebug.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosDistance.java b/altoslib/AltosDistance.java index 71ee81d7..76ca20c0 100644 --- a/altoslib/AltosDistance.java +++ b/altoslib/AltosDistance.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosDistance extends AltosUnits { diff --git a/altoslib/AltosEeprom.java b/altoslib/AltosEeprom.java index 57ee73ad..be18ba24 100644 --- a/altoslib/AltosEeprom.java +++ b/altoslib/AltosEeprom.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index c884b659..32de96bc 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 163ffad9..a2dfc438 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index 91ffc223..2a26c484 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromHeader.java b/altoslib/AltosEepromHeader.java index fe5bf6c3..0d022f46 100644 --- a/altoslib/AltosEepromHeader.java +++ b/altoslib/AltosEepromHeader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index 081721b3..415c5b62 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromList.java b/altoslib/AltosEepromList.java index a9dac13a..ab853a88 100644 --- a/altoslib/AltosEepromList.java +++ b/altoslib/AltosEepromList.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromLog.java b/altoslib/AltosEepromLog.java index cc298207..1a430c03 100644 --- a/altoslib/AltosEepromLog.java +++ b/altoslib/AltosEepromLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index f0d7097e..71719a26 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMetrum2.java b/altoslib/AltosEepromMetrum2.java index d13aac42..d137614a 100644 --- a/altoslib/AltosEepromMetrum2.java +++ b/altoslib/AltosEepromMetrum2.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMini.java b/altoslib/AltosEepromMini.java index b308fbf4..32985639 100644 --- a/altoslib/AltosEepromMini.java +++ b/altoslib/AltosEepromMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMonitor.java b/altoslib/AltosEepromMonitor.java index 9ab1a5ab..b97287c3 100644 --- a/altoslib/AltosEepromMonitor.java +++ b/altoslib/AltosEepromMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosEepromMonitor { diff --git a/altoslib/AltosEepromTM.java b/altoslib/AltosEepromTM.java index c8b1e60c..77fe20c5 100644 --- a/altoslib/AltosEepromTM.java +++ b/altoslib/AltosEepromTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromTm.java b/altoslib/AltosEepromTm.java index 049dd340..6cbb7253 100644 --- a/altoslib/AltosEepromTm.java +++ b/altoslib/AltosEepromTm.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index 79f6f1c6..2a738996 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.File; import java.util.*; diff --git a/altoslib/AltosFlash.java b/altoslib/AltosFlash.java index 25c76863..8e8722c2 100644 --- a/altoslib/AltosFlash.java +++ b/altoslib/AltosFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosFlashListener.java b/altoslib/AltosFlashListener.java index b7fcd73b..8bb86bba 100644 --- a/altoslib/AltosFlashListener.java +++ b/altoslib/AltosFlashListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosFlashListener { public void position(String label, int percent); diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index 86757e82..2fcd556e 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.io.*; diff --git a/altoslib/AltosFrequency.java b/altoslib/AltosFrequency.java index 5770b646..7c291ea9 100644 --- a/altoslib/AltosFrequency.java +++ b/altoslib/AltosFrequency.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosFrequency { public double frequency; diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 01e6fdbc..2708d026 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosGPSSat.java b/altoslib/AltosGPSSat.java index 76fa3a56..ef24d497 100644 --- a/altoslib/AltosGPSSat.java +++ b/altoslib/AltosGPSSat.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosGPSSat { public int svid; diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index b884a3bc..39df4fc8 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.lang.Math; diff --git a/altoslib/AltosHeight.java b/altoslib/AltosHeight.java index a81897e7..84981032 100644 --- a/altoslib/AltosHeight.java +++ b/altoslib/AltosHeight.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosHeight extends AltosUnits { diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java index 60f4ecdc..d5fa8f5f 100644 --- a/altoslib/AltosHexfile.java +++ b/altoslib/AltosHexfile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.LinkedList; diff --git a/altoslib/AltosHexsym.java b/altoslib/AltosHexsym.java index a98ef0fc..403b5644 100644 --- a/altoslib/AltosHexsym.java +++ b/altoslib/AltosHexsym.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosHexsym { String name; diff --git a/altoslib/AltosIMU.java b/altoslib/AltosIMU.java index 99efb76f..a22b3fed 100644 --- a/altoslib/AltosIMU.java +++ b/altoslib/AltosIMU.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.*; diff --git a/altoslib/AltosIdle.java b/altoslib/AltosIdle.java index c7b546b6..55f6f5c9 100644 --- a/altoslib/AltosIdle.java +++ b/altoslib/AltosIdle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index b0e45797..5cd8bf36 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 8342f8a5..f81abdff 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosIdleMonitorListener.java b/altoslib/AltosIdleMonitorListener.java index dcaa77a6..6a9abea2 100644 --- a/altoslib/AltosIdleMonitorListener.java +++ b/altoslib/AltosIdleMonitorListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosIdleMonitorListener { public void update(AltosState state, AltosListenerState listener_state); diff --git a/altoslib/AltosIgnite.java b/altoslib/AltosIgnite.java index 8ab47d1d..c21f17ac 100644 --- a/altoslib/AltosIgnite.java +++ b/altoslib/AltosIgnite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.*; import java.io.*; diff --git a/altoslib/AltosKML.java b/altoslib/AltosKML.java index cc9a9f51..d55da9ef 100644 --- a/altoslib/AltosKML.java +++ b/altoslib/AltosKML.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 3f25bc31..5e18202f 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.*; import java.io.*; diff --git a/altoslib/AltosLine.java b/altoslib/AltosLine.java index 9d796a89..f9c712a3 100644 --- a/altoslib/AltosLine.java +++ b/altoslib/AltosLine.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosLine { public String line; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 469b03c0..7f434a06 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosListenerState.java b/altoslib/AltosListenerState.java index 53ed33f9..5bf761b0 100644 --- a/altoslib/AltosListenerState.java +++ b/altoslib/AltosListenerState.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosListenerState { public int crc_errors; diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index 70c017b7..8ecb1e96 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.text.*; diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index a3a0a74b..9262de2d 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.*; diff --git a/altoslib/AltosMma655x.java b/altoslib/AltosMma655x.java index 0d90c351..cb2e63d4 100644 --- a/altoslib/AltosMma655x.java +++ b/altoslib/AltosMma655x.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.*; diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 4a851524..5aa3a7ec 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.*; diff --git a/altoslib/AltosNoSymbol.java b/altoslib/AltosNoSymbol.java index 791899c0..f5e53b8c 100644 --- a/altoslib/AltosNoSymbol.java +++ b/altoslib/AltosNoSymbol.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosNoSymbol extends Exception { public AltosNoSymbol(String name) { diff --git a/altoslib/AltosOrient.java b/altoslib/AltosOrient.java index d916a0fb..5fcbe28d 100644 --- a/altoslib/AltosOrient.java +++ b/altoslib/AltosOrient.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosOrient extends AltosUnits { diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index 5137fef8..1bff7682 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 484cb644..d299f27b 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index 2eb29702..461b5c80 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.File; diff --git a/altoslib/AltosProgrammer.java b/altoslib/AltosProgrammer.java index 750e1f02..c96f04ca 100644 --- a/altoslib/AltosProgrammer.java +++ b/altoslib/AltosProgrammer.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index a1414123..9e47bc80 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.*; import java.text.*; diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 4cf642ca..ac7df414 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index 506c3961..10df11af 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index 051aa766..502c6d65 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosSensorEMini.java b/altoslib/AltosSensorEMini.java index 5f43b3a9..ee0238f9 100644 --- a/altoslib/AltosSensorEMini.java +++ b/altoslib/AltosSensorEMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMM.java b/altoslib/AltosSensorMM.java index 0c23d671..e34e71b7 100644 --- a/altoslib/AltosSensorMM.java +++ b/altoslib/AltosSensorMM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMega.java b/altoslib/AltosSensorMega.java index c52f688d..02f3a256 100644 --- a/altoslib/AltosSensorMega.java +++ b/altoslib/AltosSensorMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMetrum.java b/altoslib/AltosSensorMetrum.java index bb794a1e..e5421ef5 100644 --- a/altoslib/AltosSensorMetrum.java +++ b/altoslib/AltosSensorMetrum.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index a5129783..2d60d8cf 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java index bb60a794..b9eeca0c 100644 --- a/altoslib/AltosSensorTMini.java +++ b/altoslib/AltosSensorTMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java index d93229dd..9134f5f4 100644 --- a/altoslib/AltosSpeed.java +++ b/altoslib/AltosSpeed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosSpeed extends AltosUnits { diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 4dbd751b..71263151 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -19,7 +19,7 @@ * Track flight state from telemetry or eeprom data stream */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosState implements Cloneable { diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java index 7ea3041b..be812095 100644 --- a/altoslib/AltosStateIterable.java +++ b/altoslib/AltosStateIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosStateUpdate.java b/altoslib/AltosStateUpdate.java index 4614c67a..ac4e963e 100644 --- a/altoslib/AltosStateUpdate.java +++ b/altoslib/AltosStateUpdate.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosStateUpdate { public void update_state(AltosState state) throws InterruptedException; diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 1c4ce7bc..62948378 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; diff --git a/altoslib/AltosTelemetryConfiguration.java b/altoslib/AltosTelemetryConfiguration.java index 67a43748..d1341b9e 100644 --- a/altoslib/AltosTelemetryConfiguration.java +++ b/altoslib/AltosTelemetryConfiguration.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryConfiguration extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryFile.java b/altoslib/AltosTelemetryFile.java index f6643134..3d3fa407 100644 --- a/altoslib/AltosTelemetryFile.java +++ b/altoslib/AltosTelemetryFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryIterable.java b/altoslib/AltosTelemetryIterable.java index 002f53b4..cba97ddc 100644 --- a/altoslib/AltosTelemetryIterable.java +++ b/altoslib/AltosTelemetryIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryLegacy.java b/altoslib/AltosTelemetryLegacy.java index da9296e4..3367ece7 100644 --- a/altoslib/AltosTelemetryLegacy.java +++ b/altoslib/AltosTelemetryLegacy.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; diff --git a/altoslib/AltosTelemetryLocation.java b/altoslib/AltosTelemetryLocation.java index 8dcda9e1..8368188f 100644 --- a/altoslib/AltosTelemetryLocation.java +++ b/altoslib/AltosTelemetryLocation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryLocation extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMap.java b/altoslib/AltosTelemetryMap.java index 37b2527b..8d0de355 100644 --- a/altoslib/AltosTelemetryMap.java +++ b/altoslib/AltosTelemetryMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.util.HashMap; diff --git a/altoslib/AltosTelemetryMegaData.java b/altoslib/AltosTelemetryMegaData.java index ffd82546..fac5695f 100644 --- a/altoslib/AltosTelemetryMegaData.java +++ b/altoslib/AltosTelemetryMegaData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMegaData extends AltosTelemetryStandard { int state; diff --git a/altoslib/AltosTelemetryMegaSensor.java b/altoslib/AltosTelemetryMegaSensor.java index d9fd7fde..9e73bc4e 100644 --- a/altoslib/AltosTelemetryMegaSensor.java +++ b/altoslib/AltosTelemetryMegaSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMegaSensor extends AltosTelemetryStandard { int accel; diff --git a/altoslib/AltosTelemetryMetrumData.java b/altoslib/AltosTelemetryMetrumData.java index b8f7e9ea..96617306 100644 --- a/altoslib/AltosTelemetryMetrumData.java +++ b/altoslib/AltosTelemetryMetrumData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMetrumData extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMetrumSensor.java b/altoslib/AltosTelemetryMetrumSensor.java index 232468bb..e7055404 100644 --- a/altoslib/AltosTelemetryMetrumSensor.java +++ b/altoslib/AltosTelemetryMetrumSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMini.java b/altoslib/AltosTelemetryMini.java index e0a493dc..fbfaff8e 100644 --- a/altoslib/AltosTelemetryMini.java +++ b/altoslib/AltosTelemetryMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMini extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryRaw.java b/altoslib/AltosTelemetryRaw.java index 91cfbb18..0dca62aa 100644 --- a/altoslib/AltosTelemetryRaw.java +++ b/altoslib/AltosTelemetryRaw.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryRaw extends AltosTelemetryStandard { public AltosTelemetryRaw(int[] bytes) { diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index 5e283587..3dff661a 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.io.*; diff --git a/altoslib/AltosTelemetrySatellite.java b/altoslib/AltosTelemetrySatellite.java index 24777b28..d611e88c 100644 --- a/altoslib/AltosTelemetrySatellite.java +++ b/altoslib/AltosTelemetrySatellite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetrySatellite extends AltosTelemetryStandard { int channels; diff --git a/altoslib/AltosTelemetrySensor.java b/altoslib/AltosTelemetrySensor.java index d6389865..ad4d9283 100644 --- a/altoslib/AltosTelemetrySensor.java +++ b/altoslib/AltosTelemetrySensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetrySensor extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryStandard.java b/altoslib/AltosTelemetryStandard.java index c9531fcb..23ae9d21 100644 --- a/altoslib/AltosTelemetryStandard.java +++ b/altoslib/AltosTelemetryStandard.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public abstract class AltosTelemetryStandard extends AltosTelemetry { int[] bytes; diff --git a/altoslib/AltosTemperature.java b/altoslib/AltosTemperature.java index 36e26564..5fa71b86 100644 --- a/altoslib/AltosTemperature.java +++ b/altoslib/AltosTemperature.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTemperature extends AltosUnits { diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index 82f102e4..d29cfae7 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public abstract class AltosUnits { diff --git a/altoslib/AltosUnitsListener.java b/altoslib/AltosUnitsListener.java index e9b29f9a..ca6faafd 100644 --- a/altoslib/AltosUnitsListener.java +++ b/altoslib/AltosUnitsListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosUnitsListener { public void units_changed(boolean imperial_units); diff --git a/altoslib/AltosWriter.java b/altoslib/AltosWriter.java index 0b0daebd..c3479a93 100644 --- a/altoslib/AltosWriter.java +++ b/altoslib/AltosWriter.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosWriter { diff --git a/altosui/Altos.java b/altosui/Altos.java index 4b171fa7..28038ad6 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class Altos extends AltosUILib { diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 81b08d2c..f6ccbf0c 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosAscent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java index 727a9f66..e920803a 100644 --- a/altosui/AltosBTDevice.java +++ b/altosui/AltosBTDevice.java @@ -17,7 +17,7 @@ package altosui; import libaltosJNI.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosBTDevice extends altos_bt_device implements AltosDevice { diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java index 968d72d5..3abbbe08 100644 --- a/altosui/AltosBTKnown.java +++ b/altosui/AltosBTKnown.java @@ -17,8 +17,8 @@ package altosui; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosBTKnown implements Iterable { LinkedList devices = new LinkedList(); diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java index ad1c28b6..e6e7efd4 100644 --- a/altosui/AltosBTManage.java +++ b/altosui/AltosBTManage.java @@ -23,7 +23,7 @@ import javax.swing.*; import javax.swing.plaf.basic.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosBTManage extends AltosUIDialog implements ActionListener, Iterable { LinkedBlockingQueue found_devices; diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index 95a8aeea..a0fceee5 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosCSVUI extends AltosUIDialog diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index b90240fb..42413a57 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosCompanionInfo extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index e1805fc1..3128114f 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -22,8 +22,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.text.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfig implements ActionListener { diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index 663782f0..c7181e14 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class AltosEditFreqUI extends AltosUIDialog implements ActionListener { Frame frame; diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index cd42a3b0..9df2d87d 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigPyroUI extends AltosUIDialog diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index ad9ebbfa..bfbd2c77 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -21,8 +21,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigTD implements ActionListener { diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index 55d6aed9..22b3384d 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigTDUI extends AltosUIDialog diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 7f4e1eb0..3ec3cdb0 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigUI extends AltosUIDialog diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index 80876959..e61a4a5b 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -22,7 +22,7 @@ import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigureUI extends AltosUIConfigure diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index a9344a01..43726a44 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -20,8 +20,8 @@ package altosui; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosDataChooser extends JFileChooser { JFrame frame; diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index cd993a75..5cb693fe 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosDescent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosDeviceUIDialog.java b/altosui/AltosDeviceUIDialog.java index ca34357e..307c77f8 100644 --- a/altosui/AltosDeviceUIDialog.java +++ b/altosui/AltosDeviceUIDialog.java @@ -20,7 +20,7 @@ package altosui; import javax.swing.*; import java.awt.*; import java.awt.event.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosDeviceUIDialog extends AltosDeviceDialog { diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index b2d2e291..b6ac7edb 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -21,7 +21,7 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosEepromDelete implements Runnable { AltosEepromList flights; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index e3635571..aa43ab9e 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -21,8 +21,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosEepromManage implements ActionListener { diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java index 50921da1..ce1c1625 100644 --- a/altosui/AltosEepromMonitor.java +++ b/altosui/AltosEepromMonitor.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosEepromMonitor extends AltosUIDialog { diff --git a/altosui/AltosEepromMonitorUI.java b/altosui/AltosEepromMonitorUI.java index c2e925a2..c1c1eb25 100644 --- a/altosui/AltosEepromMonitorUI.java +++ b/altosui/AltosEepromMonitorUI.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altosuilib_1.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altosuilib_2.*; +import org.altusmetrum.altoslib_4.*; public class AltosEepromMonitorUI extends AltosUIDialog implements AltosEepromMonitor { JFrame owner; diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java index b7cdbb72..66a197c9 100644 --- a/altosui/AltosEepromSelect.java +++ b/altosui/AltosEepromSelect.java @@ -21,8 +21,8 @@ import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class AltosEepromItem implements ActionListener { AltosEepromLog log; diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index ff9cb95d..d8c70a06 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -23,8 +23,8 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosFlashUI extends AltosUIDialog diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index da71154e..e7a8e728 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosFlightStatsTable extends JComponent { GridBagLayout layout; diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index b467bbde..73b84f8d 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java index e372d401..b33f40a4 100644 --- a/altosui/AltosFlightStatusTableModel.java +++ b/altosui/AltosFlightStatusTableModel.java @@ -27,7 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosFlightStatusTableModel extends AbstractTableModel { private String[] columnNames = { diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java index 93399a13..0daec04e 100644 --- a/altosui/AltosFlightStatusUpdate.java +++ b/altosui/AltosFlightStatusUpdate.java @@ -18,7 +18,7 @@ package altosui; import java.awt.event.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosFlightStatusUpdate implements ActionListener { diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index b31de12c..2bd60d6c 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener { AltosVoice voice; diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java index d5c00247..ba3875c6 100644 --- a/altosui/AltosGraph.java +++ b/altosui/AltosGraph.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java index a0b0925c..06a9b62d 100644 --- a/altosui/AltosGraphDataPoint.java +++ b/altosui/AltosGraphDataPoint.java @@ -17,8 +17,8 @@ package altosui; -import org.altusmetrum.altosuilib_1.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altosuilib_2.*; +import org.altusmetrum.altoslib_4.*; public class AltosGraphDataPoint implements AltosUIDataPoint { diff --git a/altosui/AltosGraphDataSet.java b/altosui/AltosGraphDataSet.java index d2773a3f..a90c2563 100644 --- a/altosui/AltosGraphDataSet.java +++ b/altosui/AltosGraphDataSet.java @@ -20,8 +20,8 @@ package altosui; import java.lang.*; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class AltosGraphIterator implements Iterator { AltosGraphDataSet dataSet; diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 92b9b94a..33e12130 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -9,8 +9,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 7ca935b6..62b50568 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -24,8 +24,8 @@ import javax.swing.event.*; import java.io.*; import java.util.concurrent.*; import java.util.Arrays; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener, DocumentListener { AltosDevice device; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 3028bb9c..c251bbe2 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -24,8 +24,8 @@ import java.io.*; import java.text.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosIgniteUI extends AltosUIDialog diff --git a/altosui/AltosIgnitor.java b/altosui/AltosIgnitor.java index fcab7427..7f79f42b 100644 --- a/altosui/AltosIgnitor.java +++ b/altosui/AltosIgnitor.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosIgnitor extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 3242d652..125fa94c 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import javax.swing.*; import javax.swing.table.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosInfoTable extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 25d768ad..707d8fcc 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -21,7 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener { GridBagLayout layout; diff --git a/altosui/AltosLaunch.java b/altosui/AltosLaunch.java index 04948ee6..9ac1e44c 100644 --- a/altosui/AltosLaunch.java +++ b/altosui/AltosLaunch.java @@ -20,7 +20,7 @@ package altosui; import java.io.*; import java.util.concurrent.*; import java.awt.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosLaunch { AltosDevice device; diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java index 4d9fbda5..cc082542 100644 --- a/altosui/AltosLaunchUI.java +++ b/altosui/AltosLaunchUI.java @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; class FireButton extends JButton { protected void processMouseEvent(MouseEvent e) { diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 2844b32c..a6ac70db 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosPad extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java index 89994679..d2fe54d9 100644 --- a/altosui/AltosRomconfigUI.java +++ b/altosui/AltosRomconfigUI.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosRomconfigUI extends AltosUIDialog diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 5cc74a77..1f1f59ad 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -25,8 +25,8 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class AltosScanResult { String callsign; diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index 2c5d2dfd..9b2180ba 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -25,8 +25,8 @@ import java.io.*; import java.util.*; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; import libaltosJNI.*; diff --git a/altosui/AltosSerialInUseException.java b/altosui/AltosSerialInUseException.java index b45d9157..318155c8 100644 --- a/altosui/AltosSerialInUseException.java +++ b/altosui/AltosSerialInUseException.java @@ -16,7 +16,7 @@ */ package altosui; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosSerialInUseException extends Exception { public AltosDevice device; diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index a1bc83bf..9df02ec9 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -22,8 +22,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosUI extends AltosUIFrame { public AltosVoice voice = new AltosVoice(); diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java index f85735e8..28047086 100644 --- a/altosui/AltosUIPreferencesBackend.java +++ b/altosui/AltosUIPreferencesBackend.java @@ -19,7 +19,7 @@ package altosui; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosuilib/AltosDevice.java b/altosuilib/AltosDevice.java index 2461df1b..251ae994 100644 --- a/altosuilib/AltosDevice.java +++ b/altosuilib/AltosDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import libaltosJNI.*; diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index 7fb23e13..0bedea97 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import javax.swing.*; import java.awt.*; diff --git a/altosuilib/AltosFontListener.java b/altosuilib/AltosFontListener.java index da903352..a98cc131 100644 --- a/altosuilib/AltosFontListener.java +++ b/altosuilib/AltosFontListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosFontListener { void font_size_changed(int font_size); diff --git a/altosuilib/AltosPositionListener.java b/altosuilib/AltosPositionListener.java index e75d2de5..34cf1650 100644 --- a/altosuilib/AltosPositionListener.java +++ b/altosuilib/AltosPositionListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosPositionListener { public void position_changed(int position); diff --git a/altosuilib/AltosUIAxis.java b/altosuilib/AltosUIAxis.java index 7bc2def9..74561673 100644 --- a/altosuilib/AltosUIAxis.java +++ b/altosuilib/AltosUIAxis.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIConfigure.java b/altosuilib/AltosUIConfigure.java index 153eb8ee..ae7626de 100644 --- a/altosuilib/AltosUIConfigure.java +++ b/altosuilib/AltosUIConfigure.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIDataMissing.java b/altosuilib/AltosUIDataMissing.java index c7b01859..353ff30f 100644 --- a/altosuilib/AltosUIDataMissing.java +++ b/altosuilib/AltosUIDataMissing.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public class AltosUIDataMissing extends Exception { public int id; diff --git a/altosuilib/AltosUIDataPoint.java b/altosuilib/AltosUIDataPoint.java index d3020410..3f16500e 100644 --- a/altosuilib/AltosUIDataPoint.java +++ b/altosuilib/AltosUIDataPoint.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosUIDataPoint { public abstract double x() throws AltosUIDataMissing; diff --git a/altosuilib/AltosUIDataSet.java b/altosuilib/AltosUIDataSet.java index 6f23ef9a..ee70a3fd 100644 --- a/altosuilib/AltosUIDataSet.java +++ b/altosuilib/AltosUIDataSet.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosUIDataSet { public abstract String name(); diff --git a/altosuilib/AltosUIDialog.java b/altosuilib/AltosUIDialog.java index e1e699a7..dc737414 100644 --- a/altosuilib/AltosUIDialog.java +++ b/altosuilib/AltosUIDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java index 40b5f087..8d42c09b 100644 --- a/altosuilib/AltosUIEnable.java +++ b/altosuilib/AltosUIEnable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIFrame.java b/altosuilib/AltosUIFrame.java index 3dc2a0ad..ce86ad83 100644 --- a/altosuilib/AltosUIFrame.java +++ b/altosuilib/AltosUIFrame.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index 21e13cf6..909c471b 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIGrapher.java b/altosuilib/AltosUIGrapher.java index 54f8d5a9..724fac18 100644 --- a/altosuilib/AltosUIGrapher.java +++ b/altosuilib/AltosUIGrapher.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUILib.java b/altosuilib/AltosUILib.java index 76782e2e..b51c5963 100644 --- a/altosuilib/AltosUILib.java +++ b/altosuilib/AltosUILib.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosUILib extends AltosLib { diff --git a/altosuilib/AltosUIListener.java b/altosuilib/AltosUIListener.java index 450dc0bf..75a0ad94 100644 --- a/altosuilib/AltosUIListener.java +++ b/altosuilib/AltosUIListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosUIListener { public void ui_changed(String look_and_feel); diff --git a/altosuilib/AltosUIMarker.java b/altosuilib/AltosUIMarker.java index efd27921..cd6fa589 100644 --- a/altosuilib/AltosUIMarker.java +++ b/altosuilib/AltosUIMarker.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 4c995f80..7a582a7d 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.*; import java.awt.Component; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosUIPreferences extends AltosPreferences { diff --git a/altosuilib/AltosUIPreferencesBackend.java b/altosuilib/AltosUIPreferencesBackend.java index d6575717..da29253d 100644 --- a/altosuilib/AltosUIPreferencesBackend.java +++ b/altosuilib/AltosUIPreferencesBackend.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java index 10ea1614..b0632d18 100644 --- a/altosuilib/AltosUISeries.java +++ b/altosuilib/AltosUISeries.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIVersion.java.in b/altosuilib/AltosUIVersion.java.in index 169cca1b..3f629560 100644 --- a/altosuilib/AltosUIVersion.java.in +++ b/altosuilib/AltosUIVersion.java.in @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public class AltosUIVersion { public final static String version = "@VERSION@"; diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index 4f329840..b70b5e83 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.util.*; import libaltosJNI.*; diff --git a/configure.ac b/configure.ac index 01867e9f..d2d87754 100644 --- a/configure.ac +++ b/configure.ac @@ -29,8 +29,8 @@ AC_SUBST(VERSION_DASH) dnl ========================================================================== dnl Java library versions -ALTOSUILIB_VERSION=1 -ALTOSLIB_VERSION=3 +ALTOSUILIB_VERSION=2 +ALTOSLIB_VERSION=4 AC_SUBST(ALTOSLIB_VERSION) AC_DEFINE(ALTOSLIB_VERSION,$ALTOSLIB_VERSION,[Version of the AltosLib package]) diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index e786ff1e..ca211f16 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import java.lang.*; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class MicroIterator implements Iterator { int i; diff --git a/micropeak/MicroDataPoint.java b/micropeak/MicroDataPoint.java index 61faf794..5a5e8c37 100644 --- a/micropeak/MicroDataPoint.java +++ b/micropeak/MicroDataPoint.java @@ -17,7 +17,7 @@ package org.altusmetrum.micropeak; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroDataPoint implements AltosUIDataPoint { public double time; diff --git a/micropeak/MicroDeviceDialog.java b/micropeak/MicroDeviceDialog.java index 533605d6..305421a7 100644 --- a/micropeak/MicroDeviceDialog.java +++ b/micropeak/MicroDeviceDialog.java @@ -21,7 +21,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroDeviceDialog extends AltosDeviceDialog { diff --git a/micropeak/MicroDownload.java b/micropeak/MicroDownload.java index 7d2e9eb4..1c70e1d1 100644 --- a/micropeak/MicroDownload.java +++ b/micropeak/MicroDownload.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroDownload extends AltosUIDialog implements Runnable, ActionListener, MicroSerialLog, WindowListener { MicroPeak owner; diff --git a/micropeak/MicroExport.java b/micropeak/MicroExport.java index c170f544..87d5499b 100644 --- a/micropeak/MicroExport.java +++ b/micropeak/MicroExport.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroExport extends JFileChooser { diff --git a/micropeak/MicroFile.java b/micropeak/MicroFile.java index b6a9d401..019346ae 100644 --- a/micropeak/MicroFile.java +++ b/micropeak/MicroFile.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroFile { diff --git a/micropeak/MicroFileChooser.java b/micropeak/MicroFileChooser.java index 595d1ff7..00b6690a 100644 --- a/micropeak/MicroFileChooser.java +++ b/micropeak/MicroFileChooser.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroFileChooser extends JFileChooser { JFrame frame; diff --git a/micropeak/MicroFrame.java b/micropeak/MicroFrame.java index ef8b24cc..5bfe5bf7 100644 --- a/micropeak/MicroFrame.java +++ b/micropeak/MicroFrame.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroFrame extends AltosUIFrame { static String[] micro_icon_names = { diff --git a/micropeak/MicroGraph.java b/micropeak/MicroGraph.java index 5960fe4d..f9968919 100644 --- a/micropeak/MicroGraph.java +++ b/micropeak/MicroGraph.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/micropeak/MicroPeak.java b/micropeak/MicroPeak.java index 78bc857e..19e91660 100644 --- a/micropeak/MicroPeak.java +++ b/micropeak/MicroPeak.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroPeak extends MicroFrame implements ActionListener, ItemListener { diff --git a/micropeak/MicroRaw.java b/micropeak/MicroRaw.java index d64da387..26d62012 100644 --- a/micropeak/MicroRaw.java +++ b/micropeak/MicroRaw.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import java.awt.*; import java.io.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroRaw extends JTextArea { diff --git a/micropeak/MicroSave.java b/micropeak/MicroSave.java index 0addfa88..7c5d6abe 100644 --- a/micropeak/MicroSave.java +++ b/micropeak/MicroSave.java @@ -24,8 +24,8 @@ import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroSave extends JFileChooser { diff --git a/micropeak/MicroSerial.java b/micropeak/MicroSerial.java index 39f421ec..37b68636 100644 --- a/micropeak/MicroSerial.java +++ b/micropeak/MicroSerial.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.util.*; import java.io.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroSerial extends InputStream { SWIGTYPE_p_altos_file file; diff --git a/micropeak/MicroSerialLog.java b/micropeak/MicroSerialLog.java index 0a5a0b91..7300f06d 100644 --- a/micropeak/MicroSerialLog.java +++ b/micropeak/MicroSerialLog.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.util.*; import java.io.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public interface MicroSerialLog { diff --git a/micropeak/MicroStats.java b/micropeak/MicroStats.java index 765525b0..45c9f225 100644 --- a/micropeak/MicroStats.java +++ b/micropeak/MicroStats.java @@ -18,8 +18,8 @@ package org.altusmetrum.micropeak; import java.io.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroStats { double coast_height; diff --git a/micropeak/MicroStatsTable.java b/micropeak/MicroStatsTable.java index ea1609ac..268a7ff0 100644 --- a/micropeak/MicroStatsTable.java +++ b/micropeak/MicroStatsTable.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroStatsTable extends JComponent implements AltosFontListener { GridBagLayout layout; diff --git a/micropeak/MicroUSB.java b/micropeak/MicroUSB.java index 3bd61470..437fa0bc 100644 --- a/micropeak/MicroUSB.java +++ b/micropeak/MicroUSB.java @@ -19,7 +19,7 @@ package org.altusmetrum.micropeak; import java.util.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroUSB extends altos_device implements AltosDevice { -- cgit v1.2.3 From f80075be4ebb9c5fe00c24b8c7638fad23267424 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 29 May 2014 14:03:58 -0700 Subject: java: Refactor AltosFlightDisplay units and font update handling Make AltosFlightDisplay explicitly implement AltosFontListener and AltosUnitsListener interfaces to make everyone use the same API. Then, actually go implement units listeners so that changing units updates all of the active displays immediately Signed-off-by: Keith Packard --- altosui/AltosAscent.java | 116 ++++++++++++++++++--------- altosui/AltosCompanionInfo.java | 7 +- altosui/AltosDescent.java | 86 +++++++++++++------- altosui/AltosFlightStatus.java | 5 +- altosui/AltosFlightUI.java | 37 +++++---- altosui/AltosIdleMonitorUI.java | 17 ++-- altosui/AltosIgnitor.java | 14 +++- altosui/AltosLanded.java | 67 +++++++++++----- altosui/AltosPad.java | 71 ++++++++++++----- altosuilib/AltosFlightDisplay.java | 4 +- altosuilib/AltosInfoTable.java | 5 +- altosuilib/AltosSiteMap.java | 6 +- telegps/TeleGPS.java | 16 ++-- telegps/TeleGPSInfo.java | 157 +++++++++++++++++++++++++++---------- telegps/TeleGPSStatus.java | 17 ++-- 15 files changed, 431 insertions(+), 194 deletions(-) (limited to 'altosui/AltosFlightUI.java') diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index f6ccbf0c..fb05fe11 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -26,10 +26,12 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; JLabel cur, max; - public class AscentStatus { + public class AscentStatus implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; AltosLights lights; + double v; + AltosUnits units; void show() { value.setVisible(true); @@ -50,7 +52,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { value.setText(s); } - void show(AltosUnits units, double v) { + void show(double v) { + this.v = v; show(units.show(8, v)); } @@ -63,12 +66,18 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { lights.set(false); } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); } - public AscentStatus (GridBagLayout layout, int y, String text) { + public void units_changed(boolean imperial_units) { + if (units != null) + show(v); + } + + public AscentStatus (GridBagLayout layout, int y, AltosUnits units, String text) { + this.units = units; GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -105,10 +114,13 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { } } - public class AscentValue { + public abstract class AscentValue implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; - void show(AltosState state, AltosListenerState listener_state) {} + double v; + AltosUnits units; + + abstract void show(AltosState state, AltosListenerState listener_state); void reset() { value.setText(""); @@ -124,7 +136,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { value.setText(s); } - void show(AltosUnits units, double v) { + void show(double v) { + this.v = v; show(units.show(8, v)); } @@ -136,12 +149,18 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { label.setVisible(false); value.setVisible(false); } - void set_font() { + + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); } - public AscentValue (GridBagLayout layout, int y, String text) { + public void units_changed(boolean imperial_units) { + if (units != null) + show(v); + } + + public AscentValue (GridBagLayout layout, int y, AltosUnits units, String text) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -167,13 +186,19 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { layout.setConstraints(value, c); add(value); } + + public AscentValue (GridBagLayout layout, int y, String text) { + this(layout, y, null, text); + } } - public class AscentValueHold { + public class AscentValueHold implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; JTextField max_value; double max; + AltosUnits units; + double v; void show(AltosState state, AltosListenerState listener_state) {} @@ -183,23 +208,29 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { max = AltosLib.MISSING; } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); max_value.setFont(Altos.value_font); } - void show(AltosUnits units, double v) { + public void units_changed(boolean imperial_units) { + show(v); + } + + void show(double v) { + this.v = v; if (v == AltosLib.MISSING) { value.setText("Missing"); - max_value.setText("Missing"); } else { value.setText(units.show(8, v)); - if (v > max || max == AltosLib.MISSING) { - max_value.setText(units.show(8, v)); + if (v > max || max == AltosLib.MISSING) max = v; - } } + if (max == AltosLib.MISSING) + max_value.setText("Missing"); + else + max_value.setText(units.show(8, v)); } void hide() { @@ -208,7 +239,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { max_value.setVisible(false); } - public AscentValueHold (GridBagLayout layout, int y, String text) { + public AscentValueHold (GridBagLayout layout, int y, AltosUnits units, String text) { + this.units = units; GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -245,13 +277,12 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { } } - class Height extends AscentValueHold { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.height, state.height()); + show(state.height()); } public Height (GridBagLayout layout, int y) { - super (layout, y, "Height"); + super (layout, y, AltosConvert.height, "Height"); } } @@ -259,10 +290,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { class Speed extends AscentValueHold { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.speed, state.speed()); + show(state.speed()); } public Speed (GridBagLayout layout, int y) { - super (layout, y, "Speed"); + super (layout, y, AltosConvert.speed, "Speed"); } } @@ -270,10 +301,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { class Accel extends AscentValueHold { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.accel, state.acceleration()); + show(state.acceleration()); } public Accel (GridBagLayout layout, int y) { - super (layout, y, "Acceleration"); + super (layout, y, AltosConvert.accel, "Acceleration"); } } @@ -281,10 +312,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { class Orient extends AscentValueHold { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.orient, state.orient()); + show(state.orient()); } public Orient (GridBagLayout layout, int y) { - super (layout, y, "Tilt Angle"); + super (layout, y, AltosConvert.orient, "Tilt Angle"); } } @@ -307,7 +338,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good); } public Apogee (GridBagLayout layout, int y) { - super(layout, y, "Apogee Igniter Voltage"); + super(layout, y, null, "Apogee Igniter Voltage"); } } @@ -319,7 +350,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { lights.set(state.main_voltage >= AltosLib.ao_igniter_good); } public Main (GridBagLayout layout, int y) { - super(layout, y, "Main Igniter Voltage"); + super(layout, y, null, "Main Igniter Voltage"); } } @@ -364,17 +395,28 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { orient.reset(); } - public void set_font() { + public void font_size_changed(int font_size) { cur.setFont(Altos.label_font); max.setFont(Altos.label_font); - lat.set_font(); - lon.set_font(); - main.set_font(); - apogee.set_font(); - height.set_font(); - speed.set_font(); - accel.set_font(); - orient.set_font(); + lat.font_size_changed(font_size); + lon.font_size_changed(font_size); + main.font_size_changed(font_size); + apogee.font_size_changed(font_size); + height.font_size_changed(font_size); + speed.font_size_changed(font_size); + accel.font_size_changed(font_size); + orient.font_size_changed(font_size); + } + + public void units_changed(boolean imperial_units) { + lat.units_changed(imperial_units); + lon.units_changed(imperial_units); + main.units_changed(imperial_units); + apogee.units_changed(imperial_units); + height.units_changed(imperial_units); + speed.units_changed(imperial_units); + accel.units_changed(imperial_units); + orient.units_changed(imperial_units); } public void show(AltosState state, AltosListenerState listener_state) { diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index f8d033a8..514ce611 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -33,18 +33,21 @@ public class AltosCompanionInfo extends JTable implements AltosFlightDisplay { return (infoValueMetrics.getHeight() + infoValueMetrics.getLeading()) * 18 / 10; } - public void set_font() { + public void font_size_changed(int font_size) { setFont(Altos.table_value_font); setRowHeight(desired_row_height()); doLayout(); } + public void units_changed(boolean imperial_units) { + } + public AltosCompanionInfo() { super(new AltosFlightInfoTableModel(info_rows, info_columns)); model = (AltosFlightInfoTableModel) getModel(); setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS); setShowGrid(true); - set_font(); + font_size_changed(AltosUIPreferences.font_size()); } public Dimension getPreferredScrollableViewportSize() { diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 5cb693fe..e6710524 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -25,7 +25,7 @@ import org.altusmetrum.altosuilib_2.*; public class AltosDescent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - public abstract class DescentStatus { + public abstract class DescentStatus implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; AltosLights lights; @@ -58,11 +58,14 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { lights.set(false); } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); } + public void units_changed(boolean imperial_units) { + } + public DescentStatus (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -101,9 +104,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { } } - public abstract class DescentValue { + public abstract class DescentValue implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; + AltosUnits units; + double v; void reset() { value.setText(""); @@ -126,7 +131,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { value.setText(v); } - void show(AltosUnits units, double v) { + void show(double v) { + this.v = v; show(units.show(8, v)); } @@ -134,12 +140,18 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { show(String.format(format, v)); } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); } - public DescentValue (GridBagLayout layout, int x, int y, String text) { + public void units_changed(boolean imperial_units) { + if (units != null) + show(v); + } + + public DescentValue (GridBagLayout layout, int x, int y, AltosUnits units, String text) { + this.units = units; GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -163,9 +175,13 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { c.weightx = 1; add(value, c); } + + public DescentValue (GridBagLayout layout, int x, int y, String text) { + this(layout, x, y, null, text); + } } - public abstract class DescentDualValue { + public abstract class DescentDualValue implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value1; JTextField value2; @@ -187,12 +203,15 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { value2.setVisible(false); } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value1.setFont(Altos.value_font); value2.setFont(Altos.value_font); } + public void units_changed(boolean imperial_units) { + } + abstract void show(AltosState state, AltosListenerState listener_state); void show(String v1, String v2) { @@ -246,10 +265,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { class Height extends DescentValue { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.height, state.height()); + show(state.height()); } public Height (GridBagLayout layout, int x, int y) { - super (layout, x, y, "Height"); + super (layout, x, y, AltosConvert.height, "Height"); } } @@ -257,10 +276,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { class Speed extends DescentValue { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.speed, state.speed()); + show(state.speed()); } public Speed (GridBagLayout layout, int x, int y) { - super (layout, x, y, "Speed"); + super (layout, x, y, AltosConvert.speed, "Speed"); } } @@ -308,13 +327,13 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { class Distance extends DescentValue { void show(AltosState state, AltosListenerState listener_state) { if (state.from_pad != null) - show(AltosConvert.distance, state.from_pad.distance); + show(state.from_pad.distance); else show("???"); } public Distance (GridBagLayout layout, int x, int y) { - super(layout, x, y, "Ground Distance"); + super(layout, x, y, AltosConvert.distance, "Ground Distance"); } } @@ -364,10 +383,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { class Range extends DescentValue { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.distance, state.range); + show(state.range); } public Range (GridBagLayout layout, int x, int y) { - super (layout, x, y, "Range"); + super (layout, x, y, AltosConvert.distance, "Range"); } } @@ -397,17 +416,30 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { apogee.reset(); } - public void set_font() { - lat.set_font(); - lon.set_font(); - height.set_font(); - speed.set_font(); - bearing.set_font(); - range.set_font(); - distance.set_font(); - elevation.set_font(); - main.set_font(); - apogee.set_font(); + public void font_size_changed(int font_size) { + lat.font_size_changed(font_size); + lon.font_size_changed(font_size); + height.font_size_changed(font_size); + speed.font_size_changed(font_size); + bearing.font_size_changed(font_size); + range.font_size_changed(font_size); + distance.font_size_changed(font_size); + elevation.font_size_changed(font_size); + main.font_size_changed(font_size); + apogee.font_size_changed(font_size); + } + + public void units_changed(boolean imperial_units) { + lat.units_changed(imperial_units); + lon.units_changed(imperial_units); + height.units_changed(imperial_units); + speed.units_changed(imperial_units); + bearing.units_changed(imperial_units); + range.units_changed(imperial_units); + distance.units_changed(imperial_units); + elevation.units_changed(imperial_units); + main.units_changed(imperial_units); + apogee.units_changed(imperial_units); } public void show(AltosState state, AltosListenerState listener_state) { diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index 73b84f8d..459b0495 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -159,7 +159,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay last_packet.reset(); } - public void set_font () { + public void font_size_changed(int font_size) { call.set_font(); serial.set_font(); flight.set_font(); @@ -168,6 +168,9 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay last_packet.set_font(); } + public void units_changed(boolean imperial_units) { + } + public void show (AltosState state, AltosListenerState listener_state) { call.show(state, listener_state); serial.show(state, listener_state); diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 2bd60d6c..baa18686 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -24,7 +24,7 @@ import java.util.concurrent.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener { +public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { AltosVoice voice; AltosFlightReader reader; AltosDisplayThread thread; @@ -83,22 +83,29 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A sitemap.reset(); } - public void set_font() { - pad.set_font(); - ignitor.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(); + pad.font_size_changed(font_size); + ignitor.font_size_changed(font_size); + ascent.font_size_changed(font_size); + descent.font_size_changed(font_size); + landed.font_size_changed(font_size); + flightStatus.font_size_changed(font_size); + flightInfo.font_size_changed(font_size); + sitemap.font_size_changed(font_size); + companion.font_size_changed(font_size); } + public void units_changed(boolean imperial_units) { + pad.units_changed(imperial_units); + ignitor.units_changed(imperial_units); + ascent.units_changed(imperial_units); + descent.units_changed(imperial_units); + landed.units_changed(imperial_units); + flightStatus.units_changed(imperial_units); + flightInfo.units_changed(imperial_units); + sitemap.units_changed(imperial_units); + companion.units_changed(imperial_units); + } AltosFlightStatusUpdate status_update; @@ -318,6 +325,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); AltosUIPreferences.register_font_listener(this); + AltosPreferences.register_units_listener(this); addWindowListener(new WindowAdapter() { @Override @@ -326,6 +334,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A setVisible(false); dispose(); AltosUIPreferences.unregister_font_listener(AltosFlightUI.this); + AltosPreferences.unregister_units_listener(AltosFlightUI.this); if (exit_on_close) System.exit(0); } diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index b5652df3..042111ec 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -27,7 +27,7 @@ import java.util.Arrays; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -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; @@ -56,13 +56,14 @@ 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; @@ -235,8 +236,8 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl disconnect(); } catch (Exception ex) { System.out.printf("Exception %s\n", ex.toString()); - for (StackTraceElement e : ex.getStackTrace()) - System.out.printf("%s\n", e.toString()); + for (StackTraceElement el : ex.getStackTrace()) + System.out.printf("%s\n", el.toString()); } setVisible(false); dispose(); diff --git a/altosui/AltosIgnitor.java b/altosui/AltosIgnitor.java index 7f79f42b..27917b30 100644 --- a/altosui/AltosIgnitor.java +++ b/altosui/AltosIgnitor.java @@ -25,7 +25,7 @@ import org.altusmetrum.altosuilib_2.*; public class AltosIgnitor extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - public class LaunchStatus { + public class LaunchStatus implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; AltosLights lights; @@ -66,11 +66,14 @@ public class AltosIgnitor extends JComponent implements AltosFlightDisplay { hide(); } - public void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); } + public void units_changed(boolean imperial_units) { + } + public void set_label(String text) { label.setText(text); } @@ -142,11 +145,14 @@ public class AltosIgnitor extends JComponent implements AltosFlightDisplay { ignitors[i].reset(); } - public void set_font() { + public void font_size_changed(int font_size) { if (ignitors == null) return; for (int i = 0; i < ignitors.length; i++) - ignitors[i].set_font(); + ignitors[i].font_size_changed(font_size); + } + + public void units_changed(boolean imperial_units) { } public void show(AltosState state, AltosListenerState listener_state) { diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 707d8fcc..bb52fe2b 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -27,10 +27,13 @@ import org.altusmetrum.altosuilib_2.*; public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener { GridBagLayout layout; - public class LandedValue { + public abstract class LandedValue implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; - void show(AltosState state, AltosListenerState listener_state) {} + AltosUnits units; + double v; + + abstract void show(AltosState state, AltosListenerState listener_state); void reset() { value.setText(""); @@ -46,7 +49,8 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio value.setText(s); } - void show(AltosUnits units, double v) { + void show(double v) { + this.v = v; show(units.show(8, v)); } @@ -54,17 +58,24 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio show(String.format(format, v)); } - public void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); } + public void units_changed(boolean imperial_units) { + if (units != null) + show(v); + } + void hide() { label.setVisible(false); value.setVisible(false); } - public LandedValue (GridBagLayout layout, int y, String text) { + public LandedValue (GridBagLayout layout, int y, AltosUnits units, String text) { + this.units = units; + GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -89,6 +100,10 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio layout.setConstraints(value, c); add(value); } + + public LandedValue (GridBagLayout layout, int y, String text) { + this(layout, y, null, text); + } } String pos(double p, String pos, String neg) { @@ -151,12 +166,12 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio void show (AltosState state, AltosListenerState listener_state) { show(); if (state.from_pad != null) - show(AltosConvert.distance, state.from_pad.distance); + show(state.from_pad.distance); else show("???"); } public Distance (GridBagLayout layout, int y) { - super (layout, y, "Distance"); + super (layout, y, AltosConvert.distance, "Distance"); } } @@ -164,10 +179,10 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio class Height extends LandedValue { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.height, state.max_height()); + show(state.max_height()); } public Height (GridBagLayout layout, int y) { - super (layout, y, "Maximum Height"); + super (layout, y, AltosConvert.height, "Maximum Height"); } } @@ -175,10 +190,10 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio class Speed extends LandedValue { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.speed, state.max_speed()); + show(state.max_speed()); } public Speed (GridBagLayout layout, int y) { - super (layout, y, "Maximum Speed"); + super (layout, y, AltosConvert.speed, "Maximum Speed"); } } @@ -186,10 +201,10 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio class Accel extends LandedValue { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.accel, state.max_acceleration()); + show(state.max_acceleration()); } public Accel (GridBagLayout layout, int y) { - super (layout, y, "Maximum Acceleration"); + super (layout, y, AltosConvert.accel, "Maximum Acceleration"); } } @@ -205,14 +220,24 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio accel.reset(); } - public void set_font() { - lat.set_font(); - lon.set_font(); - bearing.set_font(); - distance.set_font(); - height.set_font(); - speed.set_font(); - accel.set_font(); + public void font_size_changed(int font_size) { + lat.font_size_changed(font_size); + lon.font_size_changed(font_size); + bearing.font_size_changed(font_size); + distance.font_size_changed(font_size); + height.font_size_changed(font_size); + speed.font_size_changed(font_size); + accel.font_size_changed(font_size); + } + + public void units_changed(boolean imperial_units) { + lat.units_changed(imperial_units); + lon.units_changed(imperial_units); + bearing.units_changed(imperial_units); + distance.units_changed(imperial_units); + height.units_changed(imperial_units); + speed.units_changed(imperial_units); + accel.units_changed(imperial_units); } public void show(AltosState state, AltosListenerState listener_state) { diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index a6ac70db..ce1f2ab7 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -25,7 +25,7 @@ import org.altusmetrum.altosuilib_2.*; public class AltosPad extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - public class LaunchStatus { + public class LaunchStatus implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; AltosLights lights; @@ -62,11 +62,14 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { lights.setVisible(false); } - public void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); } + public void units_changed(boolean imperial_units) { + } + public void set_label(String text) { label.setText(text); } @@ -107,10 +110,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } } - public class LaunchValue { + public abstract class LaunchValue implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; - void show(AltosState state, AltosListenerState listener_state) {} + AltosUnits units; + double v; + + abstract void show(AltosState state, AltosListenerState listener_state); void show() { label.setVisible(true); @@ -122,17 +128,23 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { value.setVisible(false); } - public void set_font() { + public void font_size_changed(int font_size) { label.setFont(Altos.label_font); value.setFont(Altos.value_font); } + public void units_changed(boolean imperial_units) { + if (units != null) + show(v); + } + void show(String s) { show(); value.setText(s); } - void show(AltosUnits units, double v) { + void show(double v) { + this.v = v; show(units.show(8, v)); } @@ -148,7 +160,9 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { value.setText(""); } - public LaunchValue (GridBagLayout layout, int y, String text) { + public LaunchValue (GridBagLayout layout, int y, AltosUnits units, String text) { + this.units = units; + GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.weighty = 1; @@ -173,6 +187,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { layout.setConstraints(value, c); add(value); } + + public LaunchValue (GridBagLayout layout, int y, String text) { + this(layout, y, null, text); + } } class Battery extends LaunchStatus { @@ -378,13 +396,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } } if (alt != AltosLib.MISSING) { - show("%4.0f m", state.gps.alt); + show(alt); set_label(label); } else hide(); } public PadAlt (GridBagLayout layout, int y) { - super (layout, y, "Pad Altitude"); + super (layout, y, AltosConvert.height, "Pad Altitude"); } } @@ -403,17 +421,30 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { pad_alt.reset(); } - public void set_font() { - battery.set_font(); - apogee.set_font(); - main.set_font(); - logging_ready.set_font(); - gps_locked.set_font(); - gps_ready.set_font(); - receiver_battery.set_font(); - pad_lat.set_font(); - pad_lon.set_font(); - pad_alt.set_font(); + public void font_size_changed(int font_size) { + battery.font_size_changed(font_size); + apogee.font_size_changed(font_size); + main.font_size_changed(font_size); + logging_ready.font_size_changed(font_size); + gps_locked.font_size_changed(font_size); + gps_ready.font_size_changed(font_size); + receiver_battery.font_size_changed(font_size); + pad_lat.font_size_changed(font_size); + pad_lon.font_size_changed(font_size); + pad_alt.font_size_changed(font_size); + } + + public void units_changed(boolean imperial_units) { + battery.units_changed(imperial_units); + apogee.units_changed(imperial_units); + main.units_changed(imperial_units); + logging_ready.units_changed(imperial_units); + gps_locked.units_changed(imperial_units); + gps_ready.units_changed(imperial_units); + receiver_battery.units_changed(imperial_units); + pad_lat.units_changed(imperial_units); + pad_lon.units_changed(imperial_units); + pad_alt.units_changed(imperial_units); } public void show(AltosState state, AltosListenerState listener_state) { diff --git a/altosuilib/AltosFlightDisplay.java b/altosuilib/AltosFlightDisplay.java index 5695a015..5fb0cab7 100644 --- a/altosuilib/AltosFlightDisplay.java +++ b/altosuilib/AltosFlightDisplay.java @@ -19,10 +19,8 @@ package org.altusmetrum.altosuilib_2; import org.altusmetrum.altoslib_4.*; -public interface AltosFlightDisplay { +public interface AltosFlightDisplay extends AltosUnitsListener, AltosFontListener { void reset(); void show(AltosState state, AltosListenerState listener_state); - - void set_font(); } diff --git a/altosuilib/AltosInfoTable.java b/altosuilib/AltosInfoTable.java index 0d8779d1..24a895eb 100644 --- a/altosuilib/AltosInfoTable.java +++ b/altosuilib/AltosInfoTable.java @@ -62,12 +62,15 @@ public class AltosInfoTable extends JTable implements AltosFlightDisplay { doLayout(); } - public void set_font() { + public void font_size_changed(int font_size) { setFont(AltosUILib.table_value_font); set_layout(); doLayout(); } + public void units_changed(boolean imperial_units) { + } + public Dimension getPreferredScrollableViewportSize() { return getPreferredSize(); } diff --git a/altosuilib/AltosSiteMap.java b/altosuilib/AltosSiteMap.java index 7f0e1844..ed77beff 100644 --- a/altosuilib/AltosSiteMap.java +++ b/altosuilib/AltosSiteMap.java @@ -192,11 +192,15 @@ public class AltosSiteMap extends JComponent implements AltosFlightDisplay, Mous // nothing } - public void set_font() { + public void font_size_changed(int font_size) { for (AltosSiteMapTile tile : mapTiles.values()) tile.set_font(AltosUILib.value_font); } + public void units_changed(boolean imperial_units) { + set_line(); + } + static final int load_mode_cached = 1; static final int load_mode_uncached = 2; diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index d30d8dc5..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", @@ -126,13 +129,14 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo display.reset(); } - public void set_font() { + public void font_size_changed(int font_size) { for (AltosFlightDisplay display : displays) - display.set_font(); + display.font_size_changed(font_size); } - public void font_size_changed(int font_size) { - set_font(); + public void units_changed(boolean imperial_units) { + for (AltosFlightDisplay display : displays) + display.units_changed(imperial_units); } public void show(AltosState state, AltosListenerState listener_state) { @@ -343,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; @@ -430,6 +435,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); AltosUIPreferences.register_font_listener(this); + AltosPreferences.register_units_listener(this); addWindowListener(new WindowAdapter() { @Override diff --git a/telegps/TeleGPSInfo.java b/telegps/TeleGPSInfo.java index da3df44e..2765f5ab 100644 --- a/telegps/TeleGPSInfo.java +++ b/telegps/TeleGPSInfo.java @@ -26,10 +26,12 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { GridBagLayout layout; JLabel cur, max; - public class Info { + public abstract class Info implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; AltosLights lights; + double v; + AltosUnits units; void show() { value.setVisible(true); @@ -43,14 +45,15 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { label.setVisible(false); } - void show(AltosState state, AltosListenerState listener_state) {} + abstract void show(AltosState state, AltosListenerState listener_state); void show(String s) { show(); value.setText(s); } - void show(AltosUnits units, double v) { + void show(double v) { + this.v = v; show(units.show(8, v)); } @@ -67,12 +70,19 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { value.setText(""); } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(AltosUILib.label_font); value.setFont(AltosUILib.value_font); } - public Info (GridBagLayout layout, int y, String text) { + public void units_changed(boolean imperial_units) { + if (units != null) + show(v); + } + + public Info (GridBagLayout layout, int y, AltosUnits units, String text) { + this.units = units; + GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -106,12 +116,19 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { layout.setConstraints(value, c); add(value); } + + public Info (GridBagLayout layout, int y, String text) { + this(layout, y, null, text); + } } - public class Value { + public abstract class Value implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; - void show(AltosState state, AltosListenerState listener_state) {} + AltosUnits units; + double v = AltosLib.MISSING; + + abstract void show(AltosState state, AltosListenerState listener_state); void reset() { value.setText(""); @@ -127,7 +144,8 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { value.setText(s); } - void show(AltosUnits units, double v) { + void show(double v) { + this.v = v; show(units.show(8, v)); } @@ -139,10 +157,14 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { label.setVisible(false); value.setVisible(false); } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(AltosUILib.label_font); value.setFont(AltosUILib.value_font); } + public void units_changed(boolean imperial_units) { + if (units != null) + show(v); + } public Value (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); @@ -172,34 +194,44 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { } } - public abstract class DualValue { + public abstract class DualValue implements AltosFontListener, AltosUnitsListener { + AltosLights lights; JLabel label; JTextField value1; JTextField value2; void reset() { + if (lights != null) + lights.set(false); value1.setText(""); value2.setText(""); } void show() { + if (lights != null) + lights.setVisible(true); label.setVisible(true); value1.setVisible(true); value2.setVisible(true); } void hide() { + if (lights != null) + lights.setVisible(false); label.setVisible(false); value1.setVisible(false); value2.setVisible(false); } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(AltosUILib.label_font); value1.setFont(AltosUILib.value_font); value2.setFont(AltosUILib.value_font); } + public void units_changed(boolean imperial_units) { + } + abstract void show(AltosState state, AltosListenerState listener_state); void show(String v1, String v2) { @@ -207,20 +239,37 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { value1.setText(v1); value2.setText(v2); } + void show(String f1, double v1, String f2, double v2) { show(); value1.setText(String.format(f1, v1)); value2.setText(String.format(f2, v2)); } - public DualValue (GridBagLayout layout, int x, int y, String text) { + void show(String f1, int v1, String f2, int v2) { + show(); + value1.setText(String.format(f1, v1)); + value2.setText(String.format(f2, v2)); + } + + public DualValue (GridBagLayout layout, int y, String text, boolean want_lights) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; + if (want_lights) { + lights = new AltosLights(); + c.gridx = 0; c.gridy = y; + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(lights, c); + add(lights); + } + label = new JLabel(text); label.setFont(AltosUILib.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = x + 1; c.gridy = y; + c.gridx = 1; c.gridy = y; c.insets = new Insets(AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.VERTICAL; @@ -231,7 +280,7 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { value1 = new JTextField(AltosUILib.text_width); value1.setFont(AltosUILib.value_font); value1.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = x + 2; c.gridy = y; + c.gridx = 2; c.gridy = y; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; @@ -241,7 +290,7 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { value2 = new JTextField(AltosUILib.text_width); value2.setFont(AltosUILib.value_font); value2.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = x + 3; c.gridy = y; + c.gridx = 3; c.gridy = y; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; @@ -251,13 +300,15 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { } } - public class ValueHold { + abstract public class ValueHold implements AltosFontListener, AltosUnitsListener { JLabel label; JTextField value; JTextField max_value; + double v; double max; + AltosUnits units; - void show(AltosState state, AltosListenerState listener_state) {} + abstract void show(AltosState state, AltosListenerState listener_state); void reset() { value.setText(""); @@ -265,23 +316,29 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { max = AltosLib.MISSING; } - void set_font() { + public void font_size_changed(int font_size) { label.setFont(AltosUILib.label_font); value.setFont(AltosUILib.value_font); max_value.setFont(AltosUILib.value_font); } - void show(AltosUnits units, double v) { + public void units_changed(boolean imperial_units) { + show(v); + } + + void show(double v) { + this.v = v; if (v == AltosLib.MISSING) { value.setText("Missing"); - max_value.setText("Missing"); } else { value.setText(units.show(8, v)); - if (v > max || max == AltosLib.MISSING) { - max_value.setText(units.show(8, v)); + if (v > max || max == AltosLib.MISSING) max = v; - } } + if (max == AltosLib.MISSING) + max_value.setText("Missing"); + else + max_value.setText(units.show(8, max)); } void hide() { @@ -290,7 +347,8 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { max_value.setVisible(false); } - public ValueHold (GridBagLayout layout, int y, String text) { + public ValueHold (GridBagLayout layout, int y, AltosUnits units, String text) { + this.units = units; GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -330,10 +388,10 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { class Altitude extends ValueHold { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.height, state.altitude()); + show(state.altitude()); } public Altitude (GridBagLayout layout, int y) { - super (layout, y, "Altitude"); + super (layout, y, AltosConvert.height, "Altitude"); } } @@ -341,10 +399,10 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { class AscentRate extends ValueHold { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.speed, state.gps_ascent_rate()); + show(state.gps_ascent_rate()); } public AscentRate (GridBagLayout layout, int y) { - super (layout, y, "Ascent Rate"); + super (layout, y, AltosConvert.speed, "Ascent Rate"); } } @@ -352,10 +410,10 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { class GroundSpeed extends ValueHold { void show (AltosState state, AltosListenerState listener_state) { - show(AltosConvert.speed, state.gps_ground_speed()); + show(state.gps_ground_speed()); } public GroundSpeed (GridBagLayout layout, int y) { - super (layout, y, "Ground Speed"); + super (layout, y, AltosConvert.speed, "Ground Speed"); } } @@ -382,7 +440,7 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { course)); } public Course (GridBagLayout layout, int y) { - super (layout, 0, y, "Course"); + super (layout, y, "Course", false); } } @@ -416,17 +474,20 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { Lon lon; - class GPSLocked extends Info { + class GPSLocked extends DualValue { void show (AltosState state, AltosListenerState listener_state) { if (state == null || state.gps == null) hide(); else { - show("%4d sats", state.gps.nsat); - lights.set(state.gps.locked && state.gps.nsat >= 4); + int soln = state.gps.nsat; + int nsat = state.gps.cc_gps_sat != null ? state.gps.cc_gps_sat.length : 0; + show("%4d in solution", soln, + "%4d in view", nsat); + lights.set(state.gps.locked && soln >= 4); } } public GPSLocked (GridBagLayout layout, int y) { - super (layout, y, "GPS Locked"); + super (layout, y, "GPS Locked", true); } } @@ -442,16 +503,26 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { gps_locked.reset(); } - public void set_font() { + public void font_size_changed(int font_size) { cur.setFont(AltosUILib.label_font); max.setFont(AltosUILib.label_font); - lat.set_font(); - lon.set_font(); - altitude.set_font(); - ground_speed.set_font(); - ascent_rate.set_font(); - course.set_font(); - gps_locked.set_font(); + lat.font_size_changed(font_size); + lon.font_size_changed(font_size); + altitude.font_size_changed(font_size); + ground_speed.font_size_changed(font_size); + ascent_rate.font_size_changed(font_size); + course.font_size_changed(font_size); + gps_locked.font_size_changed(font_size); + } + + public void units_changed(boolean imperial_units) { + lat.units_changed(imperial_units); + lon.units_changed(imperial_units); + altitude.units_changed(imperial_units); + ground_speed.units_changed(imperial_units); + ascent_rate.units_changed(imperial_units); + course.units_changed(imperial_units); + gps_locked.units_changed(imperial_units); } public void show(AltosState state, AltosListenerState listener_state) { diff --git a/telegps/TeleGPSStatus.java b/telegps/TeleGPSStatus.java index fd66b279..37cfae37 100644 --- a/telegps/TeleGPSStatus.java +++ b/telegps/TeleGPSStatus.java @@ -25,7 +25,7 @@ import org.altusmetrum.altosuilib_2.*; public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - public class FlightValue { + public class Value { JLabel label; JTextField value; @@ -45,7 +45,7 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { value.setVisible(visible); } - public FlightValue (GridBagLayout layout, int x, String text) { + public Value (GridBagLayout layout, int x, String text) { GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.CENTER; @@ -69,7 +69,7 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { } } - class Call extends FlightValue { + class Call extends Value { void show(AltosState state, AltosListenerState listener_state) { value.setText(state.callsign); if (state.callsign == null) @@ -84,7 +84,7 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { Call call; - class Serial extends FlightValue { + class Serial extends Value { void show(AltosState state, AltosListenerState listener_state) { if (state.serial == AltosLib.MISSING) value.setText("none"); @@ -98,7 +98,7 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { Serial serial; - class RSSI extends FlightValue { + class RSSI extends Value { void show(AltosState state, AltosListenerState listener_state) { value.setText(String.format("%d", state.rssi())); if (state.rssi == AltosLib.MISSING) @@ -113,7 +113,7 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { RSSI rssi; - class LastPacket extends FlightValue { + class LastPacket extends Value { void show(AltosState state, AltosListenerState listener_state) { long secs = (System.currentTimeMillis() - state.received_time + 500) / 1000; value.setText(String.format("%d", secs)); @@ -132,13 +132,16 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { last_packet.reset(); } - public void set_font () { + public void font_size_changed(int font_size) { call.set_font(); serial.set_font(); rssi.set_font(); last_packet.set_font(); } + public void units_changed(boolean imperial_units) { + } + public void show (AltosState state, AltosListenerState listener_state) { call.show(state, listener_state); serial.show(state, listener_state); -- cgit v1.2.3 From db2443fdbf65b65703217174303027c439124a83 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 11 Jun 2014 18:46:47 -0700 Subject: altosuilib: Rewrite map GUI bits Use a single large Canvas and draw images on top by hand. Signed-off-by: Keith Packard --- altosui/AltosFlightUI.java | 4 +- altosui/AltosGraphUI.java | 4 +- altosui/AltosUI.java | 4 +- altosuilib/AltosUILatLon.java | 44 +++ altosuilib/AltosUIMap.java | 246 +++++++++++++ altosuilib/AltosUIMapCache.java | 112 ++++++ altosuilib/AltosUIMapImage.java | 113 ++++++ altosuilib/AltosUIMapLine.java | 116 ++++++ altosuilib/AltosUIMapMark.java | 59 ++++ altosuilib/AltosUIMapPath.java | 96 +++++ altosuilib/AltosUIMapPreload.java | 608 ++++++++++++++++++++++++++++++++ altosuilib/AltosUIMapRectangle.java | 45 +++ altosuilib/AltosUIMapStore.java | 203 +++++++++++ altosuilib/AltosUIMapStoreListener.java | 22 ++ altosuilib/AltosUIMapTile.java | 190 ++++++++++ altosuilib/AltosUIMapTileListener.java | 22 ++ altosuilib/AltosUIMapTransform.java | 106 ++++++ altosuilib/AltosUIMapView.java | 462 ++++++++++++++++++++++++ altosuilib/AltosUIMapZoomListener.java | 22 ++ altosuilib/Makefile.am | 24 +- telegps/TeleGPS.java | 12 +- telegps/TeleGPSGraphUI.java | 4 +- 22 files changed, 2497 insertions(+), 21 deletions(-) create mode 100644 altosuilib/AltosUILatLon.java create mode 100644 altosuilib/AltosUIMap.java create mode 100644 altosuilib/AltosUIMapCache.java create mode 100644 altosuilib/AltosUIMapImage.java create mode 100644 altosuilib/AltosUIMapLine.java create mode 100644 altosuilib/AltosUIMapMark.java create mode 100644 altosuilib/AltosUIMapPath.java create mode 100644 altosuilib/AltosUIMapPreload.java create mode 100644 altosuilib/AltosUIMapRectangle.java create mode 100644 altosuilib/AltosUIMapStore.java create mode 100644 altosuilib/AltosUIMapStoreListener.java create mode 100644 altosuilib/AltosUIMapTile.java create mode 100644 altosuilib/AltosUIMapTileListener.java create mode 100644 altosuilib/AltosUIMapTransform.java create mode 100644 altosuilib/AltosUIMapView.java create mode 100644 altosuilib/AltosUIMapZoomListener.java (limited to 'altosui/AltosFlightUI.java') diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index baa18686..f2bd70a0 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -37,7 +37,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { AltosDescent descent; AltosLanded landed; AltosCompanionInfo companion; - AltosSiteMap sitemap; + AltosUIMap sitemap; boolean has_map; boolean has_companion; boolean has_state; @@ -310,7 +310,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { has_companion = false; has_state = false; - sitemap = new AltosSiteMap(); + sitemap = new AltosUIMap(); has_map = false; /* Make the tabbed pane use the rest of the window space */ diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 9e8a1939..0df92eae 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -34,7 +34,7 @@ public class AltosGraphUI extends AltosUIFrame JTabbedPane pane; AltosGraph graph; AltosUIEnable enable; - AltosSiteMap map; + AltosUIMap map; AltosState state; AltosGraphDataSet graphDataSet; AltosFlightStats stats; @@ -46,7 +46,7 @@ public class AltosGraphUI extends AltosUIFrame for (AltosState state : states) { if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) { if (map == null) - map = new AltosSiteMap(); + map = new AltosUIMap(); map.show(state, null); has_gps = true; } diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 302f623f..6137487c 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -280,7 +280,7 @@ public class AltosUI extends AltosUIFrame { } void LoadMaps() { - new AltosSiteMapPreload(AltosUI.this); + new AltosUIMapPreload(AltosUI.this); } void LaunchController() { @@ -578,7 +578,7 @@ public class AltosUI extends AltosUIFrame { } else { double lat = Double.parseDouble(args[i+1]); double lon = Double.parseDouble(args[i+2]); - AltosSiteMap.prefetchMaps(lat, lon); +// AltosSiteMap.prefetchMaps(lat, lon); i += 2; } } else if (args[i].equals("--replay")) diff --git a/altosuilib/AltosUILatLon.java b/altosuilib/AltosUILatLon.java new file mode 100644 index 00000000..688dd58b --- /dev/null +++ b/altosuilib/AltosUILatLon.java @@ -0,0 +1,44 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.lang.Math; +import java.awt.geom.*; +import java.util.*; +import java.util.concurrent.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosUILatLon { + public double lat; + public double lon; + + public boolean equals(AltosUILatLon other) { + if (other == null) + return false; + return lat == other.lat && lon == other.lon; + } + + public AltosUILatLon(double lat, double lon) { + this.lat = lat; + this.lon = lon; + } +} diff --git a/altosuilib/AltosUIMap.java b/altosuilib/AltosUIMap.java new file mode 100644 index 00000000..fa974d36 --- /dev/null +++ b/altosuilib/AltosUIMap.java @@ -0,0 +1,246 @@ +/* + * Copyright © 2010 Anthony Towns + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.lang.Math; +import java.awt.geom.*; +import java.util.*; +import java.util.concurrent.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosUIMap extends JComponent implements AltosFlightDisplay, AltosUIMapZoomListener { + + static final int px_size = 512; + + static final int maptype_hybrid = 0; + static final int maptype_roadmap = 1; + static final int maptype_satellite = 2; + static final int maptype_terrain = 3; + static final int maptype_default = maptype_hybrid; + + static final String[] maptype_names = { + "hybrid", + "roadmap", + "satellite", + "terrain" + }; + + public static final String[] maptype_labels = { + "Hybrid", + "Roadmap", + "Satellite", + "Terrain" + }; + + public static final Color stateColors[] = { + Color.WHITE, // startup + Color.WHITE, // idle + Color.WHITE, // pad + Color.RED, // boost + Color.PINK, // fast + Color.YELLOW, // coast + Color.CYAN, // drogue + Color.BLUE, // main + Color.BLACK, // landed + Color.BLACK, // invalid + Color.CYAN, // stateless + }; + + public void reset() { + // nothing + } + + public void font_size_changed(int font_size) { + view.set_font(); + } + + public void units_changed(boolean imperial_units) { + repaint(); + } + + JLabel zoom_label; + + private void set_zoom_label() { + zoom_label.setText(String.format("Zoom %d", view.zoom() - view.default_zoom)); + } + + public void zoom_changed(int zoom) { + set_zoom_label(); + } + + public void set_zoom(int zoom) { + view.set_zoom(zoom); + } + + public int get_zoom() { + return view.zoom(); + } + + public void set_maptype(int type) { + view.set_maptype(type); + maptype_combo.setSelectedIndex(type); + } + + public void show(AltosState state, AltosListenerState listener_state) { + view.show(state, listener_state); + } + + public void centre(double lat, double lon) { + view.centre(lat, lon); + } + + public void centre(AltosState state) { + if (!state.gps.locked && state.gps.nsat < 4) + return; + centre(state.gps.lat, state.gps.lon); + } + + public void add_mark(double lat, double lon, int state) { + view.add_mark(lat, lon, state); + } + + public void clear_marks() { + view.clear_marks(); + } + + AltosUIMapView view; + + private GridBagLayout layout = new GridBagLayout(); + + JComboBox maptype_combo; + + public void set_load_params(double lat, double lon, int radius, AltosUIMapTileListener listener) { + view.set_load_params(lat, lon, radius, listener); + } + + public boolean all_fetched() { + return view.all_fetched(); + } + + public static void prefetch_maps(double lat, double lon) { + } + + public AltosUIMap() { + + view = new AltosUIMapView(); + + view.setPreferredSize(new Dimension(500,500)); + view.setVisible(true); + view.setEnabled(true); + view.add_zoom_listener(this); + + GridBagLayout my_layout = new GridBagLayout(); + + setLayout(my_layout); + + GridBagConstraints c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.BOTH; + c.gridx = 0; + c.gridy = 0; + c.gridwidth = 1; + c.gridheight = 10; + c.weightx = 1; + c.weighty = 1; + add(view, c); + + int y = 0; + + zoom_label = new JLabel("", JLabel.CENTER); + set_zoom_label(); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(zoom_label, c); + + JButton zoom_reset = new JButton("0"); + zoom_reset.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + set_zoom(view.default_zoom); + } + }); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(zoom_reset, c); + + JButton zoom_in = new JButton("+"); + zoom_in.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + set_zoom(get_zoom() + 1); + } + }); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(zoom_in, c); + + JButton zoom_out = new JButton("-"); + zoom_out.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + set_zoom(get_zoom() - 1); + } + }); + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(zoom_out, c); + + maptype_combo = new JComboBox(maptype_labels); + + maptype_combo.setEditable(false); + maptype_combo.setMaximumRowCount(maptype_combo.getItemCount()); + maptype_combo.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + view.set_maptype(maptype_combo.getSelectedIndex()); + } + }); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(maptype_combo, c); + } +} diff --git a/altosuilib/AltosUIMapCache.java b/altosuilib/AltosUIMapCache.java new file mode 100644 index 00000000..e849da79 --- /dev/null +++ b/altosuilib/AltosUIMapCache.java @@ -0,0 +1,112 @@ +/* + * Copyright © 2010 Anthony Towns + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import javax.swing.*; +import javax.imageio.ImageIO; +import java.awt.image.*; +import java.awt.*; +import java.io.*; +import java.net.*; + +public class AltosUIMapCache { + static final int success = 0; + static final int loading = 1; + static final int failed = 2; + static final int bad_request = 3; + static final int forbidden = 4; + + static private Object fetch_lock = new Object(); + + static final int min_cache_size = 9; + static final int max_cache_size = 24; + + static int cache_size = min_cache_size; + + static AltosUIMapImage[] images = new AltosUIMapImage[cache_size]; + + static Object cache_lock = new Object(); + + public static void set_cache_size(int new_size) { + if (new_size < min_cache_size) + new_size = min_cache_size; + if (new_size > max_cache_size) + new_size = max_cache_size; + if (new_size == cache_size) + return; + + synchronized(cache_lock) { + AltosUIMapImage[] new_images = new AltosUIMapImage[new_size]; + + for (int i = 0; i < cache_size; i++) { + if (i < new_size) + new_images[i] = images[i]; + else if (images[i] != null) + images[i].flush(); + } + images = new_images; + cache_size = new_size; + } + } + + static long used; + + public static Image get(AltosUIMapTile tile, AltosUIMapStore store, int width, int height) { + int oldest = -1; + long age = used; + + synchronized(cache_lock) { + AltosUIMapImage image = null; + for (int i = 0; i < cache_size; i++) { + image = images[i]; + + if (image == null) { + oldest = i; + break; + } + if (store.equals(image.store)) { + image.used = used++; + return image.image; + } + if (image.used < age) { + oldest = i; + age = image.used; + } + } + + try { + image = new AltosUIMapImage(tile, store); + image.used = used++; + if (images[oldest] != null) + images[oldest].flush(); + + images[oldest] = image; + + if (image.image == null) + tile.set_status(loading); + else + tile.set_status(success); + + return image.image; + } catch (IOException e) { + tile.set_status(failed); + return null; + } + } + } +} diff --git a/altosuilib/AltosUIMapImage.java b/altosuilib/AltosUIMapImage.java new file mode 100644 index 00000000..3819d079 --- /dev/null +++ b/altosuilib/AltosUIMapImage.java @@ -0,0 +1,113 @@ +/* + * Copyright © 2010 Anthony Towns + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import javax.swing.*; +import javax.imageio.ImageIO; +import java.awt.image.*; +import java.awt.*; +import java.io.*; +import java.net.*; + +public class AltosUIMapImage implements AltosUIMapStoreListener { + static final long google_maps_ratelimit_ms = 1200; + // Google limits static map queries to 50 per minute per IP, so + // each query should take at least 1.2 seconds. + + static final int success = 0; + static final int loading = 1; + static final int failed = 2; + static final int bad_request = 3; + static final int forbidden = 4; + + static long forbidden_time; + static boolean forbidden_set = false; + static final long forbidden_interval = 60l * 1000l * 1000l * 1000l; + + AltosUIMapTile tile; /* Notify when image has been loaded */ + Image image; + AltosUIMapStore store; + long used; + + class loader implements Runnable { + public void run() { + if (image != null) + tile.notify_image(image); + try { + image = ImageIO.read(store.file); + } catch (Exception ex) { + } + if (image == null) + tile.set_status(failed); + else + tile.set_status(success); + tile.notify_image(image); + } + } + + private void load() { + loader l = new loader(); + Thread lt = new Thread(l); + lt.start(); + } + + public void flush() { + if (image != null) { + image.flush(); + image = null; + } + } + + public boolean has_map() { + return store.status() == AltosUIMapStore.success; + } + + public synchronized void notify_store(AltosUIMapStore store, int status) { + switch (status) { + case AltosUIMapStore.loading: + break; + case AltosUIMapStore.success: + load(); + break; + default: + tile.set_status(status); + tile.notify_image(null); + } + } + + public AltosUIMapImage(AltosUIMapTile tile, AltosUIMapStore store) throws IOException { + this.tile = tile; + this.image = null; + this.store = store; + this.used = 0; + + int status = store.status(); + switch (status) { + case AltosUIMapStore.loading: + store.add_listener(this); + break; + case AltosUIMapStore.success: + load(); + break; + default: + tile.set_status(status); + tile.notify_image(null); + break; + } + } +} diff --git a/altosuilib/AltosUIMapLine.java b/altosuilib/AltosUIMapLine.java new file mode 100644 index 00000000..e09a2d9f --- /dev/null +++ b/altosuilib/AltosUIMapLine.java @@ -0,0 +1,116 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.lang.Math; +import java.awt.geom.*; +import java.util.*; +import java.util.concurrent.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosUIMapLine { + AltosUILatLon start, end; + + private Font font = null; + + public void set_font(Font font) { + this.font = font; + } + + private AltosUILatLon lat_lon(MouseEvent e, AltosUIMapTransform t) { + return t.screen_lat_lon(e.getPoint()); + } + + public void dragged(MouseEvent e, AltosUIMapTransform t) { + end = lat_lon(e, t); + } + + public void pressed(MouseEvent e, AltosUIMapTransform t) { + start = lat_lon(e, t); + end = null; + } + + private String line_dist() { + String format; + AltosGreatCircle g = new AltosGreatCircle(start.lat, start.lon, + end.lat, end.lon); + double distance = g.distance; + + if (AltosConvert.imperial_units) { + distance = AltosConvert.meters_to_feet(distance); + if (distance < 10000) { + format = "%4.0fft"; + } else { + distance /= 5280; + if (distance < 10) + format = "%5.3fmi"; + else if (distance < 100) + format = "%5.2fmi"; + else if (distance < 1000) + format = "%5.1fmi"; + else + format = "%5.0fmi"; + } + } else { + if (distance < 10000) { + format = "%4.0fm"; + } else { + distance /= 1000; + if (distance < 100) + format = "%5.2fkm"; + else if (distance < 1000) + format = "%5.1fkm"; + else + format = "%5.0fkm"; + } + } + return String.format(format, distance); + } + + public void paint(Graphics2D g, AltosUIMapTransform t) { + g.setColor(Color.BLUE); + + if (start == null || end == null) + return; + + Line2D.Double line = new Line2D.Double(t.screen(start), + t.screen(end)); + + g.draw(line); + + String message = line_dist(); + g.setFont(font); + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + Rectangle2D bounds; + bounds = font.getStringBounds(message, g.getFontRenderContext()); + + float x = (float) line.x1; + float y = (float) line.y1 + (float) bounds.getHeight() / 2.0f; + + if (line.x1 < line.x2) { + x -= (float) bounds.getWidth() + 2.0f; + } else { + x += 2.0f; + } + g.drawString(message, x, y); + } +} diff --git a/altosuilib/AltosUIMapMark.java b/altosuilib/AltosUIMapMark.java new file mode 100644 index 00000000..8c640e5f --- /dev/null +++ b/altosuilib/AltosUIMapMark.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.lang.Math; +import java.awt.geom.*; +import java.util.*; +import java.util.concurrent.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosUIMapMark { + + AltosUILatLon lat_lon; + int state; + + static public int stroke_width = 6; + + public void paint(Graphics2D g, AltosUIMapTransform t) { + + Point2D.Double pt = t.screen(lat_lon); + + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + + if (0 <= state && state < AltosUIMap.stateColors.length) + g.setColor(AltosUIMap.stateColors[state]); + else + g.setColor(AltosUIMap.stateColors[AltosLib.ao_flight_invalid]); + + g.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10); + g.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40); + g.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70); + } + + public AltosUIMapMark (double lat, double lon, int state) { + lat_lon = new AltosUILatLon(lat, lon); + this.state = state; + } +} diff --git a/altosuilib/AltosUIMapPath.java b/altosuilib/AltosUIMapPath.java new file mode 100644 index 00000000..ff17be67 --- /dev/null +++ b/altosuilib/AltosUIMapPath.java @@ -0,0 +1,96 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.lang.Math; +import java.awt.geom.*; +import java.util.*; +import java.util.concurrent.*; +import org.altusmetrum.altoslib_4.*; + +class PathPoint { + AltosUILatLon lat_lon; + int state; + + public PathPoint(AltosUILatLon lat_lon, int state) { + this.lat_lon = lat_lon; + this.state = state; + } + + public boolean equals(PathPoint other) { + if (other == null) + return false; + + return lat_lon.equals(other.lat_lon) && state == other.state; + } +} + +public class AltosUIMapPath { + + LinkedList points = new LinkedList(); + PathPoint last_point = null; + + static public int stroke_width = 6; + + public void paint(Graphics2D g, AltosUIMapTransform t) { + Point2D.Double prev = null; + + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + + for (PathPoint point : points) { + Point2D.Double cur = t.screen(point.lat_lon); + if (prev != null) { + Line2D.Double line = new Line2D.Double (prev, cur); + Rectangle bounds = line.getBounds(); + + if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { + if (0 <= point.state && point.state < AltosUIMap.stateColors.length) + g.setColor(AltosUIMap.stateColors[point.state]); + else + g.setColor(AltosUIMap.stateColors[AltosLib.ao_flight_invalid]); + + g.draw(line); + } + } + prev = cur; + } + } + + public AltosUIMapRectangle add(double lat, double lon, int state) { + PathPoint point = new PathPoint(new AltosUILatLon (lat, lon), state); + AltosUIMapRectangle rect = null; + + if (!point.equals(last_point)) { + if (last_point != null) + rect = new AltosUIMapRectangle(last_point.lat_lon, point.lat_lon); + points.add (point); + last_point = point; + } + return rect; + } + + public void clear () { + points = new LinkedList(); + } +} diff --git a/altosuilib/AltosUIMapPreload.java b/altosuilib/AltosUIMapPreload.java new file mode 100644 index 00000000..d702dddf --- /dev/null +++ b/altosuilib/AltosUIMapPreload.java @@ -0,0 +1,608 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.lang.Math; +import java.net.URL; +import java.net.URLConnection; +import org.altusmetrum.altoslib_4.*; + +class AltosUIMapPos extends Box { + AltosUIFrame owner; + JLabel label; + JComboBox hemi; + JTextField deg; + JLabel deg_label; + JTextField min; + JLabel min_label; + + public void set_value(double new_value) { + double d, m; + int h; + + h = 0; + if (new_value < 0) { + h = 1; + new_value = -new_value; + } + d = Math.floor(new_value); + deg.setText(String.format("%3.0f", d)); + m = (new_value - d) * 60.0; + min.setText(String.format("%7.4f", m)); + hemi.setSelectedIndex(h); + } + + public double get_value() throws NumberFormatException { + int h = hemi.getSelectedIndex(); + String d_t = deg.getText(); + String m_t = min.getText(); + double d, m, v; + try { + d = Double.parseDouble(d_t); + } catch (NumberFormatException ne) { + JOptionPane.showMessageDialog(owner, + String.format("Invalid degrees \"%s\"", + d_t), + "Invalid number", + JOptionPane.ERROR_MESSAGE); + throw ne; + } + try { + if (m_t.equals("")) + m = 0; + else + m = Double.parseDouble(m_t); + } catch (NumberFormatException ne) { + JOptionPane.showMessageDialog(owner, + String.format("Invalid minutes \"%s\"", + m_t), + "Invalid number", + JOptionPane.ERROR_MESSAGE); + throw ne; + } + v = d + m/60.0; + if (h == 1) + v = -v; + return v; + } + + public AltosUIMapPos(AltosUIFrame in_owner, + String label_value, + String[] hemi_names, + double default_value) { + super(BoxLayout.X_AXIS); + owner = in_owner; + label = new JLabel(label_value); + hemi = new JComboBox(hemi_names); + hemi.setEditable(false); + deg = new JTextField(5); + deg.setMinimumSize(deg.getPreferredSize()); + deg.setHorizontalAlignment(JTextField.RIGHT); + deg_label = new JLabel("°"); + min = new JTextField(9); + min.setMinimumSize(min.getPreferredSize()); + min_label = new JLabel("'"); + set_value(default_value); + add(label); + add(Box.createRigidArea(new Dimension(5, 0))); + add(hemi); + add(Box.createRigidArea(new Dimension(5, 0))); + add(deg); + add(Box.createRigidArea(new Dimension(5, 0))); + add(deg_label); + add(Box.createRigidArea(new Dimension(5, 0))); + add(min); + add(Box.createRigidArea(new Dimension(5, 0))); + add(min_label); + } +} + +class AltosUISite { + String name; + double latitude; + double longitude; + + public String toString() { + return name; + } + + public AltosUISite(String in_name, double in_latitude, double in_longitude) { + name = in_name; + latitude = in_latitude; + longitude = in_longitude; + } + + public AltosUISite(String line) throws ParseException { + String[] elements = line.split(":"); + + if (elements.length < 3) + throw new ParseException(String.format("Invalid site line %s", line), 0); + + name = elements[0]; + + try { + latitude = Double.parseDouble(elements[1]); + longitude = Double.parseDouble(elements[2]); + } catch (NumberFormatException ne) { + throw new ParseException(String.format("Invalid site line %s", line), 0); + } + } +} + +class AltosUISites extends Thread { + AltosUIMapPreload preload; + URL url; + LinkedList sites; + + void notify_complete() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + preload.set_sites(); + } + }); + } + + void add(AltosUISite site) { + sites.add(site); + } + + void add(String line) { + try { + add(new AltosUISite(line)); + } catch (ParseException pe) { + } + } + + public void run() { + try { + URLConnection uc = url.openConnection(); + //int length = uc.getContentLength(); + + InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), AltosLib.unicode_set); + BufferedReader in = new BufferedReader(in_stream); + + for (;;) { + String line = in.readLine(); + if (line == null) + break; + add(line); + } + } catch (IOException e) { + } finally { + notify_complete(); + } + } + + public AltosUISites(AltosUIMapPreload in_preload) { + sites = new LinkedList(); + preload = in_preload; + try { + url = new URL(AltosLib.launch_sites_url); + } catch (java.net.MalformedURLException e) { + notify_complete(); + } + start(); + } +} + +public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, ItemListener, AltosUIMapTileListener { + AltosUIFrame owner; + AltosUIMap map; + + AltosUIMapPos lat; + AltosUIMapPos lon; + + JProgressBar pbar; + int pbar_max; + int pbar_cur; + + AltosUISites sites; + JLabel site_list_label; + JComboBox site_list; + + JToggleButton load_button; + boolean loading; + JButton close_button; + + JCheckBox[] maptypes = new JCheckBox[AltosUIMap.maptype_terrain - AltosUIMap.maptype_hybrid + 1]; + + JComboBox min_zoom; + JComboBox max_zoom; + JComboBox radius; + + Integer[] zooms = { -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6 }; + Integer[] radii = { 1, 2, 3, 4, 5 }; + + static final String[] lat_hemi_names = { "N", "S" }; + static final String[] lon_hemi_names = { "E", "W" }; + + class updatePbar implements Runnable { + String s; + + public updatePbar(String in_s) { + s = in_s; + } + + public void run() { + int n = ++pbar_cur; + + pbar.setMaximum(pbar_max); + pbar.setValue(n); + pbar.setString(s); + } + } + + double latitude, longitude; + int min_z; + int max_z; + int cur_z; + int all_types; + int cur_type; + int r; + + int tiles_per_layer; + int tiles_loaded; + int layers_total; + int layers_loaded; + + + private void do_load() { + tiles_loaded = 0; + map.set_zoom(cur_z + AltosUIMapView.default_zoom); + map.set_maptype(cur_type); + map.set_load_params(latitude, longitude, r, this); + } + + private int next_type(int start) { + int next_type; + for (next_type = start; + next_type <= AltosUIMap.maptype_terrain && (all_types & (1 << next_type)) == 0; + next_type++) + ; + return next_type; + } + + private void next_load() { + int next_type = next_type(cur_type + 1); + + if (next_type > AltosUIMap.maptype_terrain) { + if (cur_z == max_z) { + return; + } else { + cur_z++; + } + next_type = next_type(0); + } + cur_type = next_type; + do_load(); + } + + private void start_load() { + cur_z = min_z; + int ntype = 0; + all_types = 0; + for (int t = AltosUIMap.maptype_hybrid; t <= AltosUIMap.maptype_terrain; t++) + if (maptypes[t].isSelected()) { + all_types |= (1 << t); + ntype++; + } + if (ntype == 0) { + all_types |= (1 << AltosUIMap.maptype_hybrid); + ntype = 1; + } + + cur_type = next_type(0); + tiles_per_layer = (r * 2 + 1) * (r * 2 + 1); + layers_total = (max_z - min_z + 1) * ntype; + layers_loaded = 0; + pbar_max = layers_total * tiles_per_layer; + pbar_cur = 0; + + map.clear_marks(); + map.add_mark(latitude,longitude, AltosLib.ao_flight_boost); + do_load(); + } + + /* AltosUIMapTileListener methods */ + + public void notify_tile(AltosUIMapTile tile, int status) { + if (status == AltosUIMapStore.loading) + return; + + SwingUtilities.invokeLater(new updatePbar(tile.store.file.toString())); + ++tiles_loaded; + if (tiles_loaded == tiles_per_layer) { + ++layers_loaded; + if (layers_loaded == layers_total) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + pbar.setValue(0); + pbar.setString(""); + load_button.setSelected(false); + loading = false; + } + }); + } else { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + next_load(); + } + }); + } + } + } + + public void set_sites() { + int i = 1; + for (AltosUISite site : sites.sites) { + site_list.insertItemAt(site, i); + i++; + } + } + + public void itemStateChanged(ItemEvent e) { + int state = e.getStateChange(); + + if (state == ItemEvent.SELECTED) { + Object o = e.getItem(); + if (o instanceof AltosUISite) { + AltosUISite site = (AltosUISite) o; + lat.set_value(site.latitude); + lon.set_value(site.longitude); + } + } + } + + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + + if (cmd.equals("close")) + setVisible(false); + + if (cmd.equals("load")) { + if (!loading) { + try { + latitude = lat.get_value(); + longitude = lon.get_value(); + min_z = (Integer) min_zoom.getSelectedItem(); + max_z = (Integer) max_zoom.getSelectedItem(); + if (max_z < min_z) + max_z = min_z; + r = (Integer) radius.getSelectedItem(); + loading = true; + } catch (NumberFormatException ne) { + load_button.setSelected(false); + } + start_load(); + } + } + } + + public AltosUIMapPreload(AltosUIFrame in_owner) { + System.out.printf("start creating preload ui\n"); + + owner = in_owner; + + Container pane = getContentPane(); + GridBagConstraints c = new GridBagConstraints(); + Insets i = new Insets(4,4,4,4); + + setTitle("AltOS Load Maps"); + + pane.setLayout(new GridBagLayout()); + + map = new AltosUIMap(); + + c.fill = GridBagConstraints.BOTH; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 1; + + c.gridx = 0; + c.gridy = 0; + c.gridwidth = 10; + c.anchor = GridBagConstraints.CENTER; + + pane.add(map, c); + + pbar = new JProgressBar(); + pbar.setMinimum(0); + pbar.setMaximum(1); + pbar.setValue(0); + pbar.setString(""); + pbar.setStringPainted(true); + + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 1; + c.gridwidth = 10; + + pane.add(pbar, c); + + site_list_label = new JLabel ("Known Launch Sites:"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 2; + c.gridwidth = 1; + + pane.add(site_list_label, c); + + site_list = new JComboBox(new AltosUISite[] { new AltosUISite("Site List", 0, 0) }); + site_list.addItemListener(this); + + sites = new AltosUISites(this); + + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 2; + c.gridwidth = 1; + + pane.add(site_list, c); + + lat = new AltosUIMapPos(owner, + "Latitude:", + lat_hemi_names, + 37.167833333); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 0; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 3; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(lat, c); + + lon = new AltosUIMapPos(owner, + "Longitude:", + lon_hemi_names, + -97.73975); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 0; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 3; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(lon, c); + + load_button = new JToggleButton("Load Map"); + load_button.addActionListener(this); + load_button.setActionCommand("load"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 4; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(load_button, c); + + close_button = new JButton("Close"); + close_button.addActionListener(this); + close_button.setActionCommand("close"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 4; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(close_button, c); + + JLabel types_label = new JLabel("Map Types"); + c.gridx = 2; + c.gridwidth = 2; + c.gridy = 2; + pane.add(types_label, c); + + c.gridwidth = 1; + + for (int type = AltosUIMap.maptype_hybrid; type <= AltosUIMap.maptype_terrain; type++) { + maptypes[type] = new JCheckBox(AltosUIMap.maptype_labels[type], + type == AltosUIMap.maptype_hybrid); + c.gridx = 2 + (type >> 1); + c.fill = GridBagConstraints.HORIZONTAL; + c.gridy = (type & 1) + 3; + pane.add(maptypes[type], c); + } + + JLabel min_zoom_label = new JLabel("Minimum Zoom"); + c.gridx = 4; + c.gridy = 2; + pane.add(min_zoom_label, c); + + min_zoom = new JComboBox(zooms); + min_zoom.setSelectedItem(zooms[10]); + min_zoom.setEditable(false); + c.gridx = 5; + c.gridy = 2; + pane.add(min_zoom, c); + + JLabel max_zoom_label = new JLabel("Maximum Zoom"); + c.gridx = 4; + c.gridy = 3; + pane.add(max_zoom_label, c); + + max_zoom = new JComboBox(zooms); + max_zoom.setSelectedItem(zooms[14]); + max_zoom.setEditable(false); + c.gridx = 5; + c.gridy = 3; + pane.add(max_zoom, c); + + JLabel radius_label = new JLabel("Tile Radius"); + c.gridx = 4; + c.gridy = 4; + pane.add(radius_label, c); + + radius = new JComboBox(radii); + radius.setSelectedItem(radii[4]); + radius.setEditable(true); + c.gridx = 5; + c.gridy = 4; + pane.add(radius, c); + + pack(); + setLocationRelativeTo(owner); + setVisible(true); + + System.out.printf("done creating preload ui\n"); + } +} diff --git a/altosuilib/AltosUIMapRectangle.java b/altosuilib/AltosUIMapRectangle.java new file mode 100644 index 00000000..8a5b16e1 --- /dev/null +++ b/altosuilib/AltosUIMapRectangle.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +public class AltosUIMapRectangle { + AltosUILatLon ul, lr; + + public AltosUIMapRectangle(AltosUILatLon a, AltosUILatLon b) { + double ul_lat, ul_lon; + double lr_lat, lr_lon; + + if (a.lat > b.lat) { + ul_lat = a.lat; + lr_lat = b.lat; + } else { + ul_lat = b.lat; + lr_lat = a.lat; + } + if (a.lon < b.lon) { + ul_lon = a.lon; + lr_lon = b.lon; + } else { + ul_lon = b.lon; + lr_lon = a.lon; + } + + ul = new AltosUILatLon(ul_lat, ul_lon); + lr = new AltosUILatLon(lr_lat, lr_lon); + } +} diff --git a/altosuilib/AltosUIMapStore.java b/altosuilib/AltosUIMapStore.java new file mode 100644 index 00000000..4cecb54f --- /dev/null +++ b/altosuilib/AltosUIMapStore.java @@ -0,0 +1,203 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.io.*; +import java.net.*; +import java.util.*; + +public class AltosUIMapStore { + String url; + File file; + LinkedList listeners = new LinkedList(); + + static final int success = 0; + static final int loading = 1; + static final int failed = 2; + static final int bad_request = 3; + static final int forbidden = 4; + + int status; + + public int status() { + return status; + } + + public synchronized void add_listener(AltosUIMapStoreListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public synchronized void remove_listener(AltosUIMapStoreListener listener) { + listeners.remove(listener); + } + + private synchronized void notify_listeners(int status) { + this.status = status; + for (AltosUIMapStoreListener listener : listeners) + listener.notify_store(this, status); + } + + static Object forbidden_lock = new Object(); + static long forbidden_time; + static boolean forbidden_set; + + private int fetch_url() { + URL u; + + try { + u = new URL(url); + } catch (java.net.MalformedURLException e) { + return bad_request; + } + + byte[] data; + URLConnection uc = null; + try { + uc = u.openConnection(); + String type = uc.getContentType(); + int contentLength = uc.getContentLength(); + if (uc instanceof HttpURLConnection) { + int response = ((HttpURLConnection) uc).getResponseCode(); + switch (response) { + case HttpURLConnection.HTTP_FORBIDDEN: + case HttpURLConnection.HTTP_PAYMENT_REQUIRED: + case HttpURLConnection.HTTP_UNAUTHORIZED: + synchronized (forbidden_lock) { + forbidden_time = System.nanoTime(); + forbidden_set = true; + return forbidden; + } + } + } + InputStream in = new BufferedInputStream(uc.getInputStream()); + int bytesRead = 0; + int offset = 0; + data = new byte[contentLength]; + while (offset < contentLength) { + bytesRead = in.read(data, offset, data.length - offset); + if (bytesRead == -1) + break; + offset += bytesRead; + } + in.close(); + + if (offset != contentLength) + return failed; + + } catch (IOException e) { + return failed; + } + + try { + FileOutputStream out = new FileOutputStream(file); + out.write(data); + out.flush(); + out.close(); + } catch (FileNotFoundException e) { + return bad_request; + } catch (IOException e) { + if (file.exists()) + file.delete(); + return bad_request; + } + return success; + } + + static Object fetch_lock = new Object(); + + static final long forbidden_interval = 60l * 1000l * 1000l * 1000l; + static final long google_maps_ratelimit_ms = 1200; + + class loader implements Runnable { + + public void run() { + if (file.exists()) { + notify_listeners(success); + return; + } + + synchronized(forbidden_lock) { + if (forbidden_set && (System.nanoTime() - forbidden_time) < forbidden_interval) { + notify_listeners(forbidden); + return; + } + } + + int new_status; + + if (!AltosUIVersion.has_google_maps_api_key()) { + synchronized (fetch_lock) { + long startTime = System.nanoTime(); + new_status = fetch_url(); + if (new_status == success) { + long duration_ms = (System.nanoTime() - startTime) / 1000000; + if (duration_ms < google_maps_ratelimit_ms) { + try { + Thread.sleep(google_maps_ratelimit_ms - duration_ms); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + } + } + } else { + new_status = fetch_url(); + } + notify_listeners(new_status); + } + } + + private void load() { + loader l = new loader(); + Thread lt = new Thread(l); + lt.start(); + } + + private AltosUIMapStore (String url, File file) { + this.url = url; + this.file = file; + + if (file.exists()) + status = success; + else { + status = loading; + load(); + } + } + + public boolean equals(AltosUIMapStore other) { + return url.equals(other.url); + } + + static HashMap stores = new HashMap(); + + public static AltosUIMapStore get(String url, File file) { + AltosUIMapStore store; + synchronized(stores) { + if (stores.containsKey(url)) { + store = stores.get(url); + } else { + store = new AltosUIMapStore(url, file); + stores.put(url, store); + } + } + return store; + } + +} diff --git a/altosuilib/AltosUIMapStoreListener.java b/altosuilib/AltosUIMapStoreListener.java new file mode 100644 index 00000000..91aff00c --- /dev/null +++ b/altosuilib/AltosUIMapStoreListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +public interface AltosUIMapStoreListener { + abstract void notify_store(AltosUIMapStore store, int status); +} diff --git a/altosuilib/AltosUIMapTile.java b/altosuilib/AltosUIMapTile.java new file mode 100644 index 00000000..6fbcdb4b --- /dev/null +++ b/altosuilib/AltosUIMapTile.java @@ -0,0 +1,190 @@ +/* + * Copyright © 2010 Anthony Towns + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.image.*; +import javax.swing.*; +import javax.imageio.*; +import java.awt.geom.*; +import java.io.*; +import java.util.*; +import java.awt.RenderingHints.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosUIMapTile { + AltosUIMapTileListener listener; + AltosUILatLon upper_left, center; + int px_size; + int zoom; + int maptype; + AltosUIMapStore store; + int status; + + private File map_file() { + double lat = center.lat; + double lon = center.lon; + char chlat = lat < 0 ? 'S' : 'N'; + char chlon = lon < 0 ? 'W' : 'E'; + + if (lat < 0) lat = -lat; + if (lon < 0) lon = -lon; + String maptype_string = String.format("%s-", AltosUIMap.maptype_names[maptype]); + String format_string; + if (maptype == AltosUIMap.maptype_hybrid || maptype == AltosUIMap.maptype_satellite || maptype == AltosUIMap.maptype_terrain) + format_string = "jpg"; + else + format_string = "png"; + return new File(AltosUIPreferences.mapdir(), + String.format("map-%c%.6f,%c%.6f-%s%d.%s", + chlat, lat, chlon, lon, maptype_string, zoom, format_string)); + } + + private String map_url() { + String format_string; + if (maptype == AltosUIMap.maptype_hybrid || maptype == AltosUIMap.maptype_satellite || maptype == AltosUIMap.maptype_terrain) + format_string = "jpg"; + else + format_string = "png32"; + + if (AltosUIVersion.has_google_maps_api_key()) + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s&key=%s", + center.lat, center.lon, zoom, px_size, px_size, AltosUIMap.maptype_names[maptype], format_string, AltosUIVersion.google_maps_api_key); + else + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s", + center.lat, center.lon, zoom, px_size, px_size, AltosUIMap.maptype_names[maptype], format_string); + } + private Font font = null; + + public void set_font(Font font) { + this.font = font; + } + + int painting_serial; + int painted_serial; + + Image image; + + public void paint_graphics(Graphics2D g2d, AltosUIMapTransform t, int serial) { + if (serial < painted_serial) + return; + + Point2D.Double point_double = t.screen(upper_left); + Point point = new Point((int) (point_double.x + 0.5), + (int) (point_double.y + 0.5)); + + painted_serial = serial; + + if (!g2d.hitClip(point.x, point.y, px_size, px_size)) + return; + + if (image != null) { + g2d.drawImage(image, point.x, point.y, null); + image = null; + } else { + g2d.setColor(Color.GRAY); + g2d.fillRect(point.x, point.y, px_size, px_size); + + if (t.has_location()) { + String message = null; + switch (status) { + case AltosUIMapCache.loading: + message = "Loading..."; + break; + case AltosUIMapCache.bad_request: + message = "Internal error"; + break; + case AltosUIMapCache.failed: + message = "Network error, check connection"; + break; + case AltosUIMapCache.forbidden: + message = "Too many requests, try later"; + break; + } + if (message != null && font != null) { + g2d.setFont(font); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + Rectangle2D bounds = font.getStringBounds(message, g2d.getFontRenderContext()); + + float x = px_size / 2.0f; + float y = px_size / 2.0f; + x = x - (float) bounds.getWidth() / 2.0f; + y = y + (float) bounds.getHeight() / 2.0f; + g2d.setColor(Color.BLACK); + g2d.drawString(message, (float) point_double.x + x, (float) point_double.y + y); + } + } + } + } + + public void set_status(int status) { + this.status = status; + listener.notify_tile(this, status); + } + + public void notify_image(Image image) { + listener.notify_tile(this, status); + } + + public void paint(Graphics g, AltosUIMapTransform t) { + Graphics2D g2d = (Graphics2D) g; + boolean queued = false; + + Point2D.Double point = t.screen(upper_left); + + if (!g.hitClip((int) (point.x + 0.5), (int) (point.y + 0.5), px_size, px_size)) + return; + + ++painting_serial; + + if (image == null && t.has_location()) + image = AltosUIMapCache.get(this, store, px_size, px_size); + + paint_graphics(g2d, t, painting_serial); + } + + public int store_status() { + return store.status(); + } + + public void add_store_listener(AltosUIMapStoreListener listener) { + store.add_listener(listener); + } + + public void remove_store_listener(AltosUIMapStoreListener listener) { + store.remove_listener(listener); + } + + public AltosUIMapTile(AltosUIMapTileListener listener, AltosUILatLon upper_left, AltosUILatLon center, int zoom, int maptype, int px_size, Font font) { + this.listener = listener; + this.upper_left = upper_left; + + while (center.lon < -180.0) + center.lon += 360.0; + while (center.lon > 180.0) + center.lon -= 360.0; + + this.center = center; + this.zoom = zoom; + this.maptype = maptype; + this.px_size = px_size; + this.font = font; + status = AltosUIMapCache.loading; + store = AltosUIMapStore.get(map_url(), map_file()); + } +} diff --git a/altosuilib/AltosUIMapTileListener.java b/altosuilib/AltosUIMapTileListener.java new file mode 100644 index 00000000..4cc3ff2f --- /dev/null +++ b/altosuilib/AltosUIMapTileListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +public interface AltosUIMapTileListener { + abstract public void notify_tile(AltosUIMapTile tile, int status); +} diff --git a/altosuilib/AltosUIMapTransform.java b/altosuilib/AltosUIMapTransform.java new file mode 100644 index 00000000..e6f1ffe3 --- /dev/null +++ b/altosuilib/AltosUIMapTransform.java @@ -0,0 +1,106 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.lang.Math; +import java.awt.geom.*; +import java.util.*; +import java.util.concurrent.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosUIMapTransform { + + double scale_x, scale_y; + + double offset_x, offset_y; + + public AltosUILatLon lat_lon (Point2D.Double point) { + double lat, lon; + double rads; + + lon = point.x/scale_x; + rads = 2 * Math.atan(Math.exp(-point.y/scale_y)); + lat = Math.toDegrees(rads - Math.PI/2); + + return new AltosUILatLon(lat,lon); + } + + public Point2D.Double screen_point(Point screen) { + return new Point2D.Double(screen.x + offset_x, screen.y + offset_y); + } + + public AltosUILatLon screen_lat_lon(Point screen) { + return lat_lon(screen_point(screen)); + } + + public Point2D.Double point(AltosUILatLon lat_lon) { + double x, y; + double e; + + x = lat_lon.lon * scale_x; + + e = Math.sin(Math.toRadians(lat_lon.lat)); + e = Math.max(e,-(1-1.0E-15)); + e = Math.min(e, 1-1.0E-15 ); + + y = 0.5*Math.log((1+e)/(1-e))*-scale_y; + + return new Point2D.Double(x, y); + } + + public Point2D.Double screen(Point2D.Double point) { + return new Point2D.Double(point.x - offset_x, point.y - offset_y); + } + + public Point screen(Point point) { + return new Point((int) (point.x - offset_x + 0.5), + (int) (point.y - offset_y + 0.5)); + } + + public Rectangle screen(AltosUIMapRectangle map_rect) { + Point2D.Double ul = screen(map_rect.ul); + Point2D.Double lr = screen(map_rect.lr); + + return new Rectangle((int) ul.x, (int) ul.y, (int) (lr.x - ul.x), (int) (lr.y - ul.y)); + } + + public Point2D.Double screen(AltosUILatLon lat_lon) { + return screen(point(lat_lon)); + } + + private boolean has_location; + + public boolean has_location() { + return has_location; + } + + public AltosUIMapTransform(int width, int height, int zoom, AltosUILatLon centre_lat_lon) { + scale_x = 256/360.0 * Math.pow(2, zoom); + scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom); + + Point2D.Double centre_pt = point(centre_lat_lon); + + has_location = (centre_lat_lon.lat != 0 || centre_lat_lon.lon != 0); + offset_x = centre_pt.x - width / 2.0; + offset_y = centre_pt.y - height / 2.0; + } +} diff --git a/altosuilib/AltosUIMapView.java b/altosuilib/AltosUIMapView.java new file mode 100644 index 00000000..c558118b --- /dev/null +++ b/altosuilib/AltosUIMapView.java @@ -0,0 +1,462 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import java.awt.image.*; +import javax.swing.*; +import java.io.*; +import java.lang.*; +import java.awt.geom.*; +import java.util.*; +import java.util.concurrent.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosUIMapView extends Canvas implements MouseMotionListener, MouseListener, MouseWheelListener, ComponentListener, AltosUIMapTileListener, AltosUIMapStoreListener { + + AltosUIMapPath path = new AltosUIMapPath(); + + AltosUIMapLine line = new AltosUIMapLine(); + + LinkedList marks = new LinkedList(); + + LinkedList zoom_listeners = new LinkedList(); + + boolean have_boost = false; + boolean have_landed = false; + + ConcurrentHashMap tiles = new ConcurrentHashMap(); + + static final int default_zoom = 15; + static final int min_zoom = 3; + static final int max_zoom = 21; + static final int px_size = 512; + + int load_radius; + AltosUILatLon load_centre = null; + AltosUIMapTileListener load_listener; + + int zoom = default_zoom; + int maptype = AltosUIMap.maptype_default; + + long user_input_time; + + /* Milliseconds to wait after user action before auto-scrolling + */ + static final long auto_scroll_delay = 20 * 1000; + + AltosUIMapTransform transform; + AltosUILatLon centre; + + public void set_font() { + line.set_font(AltosUILib.value_font); + for (AltosUIMapTile tile : tiles.values()) + tile.set_font(AltosUILib.value_font); + } + + private boolean is_drag_event(MouseEvent e) { + return e.getModifiers() == InputEvent.BUTTON1_MASK; + } + + Point drag_start; + + private void drag(MouseEvent e) { + if (drag_start == null) + return; + + int dx = e.getPoint().x - drag_start.x; + int dy = e.getPoint().y - drag_start.y; + + AltosUILatLon new_centre = transform.screen_lat_lon(new Point(getWidth() / 2 - dx, getHeight() / 2 - dy)); + centre (new_centre.lat, new_centre.lon); + drag_start = e.getPoint(); + } + + private void drag_start(MouseEvent e) { + drag_start = e.getPoint(); + } + + private void notice_user_input() { + user_input_time = System.currentTimeMillis(); + } + + private boolean recent_user_input() { + return (System.currentTimeMillis() - user_input_time) < auto_scroll_delay; + } + + /* MouseMotionListener methods */ + + public void mouseDragged(MouseEvent e) { + notice_user_input(); + if (is_drag_event(e)) + drag(e); + else { + line.dragged(e, transform); + repaint(); + } + } + + public void mouseMoved(MouseEvent e) { + } + + /* MouseListener methods */ + public void mouseClicked(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mousePressed(MouseEvent e) { + notice_user_input(); + if (is_drag_event(e)) + drag_start(e); + else + line.pressed(e, transform); + } + + public void mouseReleased(MouseEvent e) { + } + + /* MouseWheelListener methods */ + + public void mouseWheelMoved(MouseWheelEvent e) { + int zoom_change = e.getWheelRotation(); + + notice_user_input(); + AltosUILatLon mouse_lat_lon = transform.screen_lat_lon(e.getPoint()); + set_zoom(zoom() - zoom_change); + + Point2D.Double new_mouse = transform.screen(mouse_lat_lon); + + int dx = getWidth()/2 - e.getPoint().x; + int dy = getHeight()/2 - e.getPoint().y; + + AltosUILatLon new_centre = transform.screen_lat_lon(new Point((int) new_mouse.x + dx, (int) new_mouse.y + dy)); + + centre(new_centre.lat, new_centre.lon); + } + + /* ComponentListener methods */ + + public void componentHidden(ComponentEvent e) { + } + + public void componentMoved(ComponentEvent e) { + } + + public void componentResized(ComponentEvent e) { + set_transform(); + } + + public void componentShown(ComponentEvent e) { + set_transform(); + } + + public void repaint(Rectangle r, int pad) { + repaint(r.x - pad, r.y - pad, r.width + pad*2, r.height + pad*2); + } + + public void repaint(AltosUIMapRectangle rect, int pad) { + repaint (transform.screen(rect), pad); + } + + private boolean far_from_centre(AltosUILatLon lat_lon) { + + if (centre == null || transform == null) + return true; + + Point2D.Double screen = transform.screen(lat_lon); + + int width = getWidth(); + int dx = Math.abs ((int) screen.x - width/2); + + if (dx > width / 4) + return true; + + int height = getHeight(); + int dy = Math.abs ((int) screen.y - height/2); + + if (dy > height / 4) + return true; + + return false; + } + + public void show(AltosState state, AltosListenerState listener_state) { + + /* If insufficient gps data, nothing to update + */ + AltosGPS gps = state.gps; + + if (gps == null) + return; + + if (!gps.locked && gps.nsat < 4) + return; + + AltosUIMapRectangle damage = path.add(gps.lat, gps.lon, state.state); + + switch (state.state) { + case AltosLib.ao_flight_boost: + if (!have_boost) { + add_mark(gps.lat, gps.lon, state.state); + have_boost = true; + } + break; + case AltosLib.ao_flight_landed: + if (!have_landed) { + add_mark(gps.lat, gps.lon, state.state); + have_landed = true; + } + break; + } + + if (damage != null) + repaint(damage, AltosUIMapPath.stroke_width); + maybe_centre(gps.lat, gps.lon); + } + + private void set_transform() { + Rectangle bounds = getBounds(); + + transform = new AltosUIMapTransform(bounds.width, bounds.height, zoom, centre); + repaint(); + } + + public boolean set_zoom(int zoom) { + if (min_zoom <= zoom && zoom <= max_zoom && zoom != this.zoom) { + this.zoom = zoom; + tiles.clear(); + set_transform(); + + for (AltosUIMapZoomListener listener : zoom_listeners) + listener.zoom_changed(this.zoom); + + return true; + } + return false; + } + + public void add_zoom_listener(AltosUIMapZoomListener listener) { + if (!zoom_listeners.contains(listener)) + zoom_listeners.add(listener); + } + + public void remove_zoom_listener(AltosUIMapZoomListener listener) { + zoom_listeners.remove(listener); + } + + public void set_load_params(double lat, double lon, int radius, AltosUIMapTileListener listener) { + load_centre = new AltosUILatLon(lat, lon); + load_radius = radius; + load_listener = listener; + centre(lat, lon); + make_tiles(); + for (AltosUIMapTile tile : tiles.values()) { + tile.add_store_listener(this); + if (tile.store_status() != AltosUIMapStore.loading) + listener.notify_tile(tile, tile.store_status()); + } + repaint(); + } + + public boolean all_fetched() { + for (AltosUIMapTile tile : tiles.values()) { + if (tile.store_status() == AltosUIMapStore.loading) + return false; + } + return true; + } + + public boolean set_maptype(int maptype) { + if (maptype != this.maptype) { + this.maptype = maptype; + tiles.clear(); + repaint(); + return true; + } + return false; + } + + public int get_maptype() { + return maptype; + } + + public int zoom() { + return zoom; + } + + public void centre(AltosUILatLon lat_lon) { + centre = lat_lon; + set_transform(); + } + + public void centre(double lat, double lon) { + centre(new AltosUILatLon(lat, lon)); + } + + public void maybe_centre(double lat, double lon) { + AltosUILatLon lat_lon = new AltosUILatLon(lat, lon); + if (centre == null || (!recent_user_input() && far_from_centre(lat_lon))) + centre(lat_lon); + } + + private VolatileImage create_back_buffer() { + return getGraphicsConfiguration().createCompatibleVolatileImage(getWidth(), getHeight()); + } + + private Point floor(Point2D.Double point) { + return new Point ((int) Math.floor(point.x / px_size) * px_size, + (int) Math.floor(point.y / px_size) * px_size); + } + + private Point ceil(Point2D.Double point) { + return new Point ((int) Math.ceil(point.x / px_size) * px_size, + (int) Math.ceil(point.y / px_size) * px_size); + } + + private void make_tiles() { + Point upper_left; + Point lower_right; + + if (load_centre != null) { + Point centre = floor(transform.point(load_centre)); + + upper_left = new Point(centre.x - load_radius * px_size, + centre.y - load_radius * px_size); + lower_right = new Point(centre.x + load_radius * px_size, + centre.y + load_radius * px_size); + } else { + upper_left = floor(transform.screen_point(new Point(0, 0))); + lower_right = floor(transform.screen_point(new Point(getWidth(), getHeight()))); + } + LinkedList to_remove = new LinkedList(); + + for (Point point : tiles.keySet()) { + if (point.x < upper_left.x || lower_right.x < point.x || + point.y < upper_left.y || lower_right.y < point.y) { + to_remove.add(point); + } + } + + for (Point point : to_remove) + tiles.remove(point); + + AltosUIMapCache.set_cache_size(((lower_right.y - upper_left.y) / px_size + 1) * ((lower_right.x - upper_left.x) / px_size + 1)); + for (int y = upper_left.y; y <= lower_right.y; y += px_size) { + for (int x = upper_left.x; x <= lower_right.x; x += px_size) { + Point point = new Point(x, y); + + if (!tiles.containsKey(point)) { + AltosUILatLon ul = transform.lat_lon(new Point2D.Double(x, y)); + AltosUILatLon center = transform.lat_lon(new Point2D.Double(x + px_size/2, y + px_size/2)); + AltosUIMapTile tile = new AltosUIMapTile(this, ul, center, zoom, maptype, + px_size, AltosUILib.value_font); + tiles.put(point, tile); + } + } + } + } + + /* AltosUIMapTileListener methods */ + public void notify_tile(AltosUIMapTile tile, int status) { + for (Point point : tiles.keySet()) { + if (tile == tiles.get(point)) { + Point screen = transform.screen(point); + repaint(screen.x, screen.y, px_size, px_size); + } + } + } + + /* AltosUIMapStoreListener methods */ + public void notify_store(AltosUIMapStore store, int status) { + if (load_listener != null) { + for (AltosUIMapTile tile : tiles.values()) + if (store.equals(tile.store)) + load_listener.notify_tile(tile, status); + } + } + + private void do_paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + make_tiles(); + + for (AltosUIMapTile tile : tiles.values()) + tile.paint(g2d, transform); + + synchronized(marks) { + for (AltosUIMapMark mark : marks) + mark.paint(g2d, transform); + } + + path.paint(g2d, transform); + + line.paint(g2d, transform); + } + + public void paint(Graphics g) { + + VolatileImage back_buffer = create_back_buffer(); + do { + GraphicsConfiguration gc = getGraphicsConfiguration(); + int code = back_buffer.validate(gc); + if (code == VolatileImage.IMAGE_INCOMPATIBLE) + back_buffer = create_back_buffer(); + + Graphics g_back = back_buffer.getGraphics(); + g_back.setClip(g.getClip()); + do_paint(g_back); + g_back.dispose(); + + g.drawImage(back_buffer, 0, 0, this); + } while (back_buffer.contentsLost()); + back_buffer.flush(); + } + + public void update(Graphics g) { + paint(g); + } + + public void add_mark(double lat, double lon, int state) { + synchronized(marks) { + marks.add(new AltosUIMapMark(lat, lon, state)); + } + repaint(); + } + + public void clear_marks() { + synchronized(marks) { + marks.clear(); + } + } + + public AltosUIMapView() { + centre(0, 0); + + addComponentListener(this); + addMouseMotionListener(this); + addMouseListener(this); + addMouseWheelListener(this); + set_font(); + } +} diff --git a/altosuilib/AltosUIMapZoomListener.java b/altosuilib/AltosUIMapZoomListener.java new file mode 100644 index 00000000..02e8bb51 --- /dev/null +++ b/altosuilib/AltosUIMapZoomListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_2; + +public interface AltosUIMapZoomListener { + abstract public void zoom_changed(int zoom); +} diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index b90669ce..466cfd99 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -33,11 +33,6 @@ altosuilib_JAVA = \ AltosUISeries.java \ AltosUIVersion.java \ AltosUSBDevice.java \ - AltosSiteMap.java \ - AltosSiteMapCache.java \ - AltosSiteMapPreload.java \ - AltosSiteMapTile.java \ - AltosSiteMapImage.java \ AltosVoice.java \ AltosDisplayThread.java \ AltosDeviceUIDialog.java \ @@ -65,8 +60,23 @@ altosuilib_JAVA = \ AltosBTDevice.java \ AltosBTDeviceIterator.java \ AltosBTManage.java \ - AltosBTKnown.java - + AltosBTKnown.java \ + AltosUIMap.java \ + AltosUIMapView.java \ + AltosUIMapLine.java \ + AltosUIMapMark.java \ + AltosUIMapPath.java \ + AltosUIMapTile.java \ + AltosUIMapCache.java \ + AltosUIMapImage.java \ + AltosUIMapTransform.java \ + AltosUIMapRectangle.java \ + AltosUIMapZoomListener.java \ + AltosUIMapTileListener.java \ + AltosUIMapPreload.java \ + AltosUIMapStore.java \ + AltosUIMapStoreListener.java \ + AltosUILatLon.java JAR=altosuilib_$(ALTOSUILIB_VERSION).jar diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index c61b245e..2503d53e 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -67,7 +67,7 @@ public class TeleGPS JTabbedPane pane; - AltosSiteMap sitemap; + AltosUIMap map; TeleGPSInfo gps_info; AltosInfoTable info_table; @@ -167,7 +167,7 @@ public class TeleGPS } void load_maps() { - new AltosSiteMapPreload(this); + new AltosUIMapPreload(this); } void disconnect() { @@ -438,9 +438,9 @@ public class TeleGPS c.gridwidth = 2; bag.add(pane, c); - sitemap = new AltosSiteMap(); - pane.add("Site Map", sitemap); - displays.add(sitemap); + map = new AltosUIMap(); + pane.add("Map", map); + displays.add(map); gps_info = new TeleGPSInfo(); pane.add("Info", gps_info); @@ -578,7 +578,7 @@ public class TeleGPS } else { double lat = Double.parseDouble(args[i+1]); double lon = Double.parseDouble(args[i+2]); - AltosSiteMap.prefetchMaps(lat, lon); + AltosUIMap.prefetch_maps(lat, lon); i += 2; } } else if (args[i].equals("--replay")) diff --git a/telegps/TeleGPSGraphUI.java b/telegps/TeleGPSGraphUI.java index b7fc4caa..fbc9657e 100644 --- a/telegps/TeleGPSGraphUI.java +++ b/telegps/TeleGPSGraphUI.java @@ -38,7 +38,7 @@ public class TeleGPSGraphUI extends AltosUIFrame JTabbedPane pane; AltosGraph graph; AltosUIEnable enable; - AltosSiteMap map; + AltosUIMap map; AltosState state; AltosFlightStats stats; AltosGraphDataSet graphDataSet; @@ -69,7 +69,7 @@ public class TeleGPSGraphUI extends AltosUIFrame graph = new AltosGraph(enable, stats, graphDataSet); statsTable = new AltosFlightStatsTable(stats); - map = new AltosSiteMap(); + map = new AltosUIMap(); pane.add("Flight Graph", graph.panel); pane.add("Configure Graph", enable); -- cgit v1.2.3 From c11b2f5caa3fbe2bc977e716ec1c3ccee9e75884 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Jun 2014 14:41:13 -0700 Subject: altosui/telegps: Switch to AltosUIIndicator and AltosUIFlightTab Removes replicated code across all flight tabs Signed-off-by: Keith Packard --- altosui/AltosAscent.java | 498 +++++++------------------------------- altosui/AltosCompanionInfo.java | 2 + altosui/AltosDescent.java | 524 ++++++---------------------------------- altosui/AltosFlightStatus.java | 63 ++++- altosui/AltosFlightUI.java | 68 +++--- altosui/AltosIgnitor.java | 175 +++----------- altosui/AltosLanded.java | 302 +++++------------------ altosui/AltosPad.java | 461 ++++++++--------------------------- telegps/TeleGPS.java | 68 ++++-- telegps/TeleGPSInfo.java | 68 ++---- telegps/TeleGPSState.java | 87 ++----- telegps/TeleGPSStatus.java | 38 +++ 12 files changed, 564 insertions(+), 1790 deletions(-) (limited to 'altosui/AltosFlightUI.java') diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index c3225709..3bc80406 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -17,451 +17,151 @@ package altosui; +import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class AltosAscent extends JComponent implements AltosFlightDisplay, HierarchyListener { - GridBagLayout layout; - JLabel cur, max; +public class AltosAscent extends AltosUIFlightTab { + JLabel cur, max; - private AltosState last_state; - private AltosListenerState last_listener_state; + class Height extends AltosUIUnitsIndicator { - public class AscentStatus implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - AltosLights lights; - double v; - AltosUnits units; - - void show() { - value.setVisible(true); - lights.setVisible(true); - label.setVisible(true); - } - - void hide() { - value.setVisible(false); - lights.setVisible(false); - label.setVisible(false); - } - - void show(AltosState state, AltosListenerState listener_state) {} - - void show(String s) { - show(); - value.setText(s); - } - - void show(double v) { - this.v = v; - show(units.show(8, v)); - } - - void show(String format, double v) { - show(String.format(format, v)); - } - - void reset() { - value.setText(""); - lights.set(false); - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); - } - - public void units_changed(boolean imperial_units) { - if (units != null) - show(v); + public double value(AltosState state, int i) { + if (i == 0) + return state.height(); + else + return state.max_height(); } - public AscentStatus (GridBagLayout layout, int y, AltosUnits units, String text) { - this.units = units; - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - lights = new AltosLights(); - c.gridx = 0; c.gridy = y; - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(lights, c); - add(lights); - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 1; c.gridy = y; - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 2; c.gridy = y; - c.gridwidth = 2; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(value, c); - add(value); - + public Height(Container container, int y) { + super(container, y, AltosConvert.height, "Height", 2, false, 1); } } - public abstract class AscentValue implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - double v; - AltosUnits units; - - abstract void show(AltosState state, AltosListenerState listener_state); - - void reset() { - value.setText(""); - } - - void show() { - label.setVisible(true); - value.setVisible(true); - } - - void show(String s) { - show(); - value.setText(s); - } - - void show(double v) { - this.v = v; - show(units.show(8, v)); - } - - void show(String format, double v) { - show(String.format(format, v)); - } - - void hide() { - label.setVisible(false); - value.setVisible(false); + class Speed extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { + if (i == 0) + return state.speed(); + else + return state.max_speed(); } - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); + public Speed(Container container, int y) { + super(container, y, AltosConvert.speed, "Speed", 2, false, 1); } + } - public void units_changed(boolean imperial_units) { - if (units != null) - show(v); - } + class Accel extends AltosUIUnitsIndicator { + public boolean hide(double v) { return v == AltosLib.MISSING; } - public AscentValue (GridBagLayout layout, int y, AltosUnits units, String text) { - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 1; c.gridy = y; - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 2; c.gridy = y; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.BOTH; - c.gridwidth = 2; - c.weightx = 1; - layout.setConstraints(value, c); - add(value); + public double value(AltosState state, int i) { + if (i == 0) + return state.acceleration(); + else + return state.max_acceleration(); } - public AscentValue (GridBagLayout layout, int y, String text) { - this(layout, y, null, text); + public Accel(Container container, int y) { + super(container, y, AltosConvert.accel, "Acceleration", 2, false, 1); } } - public class AscentValueHold implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - JTextField max_value; - double max; - AltosUnits units; - double v; + class Orient extends AltosUIUnitsIndicator { - void show(AltosState state, AltosListenerState listener_state) {} - - void reset() { - value.setText(""); - max_value.setText(""); - max = AltosLib.MISSING; - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); - max_value.setFont(Altos.value_font); - } + public boolean hide(double v) { return v == AltosLib.MISSING; } - public void units_changed(boolean imperial_units) { - show(v, max); - } - - void show(double v, double max) { - this.v = v; - this.max = max; - if (v == AltosLib.MISSING) { - value.setText("Missing"); - } else { - value.setText(units.show(8, v)); - } - if (max == AltosLib.MISSING) - max_value.setText("Missing"); + public double value(AltosState state, int i) { + if (i == 0) + return state.orient(); else - max_value.setText(units.show(8, max)); + return state.max_orient(); } - void hide() { - label.setVisible(false); - value.setVisible(false); - max_value.setVisible(false); + public Orient(Container container, int y) { + super(container, y, AltosConvert.orient, "Tilt Angle", 2, false, 1); } - public AscentValueHold (GridBagLayout layout, int y, AltosUnits units, String text) { - this.units = units; - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 1; c.gridy = y; - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 2; c.gridy = y; - c.anchor = GridBagConstraints.EAST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(value, c); - add(value); - - max_value = new JTextField(Altos.text_width); - max_value.setEditable(false); - max_value.setFont(Altos.value_font); - max_value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 3; c.gridy = y; - c.anchor = GridBagConstraints.EAST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(max_value, c); - add(max_value); - } } - class Height extends AscentValueHold { - void show (AltosState state, AltosListenerState listener_state) { - show(state.height(), state.max_height()); - } - public Height (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.height, "Height"); + class Apogee extends AltosUIUnitsIndicator { + + public double value(AltosState state, int i) { + return state.apogee_voltage; } - } - Height height; + public boolean good(double v) { return v >= AltosLib.ao_igniter_good; } + public boolean hide(double v) { return v == AltosLib.MISSING; } - class Speed extends AscentValueHold { - void show (AltosState state, AltosListenerState listener_state) { - show(state.speed(), state.max_speed()); - } - public Speed (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.speed, "Speed"); + public Apogee (Container container, int y) { + super(container, y, AltosConvert.voltage, "Apogee Igniter Voltage", 1, true, 2); } } - Speed speed; - - class Accel extends AscentValueHold { - void show (AltosState state, AltosListenerState listener_state) { - show(state.acceleration(), state.max_acceleration()); + class Main extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { + return state.main_voltage; } - public Accel (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.accel, "Acceleration"); - } - } - Accel accel; + public boolean good(double v) { return v >= AltosLib.ao_igniter_good; } + public boolean hide(double v) { return v == AltosLib.MISSING; } - class Orient extends AscentValueHold { - void show (AltosState state, AltosListenerState listener_state) { - show(state.orient(), state.max_orient()); - } - public Orient (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.orient, "Tilt Angle"); + public Main (Container container, int y) { + super(container, y, AltosConvert.voltage, "Main Igniter Voltage", 1, true, 2); } } - Orient orient; + class Lat extends AltosUIUnitsIndicator { - String pos(double p, String pos, String neg) { - String h = pos; - if (p < 0) { - h = neg; - p = -p; + public boolean hide(AltosState state, int i) { + return state.gps == null || !state.gps.connected; } - int deg = (int) Math.floor(p); - double min = (p - Math.floor(p)) * 60.0; - return String.format("%s %4d° %9.6f", h, deg, min); - } - class Apogee extends AscentStatus { - void show (AltosState state, AltosListenerState listener_state) { - show("%4.2f V", state.apogee_voltage); - lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good); - } - public Apogee (GridBagLayout layout, int y) { - super(layout, y, null, "Apogee Igniter Voltage"); + public double value(AltosState state, int i) { + if (state.gps == null) + return AltosLib.MISSING; + if (!state.gps.connected) + return AltosLib.MISSING; + return state.gps.lat; } - } - - Apogee apogee; - class Main extends AscentStatus { - void show (AltosState state, AltosListenerState listener_state) { - show("%4.2f V", state.main_voltage); - lights.set(state.main_voltage >= AltosLib.ao_igniter_good); - } - public Main (GridBagLayout layout, int y) { - super(layout, y, null, "Main Igniter Voltage"); + Lat (Container container, int y) { + super (container, y, AltosConvert.latitude, "Latitude", 1, false, 2); } } - Main main; + class Lon extends AltosUIUnitsIndicator { - class Lat extends AscentValue { - void show (AltosState state, AltosListenerState listener_state) { - if (state.gps != null && state.gps.connected && state.gps.lat != AltosLib.MISSING) - show(pos(state.gps.lat,"N", "S")); - else - show("???"); + public boolean hide(AltosState state, int i) { + return state.gps == null || !state.gps.connected; } - public Lat (GridBagLayout layout, int y) { - super (layout, y, "Latitude"); - } - } - Lat lat; - - class Lon extends AscentValue { - void show (AltosState state, AltosListenerState listener_state) { - if (state.gps != null && state.gps.connected && state.gps.lon != AltosLib.MISSING) - show(pos(state.gps.lon,"E", "W")); - else - show("???"); - } - public Lon (GridBagLayout layout, int y) { - super (layout, y, "Longitude"); + public double value(AltosState state, int i) { + if (state.gps == null) + return AltosLib.MISSING; + if (!state.gps.connected) + return AltosLib.MISSING; + return state.gps.lon; } - } - Lon lon; - - public void reset() { - lat.reset(); - lon.reset(); - main.reset(); - apogee.reset(); - height.reset(); - speed.reset(); - accel.reset(); - orient.reset(); + Lon (Container container, int y) { + super (container, y, AltosConvert.longitude, "Longitude", 1, false, 2); + } } public void font_size_changed(int font_size) { - cur.setFont(Altos.label_font); - max.setFont(Altos.label_font); - lat.font_size_changed(font_size); - lon.font_size_changed(font_size); - main.font_size_changed(font_size); - apogee.font_size_changed(font_size); - height.font_size_changed(font_size); - speed.font_size_changed(font_size); - accel.font_size_changed(font_size); - orient.font_size_changed(font_size); - } - - public void units_changed(boolean imperial_units) { - lat.units_changed(imperial_units); - lon.units_changed(imperial_units); - main.units_changed(imperial_units); - apogee.units_changed(imperial_units); - height.units_changed(imperial_units); - speed.units_changed(imperial_units); - accel.units_changed(imperial_units); - orient.units_changed(imperial_units); - } - - public void show(AltosState state, AltosListenerState listener_state) { - if (!isShowing()) { - last_state = state; - last_listener_state = listener_state; - return; - } - - if (state.gps != null && state.gps.connected) { - lat.show(state, listener_state); - lon.show(state, listener_state); - } else { - lat.hide(); - lon.hide(); - } - height.show(state, listener_state); - if (state.main_voltage != AltosLib.MISSING) - main.show(state, listener_state); - else - main.hide(); - if (state.apogee_voltage != AltosLib.MISSING) - apogee.show(state, listener_state); - else - apogee.hide(); - speed.show(state, listener_state); - accel.show(state, listener_state); - if (state.orient() != AltosLib.MISSING) - orient.show(state, listener_state); - else - orient.hide(); + super.font_size_changed(font_size); + cur.setFont(AltosUILib.label_font); + max.setFont(AltosUILib.label_font); } public void labels(GridBagLayout layout, int y) { GridBagConstraints c; cur = new JLabel("Current"); - cur.setFont(Altos.label_font); + cur.setFont(AltosUILib.label_font); c = new GridBagConstraints(); c.gridx = 2; c.gridy = y; c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); @@ -469,7 +169,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay, Hiera add(cur); max = new JLabel("Maximum"); - max.setFont(Altos.label_font); + max.setFont(AltosUILib.label_font); c.gridx = 3; c.gridy = y; layout.setConstraints(max, c); add(max); @@ -479,38 +179,16 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay, Hiera return "Ascent"; } - public void hierarchyChanged(HierarchyEvent e) { - if (last_state != null && isShowing()) { - AltosState state = last_state; - AltosListenerState listener_state = last_listener_state; - - last_state = null; - last_listener_state = null; - show(state, listener_state); - } - } - public AltosAscent() { - layout = new GridBagLayout(); - - setLayout(layout); - - /* Elements in ascent display: - * - * lat - * lon - * height - */ int y = 0; labels(layout, y++); - height = new Height(layout, y++); - speed = new Speed(layout, y++); - accel = new Accel(layout, y++); - orient = new Orient(layout, y++); - lat = new Lat(layout, y++); - lon = new Lon(layout, y++); - apogee = new Apogee(layout, y++); - main = new Main(layout, y++); - addHierarchyListener(this); + add(new Height(this, y++)); + add(new Speed(this, y++)); + add(new Accel(this, y++)); + add(new Orient(this, y++)); + add(new Lat(this, y++)); + add(new Lon(this, y++)); + add(new Apogee(this, y++)); + add(new Main(this, y++)); } } diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 514ce611..e7b335ac 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -87,6 +87,8 @@ public class AltosCompanionInfo extends JTable implements AltosFlightDisplay { } } + public String getName() { return "Companion"; } + public void show(AltosState state, AltosListenerState listener_state) { if (state == null) return; diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 11bd6dbf..36fc1613 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -17,516 +17,148 @@ package altosui; +import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class AltosDescent extends JComponent implements AltosFlightDisplay, HierarchyListener { - GridBagLayout layout; +public class AltosDescent extends AltosUIFlightTab { - private AltosState last_state; - private AltosListenerState last_listener_state; - - public abstract class DescentStatus implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - AltosLights lights; - - abstract void show(AltosState state, AltosListenerState listener_state); - - void show() { - label.setVisible(true); - value.setVisible(true); - lights.setVisible(true); - } - - void show(String s) { - show(); - value.setText(s); - } - - void show(String format, double value) { - show(String.format(format, value)); - } - - void hide() { - label.setVisible(false); - value.setVisible(false); - lights.setVisible(false); - } - - void reset() { - value.setText(""); - lights.set(false); - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); - } - - public void units_changed(boolean imperial_units) { - } - - public DescentStatus (GridBagLayout layout, int y, String text) { - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - lights = new AltosLights(); - c.gridx = 0; c.gridy = y; - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(lights, c); - add(lights); - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 1; c.gridy = y; - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.gridwidth = 3; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 4; c.gridy = y; - c.gridwidth = 1; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(value, c); - add(value); + class Height extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { return state.height(); } + public Height (Container container, int x, int y) { + super (container, x, y, AltosConvert.height, "Height"); } } - public abstract class DescentValue implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - AltosUnits units; - double v; - String last_value = ""; - - void reset() { - value.setText(""); - } - - abstract void show(AltosState state, AltosListenerState listener_state); - - void show() { - label.setVisible(true); - value.setVisible(true); - } + class Speed extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { return state.speed(); } - void hide() { - label.setVisible(false); - value.setVisible(false); - } - - void show(String v) { - show(); - - if (!last_value.equals(v)) { - value.setText(v); - last_value = v; - } - } - - void show(double v) { - this.v = v; - if (v == AltosLib.MISSING) - show("Missing"); - else - show(units.show(8, v)); - } - - void show(String format, double v) { - if (v == AltosLib.MISSING) - show("Missing"); - else - show(String.format(format, v)); - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); - } - - public void units_changed(boolean imperial_units) { - if (units != null) - show(v); - } - - public DescentValue (GridBagLayout layout, int x, int y, AltosUnits units, String text) { - this.units = units; - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = x + 1; c.gridy = y; - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - add(label, c); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = x + 2; c.gridy = y; - c.gridwidth = 1; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - add(value, c); - } - - public DescentValue (GridBagLayout layout, int x, int y, String text) { - this(layout, x, y, null, text); + public Speed (Container container, int x, int y) { + super (container, x, y, AltosConvert.speed, "Speed"); } } - public abstract class DescentDualValue implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value1; - JTextField value2; + class Lat extends AltosUIUnitsIndicator { - void reset() { - value1.setText(""); - value2.setText(""); - } + public boolean hide (AltosState state, int i) { return state.gps == null || !state.gps.connected; } - void show() { - label.setVisible(true); - value1.setVisible(true); - value2.setVisible(true); + public double value(AltosState state, int i) { + if (state.gps == null) + return AltosLib.MISSING; + if (!state.gps.connected) + return AltosLib.MISSING; + return state.gps.lat; } - void hide() { - label.setVisible(false); - value1.setVisible(false); - value2.setVisible(false); - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value1.setFont(Altos.value_font); - value2.setFont(Altos.value_font); - } - - public void units_changed(boolean imperial_units) { - } - - abstract void show(AltosState state, AltosListenerState listener_state); - - void show(String v1, String v2) { - show(); - value1.setText(v1); - value2.setText(v2); - } - void show(String f1, double v1, String f2, double v2) { - show(); - value1.setText(String.format(f1, v1)); - value2.setText(String.format(f2, v2)); - } - - public DescentDualValue (GridBagLayout layout, int x, int y, String text) { - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = x + 1; c.gridy = y; - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - value1 = new JTextField(Altos.text_width); - value1.setEditable(false); - value1.setFont(Altos.value_font); - value1.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = x + 2; c.gridy = y; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(value1, c); - add(value1); - - value2 = new JTextField(Altos.text_width); - value2.setEditable(false); - value2.setFont(Altos.value_font); - value2.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = x + 4; c.gridy = y; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - c.gridwidth = 1; - layout.setConstraints(value2, c); - add(value2); - } - } - - class Height extends DescentValue { - void show (AltosState state, AltosListenerState listener_state) { - show(state.height()); - } - public Height (GridBagLayout layout, int x, int y) { - super (layout, x, y, AltosConvert.height, "Height"); + public Lat (Container container, int x, int y) { + super (container, x, y, AltosConvert.latitude, "Latitude"); } } - Height height; + class Lon extends AltosUIUnitsIndicator { + public boolean hide (AltosState state, int i) { return state.gps == null || !state.gps.connected; } - class Speed extends DescentValue { - void show (AltosState state, AltosListenerState listener_state) { - show(state.speed()); - } - public Speed (GridBagLayout layout, int x, int y) { - super (layout, x, y, AltosConvert.speed, "Speed"); + public double value(AltosState state, int i) { + if (state.gps == null) + return AltosLib.MISSING; + if (!state.gps.connected) + return AltosLib.MISSING; + return state.gps.lon; } - } - - Speed speed; - String pos(double p, String pos, String neg) { - String h = pos; - if (p < 0) { - h = neg; - p = -p; + public Lon (Container container, int x, int y) { + super (container, x, y, AltosConvert.longitude, "Longitude"); } - int deg = (int) Math.floor(p); - double min = (p - Math.floor(p)) * 60.0; - return String.format("%s %d° %9.6f", h, deg, min); } - class Lat extends DescentValue { - void show (AltosState state, AltosListenerState listener_state) { - if (state.gps != null && state.gps.connected && state.gps.lat != AltosLib.MISSING) - show(pos(state.gps.lat,"N", "S")); - else - show("???"); - } - public Lat (GridBagLayout layout, int x, int y) { - super (layout, x, y, "Latitude"); + class Apogee extends AltosUIUnitsIndicator { + public boolean hide(double v) { return v == AltosLib.MISSING; } + public double value(AltosState state, int i) { return state.apogee_voltage; } + public double good() { return AltosLib.ao_igniter_good; } + + public Apogee (Container container, int y) { + super(container, 0, y, 3, AltosConvert.voltage, "Apogee Igniter Voltage", 1, true, 3); } } - Lat lat; + class Main extends AltosUIUnitsIndicator { + public boolean hide(double v) { return v == AltosLib.MISSING; } + public double value(AltosState state, int i) { return state.main_voltage; } + public double good() { return AltosLib.ao_igniter_good; } - class Lon extends DescentValue { - void show (AltosState state, AltosListenerState listener_state) { - if (state.gps != null && state.gps.connected && state.gps.lon != AltosLib.MISSING) - show(pos(state.gps.lon,"W", "E")); - else - show("???"); - } - public Lon (GridBagLayout layout, int x, int y) { - super (layout, x, y, "Longitude"); + public Main (Container container, int y) { + super(container, 0, y, 3, AltosConvert.voltage, "Main Igniter Voltage", 1, true, 3); } } - Lon lon; - - class Distance extends DescentValue { - void show(AltosState state, AltosListenerState listener_state) { + class Distance extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { if (state.from_pad != null) - show(state.from_pad.distance); + return state.from_pad.distance; else - show("???"); + return AltosLib.MISSING; } - public Distance (GridBagLayout layout, int x, int y) { - super(layout, x, y, AltosConvert.distance, "Ground Distance"); + public Distance(Container container, int x, int y) { + super(container, x, y, AltosConvert.distance, "Ground Distance"); } } - Distance distance; - - - class Apogee extends DescentStatus { - void show (AltosState state, AltosListenerState listener_state) { - show("%4.2f V", state.apogee_voltage); - lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good); + class Range extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { + return state.range; } - public Apogee (GridBagLayout layout, int y) { - super(layout, y, "Apogee Igniter Voltage"); + public Range (Container container, int x, int y) { + super (container, x, y, AltosConvert.distance, "Range"); } } - Apogee apogee; - - class Main extends DescentStatus { - void show (AltosState state, AltosListenerState listener_state) { - show("%4.2f V", state.main_voltage); - lights.set(state.main_voltage >= AltosLib.ao_igniter_good); - } - public Main (GridBagLayout layout, int y) { - super(layout, y, "Main Igniter Voltage"); - } - } - - Main main; - - class Bearing extends DescentDualValue { - void show (AltosState state, AltosListenerState listener_state) { - if (state.from_pad != null) { + class Bearing extends AltosUIIndicator { + public void show (AltosState state, AltosListenerState listener_state) { + if (state.from_pad != null && state.from_pad.bearing != AltosLib.MISSING) { show( String.format("%3.0f°", state.from_pad.bearing), state.from_pad.bearing_words( AltosGreatCircle.BEARING_LONG)); } else { - show("???", "???"); + show("Missing", "Missing"); } } - public Bearing (GridBagLayout layout, int x, int y) { - super (layout, x, y, "Bearing"); + public Bearing (Container container, int x, int y) { + super (container, x, y, 1, "Bearing", 2, false, 1, 2); } } - Bearing bearing; - - class Range extends DescentValue { - void show (AltosState state, AltosListenerState listener_state) { - show(state.range); - } - public Range (GridBagLayout layout, int x, int y) { - super (layout, x, y, AltosConvert.distance, "Range"); - } - } - - Range range; - - class Elevation extends DescentValue { - void show (AltosState state, AltosListenerState listener_state) { - show("%3.0f°", state.elevation); - } - public Elevation (GridBagLayout layout, int x, int y) { - super (layout, x, y, "Elevation"); - } - } - - Elevation elevation; - - public void reset() { - lat.reset(); - lon.reset(); - height.reset(); - speed.reset(); - bearing.reset(); - range.reset(); - distance.reset(); - elevation.reset(); - main.reset(); - apogee.reset(); - } - - public void font_size_changed(int font_size) { - lat.font_size_changed(font_size); - lon.font_size_changed(font_size); - height.font_size_changed(font_size); - speed.font_size_changed(font_size); - bearing.font_size_changed(font_size); - range.font_size_changed(font_size); - distance.font_size_changed(font_size); - elevation.font_size_changed(font_size); - main.font_size_changed(font_size); - apogee.font_size_changed(font_size); - } - - public void units_changed(boolean imperial_units) { - lat.units_changed(imperial_units); - lon.units_changed(imperial_units); - height.units_changed(imperial_units); - speed.units_changed(imperial_units); - bearing.units_changed(imperial_units); - range.units_changed(imperial_units); - distance.units_changed(imperial_units); - elevation.units_changed(imperial_units); - main.units_changed(imperial_units); - apogee.units_changed(imperial_units); - } - - public void show(AltosState state, AltosListenerState listener_state) { - if (!isShowing()) { - last_state = state; - last_listener_state = listener_state; - return; + class Elevation extends AltosUIIndicator { + public void show (AltosState state, AltosListenerState listener_state) { + if (state.elevation == AltosLib.MISSING) + show("Missing"); + else + show("%3.0f°", state.elevation); } - - height.show(state, listener_state); - speed.show(state, listener_state); - if (state.gps != null && state.gps.connected) { - bearing.show(state, listener_state); - range.show(state, listener_state); - distance.show(state, listener_state); - elevation.show(state, listener_state); - lat.show(state, listener_state); - lon.show(state, listener_state); - } else { - bearing.hide(); - range.hide(); - distance.hide(); - elevation.hide(); - lat.hide(); - lon.hide(); + public Elevation (Container container, int x, int y) { + super (container, x, y, "Elevation", 1, false, 1); } - if (state.main_voltage != AltosLib.MISSING) - main.show(state, listener_state); - else - main.hide(); - if (state.apogee_voltage != AltosLib.MISSING) - apogee.show(state, listener_state); - else - apogee.hide(); } public String getName() { return "Descent"; } - public void hierarchyChanged(HierarchyEvent e) { - if (last_state != null && isShowing()) { - AltosState state = last_state; - AltosListenerState listener_state = last_listener_state; - - last_state = null; - last_listener_state = null; - show(state, listener_state); - } - } - public AltosDescent() { - layout = new GridBagLayout(); - - setLayout(layout); - /* Elements in descent display */ - speed = new Speed(layout, 0, 0); - height = new Height(layout, 2, 0); - elevation = new Elevation(layout, 0, 1); - range = new Range(layout, 2, 1); - bearing = new Bearing(layout, 0, 2); - distance = new Distance(layout, 0, 3); - lat = new Lat(layout, 0, 4); - lon = new Lon(layout, 2, 4); - - apogee = new Apogee(layout, 5); - main = new Main(layout, 6); - addHierarchyListener(this); + add(new Speed(this, 0, 0)); + add(new Height(this, 2, 0)); + add(new Elevation(this, 0, 1)); + add(new Range(this, 2, 1)); + add(new Bearing(this, 0, 2)); + add(new Distance(this, 0, 3)); + add(new Lat(this, 0, 4)); + add(new Lon(this, 2, 4)); + add(new Apogee(this, 5)); + add(new Main(this, 6)); } } diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index b27deba9..46c0b387 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -25,11 +25,21 @@ import org.altusmetrum.altosuilib_2.*; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - public class FlightValue { + public abstract class FlightValue { JLabel label; JTextField value; - void show(AltosState state, AltosListenerState listener_state) {} + void show() { + label.setVisible(true); + value.setVisible(true); + } + + void hide() { + label.setVisible(false); + value.setVisible(false); + } + + abstract void show(AltosState state, AltosListenerState listener_state); void reset() { value.setText(""); @@ -83,6 +93,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay void show(AltosState state, AltosListenerState listener_state) { if (!same_call(state.callsign)) { + show(); value.setText(state.callsign); if (state.callsign == null) setVisible(false); @@ -91,6 +102,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay last_call = state.callsign; } } + + public void reset() { + super.reset(); + last_call = ""; + } + public Call (GridBagLayout layout, int x) { super (layout, x, "Callsign"); } @@ -103,6 +120,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay int last_serial = -1; void show(AltosState state, AltosListenerState listener_state) { if (state.serial != last_serial) { + show(); if (state.serial == AltosLib.MISSING) value.setText("none"); else @@ -110,6 +128,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay last_serial = state.serial; } } + + public void reset() { + super.reset(); + last_serial = -1; + } + public Serial (GridBagLayout layout, int x) { super (layout, x, "Serial"); } @@ -123,6 +147,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay void show(AltosState state, AltosListenerState listener_state) { if (state.flight != last_flight) { + show(); if (state.flight == AltosLib.MISSING) value.setText("none"); else @@ -130,6 +155,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay last_flight = state.flight; } } + + public void reset() { + super.reset(); + last_flight = -1; + } + public Flight (GridBagLayout layout, int x) { super (layout, x, "Flight"); } @@ -143,10 +174,21 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay void show(AltosState state, AltosListenerState listener_state) { if (state.state != last_state) { - value.setText(state.state_name()); + if (state.state == AltosLib.ao_flight_stateless) + hide(); + else { + show(); + value.setText(state.state_name()); + } last_state = state.state; } } + + public void reset() { + super.reset(); + last_state = -1; + } + public FlightState (GridBagLayout layout, int x) { super (layout, x, "State"); } @@ -160,6 +202,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay void show(AltosState state, AltosListenerState listener_state) { if (state.rssi() != last_rssi) { + show(); value.setText(String.format("%d", state.rssi())); if (state.rssi == AltosLib.MISSING) setVisible(false); @@ -168,6 +211,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay last_rssi = state.rssi(); } } + + public void reset() { + super.reset(); + last_rssi = 10000; + } + public RSSI (GridBagLayout layout, int x) { super (layout, x, "RSSI"); } @@ -186,6 +235,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay last_secs = secs; } } + + public void reset() { + super.reset(); + last_secs = -1; + } + public LastPacket(GridBagLayout layout, int x) { super (layout, x, "Age"); } @@ -228,6 +283,8 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay return d.height; } + public String getName() { return "Flight Status"; } + public AltosFlightStatus() { layout = new GridBagLayout(); diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index f2bd70a0..43deb631 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -20,6 +20,7 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; +import java.util.*; import java.util.concurrent.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; @@ -29,6 +30,8 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { AltosFlightReader reader; AltosDisplayThread thread; + LinkedList displays; + JTabbedPane pane; AltosPad pad; @@ -56,6 +59,8 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { return ascent; if (state.state <= Altos.ao_flight_main) return descent; + if (state.state == AltosLib.ao_flight_stateless) + return descent; return landed; } @@ -74,37 +79,18 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { } public void reset() { - pad.reset(); - ignitor.reset(); - ascent.reset(); - descent.reset(); - landed.reset(); - flightInfo.clear(); - sitemap.reset(); + for (AltosFlightDisplay d : displays) + d.reset(); } public void font_size_changed(int font_size) { - pad.font_size_changed(font_size); - ignitor.font_size_changed(font_size); - ascent.font_size_changed(font_size); - descent.font_size_changed(font_size); - landed.font_size_changed(font_size); - flightStatus.font_size_changed(font_size); - flightInfo.font_size_changed(font_size); - sitemap.font_size_changed(font_size); - companion.font_size_changed(font_size); + for (AltosFlightDisplay d : displays) + d.font_size_changed(font_size); } public void units_changed(boolean imperial_units) { - pad.units_changed(imperial_units); - ignitor.units_changed(imperial_units); - ascent.units_changed(imperial_units); - descent.units_changed(imperial_units); - landed.units_changed(imperial_units); - flightStatus.units_changed(imperial_units); - flightInfo.units_changed(imperial_units); - sitemap.units_changed(imperial_units); - companion.units_changed(imperial_units); + for (AltosFlightDisplay d : displays) + d.units_changed(imperial_units); } AltosFlightStatusUpdate status_update; @@ -115,8 +101,6 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { if (state == null) state = new AltosState(); - pad.show(state, listener_state); - if (state.state != Altos.ao_flight_startup) { if (!has_state) { pane.setTitleAt(0, "Launch Pad"); @@ -127,10 +111,6 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { } } - ascent.show(state, listener_state); - descent.show(state, listener_state); - landed.show(state, listener_state); - JComponent tab = which_tab(state); if (tab != cur_tab) { if (cur_tab == pane.getSelectedComponent()) { @@ -138,15 +118,12 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { } cur_tab = tab; } - flightStatus.show(state, listener_state); - flightInfo.show(state, listener_state); if (ignitor.should_show(state)) { if (!has_ignitor) { pane.add("Ignitor", ignitor); has_ignitor = true; } - ignitor.show(state, listener_state); } else { if (has_ignitor) { pane.remove(ignitor); @@ -159,25 +136,33 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { pane.add("Companion", companion); has_companion= true; } - companion.show(state, listener_state); } 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; } - sitemap.show(state, listener_state); } else { if (has_map) { pane.remove(sitemap); has_map = false; } } + + for (AltosFlightDisplay d : displays) { + try { + d.show(state, listener_state); + } catch (Exception e) { + System.out.printf("Exception showing %s\n", d.getName()); + e.printStackTrace(); + } + } } public void set_exit_on_close() { @@ -194,6 +179,8 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) { AltosUIPreferences.set_component(this); + displays = new LinkedList(); + voice = in_voice; reader = in_reader; @@ -282,6 +269,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { /* Flight status is always visible */ flightStatus = new AltosFlightStatus(); + displays.add(flightStatus); c.gridx = 0; c.gridy = 1; c.fill = GridBagConstraints.HORIZONTAL; @@ -296,21 +284,29 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { pane = new JTabbedPane(); pad = new AltosPad(); + displays.add(pad); pane.add("Status", pad); ignitor = new AltosIgnitor(); + displays.add(ignitor); ascent = new AltosAscent(); + displays.add(ascent); descent = new AltosDescent(); + displays.add(descent); landed = new AltosLanded(reader); + displays.add(landed); flightInfo = new AltosInfoTable(); + displays.add(flightInfo); pane.add("Table", new JScrollPane(flightInfo)); companion = new AltosCompanionInfo(); + displays.add(companion); has_companion = false; has_state = false; sitemap = new AltosUIMap(); + displays.add(sitemap); has_map = false; /* Make the tabbed pane use the rest of the window space */ diff --git a/altosui/AltosIgnitor.java b/altosui/AltosIgnitor.java index 73318117..990a87e6 100644 --- a/altosui/AltosIgnitor.java +++ b/altosui/AltosIgnitor.java @@ -18,147 +18,37 @@ package altosui; import java.awt.*; +import java.awt.event.*; import javax.swing.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class AltosIgnitor extends JComponent implements AltosFlightDisplay { - GridBagLayout layout; +public class AltosIgnitor extends AltosUIFlightTab { - public class LaunchStatus implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - AltosLights lights; - - void show(AltosState state, AltosListenerState listener_state) {} - - void reset() { - value.setText(""); - lights.set(false); - } - - public void show() { - label.setVisible(true); - value.setVisible(true); - lights.setVisible(true); - } - - void show(String s) { - show(); - value.setText(s); - } - - void show(String format, double value) { - show(String.format(format, value)); - } - - void show(String format, int value) { - show(String.format(format, value)); - } - - public void hide() { - label.setVisible(false); - value.setVisible(false); - lights.setVisible(false); - } - - public void dispose() { - hide(); - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); - } - - public void units_changed(boolean imperial_units) { - } - - public void set_label(String text) { - label.setText(text); - } - - public LaunchStatus (GridBagLayout layout, int y, String text) { - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - lights = new AltosLights(); - c.gridx = 0; c.gridy = y; - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(lights, c); - add(lights); - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 1; c.gridy = y; - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 2; c.gridy = y; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(value, c); - add(value); + public class Ignitor extends AltosUIUnitsIndicator { + int ignitor; + public double value(AltosState state, int i) { + if (state.ignitor_voltage == null || + state.ignitor_voltage.length < ignitor) + return AltosLib.MISSING; + return state.ignitor_voltage[ignitor]; } - } - class Ignitor extends LaunchStatus { - int ignitor; + public double good() { return AltosLib.ao_igniter_good; } - void show (AltosState state, AltosListenerState listener_state) { - if (state == null || state.ignitor_voltage[ignitor] == AltosLib.MISSING) { - hide(); - } else { - show("%4.2f V", state.ignitor_voltage[ignitor]); - lights.set(state.ignitor_voltage[ignitor] >= AltosLib.ao_igniter_good); - } - } - - public Ignitor (GridBagLayout layout, int y) { - super(layout, y, String.format ("%s Voltage", AltosLib.ignitor_name(y))); + public Ignitor (AltosUIFlightTab container, int y) { + super(container, y, AltosConvert.voltage, String.format ("%s Voltage", AltosLib.ignitor_name(y)), 1, true, 1); ignitor = y; } } Ignitor[] ignitors; - public void reset() { - if (ignitors == null) - return; - for (int i = 0; i < ignitors.length; i++) - ignitors[i].reset(); - } - - public void font_size_changed(int font_size) { - if (ignitors == null) - return; - for (int i = 0; i < ignitors.length; i++) - ignitors[i].font_size_changed(font_size); - } - - public void units_changed(boolean imperial_units) { - } - public void show(AltosState state, AltosListenerState listener_state) { - make_ignitors(state); - if (ignitors == null) - return; - for (int i = 0; i < ignitors.length; i++) - ignitors[i].show(state, listener_state); - return; + if (isShowing()) + make_ignitors(state); + super.show(state, listener_state); } public boolean should_show(AltosState state) { @@ -170,33 +60,32 @@ public class AltosIgnitor extends JComponent implements AltosFlightDisplay { } void make_ignitors(AltosState state) { - int n = state == null ? 0 : state.ignitor_voltage.length; + int n = (state == null || state.ignitor_voltage == null) ? 0 : state.ignitor_voltage.length; + int old_n = ignitors == null ? 0 : ignitors.length; - if (n > 0) { + if (n != old_n) { - if (ignitors == null || ignitors.length != n) { - layout = new GridBagLayout(); + if (ignitors != null) { + for (int i = 0; i < ignitors.length; i++) { + remove(ignitors[i]); + ignitors[i].remove(this); + ignitors = null; + } + } - setLayout(layout); + if (n > 0) { + setVisible(true); ignitors = new Ignitor[n]; - for (int i = 0; i < n; i++) - ignitors[i] = new Ignitor(layout, i); - } - } else { - if (ignitors != null) { - for (int i = 0; i < n; i++) - ignitors[i].dispose(); - ignitors = null; + for (int i = 0; i < n; i++) { + ignitors[i] = new Ignitor(this, i); + add(ignitors[i]); + } + } else setVisible(false); - } } } public String getName() { return "Ignitors"; } - - public AltosIgnitor() { - make_ignitors(null); - } } diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 760b2d64..dd5cf9ab 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -24,256 +24,91 @@ import java.io.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener, HierarchyListener { - GridBagLayout layout; - - private AltosState last_state; - private AltosListenerState last_listener_state; - - public abstract class LandedValue implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - AltosUnits units; - double v; - String last_value = ""; - - abstract void show(AltosState state, AltosListenerState listener_state); - - void reset() { - value.setText(""); - } - - void show() { - label.setVisible(true); - value.setVisible(true); - } - - void show(String s) { - show(); - if (!last_value.equals(s)) { - value.setText(s); - last_value = s; +public class AltosLanded extends AltosUIFlightTab implements ActionListener { + + class Bearing extends AltosUIIndicator { + public void show (AltosState state, AltosListenerState listener_state) { + if (state.from_pad != null && state.from_pad.bearing != AltosLib.MISSING) { + show( String.format("%3.0f°", state.from_pad.bearing), + state.from_pad.bearing_words( + AltosGreatCircle.BEARING_LONG)); + } else { + show("Missing", "Missing"); } } - - void show(double v) { - this.v = v; - if (v == AltosLib.MISSING) - show("Missing"); - else - show(units.show(8, v)); - } - - void show(String format, double v) { - show(String.format(format, v)); - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); - } - - public void units_changed(boolean imperial_units) { - if (units != null) - show(v); - } - - void hide() { - label.setVisible(false); - value.setVisible(false); - } - - public LandedValue (GridBagLayout layout, int y, AltosUnits units, String text) { - this.units = units; - - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 0; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); - c.anchor = GridBagConstraints.WEST; - c.weightx = 0; - c.fill = GridBagConstraints.VERTICAL; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 1; c.gridy = y; - c.anchor = GridBagConstraints.WEST; - c.weightx = 1; - c.fill = GridBagConstraints.BOTH; - layout.setConstraints(value, c); - add(value); - } - - public LandedValue (GridBagLayout layout, int y, String text) { - this(layout, y, null, text); + public Bearing (Container container, int y) { + super (container, y, "Bearing", 2); } } - String pos(double p, String pos, String neg) { - String h = pos; - if (p < 0) { - h = neg; - p = -p; - } - int deg = (int) Math.floor(p); - double min = (p - Math.floor(p)) * 60.0; - return String.format("%s %4d° %9.6f", h, deg, min); - } - - class Lat extends LandedValue { - void show (AltosState state, AltosListenerState listener_state) { - show(); - if (state.gps != null && state.gps.connected && state.gps.lat != AltosLib.MISSING) - show(pos(state.gps.lat,"N", "S")); + class Distance extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { + if (state.from_pad != null) + return state.from_pad.distance; else - show("???"); - } - public Lat (GridBagLayout layout, int y) { - super (layout, y, "Latitude"); + return AltosLib.MISSING; } - } - - Lat lat; - class Lon extends LandedValue { - void show (AltosState state, AltosListenerState listener_state) { - show(); - if (state.gps != null && state.gps.connected && state.gps.lon != AltosLib.MISSING) - show(pos(state.gps.lon,"E", "W")); - else - show("???"); - } - public Lon (GridBagLayout layout, int y) { - super (layout, y, "Longitude"); + public Distance(Container container, int y) { + super(container, y, AltosConvert.distance, "Ground Distance", 2); } } - Lon lon; + class Lat extends AltosUIUnitsIndicator { - class Bearing extends LandedValue { - void show (AltosState state, AltosListenerState listener_state) { - show(); - if (state.from_pad != null) - show("%3.0f°", state.from_pad.bearing); - else - show("???"); - } - public Bearing (GridBagLayout layout, int y) { - super (layout, y, "Bearing"); - } - } - - Bearing bearing; + public boolean hide (AltosState state, int i) { return state.gps == null || !state.gps.connected; } - class Distance extends LandedValue { - void show (AltosState state, AltosListenerState listener_state) { - show(); - if (state.from_pad != null) - show(state.from_pad.distance); - else - show("???"); + public double value(AltosState state, int i) { + if (state.gps == null) + return AltosLib.MISSING; + if (!state.gps.connected) + return AltosLib.MISSING; + return state.gps.lat; } - public Distance (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.distance, "Distance"); - } - } - - Distance distance; - class Height extends LandedValue { - void show (AltosState state, AltosListenerState listener_state) { - show(state.max_height()); - } - public Height (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.height, "Maximum Height"); + public Lat (Container container, int y) { + super (container, y, AltosConvert.latitude, "Latitude", 2); } } - Height height; + class Lon extends AltosUIUnitsIndicator { + public boolean hide (AltosState state, int i) { return state.gps == null || !state.gps.connected; } - class Speed extends LandedValue { - void show (AltosState state, AltosListenerState listener_state) { - show(state.max_speed()); + public double value(AltosState state, int i) { + if (state.gps == null) + return AltosLib.MISSING; + if (!state.gps.connected) + return AltosLib.MISSING; + return state.gps.lon; } - public Speed (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.speed, "Maximum Speed"); + + public Lon (Container container, int y) { + super (container, y, AltosConvert.longitude, "Longitude", 2); } } - Speed speed; + class MaxHeight extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { return state.max_height(); } - class Accel extends LandedValue { - void show (AltosState state, AltosListenerState listener_state) { - show(state.max_acceleration()); - } - public Accel (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.accel, "Maximum Acceleration"); + public MaxHeight (Container container, int y) { + super (container, y, AltosConvert.height, "Maximum Height", 2); } } - Accel accel; - - public void reset() { - lat.reset(); - lon.reset(); - bearing.reset(); - distance.reset(); - height.reset(); - speed.reset(); - accel.reset(); - } + class MaxSpeed extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { return state.max_speed(); } - public void font_size_changed(int font_size) { - lat.font_size_changed(font_size); - lon.font_size_changed(font_size); - bearing.font_size_changed(font_size); - distance.font_size_changed(font_size); - height.font_size_changed(font_size); - speed.font_size_changed(font_size); - accel.font_size_changed(font_size); + public MaxSpeed (Container container, int y) { + super (container, y, AltosConvert.speed, "Maximum Speed", 2); + } } - public void units_changed(boolean imperial_units) { - lat.units_changed(imperial_units); - lon.units_changed(imperial_units); - bearing.units_changed(imperial_units); - distance.units_changed(imperial_units); - height.units_changed(imperial_units); - speed.units_changed(imperial_units); - accel.units_changed(imperial_units); - } + class MaxAccel extends AltosUIUnitsIndicator { + public double value(AltosState state, int i) { return state.max_acceleration(); } - public void show(AltosState state, AltosListenerState listener_state) { - if (!isShowing()) { - last_state = state; - last_listener_state = listener_state; - return; + public MaxAccel (Container container, int y) { + super (container, y, AltosConvert.speed, "Maximum acceleration", 2); } - - if (state.gps != null && state.gps.connected) { - bearing.show(state, listener_state); - distance.show(state, listener_state); - lat.show(state, listener_state); - lon.show(state, listener_state); - } else { - bearing.hide(); - distance.hide(); - lat.hide(); - lon.hide(); - } - height.show(state, listener_state); - speed.show(state, listener_state); - accel.show(state, listener_state); - if (reader.backing_file() != null) - graph.setEnabled(true); } JButton graph; @@ -316,32 +151,17 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio return "Landed"; } - public void hierarchyChanged(HierarchyEvent e) { - if (last_state != null && isShowing()) { - AltosState state = last_state; - AltosListenerState listener_state = last_listener_state; - - last_state = null; - last_listener_state = null; - show(state, listener_state); - } - } - public AltosLanded(AltosFlightReader in_reader) { - layout = new GridBagLayout(); - reader = in_reader; - setLayout(layout); - /* Elements in descent display */ - bearing = new Bearing(layout, 0); - distance = new Distance(layout, 1); - lat = new Lat(layout, 2); - lon = new Lon(layout, 3); - height = new Height(layout, 4); - speed = new Speed(layout, 5); - accel = new Accel(layout, 6); + add(new Bearing(this, 0)); + add(new Distance(this, 1)); + add(new Lat(this, 2)); + add(new Lon(this, 3)); + add(new MaxHeight(this, 4)); + add(new MaxSpeed(this, 5)); + add(new MaxAccel(this, 6)); graph = new JButton ("Graph Flight"); graph.setActionCommand("graph"); @@ -350,7 +170,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 7; + c.gridx = 1; c.gridy = 7; c.insets = new Insets(10, 10, 10, 10); c.anchor = GridBagConstraints.WEST; c.weightx = 0; diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 3294949c..6b5fd150 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -17,280 +17,73 @@ package altosui; -import java.awt.*; -import javax.swing.*; +import java.util.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class AltosPad extends JComponent implements AltosFlightDisplay { - GridBagLayout layout; +public class AltosPad extends AltosUIFlightTab { - public class LaunchStatus implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - AltosLights lights; - - void show(AltosState state, AltosListenerState listener_state) {} - - void reset() { - value.setText(""); - lights.set(false); - } - - public void show() { - label.setVisible(true); - value.setVisible(true); - lights.setVisible(true); - } - - void show(String s) { - show(); - value.setText(s); - } - - void show(String format, double value) { - show(String.format(format, value)); - } - - void show(String format, int value) { - show(String.format(format, value)); - } - - public void hide() { - label.setVisible(false); - value.setVisible(false); - lights.setVisible(false); - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); - } - - public void units_changed(boolean imperial_units) { - } - - public void set_label(String text) { - label.setText(text); - } - - public LaunchStatus (GridBagLayout layout, int y, String text) { - GridBagConstraints c = new GridBagConstraints(); - c.weighty = 1; - - lights = new AltosLights(); - c.gridx = 0; c.gridy = y; - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(lights, c); - add(lights); - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 1; c.gridy = y; - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 2; c.gridy = y; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(value, c); - add(value); - - } + class Battery extends AltosUIVoltageIndicator { + public double voltage(AltosState state) { return state.battery_voltage; } + public double good() { return AltosLib.ao_battery_good; } + public Battery (AltosUIFlightTab container, int y) { super(container, y, "Battery Voltage", 2); } } - public abstract class LaunchValue implements AltosFontListener, AltosUnitsListener { - JLabel label; - JTextField value; - AltosUnits units; - double v; - - abstract void show(AltosState state, AltosListenerState listener_state); - - void show() { - label.setVisible(true); - value.setVisible(true); - } - - void hide() { - label.setVisible(false); - value.setVisible(false); - } - - public void font_size_changed(int font_size) { - label.setFont(Altos.label_font); - value.setFont(Altos.value_font); - } - - public void units_changed(boolean imperial_units) { - if (units != null) - show(v); - } - - void show(String s) { - show(); - value.setText(s); - } - - void show(double v) { - this.v = v; - show(units.show(8, v)); - } - - void show(String format, double v) { - show(String.format(format, v)); - } - - public void set_label(String text) { - label.setText(text); - } - - void reset() { - value.setText(""); - } - - public LaunchValue (GridBagLayout layout, int y, AltosUnits units, String text) { - this.units = units; - - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.weighty = 1; - - label = new JLabel(text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 1; c.gridy = y; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(Altos.text_width); - value.setEditable(false); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 2; c.gridy = y; - c.anchor = GridBagConstraints.EAST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(value, c); - add(value); - } - - public LaunchValue (GridBagLayout layout, int y, String text) { - this(layout, y, null, text); - } + class Apogee extends AltosUIVoltageIndicator { + public boolean hide(double v) { return v == AltosLib.MISSING; } + public double voltage(AltosState state) { return state.apogee_voltage; } + public double good() { return AltosLib.ao_igniter_good; } + public Apogee (AltosUIFlightTab container, int y) { super(container, y, "Apogee Igniter Voltage", 2); } } - class Voltage extends LaunchStatus { - - double voltage(AltosState state) { return AltosLib.MISSING; }; - double good() { return 0; }; - - double last_voltage = -1; - - void show (AltosState state, AltosListenerState listener_state) { - double voltage = AltosLib.MISSING; - if (state != null) - voltage = voltage(state); - - if (voltage != last_voltage) { - if (voltage == AltosLib.MISSING) - hide(); - else { - show("%4.2f V", voltage); - lights.set(voltage >= good()); - } - last_voltage = voltage; - } - } - public Voltage (GridBagLayout layout, int y, String name) { super(layout, y, name); } - } - - - class Battery extends Voltage { - double voltage(AltosState state) { return state.battery_voltage; } - double good() { return AltosLib.ao_battery_good; } - - public Battery (GridBagLayout layout, int y) { - super(layout, y, "Battery Voltage"); - } - + class Main extends AltosUIVoltageIndicator { + public boolean hide(double v) { return v == AltosLib.MISSING; } + public double voltage(AltosState state) { return state.main_voltage; } + public double good() { return AltosLib.ao_igniter_good; } + public Main (AltosUIFlightTab container, int y) { super(container, y, "Main Igniter Voltage", 2); } } - Battery battery; - - class Apogee extends Voltage { - double voltage(AltosState state) { return state.apogee_voltage; } - double good() { return AltosLib.ao_igniter_good; } - public Apogee (GridBagLayout layout, int y) { super(layout, y, "Apogee Igniter Voltage"); } - } - - Apogee apogee; - - class Main extends Voltage { - double voltage(AltosState state) { return state.main_voltage; } - double good() { return AltosLib.ao_igniter_good; } - public Main (GridBagLayout layout, int y) { super(layout, y, "Main Igniter Voltage"); } - } - - Main main; - - class LoggingReady extends LaunchStatus { - void show (AltosState state, AltosListenerState listener_state) { + class LoggingReady extends AltosUIIndicator { + public void show (AltosState state, AltosListenerState listener_state) { if (state == null || state.flight == AltosLib.MISSING) { hide(); } else { if (state.flight != 0) { if (state.state <= Altos.ao_flight_pad) show("Ready to record"); - else if (state.state < Altos.ao_flight_landed) + else if (state.state < Altos.ao_flight_landed || + state.state == AltosLib.ao_flight_stateless) show("Recording data"); else show("Recorded data"); } else show("Storage full"); - lights.set(state.flight != 0); + set_lights(state.flight != 0); } } - public LoggingReady (GridBagLayout layout, int y) { - super(layout, y, "On-board Data Logging"); + public LoggingReady (AltosUIFlightTab container, int y) { + super(container, y, "On-board Data Logging", 1, true, 2); } } - LoggingReady logging_ready; - - class GPSLocked extends LaunchStatus { - void show (AltosState state, AltosListenerState listener_state) { + class GPSLocked extends AltosUIIndicator { + public void show (AltosState state, AltosListenerState listener_state) { if (state == null || state.gps == null) hide(); else { - show("%4d sats", state.gps.nsat); - lights.set(state.gps.locked && state.gps.nsat >= 4); + int sol = state.gps.nsat; + int sat = state.gps.cc_gps_sat == null ? 0 : state.gps.cc_gps_sat.length; + show("%d in solution", sol, "%d in view", sat); + set_lights(state.gps.locked && sol >= 4); } } - public GPSLocked (GridBagLayout layout, int y) { - super (layout, y, "GPS Locked"); + public GPSLocked (AltosUIFlightTab container, int y) { + super (container, y, "GPS Locked", 2, true, 1); } } - GPSLocked gps_locked; - - class GPSReady extends LaunchStatus { - void show (AltosState state, AltosListenerState listener_state) { + class GPSReady extends AltosUIIndicator { + public void show (AltosState state, AltosListenerState listener_state) { if (state == null || state.gps == null) hide(); else { @@ -298,48 +91,37 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { show("Ready"); else show("Waiting %d", state.gps_waiting); - lights.set(state.gps_ready); + set_lights(state.gps_ready); } } - public GPSReady (GridBagLayout layout, int y) { - super (layout, y, "GPS Ready"); + public GPSReady (AltosUIFlightTab container, int y) { + super (container, y, "GPS Ready", 1, true, 2); } } - GPSReady gps_ready; + class ReceiverBattery extends AltosUIVoltageIndicator { - class ReceiverBattery extends LaunchStatus { - void show (AltosState state, AltosListenerState listener_state) { - if (listener_state == null || listener_state.battery == AltosLib.MISSING) - hide(); - else { - show("%4.2f V", listener_state.battery); - lights.set(listener_state.battery > AltosLib.ao_battery_good); - } - } - public ReceiverBattery (GridBagLayout layout, int y) { - super(layout, y, "Receiver Battery"); - } - } + public double voltage(AltosState state) { return AltosLib.MISSING; } + + public boolean hide(double v) { return v == AltosLib.MISSING; } + public double good() { return AltosLib.ao_battery_good; } - ReceiverBattery receiver_battery; + public double value(AltosState state, AltosListenerState listener_state, int i) { + if (listener_state == null) + return AltosLib.MISSING; + return listener_state.battery; + } - String pos(double p, String pos, String neg) { - String h = pos; - if (p < 0) { - h = neg; - p = -p; + public ReceiverBattery (AltosUIFlightTab container, int y) { + super(container, y, "Receiver Battery", 2); } - int deg = (int) Math.floor(p); - double min = (p - Math.floor(p)) * 60.0; - return String.format("%s %4d° %9.6f", h, deg, min); } - class PadLat extends LaunchValue { + class PadLat extends AltosUIIndicator { - double last_lat = 1000; + double last_lat = AltosLib.MISSING - 1; - void show (AltosState state, AltosListenerState listener_state) { + public void show (AltosState state, AltosListenerState listener_state) { double lat = AltosLib.MISSING; String label = null; @@ -354,25 +136,29 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } if (lat != last_lat) { if (lat != AltosLib.MISSING) { - show(pos(lat,"N", "S")); + show(AltosConvert.latitude.show(10, lat)); set_label(label); } else hide(); last_lat = lat; } } - public PadLat (GridBagLayout layout, int y) { - super (layout, y, "Pad Latitude"); + + public void reset() { + super.reset(); + last_lat = AltosLib.MISSING - 1; } - } - PadLat pad_lat; + public PadLat (AltosUIFlightTab container, int y) { + super (container, y, "Pad Latitude", 1, false, 2); + } + } - class PadLon extends LaunchValue { + class PadLon extends AltosUIIndicator { - double last_lon = 1000; + double last_lon = AltosLib.MISSING - 1; - void show (AltosState state, AltosListenerState listener_state) { + public void show (AltosState state, AltosListenerState listener_state) { double lon = AltosLib.MISSING; String label = null; @@ -387,25 +173,29 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } if (lon != last_lon) { if (lon != AltosLib.MISSING) { - show(pos(lon,"E", "W")); + show(AltosConvert.longitude.show(10, lon)); set_label(label); } else hide(); last_lon = lon; } } - public PadLon (GridBagLayout layout, int y) { - super (layout, y, "Pad Longitude"); + + public void reset() { + super.reset(); + last_lon = AltosLib.MISSING - 1; } - } - PadLon pad_lon; + public PadLon (AltosUIFlightTab container, int y) { + super (container, y, "Pad Longitude", 1, false, 2); + } + } - class PadAlt extends LaunchValue { + class PadAlt extends AltosUIIndicator { - double last_alt = -1000000; + double last_alt = AltosLib.MISSING - 1; - void show (AltosState state, AltosListenerState listener_state) { + public void show (AltosState state, AltosListenerState listener_state) { double alt = AltosLib.MISSING; String label = null; @@ -420,97 +210,36 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } if (alt != last_alt) { if (alt != AltosLib.MISSING) { - show(alt); + show(AltosConvert.height.show(5, alt)); set_label(label); } else hide(); last_alt = alt; } } - public PadAlt (GridBagLayout layout, int y) { - super (layout, y, AltosConvert.height, "Pad Altitude"); - } - } - - PadAlt pad_alt; - - public void reset() { - battery.reset(); - apogee.reset(); - main.reset(); - logging_ready.reset(); - gps_locked.reset(); - gps_ready.reset(); - receiver_battery.reset(); - pad_lat.reset(); - pad_lon.reset(); - pad_alt.reset(); - } - public void font_size_changed(int font_size) { - battery.font_size_changed(font_size); - apogee.font_size_changed(font_size); - main.font_size_changed(font_size); - logging_ready.font_size_changed(font_size); - gps_locked.font_size_changed(font_size); - gps_ready.font_size_changed(font_size); - receiver_battery.font_size_changed(font_size); - pad_lat.font_size_changed(font_size); - pad_lon.font_size_changed(font_size); - pad_alt.font_size_changed(font_size); - } - - public void units_changed(boolean imperial_units) { - battery.units_changed(imperial_units); - apogee.units_changed(imperial_units); - main.units_changed(imperial_units); - logging_ready.units_changed(imperial_units); - gps_locked.units_changed(imperial_units); - gps_ready.units_changed(imperial_units); - receiver_battery.units_changed(imperial_units); - pad_lat.units_changed(imperial_units); - pad_lon.units_changed(imperial_units); - pad_alt.units_changed(imperial_units); - } + public void reset() { + super.reset(); + last_alt = AltosLib.MISSING - 1; + } - public void show(AltosState state, AltosListenerState listener_state) { - battery.show(state, listener_state); - apogee.show(state, listener_state); - main.show(state, listener_state); - logging_ready.show(state, listener_state); - pad_alt.show(state, listener_state); - receiver_battery.show(state, listener_state); - gps_locked.show(state, listener_state); - gps_ready.show(state, listener_state); - pad_lat.show(state, listener_state); - pad_lon.show(state, listener_state); + public PadAlt (AltosUIFlightTab container, int y) { + super (container, y, "Pad Altitude", 1, false, 2); + } } + public String getName() { return "Pad"; } public AltosPad() { - layout = new GridBagLayout(); - - setLayout(layout); - - /* Elements in pad display: - * - * Battery voltage - * Igniter continuity - * GPS lock status - * GPS ready status - * GPS location - * Pad altitude - * RSSI - */ - battery = new Battery(layout, 0); - apogee = new Apogee(layout, 1); - main = new Main(layout, 2); - logging_ready = new LoggingReady(layout, 3); - gps_locked = new GPSLocked(layout, 4); - gps_ready = new GPSReady(layout, 5); - receiver_battery = new ReceiverBattery(layout, 6); - pad_lat = new PadLat(layout, 7); - pad_lon = new PadLon(layout, 8); - pad_alt = new PadAlt(layout, 9); - show(null, null); + int y = 0; + add(new Battery(this, y++)); + add(new Apogee(this, y++)); + add(new Main(this, y++)); + add(new LoggingReady(this, y++)); + add(new GPSLocked(this, y++)); + add(new GPSReady(this, y++)); + add(new ReceiverBattery(this, y++)); + add(new PadLat(this, y++)); + add(new PadLon(this, y++)); + add(new PadAlt(this, y++)); } } diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index eddb47d8..6e68dd30 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -59,11 +59,13 @@ public class TeleGPS JMenu monitor_menu; JMenu device_menu; AltosFreqList frequencies; + ActionListener frequency_listener; Container bag; TeleGPSStatus telegps_status; TeleGPSStatusUpdate status_update; + javax.swing.Timer status_timer; JTabbedPane pane; @@ -174,7 +176,14 @@ public class TeleGPS void disconnect() { setTitle("TeleGPS"); stop_display(); - remove_frequency_menu(); + if (status_timer != null) { + status_timer.stop(); + status_timer = null; + status_update = null; + } + + telegps_status.disable_receive(); + disable_frequency_menu(); } void connect(AltosDevice device) { @@ -182,8 +191,7 @@ public class TeleGPS disconnect(); try { AltosFlightReader reader = new AltosTelemetryReader(new AltosSerial(device)); - set_reader(reader); - add_frequency_menu(device.getSerial(), reader); + set_reader(reader, device); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(this, ee.getMessage(), @@ -322,15 +330,12 @@ public class TeleGPS } } - void add_frequency_menu(int serial, final AltosFlightReader reader) { - // Channel menu - if (frequencies != null) - return; + void enable_frequency_menu(int serial, final AltosFlightReader reader) { - frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial)); - frequencies.set_product("Monitor"); - frequencies.set_serial(serial); - frequencies.addActionListener(new ActionListener() { + if (frequency_listener != null) + disable_frequency_menu(); + + frequency_listener = new ActionListener() { public void actionPerformed(ActionEvent e) { double frequency = frequencies.frequency(); try { @@ -340,22 +345,37 @@ public class TeleGPS } reader.save_frequency(); } - }); - menu_bar.add(frequencies); + }; + + frequencies.addActionListener(frequency_listener); + frequencies.set_product("Monitor"); + frequencies.set_serial(serial); + frequencies.set_frequency(AltosUIPreferences.frequency(serial)); + frequencies.setEnabled(true); + } - void remove_frequency_menu() { - if (frequencies != null) { - menu_bar.remove(frequencies); - menu_bar.repaint(); - frequencies = null; + void disable_frequency_menu() { + if (frequency_listener != null) { + frequencies.removeActionListener(frequency_listener); + frequencies.setEnabled(false); + frequency_listener = null; } + } - public void set_reader(AltosFlightReader reader) { + public void set_reader(AltosFlightReader reader, AltosDevice device) { + status_update = new TeleGPSStatusUpdate(telegps_status); + + status_timer = new javax.swing.Timer(100, status_update); + status_timer.start(); + setTitle(String.format("TeleGPS %s", reader.name)); thread = new TeleGPSDisplayThread(this, voice(), this, reader); thread.start(); + + if (device != null) + enable_frequency_menu(device.getSerial(), reader); } static int number_of_windows; @@ -414,6 +434,10 @@ public class TeleGPS file_menu = make_menu("File", file_menu_entries); monitor_menu = make_menu("Monitor", monitor_menu_entries); device_menu = make_menu("Device", device_menu_entries); + frequencies = new AltosFreqList(); + frequencies.setEnabled(false); + menu_bar.add(frequencies); + displays = new LinkedList(); int serial = -1; @@ -476,15 +500,11 @@ public class TeleGPS setVisible(true); add_window(); - - status_update = new TeleGPSStatusUpdate(telegps_status); - - new javax.swing.Timer(100, status_update).start(); } public TeleGPS(AltosFlightReader reader) { this(); - set_reader(reader); + set_reader(reader, null); } public TeleGPS(AltosDevice device) { diff --git a/telegps/TeleGPSInfo.java b/telegps/TeleGPSInfo.java index bbf4b472..e87fea90 100644 --- a/telegps/TeleGPSInfo.java +++ b/telegps/TeleGPSInfo.java @@ -24,13 +24,10 @@ import javax.swing.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class TeleGPSInfo extends JComponent implements AltosFlightDisplay, HierarchyListener { +public class TeleGPSInfo extends AltosUIFlightTab { JLabel cur, max; - private AltosState last_state; - private AltosListenerState last_listener_state; - abstract class Value extends AltosUIUnitsIndicator { public abstract void show(AltosState state, AltosListenerState listener_state); @@ -48,7 +45,6 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay, Hiera abstract class ValueHold extends DualValue { public void reset() { super.reset(); - last_values[1] = AltosLib.MISSING; } public ValueHold (Container container, int y, AltosUnits units, String text) { super(container, y, units, text); @@ -96,7 +92,9 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay, Hiera public void show (AltosState state, AltosListenerState listener_state) { double course = state.gps_course(); - if (course != AltosLib.MISSING) + if (course == AltosLib.MISSING) + show("Missing", "Missing"); + else show( String.format("%3.0f°", course), AltosConvert.bearing_to_words( AltosConvert.BEARING_LONG, @@ -124,7 +122,7 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay, Hiera if (state.gps != null && state.gps.connected && state.gps.lat != AltosLib.MISSING) show(pos(state.gps.lat,"N", "S")); else - show("???"); + show("Missing"); } public Lat (Container container, int y) { super (container, y, "Latitude", 1, false, 2); @@ -148,7 +146,7 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay, Hiera if (state.gps != null && state.gps.connected && state.gps.lon != AltosLib.MISSING) show(pos(state.gps.lon,"E", "W")); else - show("???"); + show("Missing"); } public Lon (Container container, int y) { super (container, y, "Longitude", 1, false, 2); @@ -173,34 +171,10 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay, Hiera } } - LinkedList indicators = new LinkedList(); - - public void reset() { - for (AltosUIIndicator i : indicators) - i.reset(); - } - public void font_size_changed(int font_size) { cur.setFont(AltosUILib.label_font); max.setFont(AltosUILib.label_font); - for (AltosUIIndicator i : indicators) - i.font_size_changed(font_size); - } - - public void units_changed(boolean imperial_units) { - for (AltosUIIndicator i : indicators) - i.units_changed(imperial_units); - } - - public void show(AltosState state, AltosListenerState listener_state) { - if (!isShowing()) { - last_state = state; - last_listener_state = listener_state; - return; - } - - for (AltosUIIndicator i : indicators) - i.show(state, listener_state); + super.font_size_changed(font_size); } public void labels(Container container, int y) { @@ -226,29 +200,15 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay, Hiera return "Location"; } - public void hierarchyChanged(HierarchyEvent e) { - if (last_state != null && isShowing()) { - AltosState state = last_state; - AltosListenerState listener_state = last_listener_state; - - last_state = null; - last_listener_state = null; - show(state, listener_state); - } - } - public TeleGPSInfo() { - setLayout(new GridBagLayout()); - int y = 0; labels(this, y++); - indicators.add(new Altitude(this, y++)); - indicators.add(new GroundSpeed(this, y++)); - indicators.add(new AscentRate(this, y++)); - indicators.add(new Course(this, y++)); - indicators.add(new Lat(this, y++)); - indicators.add(new Lon(this, y++)); - indicators.add(new GPSLocked(this, y++)); - addHierarchyListener(this); + add(new Altitude(this, y++)); + add(new GroundSpeed(this, y++)); + add(new AscentRate(this, y++)); + add(new Course(this, y++)); + add(new Lat(this, y++)); + add(new Lon(this, y++)); + add(new GPSLocked(this, y++)); } } diff --git a/telegps/TeleGPSState.java b/telegps/TeleGPSState.java index b10e8e70..a76182ed 100644 --- a/telegps/TeleGPSState.java +++ b/telegps/TeleGPSState.java @@ -24,12 +24,9 @@ import javax.swing.*; import org.altusmetrum.altoslib_4.*; import org.altusmetrum.altosuilib_2.*; -public class TeleGPSState extends JComponent implements AltosFlightDisplay, HierarchyListener { - GridBagLayout layout; - JLabel cur, max; +public class TeleGPSState extends AltosUIFlightTab { - private AltosState last_state; - private AltosListenerState last_listener_state; + JLabel cur, max; abstract class Value extends AltosUIUnitsIndicator { public Value (Container container, int y, AltosUnits units, String text) { @@ -44,10 +41,6 @@ public class TeleGPSState extends JComponent implements AltosFlightDisplay, Hier } abstract class ValueHold extends DualValue { - public void reset() { - super.reset(); - last_values[1] = AltosLib.MISSING; - } public ValueHold (Container container, int y, AltosUnits units, String text) { super(container, y, units, text); } @@ -103,12 +96,12 @@ public class TeleGPSState extends JComponent implements AltosFlightDisplay, Hier class Bearing extends AltosUIIndicator { public void show (AltosState state, AltosListenerState listener_state) { - if (state.from_pad != null) { + if (state.from_pad != null && state.from_pad.bearing != AltosLib.MISSING) { show( String.format("%3.0f°", state.from_pad.bearing), state.from_pad.bearing_words( AltosGreatCircle.BEARING_LONG)); } else { - show("???", "???"); + show("Missing", "Missing"); } } public Bearing (Container container, int y) { @@ -118,7 +111,10 @@ public class TeleGPSState extends JComponent implements AltosFlightDisplay, Hier class Elevation extends AltosUIIndicator { public void show (AltosState state, AltosListenerState listener_state) { - show("%3.0f°", state.elevation); + if (state.elevation == AltosLib.MISSING) + show("Missing"); + else + show("%3.0f°", state.elevation); } public Elevation (Container container, int y) { super (container, y, "Elevation", 1, false, 2); @@ -165,7 +161,6 @@ public class TeleGPSState extends JComponent implements AltosFlightDisplay, Hier } } - LinkedList indicators = new LinkedList(); public void labels(Container container, int y) { GridBagLayout layout = (GridBagLayout)(container.getLayout()); @@ -186,69 +181,27 @@ public class TeleGPSState extends JComponent implements AltosFlightDisplay, Hier add(max); } - public void reset() { - for (AltosUIIndicator i : indicators) - i.reset(); - } - public void font_size_changed(int font_size) { - for (AltosUIIndicator i : indicators) - i.font_size_changed(font_size); - } - - public void units_changed(boolean imperial_units) { - for (AltosUIIndicator i : indicators) - i.units_changed(imperial_units); - } - - public void show(AltosState state, AltosListenerState listener_state) { - if (!isShowing()) { - last_state = state; - last_listener_state = listener_state; - return; - } - - for (AltosUIIndicator i : indicators) - i.show(state, listener_state); + cur.setFont(AltosUILib.label_font); + max.setFont(AltosUILib.label_font); + super.font_size_changed(font_size); } public String getName() { return "Status"; } - public void hierarchyChanged(HierarchyEvent e) { - if (last_state != null && isShowing()) { - AltosState state = last_state; - AltosListenerState listener_state = last_listener_state; - - last_state = null; - last_listener_state = null; - show(state, listener_state); - } - } - public TeleGPSState() { - layout = new GridBagLayout(); - - setLayout(layout); - - /* Elements in state display: - * - * config_version; - * lon - * height - */ int y = 0; labels(this, y++); - indicators.add(new Height(this, y++)); - indicators.add(new Speed(this, y++)); - indicators.add(new Distance(this, y++)); - indicators.add(new Range(this, y++)); - indicators.add(new Bearing(this, y++)); - indicators.add(new Elevation(this, y++)); - indicators.add(new FirmwareVersion(this, y++)); - indicators.add(new FlightLogMax(this, y++)); - indicators.add(new BatteryVoltage(this, y++)); - addHierarchyListener(this); + add(new Height(this, y++)); + add(new Speed(this, y++)); + add(new Distance(this, y++)); + add(new Range(this, y++)); + add(new Bearing(this, y++)); + add(new Elevation(this, y++)); + add(new FirmwareVersion(this, y++)); + add(new FlightLogMax(this, y++)); + add(new BatteryVoltage(this, y++)); } } diff --git a/telegps/TeleGPSStatus.java b/telegps/TeleGPSStatus.java index 14706877..f3951a37 100644 --- a/telegps/TeleGPSStatus.java +++ b/telegps/TeleGPSStatus.java @@ -83,6 +83,12 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { else setVisible(true); } + + public void reset() { + super.reset(); + call = ""; + } + public Call (GridBagLayout layout, int x) { super (layout, x, "Callsign"); } @@ -101,6 +107,12 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { serial = state.serial; } } + + public void reset() { + super.reset(); + serial = -1; + } + public Serial (GridBagLayout layout, int x) { super (layout, x, "Serial"); } @@ -121,6 +133,12 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { last_flight = state.flight; } } + + public void reset() { + super.reset(); + last_flight = -1; + } + public Flight (GridBagLayout layout, int x) { super (layout, x, "Flight"); } @@ -143,6 +161,12 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { rssi = new_rssi; } } + + public void reset() { + super.reset(); + rssi = 10000; + } + public RSSI (GridBagLayout layout, int x) { super (layout, x, "RSSI"); } @@ -162,6 +186,16 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { last_secs = secs; } } + + void reset() { + super.reset(); + last_secs = -1; + } + + void disable() { + value.setText(""); + } + public LastPacket(GridBagLayout layout, int x) { super (layout, x, "Age"); } @@ -169,6 +203,10 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { LastPacket last_packet; + public void disable_receive() { + last_packet.disable(); + } + public void reset () { call.reset(); serial.reset(); -- cgit v1.2.3