X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosAscent.java;h=007c74ec639694ea46aeda47d960e1886b3d06be;hp=945af7e26104665951e0768093e218d8df7358fb;hb=52d3cad4f744140e1aa06fdfc0d49a0cf8734fd4;hpb=6e0d672b8a516a604d8ea1abd2bed113c608143f diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 945af7e2..007c74ec 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -43,6 +43,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); @@ -104,6 +118,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); @@ -260,8 +287,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) { @@ -273,8 +299,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) { @@ -286,11 +311,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"); @@ -301,11 +325,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");