elide reference to GPS since we don't have it
[fw/altos] / teststand / AltosGraphUI.java
1 /*
2  * Copyright © 2010 Anthony Towns
3  *
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.
8  *
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.
13  *
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.
17  */
18
19 package teststand;
20
21 import java.io.*;
22 import java.util.ArrayList;
23
24 import java.awt.*;
25 import java.awt.event.*;
26 import javax.swing.*;
27 import org.altusmetrum.altoslib_12.*;
28 import org.altusmetrum.altosuilib_12.*;
29
30 import org.jfree.chart.ChartPanel;
31 import org.jfree.chart.JFreeChart;
32 import org.jfree.ui.RefineryUtilities;
33
34 public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, AltosUnitsListener, AltosFilterListener
35 {
36         JTabbedPane             pane;
37         TestStandGraph          graph;
38         AltosUIEnable           enable;
39         TestStats       stats;
40         TestStatsTable          statsTable;
41
42         public void font_size_changed(int font_size) {
43                 if (statsTable != null)
44                         statsTable.font_size_changed(font_size);
45         }
46
47         public void units_changed(boolean imperial_units) {
48                 if (enable != null)
49                         enable.units_changed(imperial_units);
50         }
51
52         AltosUIFlightSeries flight_series;
53
54         public void filter_changed(double speed_filter, double accel_filter) {
55                 flight_series.set_filter(speed_filter, accel_filter);
56                 graph.filter_changed();
57                 stats = new TestStats(flight_series);
58                 statsTable.filter_changed(stats);
59         }
60
61         public double speed_filter() {
62                 return flight_series.speed_filter_width;
63         }
64
65         public double accel_filter() {
66                 return flight_series.accel_filter_width;
67         }
68
69         AltosGraphUI(AltosRecordSet set, File file) throws InterruptedException, IOException {
70                 super(file.getName());
71                 AltosCalData    cal_data = set.cal_data();
72
73
74                 pane = new JTabbedPane();
75
76                 flight_series = new AltosUIFlightSeries(cal_data);
77
78                 enable = new AltosUIEnable(this);
79
80                 set.capture_series(flight_series);
81
82                 flight_series.finish();
83
84                 stats = new TestStats(flight_series);
85
86                 graph = new TestStandGraph(enable, stats, flight_series);
87
88                 statsTable = new TestStatsTable(stats);
89
90                 pane.add("Test Graph", graph.panel);
91                 pane.add("Configure Graph", enable);
92                 pane.add("Test Statistics", statsTable);
93
94                 setContentPane (pane);
95
96                 AltosUIPreferences.register_font_listener(this);
97                 AltosPreferences.register_units_listener(this);
98
99                 addWindowListener(new WindowAdapter() {
100                                 @Override
101                                 public void windowClosing(WindowEvent e) {
102                                         AltosUIPreferences.unregister_font_listener(AltosGraphUI.this);
103                                         AltosPreferences.unregister_units_listener(AltosGraphUI.this);
104                                 }
105                         });
106                 pack();
107
108                 setVisible(true);
109         }
110 }