altosuilib: Rewrite map GUI bits
[fw/altos] / telegps / TeleGPSGraphUI.java
index b7c17780d522e91f776ecaa3554ee8114ee12769..fbc9657e1b7d0fc6d22906d3f74fca5980b36731 100644 (file)
@@ -21,7 +21,11 @@ import java.io.*;
 import java.util.ArrayList;
 
 import java.awt.*;
+import java.awt.event.*;
 import javax.swing.*;
+import java.io.*;
+import java.util.concurrent.*;
+import java.util.*;
 import org.altusmetrum.altoslib_4.*;
 import org.altusmetrum.altosuilib_2.*;
 
@@ -34,10 +38,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 +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;
@@ -56,20 +67,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);
+
+               map = new AltosUIMap();
 
                pane.add("Flight 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);
+
        }
 }