X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=telegps%2FTeleGPSGraphUI.java;h=e9fc683101b637bf4f1d3596ddf2227dfb1de91f;hp=701a7e30164db82774fbaaab0cc6382a028fd59b;hb=52149fd81df45f37f5097850795f290f463c43ef;hpb=97adfff4cfb67c17a96f3ff46606b4e439422b01 diff --git a/telegps/TeleGPSGraphUI.java b/telegps/TeleGPSGraphUI.java index 701a7e30..e9fc6831 100644 --- a/telegps/TeleGPSGraphUI.java +++ b/telegps/TeleGPSGraphUI.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 or any later version 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 @@ -26,28 +27,52 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_11.*; -import org.altusmetrum.altosuilib_11.*; +import org.altusmetrum.altoslib_14.*; +import org.altusmetrum.altosuilib_14.*; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.ui.RefineryUtilities; -public class TeleGPSGraphUI extends AltosUIFrame +public class TeleGPSGraphUI extends AltosUIFrame implements AltosFontListener, AltosUnitsListener, AltosFilterListener { JTabbedPane pane; AltosGraph graph; AltosUIEnable enable; - AltosUIMapNew map; + AltosUIMap map; AltosState state; AltosFlightStats stats; - AltosGraphDataSet graphDataSet; AltosFlightStatsTable statsTable; - - void fill_map(AltosStateIterable states) { - for (AltosState state : states) { - if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) - map.show(state, null); + 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) { + gtv_last = gtv; + AltosGPS gps = gtv.gps; + if (gps != null && + gps.locked && + gps.nsat >= 4) { + if (map == null) + map = new AltosUIMap(); + 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; + has_gps = true; + } + } + } + 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, gps_height); } } @@ -57,28 +82,70 @@ public class TeleGPSGraphUI extends AltosUIFrame TeleGPS.subtract_window(); } - TeleGPSGraphUI(AltosStateIterable states, File file) throws InterruptedException, IOException { + public void font_size_changed(int font_size) { + if (map != null) + map.font_size_changed(font_size); + if (statsTable != null) + statsTable.font_size_changed(font_size); + } + + public void units_changed(boolean imperial_units) { + if (map != null) + map.units_changed(imperial_units); + if (enable != null) + enable.units_changed(imperial_units); + } + + AltosUIFlightSeries flight_series; + + public void filter_changed(double speed_filter, double accel_filter) { + flight_series.set_filter(speed_filter, accel_filter); + graph.filter_changed(); + stats = new AltosFlightStats(flight_series); + statsTable.filter_changed(stats); + } + + public double speed_filter() { + return flight_series.speed_filter_width; + } + + public double accel_filter() { + return flight_series.accel_filter_width; + } + + TeleGPSGraphUI(AltosRecordSet set, File file) throws InterruptedException, IOException { super(file.getName()); - state = null; + AltosCalData cal_data = set.cal_data(); pane = new JTabbedPane(); - enable = new AltosUIEnable(); - stats = new AltosFlightStats(states); - graphDataSet = new AltosGraphDataSet(states); - graph = new AltosGraph(enable, stats, graphDataSet); + flight_series = new AltosUIFlightSeries(cal_data); + + enable = new AltosUIEnable(this); + + set.capture_series(flight_series); + + flight_series.finish(); + + stats = new AltosFlightStats(flight_series); + + graph = new AltosGraph(enable, stats, flight_series); + statsTable = new AltosFlightStatsTable(stats); - map = new AltosUIMapNew(); + map = new AltosUIMap(); pane.add("Graph", graph.panel); pane.add("Configure Graph", enable); pane.add("Statistics", statsTable); - fill_map(states); + fill_map(flight_series); pane.add("Map", map); setContentPane (pane); + AltosUIPreferences.register_font_listener(this); + AltosPreferences.register_units_listener(this); + addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) {