Merge branch 'telescience-v0.2'
[fw/altos] / altosui / AltosGraphUI.java
index b376f7de69ee29d4adea4d1d46e56b003bd21af9..2f3575a4387bbbd9e39f0e58a4a8394ce53a1f27 100644 (file)
@@ -21,21 +21,47 @@ public class AltosGraphUI extends AltosUIFrame
        JTabbedPane             pane;
        AltosGraph              graph;
        AltosUIEnable           enable;
+       AltosSiteMap            map;
+       AltosState              state;
+       AltosGraphDataSet       graphDataSet;
+       AltosFlightStats        stats;
+       AltosFlightStatsTable   statsTable;
+
+       boolean fill_map(AltosRecordIterable records) {
+               boolean         any_gps = false;
+               for (AltosRecord record : records) {
+                       state = new AltosState(record, state);
+                       if (state.gps.locked && state.gps.nsat >= 4) {
+                               map.show(state, 0);
+                               any_gps = true;
+                       }
+               }
+               return any_gps;
+       }
+
+       AltosGraphUI(AltosRecordIterable records, File file) throws InterruptedException, IOException {
+               super(file.getName());
+               state = null;
 
-       AltosGraphUI(AltosRecordIterable records, String file) throws InterruptedException, IOException {
                pane = new JTabbedPane();
 
                enable = new AltosUIEnable();
 
-               AltosGraph graph = new AltosGraph(enable);
+               stats = new AltosFlightStats(records);
+               graphDataSet = new AltosGraphDataSet(records);
+
+               graph = new AltosGraph(enable, stats, graphDataSet);
+
+               statsTable = new AltosFlightStatsTable(stats);
 
-               graph.setDataSet(new AltosGraphDataSet(records));
+               map = new AltosSiteMap();
 
                pane.add("Flight Graph", graph.panel);
                pane.add("Configure Graph", enable);
+               pane.add("Flight Statistics", statsTable);
 
-               AltosFlightStatsTable stats = new AltosFlightStatsTable(new AltosFlightStats(records));
-               pane.add("Flight Statistics", stats);
+               if (fill_map(records))
+                       pane.add("Map", map);
 
                setContentPane (pane);
 
@@ -43,5 +69,7 @@ public class AltosGraphUI extends AltosUIFrame
 
                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                setVisible(true);
+               if (state != null)
+                       map.centre(state);
        }
 }