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; version 2 or any later version of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 import java.util.ArrayList;
24 import java.awt.event.*;
26 import org.altusmetrum.altoslib_9.*;
27 import org.altusmetrum.altosuilib_9.*;
29 import org.jfree.chart.ChartPanel;
30 import org.jfree.chart.JFreeChart;
31 import org.jfree.ui.RefineryUtilities;
33 public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, AltosUnitsListener
40 AltosGraphDataSet graphDataSet;
41 AltosFlightStats stats;
42 AltosFlightStatsTable statsTable;
45 void fill_map(AltosStateIterable states) {
46 boolean any_gps = false;
47 for (AltosState state : states) {
48 if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
50 map = new AltosUIMapNew();
51 map.show(state, null);
57 public void font_size_changed(int font_size) {
59 map.font_size_changed(font_size);
60 if (statsTable != null)
61 statsTable.font_size_changed(font_size);
64 public void units_changed(boolean imperial_units) {
66 map.units_changed(imperial_units);
68 enable.units_changed(imperial_units);
71 AltosGraphUI(AltosStateIterable states, File file) throws InterruptedException, IOException {
72 super(file.getName());
75 pane = new JTabbedPane();
77 enable = new AltosUIEnable();
79 stats = new AltosFlightStats(states);
80 graphDataSet = new AltosGraphDataSet(states);
82 graph = new AltosGraph(enable, stats, graphDataSet);
84 statsTable = new AltosFlightStatsTable(stats);
86 pane.add("Flight Graph", graph.panel);
87 pane.add("Configure Graph", enable);
88 pane.add("Flight Statistics", statsTable);
95 setContentPane (pane);
97 AltosUIPreferences.register_font_listener(this);
98 AltosPreferences.register_units_listener(this);
100 addWindowListener(new WindowAdapter() {
102 public void windowClosing(WindowEvent e) {
105 AltosUIPreferences.unregister_font_listener(AltosGraphUI.this);
106 AltosPreferences.unregister_units_listener(AltosGraphUI.this);
112 if (state != null && has_gps)