altosui/telegps: Expose configurable APRS SSID
[fw/altos] / telegps / TeleGPSGraphUI.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; version 2 or any later version of the License.
7  *
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.
12  *
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.
16  */
17
18 package org.altusmetrum.telegps;
19
20 import java.io.*;
21 import java.util.ArrayList;
22
23 import java.awt.*;
24 import java.awt.event.*;
25 import javax.swing.*;
26 import java.io.*;
27 import java.util.concurrent.*;
28 import java.util.*;
29 import org.altusmetrum.altoslib_5.*;
30 import org.altusmetrum.altosuilib_3.*;
31
32 import org.jfree.chart.ChartPanel;
33 import org.jfree.chart.JFreeChart;
34 import org.jfree.ui.RefineryUtilities;
35
36 public class TeleGPSGraphUI extends AltosUIFrame
37 {
38         JTabbedPane             pane;
39         AltosGraph              graph;
40         AltosUIEnable           enable;
41         AltosUIMap              map;
42         AltosState              state;
43         AltosFlightStats        stats;
44         AltosGraphDataSet       graphDataSet;
45         AltosFlightStatsTable   statsTable;
46
47         void fill_map(AltosStateIterable states) {
48                 for (AltosState state : states) {
49                         if (state.gps != null && state.gps.locked && state.gps.nsat >= 4)
50                                 map.show(state, null);
51                 }
52         }
53
54         private void close() {
55                 setVisible(false);
56                 dispose();
57                 TeleGPS.subtract_window();
58         }
59
60         TeleGPSGraphUI(AltosStateIterable states, File file) throws InterruptedException, IOException {
61                 super(file.getName());
62                 state = null;
63
64                 pane = new JTabbedPane();
65
66                 enable = new AltosUIEnable();
67                 stats = new AltosFlightStats(states);
68                 graphDataSet = new AltosGraphDataSet(states);
69                 graph = new AltosGraph(enable, stats, graphDataSet);
70                 statsTable = new AltosFlightStatsTable(stats);
71
72                 map = new AltosUIMap();
73
74                 pane.add("Graph", graph.panel);
75                 pane.add("Configure Graph", enable);
76                 pane.add("Statistics", statsTable);
77                 fill_map(states);
78                 pane.add("Map", map);
79
80                 setContentPane (pane);
81
82                 addWindowListener(new WindowAdapter() {
83                                 @Override
84                                 public void windowClosing(WindowEvent e) {
85                                         close();
86                                 }
87                         });
88
89                 pack();
90
91                 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
92
93                 TeleGPS.add_window();
94
95                 setVisible(true);
96
97                 if (state != null)
98                         map.centre(state);
99
100         }
101 }