* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-package org.altusmetrum.altosuilib_1;
+package org.altusmetrum.altosuilib_7;
import java.io.*;
import java.util.ArrayList;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_7.*;
import org.jfree.ui.*;
import org.jfree.chart.*;
AltosUIEnable enable;
ArrayList<AltosUIGrapher> graphers;
AltosUIDataSet dataSet;
- int index;
+ int axis_index;
+ int series_index;
static final private Color gridline_color = new Color(0, 0, 0);
static final private Color border_color = new Color(255, 255, 255);
return panel;
}
- public void addSeries(String label, int fetch, AltosUnits units, Color color) {
- AltosUISeries series = new AltosUISeries(label, fetch, units, color);
+ public AltosUIAxis newAxis(String label, AltosUnits units, Color color, int flags) {
+ AltosUIAxis axis = new AltosUIAxis(label, units, color, axis_index++, flags);
+ plot.setRangeAxis(axis.index, axis);
+ return axis;
+ }
+
+ public AltosUIAxis newAxis(String label, AltosUnits units, Color color) {
+ return newAxis(label, units, color, AltosUIAxis.axis_default);
+ }
+
+ public void addSeries(String label, int fetch, AltosUnits units, Color color,
+ boolean enabled, AltosUIAxis axis) {
+ AltosUISeries series = new AltosUISeries(label, fetch, units, color, enabled, axis);
XYSeriesCollection dataset = new XYSeriesCollection(series);
series.renderer.setPlot(plot);
- plot.setRangeAxis(index, series.axis);
- plot.setDataset(index, dataset);
- plot.setRenderer(index, series.renderer);
- plot.mapDatasetToRangeAxis(index, index);
+ plot.setDataset(series_index, dataset);
+ plot.setRenderer(series_index, series.renderer);
+ plot.mapDatasetToRangeAxis(series_index, axis.index);
if (enable != null)
- enable.add(label, series, true);
+ enable.add(label, series, enabled);
this.graphers.add(series);
- index++;
+ series_index++;
+ }
+
+ public void addSeries(String label, int fetch, AltosUnits units, Color color) {
+ addSeries(label, fetch, units, color, true, newAxis(label, units, color));
}
-
+
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 (AltosUIGrapher g : graphers)
+ for (AltosUIGrapher g : graphers) {
g.clear();
+ g.setNotify(false);
+ }
if (dataSet != null) {
for (AltosUIDataPoint dataPoint : dataSet.dataPoints())
for (AltosUIGrapher g : graphers)
g.add(dataPoint);
}
+ for (AltosUIGrapher g : graphers) {
+ g.setNotify(true);
+ g.fireSeriesChanged();
+ }
}
public void units_changed(boolean imperial_units) {
public void setDataSet (AltosUIDataSet dataSet) {
this.dataSet = dataSet;
+ resetData();
if (dataSet != null)
setName(dataSet.name());
- resetData();
}
public AltosUIGraph(AltosUIEnable enable) {
this.enable = enable;
this.graphers = new ArrayList<AltosUIGrapher>();
- this.index = 0;
+ this.series_index = 0;
+ this.axis_index = 0;
xAxis = new NumberAxis("Time (s)");
-
+
xAxis.setAutoRangeIncludesZero(true);
plot = new XYPlot();
AltosPreferences.register_units_listener(this);
}
-}
\ No newline at end of file
+}