X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=micropeak%2FMicroData.java;h=26e3c07dc41851e75efd886a6ac900655633cab8;hb=ab9caa22ea905844a99e08b5f6d3b072f094283e;hp=473af44bc691da619c51deef5988039717d0582f;hpb=9839b0b62d797a8616fc66038e3f3c68e2a214d0;p=fw%2Faltos diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index 473af44b..26e3c07d 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -21,6 +21,7 @@ import java.lang.*; import java.io.*; import java.util.*; import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; class MicroIterator implements Iterator { int i; @@ -56,7 +57,40 @@ class MicroIterable implements Iterable { } } -public class MicroData { +class MicroUIIterator implements Iterator { + int i; + MicroData data; + + public boolean hasNext() { + return i < data.pressures.length; + } + + public AltosUIDataPoint next() { + return new MicroDataPoint(data, i++); + } + + public MicroUIIterator (MicroData data) { + this.data = data; + i = 0; + } + + public void remove() { + } +} + +class MicroUIIterable implements Iterable { + MicroData data; + + public Iterator iterator() { + return new MicroUIIterator(data); + } + + public MicroUIIterable(MicroData data) { + this.data = data; + } +} + +public class MicroData implements AltosUIDataSet { public int ground_pressure; public int min_pressure; public int[] pressures; @@ -65,7 +99,6 @@ public class MicroData { private ArrayList bytes; String name; - class FileEndedException extends Exception { } @@ -178,6 +211,14 @@ public class MicroData { return AltosConvert.pressure_to_altitude(pressures[i]); } + public String name() { + return name; + } + + public Iterable dataPoints() { + return new MicroUIIterable(this); + } + public Iterable points() { return new MicroIterable(this); }