telegps: Add statistics tab to graph UI
[fw/altos] / telegps / TeleGPSGraphUI.java
index b7c17780d522e91f776ecaa3554ee8114ee12769..b7fc4caae911d39b18e4a2e8ebb68a1e793c43ac 100644 (file)
@@ -21,7 +21,11 @@ import java.io.*;
 import java.util.ArrayList;
 
 import java.awt.*;
 import java.util.ArrayList;
 
 import java.awt.*;
+import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.*;
+import java.io.*;
+import java.util.concurrent.*;
+import java.util.*;
 import org.altusmetrum.altoslib_4.*;
 import org.altusmetrum.altosuilib_2.*;
 
 import org.altusmetrum.altoslib_4.*;
 import org.altusmetrum.altosuilib_2.*;
 
@@ -38,6 +42,7 @@ public class TeleGPSGraphUI extends AltosUIFrame
        AltosState              state;
        AltosFlightStats        stats;
        AltosGraphDataSet       graphDataSet;
        AltosState              state;
        AltosFlightStats        stats;
        AltosGraphDataSet       graphDataSet;
+       AltosFlightStatsTable   statsTable;
 
        void fill_map(AltosStateIterable states) {
                for (AltosState state : states) {
 
        void fill_map(AltosStateIterable states) {
                for (AltosState state : states) {
@@ -46,6 +51,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;
        TeleGPSGraphUI(AltosStateIterable states, File file) throws InterruptedException, IOException {
                super(file.getName());
                state = null;
@@ -56,20 +67,35 @@ public class TeleGPSGraphUI extends AltosUIFrame
                stats = new AltosFlightStats(states);
                graphDataSet = new AltosGraphDataSet(states);
                graph = new AltosGraph(enable, stats, graphDataSet);
                stats = new AltosFlightStats(states);
                graphDataSet = new AltosGraphDataSet(states);
                graph = new AltosGraph(enable, stats, graphDataSet);
+               statsTable = new AltosFlightStatsTable(stats);
+
                map = new AltosSiteMap();
 
                pane.add("Flight Graph", graph.panel);
                pane.add("Configure Graph", enable);
                map = new AltosSiteMap();
 
                pane.add("Flight Graph", graph.panel);
                pane.add("Configure Graph", enable);
+               pane.add("Statistics", statsTable);
                fill_map(states);
                pane.add("Map", map);
 
                setContentPane (pane);
 
                fill_map(states);
                pane.add("Map", map);
 
                setContentPane (pane);
 
+               addWindowListener(new WindowAdapter() {
+                               @Override
+                               public void windowClosing(WindowEvent e) {
+                                       close();
+                               }
+                       });
+
                pack();
 
                pack();
 
-               setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+               setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+
+               TeleGPS.add_window();
+
                setVisible(true);
                setVisible(true);
+
                if (state != null)
                        map.centre(state);
                if (state != null)
                        map.centre(state);
+
        }
 }
        }
 }