2 * Copyright © 2010 Anthony Towns
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 package org.altusmetrum.telegps;
22 import java.util.ArrayList;
25 import java.awt.event.*;
28 import java.util.concurrent.*;
30 import org.altusmetrum.altoslib_13.*;
31 import org.altusmetrum.altosuilib_13.*;
33 import org.jfree.chart.ChartPanel;
34 import org.jfree.chart.JFreeChart;
35 import org.jfree.ui.RefineryUtilities;
37 public class TeleGPSGraphUI extends AltosUIFrame implements AltosFontListener, AltosUnitsListener, AltosFilterListener
44 AltosFlightStats stats;
45 AltosFlightStatsTable statsTable;
49 void fill_map(AltosFlightSeries flight_series) {
50 boolean any_gps = false;
51 AltosGPSTimeValue gtv_last = null;
53 if (flight_series.gps_series != null) {
54 for (AltosGPSTimeValue gtv : flight_series.gps_series) {
56 AltosGPS gps = gtv.gps;
61 map = new AltosUIMap();
62 map.show(gps, (int) flight_series.value_before(AltosFlightSeries.state_name, gtv.time));
68 if (gtv_last != null) {
69 int state = (int) flight_series.value_after(AltosFlightSeries.state_name, gtv_last.time);
70 if (state == AltosLib.ao_flight_landed)
71 map.show(gtv_last.gps, state);
75 private void close() {
78 TeleGPS.subtract_window();
81 public void font_size_changed(int font_size) {
83 map.font_size_changed(font_size);
84 if (statsTable != null)
85 statsTable.font_size_changed(font_size);
88 public void units_changed(boolean imperial_units) {
90 map.units_changed(imperial_units);
92 enable.units_changed(imperial_units);
95 AltosUIFlightSeries flight_series;
97 public void filter_changed(double speed_filter, double accel_filter) {
98 flight_series.set_filter(speed_filter, accel_filter);
99 graph.filter_changed();
100 stats = new AltosFlightStats(flight_series);
101 statsTable.filter_changed(stats);
104 public double speed_filter() {
105 return flight_series.speed_filter_width;
108 public double accel_filter() {
109 return flight_series.accel_filter_width;
112 TeleGPSGraphUI(AltosRecordSet set, File file) throws InterruptedException, IOException {
113 super(file.getName());
114 AltosCalData cal_data = set.cal_data();
116 flight_series = new AltosUIFlightSeries(cal_data);
117 set.capture_series(flight_series);
118 flight_series.finish();
120 pane = new JTabbedPane();
122 graph = new AltosGraph(enable, stats, flight_series);
124 stats = new AltosFlightStats(flight_series);
126 enable = new AltosUIEnable(this);
128 statsTable = new AltosFlightStatsTable(stats);
130 map = new AltosUIMap();
132 pane.add("Graph", graph.panel);
133 pane.add("Configure Graph", enable);
134 pane.add("Statistics", statsTable);
135 fill_map(flight_series);
136 pane.add("Map", map);
138 setContentPane (pane);
140 AltosUIPreferences.register_font_listener(this);
141 AltosPreferences.register_units_listener(this);
143 addWindowListener(new WindowAdapter() {
145 public void windowClosing(WindowEvent e) {
152 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
154 TeleGPS.add_window();