X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosAscent.java;h=3fe517aa6bb08388aeef0874e11ff2577dac8e89;hp=de6c90a1098e97a9503860f82e22971b4ef1637f;hb=97ab77d548964115e4b41ad5952194fcd1455c96;hpb=708e7937cba52982b91244cf89bfbff46d346135 diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index de6c90a1..3fe517aa 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; @@ -51,6 +51,20 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { } 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); @@ -112,6 +126,19 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { 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); @@ -268,8 +295,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { 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) { @@ -281,8 +307,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { 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) { @@ -294,11 +319,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { 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"); @@ -309,11 +333,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { 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");