From 96de483d745ea0ef95326de2847a2534f7057846 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 11 May 2017 17:16:56 -0700 Subject: [PATCH] altosuilib: Start creating new graph interface that takes time series data Replace the AltosState interface so the graph can get better data, and can be used for more stuff. Signed-off-by: Keith Packard --- altosuilib/AltosGraph.java | 48 +--- altosuilib/AltosGraphNew.java | 361 ++++++++++++++++++++++++++++ altosuilib/AltosUIFlightSeries.java | 68 ++++++ altosuilib/AltosUIGraphNew.java | 153 ++++++++++++ altosuilib/AltosUIGrapher.java | 2 + altosuilib/AltosUIMarker.java | 4 +- altosuilib/AltosUISeries.java | 2 + altosuilib/AltosUITimeSeries.java | 83 ++++++- altosuilib/Makefile.am | 3 + 9 files changed, 672 insertions(+), 52 deletions(-) create mode 100644 altosuilib/AltosGraphNew.java create mode 100644 altosuilib/AltosUIFlightSeries.java create mode 100644 altosuilib/AltosUIGraphNew.java diff --git a/altosuilib/AltosGraph.java b/altosuilib/AltosGraph.java index 2dbd1612..880fc8a2 100644 --- a/altosuilib/AltosGraph.java +++ b/altosuilib/AltosGraph.java @@ -35,29 +35,6 @@ import org.jfree.chart.labels.*; import org.jfree.data.xy.*; import org.jfree.data.*; -class AltosVoltage extends AltosUnits { - - public double value(double v, boolean imperial_units) { - return v; - } - - public double inverse(double v, boolean imperial_units) { - return v; - } - - public String show_units(boolean imperial_units) { - return "V"; - } - - public String say_units(boolean imperial_units) { - return "volts"; - } - - public int show_fraction(int width, boolean imperial_units) { - return width / 2; - } -} - class AltosNsat extends AltosUnits { public double value(double v, boolean imperial_units) { @@ -104,29 +81,6 @@ class AltosDbm extends AltosUnits { } } -class AltosGyroUnits extends AltosUnits { - - public double value(double p, boolean imperial_units) { - return p; - } - - public double inverse(double p, boolean imperial_units) { - return p; - } - - public String show_units(boolean imperial_units) { - return "°/sec"; - } - - public String say_units(boolean imperial_units) { - return "degrees per second"; - } - - public int show_fraction(int width, boolean imperial_units) { - return 1; - } -} - class AltosMagUnits extends AltosUnits { public double value(double p, boolean imperial_units) { @@ -213,7 +167,7 @@ public class AltosGraph extends AltosUIGraph { static AltosPressure pressure_units = new AltosPressure(); static AltosNsat nsat_units = new AltosNsat(); static AltosDbm dbm_units = new AltosDbm(); - static AltosGyroUnits gyro_units = new AltosGyroUnits(); + static AltosRotationRate gyro_units = new AltosRotationRate(); static AltosOrient orient_units = new AltosOrient(); static AltosMagUnits mag_units = new AltosMagUnits(); static AltosDopUnits dop_units = new AltosDopUnits(); diff --git a/altosuilib/AltosGraphNew.java b/altosuilib/AltosGraphNew.java new file mode 100644 index 00000000..ba2dc717 --- /dev/null +++ b/altosuilib/AltosGraphNew.java @@ -0,0 +1,361 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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_11; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_11.*; + +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 AltosGraphNew extends AltosUIGraphNew { + + static final private Color height_color = new Color(194,31,31); + static final private Color gps_height_color = new Color(150,31,31); + static final private Color pressure_color = new Color (225,31,31); + static final private Color range_color = new Color(100, 31, 31); + static final private Color distance_color = new Color(100, 31, 194); + static final private Color speed_color = new Color(31,194,31); + static final private Color accel_color = new Color(31,31,194); + static final private Color voltage_color = new Color(194, 194, 31); + static final private Color battery_voltage_color = new Color(194, 194, 31); + static final private Color drogue_voltage_color = new Color(150, 150, 31); + static final private Color main_voltage_color = new Color(100, 100, 31); + static final private Color gps_nsat_color = new Color (194, 31, 194); + static final private Color gps_nsat_solution_color = new Color (194, 31, 194); + static final private Color gps_nsat_view_color = new Color (150, 31, 150); + static final private Color gps_course_color = new Color (100, 31, 112); + static final private Color gps_ground_speed_color = new Color (31, 112, 100); + static final private Color gps_climb_rate_color = new Color (31, 31, 112); + static final private Color gps_pdop_color = new Color(50, 194, 0); + static final private Color gps_hdop_color = new Color(50, 0, 194); + static final private Color gps_vdop_color = new Color(194, 0, 50); + static final private Color temperature_color = new Color (31, 194, 194); + static final private Color dbm_color = new Color(31, 100, 100); + static final private Color state_color = new Color(0,0,0); + static final private Color accel_x_color = new Color(255, 0, 0); + static final private Color accel_y_color = new Color(0, 255, 0); + static final private Color accel_z_color = new Color(0, 0, 255); + static final private Color gyro_x_color = new Color(192, 0, 0); + static final private Color gyro_y_color = new Color(0, 192, 0); + static final private Color gyro_z_color = new Color(0, 0, 192); + static final private Color mag_x_color = new Color(128, 0, 0); + static final private Color mag_y_color = new Color(0, 128, 0); + static final private Color mag_z_color = new Color(0, 0, 128); + static final private Color orient_color = new Color(31, 31, 31); + + static AltosNsat nsat_units = new AltosNsat(); + static AltosDbm dbm_units = new AltosDbm(); + static AltosOrient orient_units = new AltosOrient(); + static AltosMagUnits mag_units = new AltosMagUnits(); + static AltosDopUnits dop_units = new AltosDopUnits(); + + AltosUIFlightSeries flight_series; + + AltosUITimeSeries[] setup(AltosFlightStats stats, AltosRecordSet record_set) { + + AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis; + AltosUIAxis distance_axis, pressure_axis; + AltosUIAxis gyro_axis, orient_axis, mag_axis; + AltosUIAxis course_axis, dop_axis; + + height_axis = newAxis("Height", AltosConvert.height, height_color); + pressure_axis = newAxis("Pressure", AltosConvert.pressure, pressure_color, 0); + speed_axis = newAxis("Speed", AltosConvert.speed, speed_color); + accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color); + voltage_axis = newAxis("Voltage", AltosConvert.voltage, voltage_color); + temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0); + nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color, + AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer); + dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0); + distance_axis = newAxis("Distance", AltosConvert.distance, range_color); + + gyro_axis = newAxis("Rotation Rate", AltosConvert.rotation_rate, gyro_z_color, 0); + orient_axis = newAxis("Tilt Angle", orient_units, orient_color, 0); + mag_axis = newAxis("Magnetic Field", mag_units, mag_x_color, 0); + course_axis = newAxis("Course", orient_units, gps_course_color, 0); + dop_axis = newAxis("Dilution of Precision", dop_units, gps_pdop_color, 0); + + flight_series = new AltosUIFlightSeries(); + + flight_series.register_extra("default", + speed_color, + false, + speed_axis); + + flight_series.register_extra(AltosUIFlightSeries.accel_name, + accel_color, + true, + accel_axis); + + flight_series.register_extra(AltosUIFlightSeries.pressure_name, + pressure_color, + true, + pressure_axis); + +// addMarker("State", AltosGraphDataPoint.data_state, state_color); + + record_set.capture_series(flight_series); + + return flight_series.series(); +/* + if (stats.has_flight_data) { + addSeries("Height", + AltosGraphDataPoint.data_height, + AltosConvert.height, + height_color, + true, + height_axis); + addSeries("Pressure", + AltosGraphDataPoint.data_pressure, + pressure_units, + pressure_color, + false, + pressure_axis); + addSeries("Speed", + AltosGraphDataPoint.data_speed, + AltosConvert.speed, + speed_color, + true, + speed_axis); + addSeries("Acceleration", + AltosGraphDataPoint.data_accel, + AltosConvert.accel, + accel_color, + true, + accel_axis); + } + if (stats.has_gps) { + boolean enable_gps = false; + + if (!stats.has_flight_data) + enable_gps = true; + + addSeries("Range", + AltosGraphDataPoint.data_range, + AltosConvert.distance, + range_color, + false, + distance_axis); + addSeries("Distance", + AltosGraphDataPoint.data_distance, + AltosConvert.distance, + distance_color, + enable_gps, + distance_axis); + addSeries("GPS Height", + AltosGraphDataPoint.data_gps_height, + AltosConvert.height, + gps_height_color, + enable_gps, + height_axis); + addSeries("GPS Altitude", + AltosGraphDataPoint.data_gps_altitude, + AltosConvert.height, + gps_height_color, + false, + height_axis); + addSeries("GPS Satellites in Solution", + AltosGraphDataPoint.data_gps_nsat_solution, + nsat_units, + gps_nsat_solution_color, + false, + nsat_axis); + if (stats.has_gps_sats) { + addSeries("GPS Satellites in View", + AltosGraphDataPoint.data_gps_nsat_view, + nsat_units, + gps_nsat_view_color, + false, + nsat_axis); + } + if (stats.has_gps_detail) { + addSeries("GPS Course", + AltosGraphDataPoint.data_gps_course, + orient_units, + gps_course_color, + false, + course_axis); + addSeries("GPS Ground Speed", + AltosGraphDataPoint.data_gps_ground_speed, + AltosConvert.speed, + gps_ground_speed_color, + enable_gps, + speed_axis); + addSeries("GPS Climb Rate", + AltosGraphDataPoint.data_gps_climb_rate, + AltosConvert.speed, + gps_climb_rate_color, + enable_gps, + speed_axis); + } + addSeries("GPS Position DOP", + AltosGraphDataPoint.data_gps_pdop, + dop_units, + gps_pdop_color, + false, + dop_axis); + if (stats.has_gps_detail) { + addSeries("GPS Horizontal DOP", + AltosGraphDataPoint.data_gps_hdop, + dop_units, + gps_hdop_color, + false, + dop_axis); + addSeries("GPS Vertical DOP", + AltosGraphDataPoint.data_gps_vdop, + dop_units, + gps_vdop_color, + false, + dop_axis); + } + } + if (stats.has_rssi) + addSeries("Received Signal Strength", + AltosGraphDataPoint.data_rssi, + dbm_units, + dbm_color, + false, + dbm_axis); + + if (stats.has_battery) + addSeries("Battery Voltage", + AltosGraphDataPoint.data_battery_voltage, + voltage_units, + battery_voltage_color, + false, + voltage_axis); + + if (stats.has_flight_adc) { + addSeries("Temperature", + AltosGraphDataPoint.data_temperature, + AltosConvert.temperature, + temperature_color, + false, + temperature_axis); + addSeries("Drogue Voltage", + AltosGraphDataPoint.data_drogue_voltage, + voltage_units, + drogue_voltage_color, + false, + voltage_axis); + addSeries("Main Voltage", + AltosGraphDataPoint.data_main_voltage, + voltage_units, + main_voltage_color, + false, + voltage_axis); + } + + if (stats.has_imu) { + addSeries("Acceleration Along", + AltosGraphDataPoint.data_accel_along, + AltosConvert.accel, + accel_x_color, + false, + accel_axis); + addSeries("Acceleration Across", + AltosGraphDataPoint.data_accel_across, + AltosConvert.accel, + accel_y_color, + false, + accel_axis); + addSeries("Acceleration Through", + AltosGraphDataPoint.data_accel_through, + AltosConvert.accel, + accel_z_color, + false, + accel_axis); + addSeries("Roll Rate", + AltosGraphDataPoint.data_gyro_roll, + gyro_units, + gyro_x_color, + false, + gyro_axis); + addSeries("Pitch Rate", + AltosGraphDataPoint.data_gyro_pitch, + gyro_units, + gyro_y_color, + false, + gyro_axis); + addSeries("Yaw Rate", + AltosGraphDataPoint.data_gyro_yaw, + gyro_units, + gyro_z_color, + false, + gyro_axis); + } + if (stats.has_mag) { + addSeries("Magnetometer Along", + AltosGraphDataPoint.data_mag_along, + mag_units, + mag_x_color, + false, + mag_axis); + addSeries("Magnetometer Across", + AltosGraphDataPoint.data_mag_across, + mag_units, + mag_y_color, + false, + mag_axis); + addSeries("Magnetometer Through", + AltosGraphDataPoint.data_mag_through, + mag_units, + mag_z_color, + false, + mag_axis); + } + if (stats.has_orient) + addSeries("Tilt Angle", + AltosGraphDataPoint.data_orient, + orient_units, + orient_color, + false, + orient_axis); + if (stats.num_ignitor > 0) { + for (int i = 0; i < stats.num_ignitor; i++) + addSeries(AltosLib.ignitor_name(i), + AltosGraphDataPoint.data_ignitor_0 + i, + voltage_units, + main_voltage_color, + false, + voltage_axis); + for (int i = 0; i < stats.num_ignitor; i++) + addMarker(AltosLib.ignitor_name(i), AltosGraphDataPoint.data_ignitor_fired_0 + i, state_color); + } +*/ + } + + public AltosGraphNew(AltosUIEnable enable, AltosFlightStats stats, AltosRecordSet record_set) { + super(enable, "Flight"); + + set_series(setup(stats, record_set)); + } +} diff --git a/altosuilib/AltosUIFlightSeries.java b/altosuilib/AltosUIFlightSeries.java new file mode 100644 index 00000000..d15c4071 --- /dev/null +++ b/altosuilib/AltosUIFlightSeries.java @@ -0,0 +1,68 @@ +/* + * Copyright © 2017 Keith Packard + * + * 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, either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + +package org.altusmetrum.altosuilib_11; + +import java.util.*; +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_11.*; + +class AltosUITimeSeriesExtra { + Color color; + boolean enabled; + AltosUIAxis axis; + + public AltosUITimeSeriesExtra(Color color, boolean enabled, AltosUIAxis axis) { + this.color = color; + this.enabled = enabled; + this.axis = axis; + } +} + +public class AltosUIFlightSeries extends AltosFlightSeries { + + Hashtable extra; + + public void register_extra(String label, + Color color, + boolean enabled, + AltosUIAxis axis) { + + AltosUITimeSeriesExtra e = new AltosUITimeSeriesExtra(color, + enabled, + axis); + System.out.printf("register extra label %s extra %s\n", label, e); + extra.put(label, e); + } + + public AltosTimeSeries make_series(String label, AltosUnits units) { + + AltosUITimeSeriesExtra e = extra.get(label); + + if (e == null) + e = extra.get("default"); + return new AltosUITimeSeries(label, units, + e.color, e.enabled, e.axis); + } + + public AltosUITimeSeries[] series() { + return series.toArray(new AltosUITimeSeries[0]); + } + + public AltosUIFlightSeries () { + super(); + extra = new Hashtable(); + } +} diff --git a/altosuilib/AltosUIGraphNew.java b/altosuilib/AltosUIGraphNew.java new file mode 100644 index 00000000..acfcd23d --- /dev/null +++ b/altosuilib/AltosUIGraphNew.java @@ -0,0 +1,153 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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_11; + +import java.io.*; +import java.util.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_11.*; + +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 AltosUIGraphNew implements AltosUnitsListener { + + XYPlot plot; + JFreeChart chart; + public ChartPanel panel; + NumberAxis xAxis; + AltosUIEnable enable; + AltosUITimeSeries[] series; + int axis_index; + int series_index; + Hashtable axes_added; + + 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); + } + + void addAxis(AltosUIAxis axis) { + if (!axes_added.containsKey(axis.index)) { + System.out.printf("Add axis %s %d\n", axis.label, axis_index); + axes_added.put(axis.index, true); + plot.setRangeAxis(axis.index, axis); + } + } + + public void addSeries(AltosUITimeSeries series) { + XYSeriesCollection dataset = new XYSeriesCollection(series.xy_series()); + + addAxis(series.axis); + + series.renderer.setPlot(plot); + plot.setDataset(series_index, dataset); + plot.setRenderer(series_index, series.renderer); + plot.mapDatasetToRangeAxis(series_index, series.axis.index); + if (enable != null) + enable.add(series.label, series, series.enable); + series_index++; + } + +/* + public void addMarker(String label, int fetch, Color color) { + AltosUIMarker marker = new AltosUIMarker(fetch, color, plot); + this.graphers.add(marker); + } +*/ + + public void units_changed(boolean imperial_units) { + for (AltosUITimeSeries s : series) + s.set_units(); + } + + public void setName (String name) { + chart.setTitle(name); + } + + public void set_series(AltosUITimeSeries[] series) { + this.series = series; + + for (AltosUITimeSeries s : series) + addSeries(s); + + units_changed(false); + } + + public AltosUIGraphNew(AltosUIEnable enable, String title) { + + this.enable = enable; + this.series = null; + this.axis_index = 0; + + axes_added = new Hashtable(); + + 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); + + } +} diff --git a/altosuilib/AltosUIGrapher.java b/altosuilib/AltosUIGrapher.java index 07358144..9bb91340 100644 --- a/altosuilib/AltosUIGrapher.java +++ b/altosuilib/AltosUIGrapher.java @@ -39,6 +39,8 @@ interface AltosUIGrapher { public abstract void set_units(); + public abstract boolean need_reset(); + public abstract void clear(); public abstract void add(AltosUIDataPoint dataPoint); diff --git a/altosuilib/AltosUIMarker.java b/altosuilib/AltosUIMarker.java index 9d8dde60..d50dfe9a 100644 --- a/altosuilib/AltosUIMarker.java +++ b/altosuilib/AltosUIMarker.java @@ -56,6 +56,8 @@ public class AltosUIMarker implements AltosUIGrapher { public void set_units() { } + public boolean need_reset() { return true; } + public void set_enable(boolean enable) { if (enabled == enable) return; @@ -110,4 +112,4 @@ public class AltosUIMarker implements AltosUIGrapher { public AltosUIMarker (int fetch, Color color, XYPlot plot) { this(fetch, color, plot, true); } -} \ No newline at end of file +} diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java index 66cc7d69..aa598bac 100644 --- a/altosuilib/AltosUISeries.java +++ b/altosuilib/AltosUISeries.java @@ -76,6 +76,8 @@ public class AltosUISeries extends XYSeries implements AltosUIGrapher { renderer.setBaseToolTipGenerator(ttg); } + public boolean need_reset() { return true; } + public void set_enable(boolean enable) { if (this.enable != enable) { this.enable = enable; diff --git a/altosuilib/AltosUITimeSeries.java b/altosuilib/AltosUITimeSeries.java index dce48baa..fbee3125 100644 --- a/altosuilib/AltosUITimeSeries.java +++ b/altosuilib/AltosUITimeSeries.java @@ -35,17 +35,92 @@ import org.jfree.chart.labels.*; import org.jfree.data.xy.*; import org.jfree.data.*; -public class AltosUITimeSeries extends AltosTimeSeries { +class AltosXYSeries extends XYSeries { + + public AltosXYSeries(String label) { + super(label); + } +} + +public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher { Color color; - boolean enabled; + boolean enable; AltosUIAxis axis; + XYItemRenderer renderer; + AltosXYSeries xy_series; + + /* AltosUIGrapher interface */ + public boolean need_reset() { + return false; + } + + public void clear() { + } + + public void add(AltosUIDataPoint dataPoint) { + } + + public void setNotify(boolean notify) { + } + + public void fireSeriesChanged() { + } + + void set_data() { + xy_series.clear(); + + for (AltosTimeValue v : this) { + double y = v.y; + if (units != null) + y = units.graph_value(y); + xy_series.add(v.x, y); + } + } + + public void set_units() { + axis.set_units(); + StandardXYToolTipGenerator ttg; + + if (units != null) { + String time_example = (new AltosUITime()).graph_format(7); + String example = units.graph_format(7); + + ttg = new StandardXYToolTipGenerator(String.format("{1}s: {2}%s ({0})", + units.graph_units()), + new java.text.DecimalFormat(time_example), + new java.text.DecimalFormat(example)); + renderer.setBaseToolTipGenerator(ttg); + } + set_data(); + } + + public AltosXYSeries xy_series() { + return xy_series; + } + + public void set_enable(boolean enable) { + if (this.enable != enable) { + this.enable = enable; + renderer.setSeriesVisible(0, enable); + axis.set_enable(enable); + } + } public AltosUITimeSeries(String label, AltosUnits units, - Color color, boolean enabled, + Color color, boolean enable, AltosUIAxis axis) { super(label, units); + System.out.printf("time series %s units %s\n", label, units); this.color = color; - this.enabled = enabled; + this.enable = enable; this.axis = axis; + + axis.ref(this.enable); + + renderer = new XYLineAndShapeRenderer(true, false); + renderer.setSeriesPaint(0, color); + renderer.setSeriesStroke(0, new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + renderer.setSeriesVisible(0, enable); + xy_series = new AltosXYSeries(label); } } diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 88ed6ff6..d868ef25 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -29,6 +29,9 @@ altosuilib_JAVA = \ AltosUIPreferencesBackend.java \ AltosUIPreferences.java \ AltosUISeries.java \ + AltosUIFlightSeries.java \ + AltosUIGraphNew.java \ + AltosGraphNew.java \ AltosUSBDevice.java \ AltosVoice.java \ AltosDisplayThread.java \ -- 2.30.2