From cbf5a649c8b7101bef9d57e48e42ac775e758c79 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 8 Oct 2011 11:46:38 -0600 Subject: [PATCH] altosui: Allow for multiple instances of each state in the graph With the new boost re-detect code, we can get multiple instances of boost/fast/coast, so make sure each are displayed in the graph. Signed-off-by: Keith Packard --- altosui/AltosGraphTime.java | 31 +++++++++++++++++-------------- altosui/AltosGraphUI.java | 6 ++++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/altosui/AltosGraphTime.java b/altosui/AltosGraphTime.java index ada6ef13..6a084b2c 100644 --- a/altosui/AltosGraphTime.java +++ b/altosui/AltosGraphTime.java @@ -4,6 +4,11 @@ package altosui; +import java.lang.*; +import java.io.*; +import java.util.concurrent.*; +import java.util.*; +import java.text.*; import java.awt.Color; import java.util.ArrayList; import java.util.HashMap; @@ -98,9 +103,10 @@ class AltosGraphTime extends AltosGraph { } static class StateMarker implements Element { - private double val = Double.NaN; + private LinkedList times = new LinkedList(); private String name; private int state; + private int prev_state = Altos.ao_flight_startup; StateMarker(int state, String name) { this.state = state; @@ -109,22 +115,19 @@ class AltosGraphTime extends AltosGraph { public void attachGraph(AltosGraphTime g) { return; } public void gotTimeData(double time, AltosDataPoint d) { - if (Double.isNaN(val) || time < val) { - if (d.state() == state) { - val = time; - } - } + if (prev_state != state && d.state() == state) + times.add(time); + prev_state = d.state(); } public void addToPlot(AltosGraphTime g, XYPlot plot) { - if (Double.isNaN(val)) - return; - - ValueMarker m = new ValueMarker(val); - m.setLabel(name); - m.setLabelAnchor(RectangleAnchor.TOP_RIGHT); - m.setLabelTextAnchor(TextAnchor.TOP_LEFT); - plot.addDomainMarker(m); + for (double time : times) { + ValueMarker m = new ValueMarker(time); + m.setLabel(name); + m.setLabelAnchor(RectangleAnchor.TOP_RIGHT); + m.setLabelTextAnchor(TextAnchor.TOP_LEFT); + plot.addDomainMarker(m); + } } } diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index be52bd4e..030bbc25 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -109,6 +109,8 @@ public class AltosGraphUI extends JFrame protected AltosGraphTime myAltosGraphTime(String suffix) { return (new AltosGraphTime("Overall " + suffix)) .addElement(e_boost) + .addElement(e_fast) + .addElement(e_coast) .addElement(e_drogue) .addElement(e_main) .addElement(e_landed); @@ -238,8 +240,8 @@ public class AltosGraphUI extends JFrame { ArrayList graph = new ArrayList(); graph.addAll((new OverallGraphs()).graphs()); - graph.addAll((new AscentGraphs()).graphs()); - graph.addAll((new DescentGraphs()).graphs()); +// graph.addAll((new AscentGraphs()).graphs()); +// graph.addAll((new DescentGraphs()).graphs()); if (which > 0) { if (which >= graph.size()) { -- 2.30.2