diff options
| author | Keith Packard <keithp@keithp.com> | 2013-02-10 00:29:29 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2013-02-10 00:30:32 -0800 | 
| commit | 2efd3ad80d4fefa8ccc1b80a2e657dbf9ba0c60f (patch) | |
| tree | 02fdd0be077d082702da5f150670437e080318e2 /altosuilib/AltosUIGraph.java | |
| parent | 0169e56ad030c0096b1068d00f06957990dfb31f (diff) | |
altosui/altoslib/altosuilib: Switch altosui to shared graph code
This adds a configuration tab to the graph window to enable/disable
various plotted values.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib/AltosUIGraph.java')
| -rw-r--r-- | altosuilib/AltosUIGraph.java | 38 | 
1 files changed, 27 insertions, 11 deletions
| diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index e212093a..5c589c02 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -43,7 +43,8 @@ public class AltosUIGraph implements AltosUnitsListener {  	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); @@ -53,19 +54,33 @@ public class AltosUIGraph implements AltosUnitsListener {  		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) { @@ -97,16 +112,17 @@ public class AltosUIGraph implements AltosUnitsListener {  	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)"); | 
