X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUIGraph.java;h=e212093ab64c516fa2a222a7cc0370b518d59cec;hp=e79e36ba7d3bddb7e1c62c56ca1940500e68edd1;hb=0169e56ad030c0096b1068d00f06957990dfb31f;hpb=518b16f64f4be096ceff13ab31b96d6909fe3ae2 diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index e79e36ba..e212093a 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -41,8 +41,9 @@ public class AltosUIGraph implements AltosUnitsListener { public ChartPanel panel; NumberAxis xAxis; AltosUIEnable enable; - ArrayList series; + ArrayList graphers; AltosUIDataSet dataSet; + int index; static final private Color gridline_color = new Color(0, 0, 0); static final private Color border_color = new Color(255, 255, 255); @@ -52,7 +53,7 @@ public class AltosUIGraph implements AltosUnitsListener { return panel; } - public void addSeries(int index, String label, int fetch, AltosUnits units, Color color) { + public void addSeries(String label, int fetch, AltosUnits units, Color color) { AltosUISeries series = new AltosUISeries(label, fetch, units, color); XYSeriesCollection dataset = new XYSeriesCollection(series); @@ -63,22 +64,30 @@ public class AltosUIGraph implements AltosUnitsListener { plot.mapDatasetToRangeAxis(index, index); if (enable != null) enable.add(label, series, true); - this.series.add(series); + this.graphers.add(series); + index++; } + public void addMarker(String label, int fetch, Color color) { + AltosUIMarker marker = new AltosUIMarker(fetch, color, plot); + if (enable != null) + enable.add(label, marker, true); + this.graphers.add(marker); + } + public void resetData() { - for (AltosUISeries s : series) - s.clear(); + for (AltosUIGrapher g : graphers) + g.clear(); if (dataSet != null) { for (AltosUIDataPoint dataPoint : dataSet.dataPoints()) - for (AltosUISeries s : series) - s.add(dataPoint); + for (AltosUIGrapher g : graphers) + g.add(dataPoint); } } public void units_changed(boolean imperial_units) { - for (AltosUISeries s : series) - s.set_units(); + for (AltosUIGrapher g : graphers) + g.set_units(); resetData(); } @@ -96,7 +105,8 @@ public class AltosUIGraph implements AltosUnitsListener { public AltosUIGraph(AltosUIEnable enable) { this.enable = enable; - this.series = new ArrayList(); + this.graphers = new ArrayList(); + this.index = 0; xAxis = new NumberAxis("Time (s)");