From ab9caa22ea905844a99e08b5f6d3b072f094283e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 9 Feb 2013 01:59:18 -0800 Subject: micropeak: Use altosuilib graphing functions Move these out of micropeak and into shared code Signed-off-by: Keith Packard --- micropeak/MicroData.java | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'micropeak/MicroData.java') 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); } -- cgit v1.2.3