X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=micropeak%2FMicroPeak.java;h=607bf20c678607f2f5621a230338ea5c000ed04d;hp=e6aa9ab027dbd1768d42acd776fce06a0bdf9d3f;hb=a61217f0a6d0ef48b6471f632c4600255867e831;hpb=5a3c5de6657d1c26e52015a8acec0cd05e294cef diff --git a/micropeak/MicroPeak.java b/micropeak/MicroPeak.java index e6aa9ab0..607bf20c 100644 --- a/micropeak/MicroPeak.java +++ b/micropeak/MicroPeak.java @@ -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 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 @@ -23,14 +24,15 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_12.*; +import org.altusmetrum.altosuilib_12.*; public class MicroPeak extends MicroFrame implements ActionListener, ItemListener { File filename; - MicroGraph graph; - MicroStatsTable stats; + AltosGraph graph; + AltosUIEnable enable; + AltosFlightStatsTable statsTable; MicroRaw raw; MicroData data; Container container; @@ -44,8 +46,12 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene return mp.SetData(data); } this.data = data; - graph.setData(data); - stats.setData(data); + if (data.flight_series == null) + System.out.printf("no data in flight\n"); + if (data.flight_stats == null) + System.out.printf("no stats in flight\n"); + graph.set_data(data.flight_stats, data.flight_series); + statsTable.set_stats(data.flight_stats); raw.setData(data); setTitle(data.name); return this; @@ -61,6 +67,11 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene FileInputStream fis = new FileInputStream(filename); try { data = new MicroData((InputStream) fis, filename.getName()); + AltosUIPreferences.set_last_logdir(filename); + } catch (MicroData.NonHexcharException nhe) { + data = null; + } catch (MicroData.FileEndedException nhe) { + data = null; } catch (InterruptedException ie) { data = null; } finally { @@ -99,7 +110,7 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene private void DownloadData() { AltosDevice device = MicroDeviceDialog.show(this); - + if (device != null) new MicroDownload(this, device); } @@ -120,7 +131,7 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene if (save.runDialog()) SetName(data.name); } - + private void Export() { if (data == null) { no_data(); @@ -182,10 +193,25 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene public void itemStateChanged(ItemEvent e) { } + /* OSXAdapter interfaces */ + public void macosx_file_handler(String path) { + CommandGraph(new File(path)); + } + + public void macosx_quit_handler() { + System.exit(0); + } + + public void macosx_preferences_handler() { + Preferences(); + } + public MicroPeak() { ++number_of_windows; + register_for_macosx_events(); + AltosUIPreferences.set_component(this); container = getContentPane(); @@ -227,20 +253,27 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene fileMenu.add(exitAction); exitAction.addActionListener(this); + JButton downloadButton = new JButton ("Download"); + downloadButton.addActionListener(this); + menuBar.add(downloadButton); + setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - stats.tell_closing(); + statsTable.tell_closing(); Close(); } }); - graph = new MicroGraph(); - stats = new MicroStatsTable(); + enable = new AltosUIEnable(); + + graph = new AltosGraph(enable); + statsTable = new AltosFlightStatsTable(); raw = new MicroRaw(); pane.add(graph.panel, "Graph"); - pane.add(stats, "Statistics"); + pane.add(enable, "Configure Graph"); + pane.add(statsTable, "Statistics"); JScrollPane scroll = new JScrollPane(raw); pane.add(scroll, "Raw Data"); pane.doLayout(); @@ -294,8 +327,9 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene CommandExport(file); opened = true; } catch (Exception e) { - System.err.printf("Error processing \"%s\": %s\n", - file.getName(), e.getMessage()); + System.err.printf("Error processing \"%s\": %s %s\n", + file.getName(), e.toString(), e.getMessage()); + e.printStackTrace(); } } }