diff options
Diffstat (limited to 'altosuilib')
23 files changed, 694 insertions, 24 deletions
diff --git a/altosuilib/AltosDevice.java b/altosuilib/AltosDevice.java index 69b025ba..2461df1b 100644 --- a/altosuilib/AltosDevice.java +++ b/altosuilib/AltosDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import libaltosJNI.*; diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index cde545a7..73bc0b2f 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import javax.swing.*; import java.awt.*; diff --git a/altosuilib/AltosFontListener.java b/altosuilib/AltosFontListener.java index ef543264..da903352 100644 --- a/altosuilib/AltosFontListener.java +++ b/altosuilib/AltosFontListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public interface AltosFontListener { void font_size_changed(int font_size); diff --git a/altosuilib/AltosPositionListener.java b/altosuilib/AltosPositionListener.java index 4f90446c..e75d2de5 100644 --- a/altosuilib/AltosPositionListener.java +++ b/altosuilib/AltosPositionListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public interface AltosPositionListener { public void position_changed(int position); diff --git a/altosuilib/AltosUIAxis.java b/altosuilib/AltosUIAxis.java new file mode 100644 index 00000000..70084a00 --- /dev/null +++ b/altosuilib/AltosUIAxis.java @@ -0,0 +1,92 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +public class AltosUIAxis extends NumberAxis { + String label; + AltosUnits units; + Color color; + int ref; + int visible; + int index; + + public final static int axis_integer = 1; + public final static int axis_include_zero = 2; + + public final static int axis_default = axis_include_zero; + + public void set_units() { + setLabel(String.format("%s (%s)", label, units.show_units())); + } + + public void set_enable(boolean enable) { + if (enable) { + visible++; + if (visible > ref) + System.out.printf("too many visible\n"); + } else { + visible--; + if (visible < 0) + System.out.printf("too few visible\n"); + } + setVisible(visible > 0); + } + + public void ref(boolean enable) { + ++ref; + if (enable) { + ++visible; + setVisible(visible > 0); + } + } + + public AltosUIAxis(String label, AltosUnits units, Color color, int index, int flags) { + this.label = label; + this.units = units; + this.index = index; + this.visible = 0; + this.ref = 0; + setLabelPaint(color); + setTickLabelPaint(color); + setVisible(false); + if ((flags & axis_integer) != 0) + setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + setAutoRangeIncludesZero((flags & axis_include_zero) != 0); + } + + public AltosUIAxis(String label, AltosUnits units, Color color, int index) { + this(label, units, color, index, axis_default); + } +} diff --git a/altosuilib/AltosUIConfigure.java b/altosuilib/AltosUIConfigure.java index 90b413d6..9e72e403 100644 --- a/altosuilib/AltosUIConfigure.java +++ b/altosuilib/AltosUIConfigure.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIDataMissing.java b/altosuilib/AltosUIDataMissing.java new file mode 100644 index 00000000..c7b01859 --- /dev/null +++ b/altosuilib/AltosUIDataMissing.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +public class AltosUIDataMissing extends Exception { + public int id; + public AltosUIDataMissing(int id) { + this.id = id; + } +}
\ No newline at end of file diff --git a/altosuilib/AltosUIDataPoint.java b/altosuilib/AltosUIDataPoint.java new file mode 100644 index 00000000..d3020410 --- /dev/null +++ b/altosuilib/AltosUIDataPoint.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +public interface AltosUIDataPoint { + public abstract double x() throws AltosUIDataMissing; + public abstract double y(int index) throws AltosUIDataMissing; + public abstract int id(int index) throws AltosUIDataMissing; + public abstract String id_name(int index) throws AltosUIDataMissing; +} diff --git a/altosuilib/AltosUnitsListener.java b/altosuilib/AltosUIDataSet.java index 22c66cd4..6f23ef9a 100644 --- a/altosuilib/AltosUnitsListener.java +++ b/altosuilib/AltosUIDataSet.java @@ -1,5 +1,5 @@ /* - * Copyright © 2012 Keith Packard <keithp@keithp.com> + * Copyright © 2013 Keith Packard <keithp@keithp.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,8 +15,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; -public interface AltosUnitsListener { - public void units_changed(); +public interface AltosUIDataSet { + public abstract String name(); + public abstract Iterable<AltosUIDataPoint> dataPoints(); } diff --git a/altosuilib/AltosUIDialog.java b/altosuilib/AltosUIDialog.java index c0c33ba6..e1e699a7 100644 --- a/altosuilib/AltosUIDialog.java +++ b/altosuilib/AltosUIDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java new file mode 100644 index 00000000..55486dea --- /dev/null +++ b/altosuilib/AltosUIEnable.java @@ -0,0 +1,121 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.util.concurrent.*; +import java.util.*; +import org.altusmetrum.altoslib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +public class AltosUIEnable extends Container { + + Insets il, ir; + int y; + + class GraphElement implements ActionListener { + AltosUIGrapher grapher; + JLabel label; + JRadioButton enable; + String name; + + public void actionPerformed(ActionEvent ae) { + grapher.set_enable(enable.isSelected()); + } + + GraphElement (String name, AltosUIGrapher grapher, boolean enabled) { + this.name = name; + this.grapher = grapher; + label = new JLabel(name); + enable = new JRadioButton("Enable", enabled); + grapher.set_enable(enabled); + enable.addActionListener(this); + } + } + + public void add(String name, AltosUIGrapher grapher, boolean enabled) { + + GraphElement e = new GraphElement(name, grapher, enabled); + + /* Add label */ + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 0; c.gridy = y; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + add(e.label, c); + + /* Add radio button */ + c = new GridBagConstraints(); + c.gridx = 1; c.gridy = y; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.CENTER; + c.insets = ir; + add(e.enable, c); + + /* Next row */ + y++; + } + + public void add_units() { + /* Imperial units setting */ + /* Add label */ + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 0; c.gridy = 1000; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + add(new JLabel("Imperial Units"), c); + + JRadioButton imperial_units = new JRadioButton("Enable", AltosUIPreferences.imperial_units()); + imperial_units.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JRadioButton item = (JRadioButton) e.getSource(); + boolean enabled = item.isSelected(); + AltosUIPreferences.set_imperial_units(enabled); + } + }); + imperial_units.setToolTipText("Use Imperial units instead of metric"); + c = new GridBagConstraints(); + c.gridx = 1; c.gridy = 1000; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + add(imperial_units, c); + } + + public AltosUIEnable() { + il = new Insets(4,4,4,4); + ir = new Insets(4,4,4,4); + y = 0; + setLayout(new GridBagLayout()); + add_units(); + } +} diff --git a/altosuilib/AltosUIFrame.java b/altosuilib/AltosUIFrame.java index b93b2d21..3fc99910 100644 --- a/altosuilib/AltosUIFrame.java +++ b/altosuilib/AltosUIFrame.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java new file mode 100644 index 00000000..5c589c02 --- /dev/null +++ b/altosuilib/AltosUIGraph.java @@ -0,0 +1,155 @@ +/* + * Copyright © 2012 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +public class AltosUIGraph implements AltosUnitsListener { + + XYPlot plot; + JFreeChart chart; + public ChartPanel panel; + NumberAxis xAxis; + AltosUIEnable enable; + ArrayList<AltosUIGrapher> graphers; + AltosUIDataSet dataSet; + 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); + static final private Color background_color = new Color(255, 255, 255); + + public JPanel panel() { + return panel; + } + + 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.setDataset(series_index, dataset); + plot.setRenderer(series_index, series.renderer); + plot.mapDatasetToRangeAxis(series_index, axis.index); + if (enable != null) + enable.add(label, series, enabled); + this.graphers.add(series); + 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) + g.clear(); + if (dataSet != null) { + for (AltosUIDataPoint dataPoint : dataSet.dataPoints()) + for (AltosUIGrapher g : graphers) + g.add(dataPoint); + } + } + + public void units_changed(boolean imperial_units) { + for (AltosUIGrapher g : graphers) + g.set_units(); + resetData(); + } + + public void setName (String name) { + chart.setTitle(name); + } + + public void setDataSet (AltosUIDataSet dataSet) { + this.dataSet = dataSet; + resetData(); + if (dataSet != null) + setName(dataSet.name()); + } + + public AltosUIGraph(AltosUIEnable enable) { + + this.enable = enable; + this.graphers = new ArrayList<AltosUIGrapher>(); + this.series_index = 0; + this.axis_index = 0; + + xAxis = new NumberAxis("Time (s)"); + + xAxis.setAutoRangeIncludesZero(true); + + plot = new XYPlot(); + plot.setDomainAxis(xAxis); + plot.setOrientation(PlotOrientation.VERTICAL); + plot.setDomainPannable(true); + plot.setRangePannable(true); + + chart = new JFreeChart("Flight", JFreeChart.DEFAULT_TITLE_FONT, + plot, true); + + ChartUtilities.applyCurrentTheme(chart); + + plot.setDomainGridlinePaint(gridline_color); + plot.setRangeGridlinePaint(gridline_color); + plot.setBackgroundPaint(background_color); + plot.setBackgroundAlpha((float) 1); + + chart.setBackgroundPaint(background_color); + chart.setBorderPaint(border_color); + panel = new ChartPanel(chart); + panel.setMouseWheelEnabled(true); + panel.setPreferredSize(new java.awt.Dimension(800, 500)); + + AltosPreferences.register_units_listener(this); + } +}
\ No newline at end of file diff --git a/altosuilib/AltosUIGrapher.java b/altosuilib/AltosUIGrapher.java new file mode 100644 index 00000000..c627fec5 --- /dev/null +++ b/altosuilib/AltosUIGrapher.java @@ -0,0 +1,46 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +interface AltosUIGrapher { + + public abstract void set_units(); + + public abstract void clear(); + + public abstract void add(AltosUIDataPoint dataPoint); + + public abstract void set_enable(boolean enable); +} diff --git a/altosuilib/AltosUILib.java b/altosuilib/AltosUILib.java index d0bdc5b6..1b121405 100644 --- a/altosuilib/AltosUILib.java +++ b/altosuilib/AltosUILib.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; public class AltosUILib extends AltosLib { diff --git a/altosuilib/AltosUIListener.java b/altosuilib/AltosUIListener.java index f4127f58..450dc0bf 100644 --- a/altosuilib/AltosUIListener.java +++ b/altosuilib/AltosUIListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public interface AltosUIListener { public void ui_changed(String look_and_feel); diff --git a/altosuilib/AltosUIMarker.java b/altosuilib/AltosUIMarker.java new file mode 100644 index 00000000..e2eb9028 --- /dev/null +++ b/altosuilib/AltosUIMarker.java @@ -0,0 +1,106 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +public class AltosUIMarker implements AltosUIGrapher { + ArrayList<ValueMarker> markers; + int last_id; + XYPlot plot; + boolean enabled; + int fetch; + Color color; + + private void remove_markers() { + for (ValueMarker marker : markers) + plot.removeDomainMarker(marker); + } + + private void add_markers() { + for (ValueMarker marker : markers) + plot.addDomainMarker(marker); + } + + public void set_units() { + } + + public void set_enable(boolean enable) { + if (enabled == enable) + return; + if (enable) + add_markers(); + else + remove_markers(); + enabled = enable; + } + + public void clear() { + if (enabled) + remove_markers(); + markers = new ArrayList<ValueMarker>(); + } + + public void add(AltosUIDataPoint dataPoint) { + try { + int id = dataPoint.id(fetch); + if (id < 0) + return; + if (id == last_id) + return; + ValueMarker marker = new ValueMarker(dataPoint.x()); + marker.setLabel(dataPoint.id_name(fetch)); + marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); + marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); + marker.setPaint(color); + if (enabled) + plot.addDomainMarker(marker); + markers.add(marker); + last_id = id; + } catch (AltosUIDataMissing m) { + } + } + + public AltosUIMarker (int fetch, Color color, XYPlot plot, boolean enable) { + markers = new ArrayList<ValueMarker>(); + last_id = -1; + this.fetch = fetch; + this.color = color; + this.plot = plot; + this.enabled = enable; + } + + public AltosUIMarker (int fetch, Color color, XYPlot plot) { + this(fetch, color, plot, true); + } +}
\ No newline at end of file diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 50211fce..49321bce 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.io.*; import java.util.*; import java.awt.Component; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; public class AltosUIPreferences extends AltosPreferences { diff --git a/altosuilib/AltosUIPreferencesBackend.java b/altosuilib/AltosUIPreferencesBackend.java index c6c05e55..8a5386c3 100644 --- a/altosuilib/AltosUIPreferencesBackend.java +++ b/altosuilib/AltosUIPreferencesBackend.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java new file mode 100644 index 00000000..ac09a3cc --- /dev/null +++ b/altosuilib/AltosUISeries.java @@ -0,0 +1,91 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +public class AltosUISeries extends XYSeries implements AltosUIGrapher { + AltosUIAxis axis; + String label; + AltosUnits units; + Color color; + XYItemRenderer renderer; + int fetch; + boolean enable; + + public void set_units() { + axis.set_units(); + StandardXYToolTipGenerator ttg; + + String example = units.graph_format(4); + + ttg = new StandardXYToolTipGenerator(String.format("{1}s: {2}%s ({0})", + units.show_units()), + new java.text.DecimalFormat(example), + new java.text.DecimalFormat(example)); + renderer.setBaseToolTipGenerator(ttg); + } + + public void set_enable(boolean enable) { + if (this.enable != enable) { + this.enable = enable; + renderer.setSeriesVisible(0, enable); + axis.set_enable(enable); + } + } + + public void add(AltosUIDataPoint dataPoint) { + try { + super.add(dataPoint.x(), units.value(dataPoint.y(fetch))); + } catch (AltosUIDataMissing dm) { + } + } + + public AltosUISeries (String label, int fetch, AltosUnits units, Color color, + boolean enable, AltosUIAxis axis) { + super(label); + this.label = label; + this.fetch = fetch; + this.units = units; + this.color = color; + this.enable = enable; + this.axis = axis; + + axis.ref(this.enable); + + renderer = new XYLineAndShapeRenderer(true, false); + renderer.setSeriesPaint(0, color); + renderer.setSeriesVisible(0, enable); + set_units(); + } +} diff --git a/altosuilib/AltosUIVersion.java.in b/altosuilib/AltosUIVersion.java.in index 6fb3b38b..169cca1b 100644 --- a/altosuilib/AltosUIVersion.java.in +++ b/altosuilib/AltosUIVersion.java.in @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public class AltosUIVersion { public final static String version = "@VERSION@"; diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index bab16fb0..a5496597 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.util.*; import libaltosJNI.*; diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 5fb82793..0cd2aaea 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -9,22 +9,30 @@ SRC=. altosuilibdir = $(datadir)/java altosuilib_JAVA = \ - AltosUIConfigure.java \ AltosDevice.java \ AltosDeviceDialog.java \ - AltosUSBDevice.java \ AltosFontListener.java \ AltosPositionListener.java \ + AltosUIConfigure.java \ + AltosUIAxis.java \ + AltosUIDataMissing.java \ + AltosUIDataPoint.java \ + AltosUIDataSet.java \ + AltosUIGraph.java \ + AltosUIGrapher.java \ AltosUIDialog.java \ + AltosUIEnable.java \ AltosUIFrame.java \ AltosUILib.java \ AltosUIListener.java \ + AltosUIMarker.java \ AltosUIPreferencesBackend.java \ AltosUIPreferences.java \ + AltosUISeries.java \ AltosUIVersion.java \ - AltosUnitsListener.java + AltosUSBDevice.java -JAR=altosuilib.jar +JAR=altosuilib_$(ALTOSUILIB_VERSION).jar all-local: $(JAR) |
