atosui: Hide Callsign and RSSI tabs for devices without a radio
authorKeith Packard <keithp@keithp.com>
Tue, 13 May 2014 05:47:55 +0000 (22:47 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 13 May 2014 05:47:55 +0000 (22:47 -0700)
When doing Monitor Idle with EasyMini, it's nice to not put fields on
the screen which won't ever have useful data in them.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosFlightStatus.java

index c6d75420fba38af29e9f237097e53481f56ad610..b467bbdee4d8b2154dc7f134e4cb58354ecafea5 100644 (file)
@@ -39,6 +39,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
                        value.setFont(Altos.status_font);
                }
 
                        value.setFont(Altos.status_font);
                }
 
+               void setVisible(boolean visible) {
+                       label.setVisible(visible);
+                       value.setVisible(visible);
+               }
+
                public FlightValue (GridBagLayout layout, int x, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.insets = new Insets(5, 5, 5, 5);
                public FlightValue (GridBagLayout layout, int x, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.insets = new Insets(5, 5, 5, 5);
@@ -66,6 +71,10 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
        class Call extends FlightValue {
                void show(AltosState state, AltosListenerState listener_state) {
                        value.setText(state.callsign);
        class Call extends FlightValue {
                void show(AltosState state, AltosListenerState listener_state) {
                        value.setText(state.callsign);
+                       if (state.callsign == null)
+                               setVisible(false);
+                       else
+                               setVisible(true);
                }
                public Call (GridBagLayout layout, int x) {
                        super (layout, x, "Callsign");
                }
                public Call (GridBagLayout layout, int x) {
                        super (layout, x, "Callsign");
@@ -116,6 +125,10 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
        class RSSI extends FlightValue {
                void show(AltosState state, AltosListenerState listener_state) {
                        value.setText(String.format("%d", state.rssi()));
        class RSSI extends FlightValue {
                void show(AltosState state, AltosListenerState listener_state) {
                        value.setText(String.format("%d", state.rssi()));
+                       if (state.rssi == AltosLib.MISSING)
+                               setVisible(false);
+                       else
+                               setVisible(true);
                }
                public RSSI (GridBagLayout layout, int x) {
                        super (layout, x, "RSSI");
                }
                public RSSI (GridBagLayout layout, int x) {
                        super (layout, x, "RSSI");