altosui: Hacks to plug into the new graph stuff
[fw/altos] / altosui / AltosUI.java
index 019bbb9e79e00dbcdbf7dc81229fd38aedabd27c..7caaa3e9a5107f067b02dc5584b42ab174de8072 100644 (file)
@@ -348,7 +348,7 @@ public class AltosUI extends AltosUIFrame {
                if (states == null)
                        return;
                try {
-                       new AltosGraphUI(states, chooser.file());
+                       new AltosGraphUI(states, new AltosEepromRecordSet(new FileReader(chooser.file())), chooser.file());
                } catch (InterruptedException ie) {
                } catch (IOException ie) {
                }
@@ -367,16 +367,16 @@ public class AltosUI extends AltosUIFrame {
 
        static AltosStateIterable open_logfile(File file) {
                try {
-                       FileInputStream in;
-
-                       in = new FileInputStream(file);
                        if (file.getName().endsWith("telem"))
-                               return new AltosTelemetryFile(in);
+                               return new AltosTelemetryFile(new FileInputStream(file));
                        else
-                               return new AltosEepromFile(in);
+                               return new AltosEepromFile(new FileReader(file));
                } catch (FileNotFoundException fe) {
                        System.out.printf("%s\n", fe.getMessage());
                        return null;
+               } catch (IOException ie) {
+                       System.out.printf("%s\n", ie.getMessage());
+                       return null;
                }
        }
 
@@ -448,16 +448,23 @@ public class AltosUI extends AltosUIFrame {
 
        static AltosStateIterable record_iterable(File file) {
                FileInputStream in;
-               try {
-                       in = new FileInputStream(file);
-               } catch (Exception e) {
-                       System.out.printf("Failed to open file '%s'\n", file);
-                       return null;
+               if (file.getName().endsWith("telem")) {
+                       try {
+                               in = new FileInputStream(file);
+                               return new AltosTelemetryFile(in);
+                       } catch (Exception e) {
+                               System.out.printf("Failed to open file '%s'\n", file);
+                       }
+               } else {
+
+                       try {
+                               AltosEepromFile f = new AltosEepromFile(new FileReader(file));
+                               return f;
+                       } catch (Exception e) {
+                               System.out.printf("Failed to open file '%s'\n", file);
+                       }
                }
-               if (file.getName().endsWith("telem"))
-                       return new AltosTelemetryFile(in);
-               else
-                       return new AltosEepromFile(in);
+               return null;
        }
 
        static AltosReplayReader replay_file(File file) {
@@ -480,7 +487,7 @@ public class AltosUI extends AltosUIFrame {
                if (states == null)
                        return false;
                try {
-                       new AltosGraphUI(states, file);
+                       new AltosGraphUI(states, new AltosEepromRecordSet(new FileReader(file)), file);
                        return true;
                } catch (InterruptedException ie) {
                } catch (IOException ie) {