summaryrefslogtreecommitdiff
path: root/micropeak/MicroData.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-02-09 01:59:18 -0800
committerKeith Packard <keithp@keithp.com>2013-02-10 00:30:32 -0800
commitab9caa22ea905844a99e08b5f6d3b072f094283e (patch)
tree4555f3f77eccb1390693157880c834030e7512d0 /micropeak/MicroData.java
parent9839b0b62d797a8616fc66038e3f3c68e2a214d0 (diff)
micropeak: Use altosuilib graphing functions
Move these out of micropeak and into shared code Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'micropeak/MicroData.java')
-rw-r--r--micropeak/MicroData.java45
1 files changed, 43 insertions, 2 deletions
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<MicroDataPoint> {
int i;
@@ -56,7 +57,40 @@ class MicroIterable implements Iterable<MicroDataPoint> {
}
}
-public class MicroData {
+class MicroUIIterator implements Iterator<AltosUIDataPoint> {
+ 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<AltosUIDataPoint> {
+ MicroData data;
+
+ public Iterator<AltosUIDataPoint> 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<Integer> 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<AltosUIDataPoint> dataPoints() {
+ return new MicroUIIterable(this);
+ }
+
public Iterable<MicroDataPoint> points() {
return new MicroIterable(this);
}