telegps: use new eeprom reading code
[fw/altos] / telegps / TeleGPSGraphUI.java
index b7c17780d522e91f776ecaa3554ee8114ee12769..55ee370e33b2a4e1dda1e3b3a0dd629114d1f7a4 100644 (file)
@@ -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
@@ -21,9 +22,13 @@ import java.io.*;
 import java.util.ArrayList;
 
 import java.awt.*;
+import java.awt.event.*;
 import javax.swing.*;
-import org.altusmetrum.altoslib_4.*;
-import org.altusmetrum.altosuilib_2.*;
+import java.io.*;
+import java.util.concurrent.*;
+import java.util.*;
+import org.altusmetrum.altoslib_11.*;
+import org.altusmetrum.altosuilib_11.*;
 
 import org.jfree.chart.ChartPanel;
 import org.jfree.chart.JFreeChart;
@@ -34,10 +39,11 @@ public class TeleGPSGraphUI extends AltosUIFrame
        JTabbedPane             pane;
        AltosGraph              graph;
        AltosUIEnable           enable;
-       AltosSiteMap            map;
+       AltosUIMap              map;
        AltosState              state;
        AltosFlightStats        stats;
        AltosGraphDataSet       graphDataSet;
+       AltosFlightStatsTable   statsTable;
 
        void fill_map(AltosStateIterable states) {
                for (AltosState state : states) {
@@ -46,6 +52,12 @@ public class TeleGPSGraphUI extends AltosUIFrame
                }
        }
 
+       private void close() {
+               setVisible(false);
+               dispose();
+               TeleGPS.subtract_window();
+       }
+
        TeleGPSGraphUI(AltosStateIterable states, File file) throws InterruptedException, IOException {
                super(file.getName());
                state = null;
@@ -56,20 +68,35 @@ public class TeleGPSGraphUI extends AltosUIFrame
                stats = new AltosFlightStats(states);
                graphDataSet = new AltosGraphDataSet(states);
                graph = new AltosGraph(enable, stats, graphDataSet);
-               map = new AltosSiteMap();
+               statsTable = new AltosFlightStatsTable(stats);
 
-               pane.add("Flight Graph", graph.panel);
+               map = new AltosUIMap();
+
+               pane.add("Graph", graph.panel);
                pane.add("Configure Graph", enable);
+               pane.add("Statistics", statsTable);
                fill_map(states);
                pane.add("Map", map);
 
                setContentPane (pane);
 
+               addWindowListener(new WindowAdapter() {
+                               @Override
+                               public void windowClosing(WindowEvent e) {
+                                       close();
+                               }
+                       });
+
                pack();
 
-               setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+               setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+
+               TeleGPS.add_window();
+
                setVisible(true);
+
                if (state != null)
                        map.centre(state);
+
        }
 }