X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=telegps%2FTeleGPSInfo.java;h=dcfbace5fa823b2094d300fbbe62064f6d0706fd;hp=bbf4b47265e1d97eb3f34d6d6b977c857deba962;hb=346fdfb469f7f3c1f87a39dee5bfb4568631c28b;hpb=3f7e885055f8a97f334e0cd3163b760b174114b6 diff --git a/telegps/TeleGPSInfo.java b/telegps/TeleGPSInfo.java index bbf4b472..dcfbace5 100644 --- a/telegps/TeleGPSInfo.java +++ b/telegps/TeleGPSInfo.java @@ -3,7 +3,8 @@ * * 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. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,16 +22,13 @@ import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_4.*; -import org.altusmetrum.altosuilib_2.*; +import org.altusmetrum.altoslib_13.*; +import org.altusmetrum.altosuilib_13.*; -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 +46,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 +93,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 +123,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 +147,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 +172,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 +201,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++)); } }