altosui: Add config and pyro tabs to graph widget
[fw/altos] / altosui / AltosGraphUI.java
index c1e18ac1b9d97dce0233c123e994ad400021e660..8f52728bf13cfe1ea9d6c5e95a0e104d341e3440 100644 (file)
@@ -24,8 +24,8 @@ import java.util.ArrayList;
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
-import org.altusmetrum.altoslib_13.*;
-import org.altusmetrum.altosuilib_13.*;
+import org.altusmetrum.altoslib_14.*;
+import org.altusmetrum.altosuilib_14.*;
 
 import org.jfree.chart.ChartPanel;
 import org.jfree.chart.JFreeChart;
@@ -39,12 +39,15 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
        AltosUIMap              map;
        AltosFlightStats        stats;
        AltosFlightStatsTable   statsTable;
+       AltosFlightConfigTable  configTable;
+       AltosFlightPyroTable    pyroTable;
        AltosGPS                gps;
        boolean                 has_gps;
 
        void fill_map(AltosFlightSeries flight_series) {
                boolean                 any_gps = false;
                AltosGPSTimeValue       gtv_last = null;
+               double gps_pad_altitude = flight_series.cal_data().gps_pad_altitude;;
 
                if (flight_series.gps_series != null) {
                        for (AltosGPSTimeValue gtv : flight_series.gps_series) {
@@ -54,7 +57,9 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
                                    gps.nsat >= 4) {
                                        if (map == null)
                                                map = new AltosUIMap();
-                                       map.show(gps, gtv. time, (int) flight_series.value_before(AltosFlightSeries.state_name, gtv.time));
+                                       double gps_height = gps.alt - gps_pad_altitude;
+                                       int state = (int) flight_series.value_before(AltosFlightSeries.state_name, gtv.time);
+                                       map.show(gps, gtv.time, state, gps_height);
                                        this.gps = gps;
                                        gtv_last = gtv;
                                        has_gps = true;
@@ -63,8 +68,9 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
                }
                if (gtv_last != null) {
                        int state = (int) flight_series.value_after(AltosFlightSeries.state_name, gtv_last.time);
+                       double gps_height = gps.alt - gps_pad_altitude;
                        if (state == AltosLib.ao_flight_landed)
-                               map.show(gtv_last.gps, gtv_last.time, state);
+                               map.show(gtv_last.gps, gtv_last.time, state,gps_height);
                }
        }
 
@@ -73,6 +79,10 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
                        map.font_size_changed(font_size);
                if (statsTable != null)
                        statsTable.font_size_changed(font_size);
+               if (configTable != null)
+                       configTable.font_size_changed(font_size);
+               if (pyroTable != null)
+                       pyroTable.font_size_changed(font_size);
        }
 
        public void units_changed(boolean imperial_units) {
@@ -80,6 +90,10 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
                        map.units_changed(imperial_units);
                if (enable != null)
                        enable.units_changed(imperial_units);
+               if (configTable != null)
+                       configTable.units_changed(imperial_units);
+               if (pyroTable != null)
+                       pyroTable.units_changed(imperial_units);
        }
 
        AltosUIFlightSeries flight_series;
@@ -102,7 +116,7 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
        AltosGraphUI(AltosRecordSet set, File file) throws InterruptedException, IOException {
                super(file.getName());
                AltosCalData    cal_data = set.cal_data();
-
+               AltosConfigData config_data = set.config_data();
 
                pane = new JTabbedPane();
 
@@ -123,6 +137,14 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
                pane.add("Flight Graph", graph.panel);
                pane.add("Configure Graph", enable);
                pane.add("Flight Statistics", statsTable);
+               if (config_data != null) {
+                       configTable = new AltosFlightConfigTable(config_data);
+                       pane.add("Configuration", configTable);
+                       if (config_data.npyro > 0) {
+                               pyroTable = new AltosFlightPyroTable(config_data.pyros, config_data.npyro);
+                               pane.add("Pyros", pyroTable);
+                       }
+               }
 
                has_gps = false;
                fill_map(flight_series);