From: Keith Packard Date: Thu, 20 Sep 2012 09:29:55 +0000 (+0200) Subject: Merge remote-tracking branch 'mjb/altosui_mjb' X-Git-Tag: 1.1.9.1~55 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=19243ecc9b5bbdcc069ae24acf1ca807322c84d8;hp=-c Merge remote-tracking branch 'mjb/altosui_mjb' --- 19243ecc9b5bbdcc069ae24acf1ca807322c84d8 diff --combined altosui/AltosAscent.java index 3fe517aa,945af7e2..007c74ec --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@@ -18,15 -18,7 +18,7 @@@ package altosui; import java.awt.*; - import java.awt.event.*; import javax.swing.*; - import javax.swing.filechooser.FileNameExtensionFilter; - import javax.swing.table.*; - import java.io.*; - import java.util.*; - import java.text.*; - import java.util.prefs.*; - import java.util.concurrent.LinkedBlockingQueue; import org.altusmetrum.AltosLib.*; public class AltosAscent extends JComponent implements AltosFlightDisplay { @@@ -51,20 -43,6 +43,20 @@@ } void show(AltosState state, int crc_errors) {} + + void show(String s) { + show(); + value.setText(s); + } + + void show(AltosUnits units, double v) { + show(units.show(8, v)); + } + + void show(String format, double v) { + show(String.format(format, v)); + } + void reset() { value.setText(""); lights.set(false); @@@ -126,19 -104,6 +118,19 @@@ value.setVisible(true); } + void show(String s) { + show(); + value.setText(s); + } + + void show(AltosUnits units, double 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); @@@ -295,7 -260,8 +287,7 @@@ class Apogee extends AscentStatus { void show (AltosState state, int crc_errors) { - show(); - value.setText(String.format("%4.2f V", state.drogue_sense)); + show("%4.2f V", state.drogue_sense); lights.set(state.drogue_sense > 3.2); } public Apogee (GridBagLayout layout, int y) { @@@ -307,7 -273,8 +299,7 @@@ class Main extends AscentStatus { void show (AltosState state, int crc_errors) { - show(); - value.setText(String.format("%4.2f V", state.main_sense)); + show("%4.2f V", state.main_sense); lights.set(state.main_sense > 3.2); } public Main (GridBagLayout layout, int y) { @@@ -319,10 -286,11 +311,10 @@@ class Lat extends AscentValue { void show (AltosState state, int crc_errors) { - show(); if (state.gps != null) - value.setText(pos(state.gps.lat,"N", "S")); + show(pos(state.gps.lat,"N", "S")); else - value.setText("???"); + show("???"); } public Lat (GridBagLayout layout, int y) { super (layout, y, "Latitude"); @@@ -333,10 -301,11 +325,10 @@@ class Lon extends AscentValue { void show (AltosState state, int crc_errors) { - show(); if (state.gps != null) - value.setText(pos(state.gps.lon,"E", "W")); + show(pos(state.gps.lon,"E", "W")); else - value.setText("???"); + show("???"); } public Lon (GridBagLayout layout, int y) { super (layout, y, "Longitude"); diff --combined altosui/AltosDescent.java index 2fe7d544,61709afe..e9ff590b --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@@ -18,15 -18,7 +18,7 @@@ package altosui; import java.awt.*; - import java.awt.event.*; import javax.swing.*; - import javax.swing.filechooser.FileNameExtensionFilter; - import javax.swing.table.*; - import java.io.*; - import java.util.*; - import java.text.*; - import java.util.prefs.*; - import java.util.concurrent.LinkedBlockingQueue; import org.altusmetrum.AltosLib.*; public class AltosDescent extends JComponent implements AltosFlightDisplay { @@@ -45,15 -37,6 +37,15 @@@ 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); @@@ -128,17 -111,16 +120,17 @@@ value.setVisible(false); } - void show(AltosUnits units, double v) { - value.setText(units.show(8, v)); + void show(String v) { + show(); + value.setText(v); } - void show(String format, double v) { - value.setText(String.format(format, v)); + void show(AltosUnits units, double v) { + show(units.show(8, v)); } - void show(String v) { - value.setText(v); + void show(String format, double v) { + show(String.format(format, v)); } void set_font() { @@@ -315,22 -297,10 +307,22 @@@ Lon lon; + class Distance extends DescentValue { + void show(AltosState state, int crc_errors) { + show(AltosConvert.distance, state.from_pad.distance); + } + + public Distance (GridBagLayout layout, int x, int y) { + super(layout, x, y, "Ground Distance"); + } + } + + Distance distance; + + class Apogee extends DescentStatus { void show (AltosState state, int crc_errors) { - show(); - value.setText(String.format("%4.2f V", state.drogue_sense)); + show("%4.2f V", state.drogue_sense); lights.set(state.drogue_sense > 3.2); } public Apogee (GridBagLayout layout, int y) { @@@ -342,7 -312,8 +334,7 @@@ class Main extends DescentStatus { void show (AltosState state, int crc_errors) { - show(); - value.setText(String.format("%4.2f V", state.main_sense)); + show("%4.2f V", state.main_sense); lights.set(state.main_sense > 3.2); } public Main (GridBagLayout layout, int y) { @@@ -398,7 -369,6 +390,7 @@@ speed.reset(); bearing.reset(); range.reset(); + distance.reset(); elevation.reset(); main.reset(); apogee.reset(); @@@ -411,7 -381,6 +403,7 @@@ speed.set_font(); bearing.set_font(); range.set_font(); + distance.set_font(); elevation.set_font(); main.set_font(); apogee.set_font(); @@@ -423,14 -392,12 +415,14 @@@ if (state.gps != null && state.gps.connected) { bearing.show(state, crc_errors); range.show(state, crc_errors); + distance.show(state, crc_errors); elevation.show(state, crc_errors); lat.show(state, crc_errors); lon.show(state, crc_errors); } else { bearing.hide(); range.hide(); + distance.hide(); elevation.hide(); lat.hide(); lon.hide(); @@@ -456,11 -423,10 +448,11 @@@ elevation = new Elevation(layout, 0, 1); range = new Range(layout, 2, 1); bearing = new Bearing(layout, 0, 2); - lat = new Lat(layout, 0, 3); - lon = new Lon(layout, 2, 3); + distance = new Distance(layout, 0, 3); + lat = new Lat(layout, 0, 4); + lon = new Lon(layout, 2, 4); - apogee = new Apogee(layout, 4); - main = new Main(layout, 5); + apogee = new Apogee(layout, 5); + main = new Main(layout, 6); } } diff --combined altosui/AltosKML.java index 73a5ae53,952fb141..57339b19 --- a/altosui/AltosKML.java +++ b/altosui/AltosKML.java @@@ -17,10 -17,7 +17,7 @@@ package altosui; - import java.lang.*; import java.io.*; - import java.text.*; - import java.util.*; import org.altusmetrum.AltosLib.*; public class AltosKML implements AltosWriter { @@@ -133,7 -130,6 +130,7 @@@ if (gps == null) return; + if ((record.seen & (AltosRecord.seen_flight)) == 0) return; if ((record.seen & (AltosRecord.seen_gps_lat)) == 0) diff --combined altosui/AltosLanded.java index 68efae8d,c6ef55fd..57c2d476 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@@ -20,13 -20,7 +20,7 @@@ package altosui import java.awt.*; import java.awt.event.*; import javax.swing.*; - import javax.swing.filechooser.FileNameExtensionFilter; - import javax.swing.table.*; import java.io.*; - import java.util.*; - import java.text.*; - import java.util.prefs.*; - import java.util.concurrent.LinkedBlockingQueue; import org.altusmetrum.AltosLib.*; public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener { @@@ -46,19 -40,6 +40,19 @@@ value.setVisible(true); } + void show(String s) { + show(); + value.setText(s); + } + + void show(AltosUnits units, double v) { + show(units.show(8, v)); + } + + void show(String format, double v) { + show(String.format(format, v)); + } + public void set_font() { label.setFont(Altos.label_font); value.setFont(Altos.value_font); @@@ -69,6 -50,12 +63,6 @@@ value.setVisible(false); } - void show(String format, double v) { - show(); - value.setText(String.format(format, v)); - } - - public LandedValue (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@@ -109,10 -96,11 +103,10 @@@ class Lat extends LandedValue { void show (AltosState state, int crc_errors) { - show(); if (state.gps != null && state.gps.connected) - value.setText(pos(state.gps.lat,"N", "S")); + show(pos(state.gps.lat,"N", "S")); else - value.setText("???"); + show("???"); } public Lat (GridBagLayout layout, int y) { super (layout, y, "Latitude"); @@@ -125,9 -113,9 +119,9 @@@ void show (AltosState state, int crc_errors) { show(); if (state.gps != null && state.gps.connected) - value.setText(pos(state.gps.lon,"E", "W")); + show(pos(state.gps.lon,"E", "W")); else - value.setText("???"); + show("???"); } public Lon (GridBagLayout layout, int y) { super (layout, y, "Longitude"); @@@ -142,7 -130,7 +136,7 @@@ if (state.from_pad != null) show("%3.0f°", state.from_pad.bearing); else - value.setText("???"); + show("???"); } public Bearing (GridBagLayout layout, int y) { super (layout, y, "Bearing"); @@@ -155,9 -143,9 +149,9 @@@ void show (AltosState state, int crc_errors) { show(); if (state.from_pad != null) - show("%6.0f m", state.from_pad.distance); + show(AltosConvert.distance, state.from_pad.distance); else - value.setText("???"); + show("???"); } public Distance (GridBagLayout layout, int y) { super (layout, y, "Distance"); @@@ -168,7 -156,7 +162,7 @@@ class Height extends LandedValue { void show (AltosState state, int crc_errors) { - show("%6.0f m", state.max_height); + show(AltosConvert.height, state.max_height); } public Height (GridBagLayout layout, int y) { super (layout, y, "Maximum Height"); @@@ -179,7 -167,7 +173,7 @@@ class Speed extends LandedValue { void show (AltosState state, int crc_errors) { - show("%6.0f m/s", state.max_speed); + show(AltosConvert.speed, state.max_speed); } public Speed (GridBagLayout layout, int y) { super (layout, y, "Maximum Speed"); @@@ -190,7 -178,7 +184,7 @@@ class Accel extends LandedValue { void show (AltosState state, int crc_errors) { - show("%6.0f m/s²", state.max_acceleration); + show(AltosConvert.accel, state.max_acceleration); } public Accel (GridBagLayout layout, int y) { super (layout, y, "Maximum Acceleration"); diff --combined altosui/AltosPad.java index 947c7540,f2deb165..2d9c8323 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@@ -18,15 -18,7 +18,7 @@@ package altosui; import java.awt.*; - import java.awt.event.*; import javax.swing.*; - import javax.swing.filechooser.FileNameExtensionFilter; - import javax.swing.table.*; - import java.io.*; - import java.util.*; - import java.text.*; - import java.util.prefs.*; - import java.util.concurrent.LinkedBlockingQueue; import org.altusmetrum.AltosLib.*; public class AltosPad extends JComponent implements AltosFlightDisplay { @@@ -38,7 -30,6 +30,7 @@@ AltosLights lights; void show(AltosState state, int crc_errors) {} + void reset() { value.setText(""); lights.set(false); @@@ -50,19 -41,6 +42,19 @@@ 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); @@@ -130,23 -108,9 +122,23 @@@ value.setFont(Altos.value_font); } + void show(String s) { + show(); + value.setText(s); + } + + void show(AltosUnits units, double v) { + show(units.show(8, v)); + } + + void show(String format, double v) { + show(String.format(format, v)); + } + void reset() { value.setText(""); } + public LaunchValue (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); @@@ -176,7 -140,7 +168,7 @@@ class Battery extends LaunchStatus { void show (AltosState state, int crc_errors) { - value.setText(String.format("%4.2f V", state.battery)); + show("%4.2f V", state.battery); lights.set(state.battery > 3.7); } public Battery (GridBagLayout layout, int y) { @@@ -188,7 -152,8 +180,7 @@@ class Apogee extends LaunchStatus { void show (AltosState state, int crc_errors) { - show(); - value.setText(String.format("%4.2f V", state.drogue_sense)); + show("%4.2f V", state.drogue_sense); lights.set(state.drogue_sense > 3.2); } public Apogee (GridBagLayout layout, int y) { @@@ -200,7 -165,8 +192,7 @@@ class Main extends LaunchStatus { void show (AltosState state, int crc_errors) { - show(); - value.setText(String.format("%4.2f V", state.main_sense)); + show("%4.2f V", state.main_sense); lights.set(state.main_sense > 3.2); } public Main (GridBagLayout layout, int y) { @@@ -212,16 -178,17 +204,16 @@@ class LoggingReady extends LaunchStatus { void show (AltosState state, int crc_errors) { - show(); if (state.data.flight != 0) { if (state.data.state <= Altos.ao_flight_pad) - value.setText("Ready to record"); + show("Ready to record"); else if (state.data.state < Altos.ao_flight_landed) - value.setText("Recording data"); + show("Recording data"); else - value.setText("Recorded data"); + show("Recorded data"); } else - value.setText("Storage full"); + show("Storage full"); lights.set(state.data.flight != 0); } public LoggingReady (GridBagLayout layout, int y) { @@@ -233,7 -200,8 +225,7 @@@ class GPSLocked extends LaunchStatus { void show (AltosState state, int crc_errors) { - show(); - value.setText(String.format("%4d sats", state.gps.nsat)); + show("%4d sats", state.gps.nsat); lights.set(state.gps.locked && state.gps.nsat >= 4); } public GPSLocked (GridBagLayout layout, int y) { @@@ -245,10 -213,11 +237,10 @@@ class GPSReady extends LaunchStatus { void show (AltosState state, int crc_errors) { - show(); if (state.gps_ready) - value.setText("Ready"); + show("Ready"); else - value.setText(String.format("Waiting %d", state.gps_waiting)); + show("Waiting %d", state.gps_waiting); lights.set(state.gps_ready); } public GPSReady (GridBagLayout layout, int y) { @@@ -271,7 -240,8 +263,7 @@@ class PadLat extends LaunchValue { void show (AltosState state, int crc_errors) { - show(); - value.setText(pos(state.pad_lat,"N", "S")); + show(pos(state.pad_lat,"N", "S")); } public PadLat (GridBagLayout layout, int y) { super (layout, y, "Pad Latitude"); @@@ -282,7 -252,8 +274,7 @@@ class PadLon extends LaunchValue { void show (AltosState state, int crc_errors) { - show(); - value.setText(pos(state.pad_lon,"E", "W")); + show(pos(state.pad_lon,"E", "W")); } public PadLon (GridBagLayout layout, int y) { super (layout, y, "Pad Longitude"); @@@ -293,7 -264,7 +285,7 @@@ class PadAlt extends LaunchValue { void show (AltosState state, int crc_errors) { - value.setText(String.format("%4.0f m", state.pad_alt)); + show("%4.0f m", state.pad_alt); } public PadAlt (GridBagLayout layout, int y) { super (layout, y, "Pad Altitude");