2 * Copyright © 2013 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 import java.util.ArrayList;
25 import org.altusmetrum.altoslib_1.*;
26 import org.altusmetrum.altosuilib_1.*;
28 import org.jfree.ui.*;
29 import org.jfree.chart.*;
30 import org.jfree.chart.plot.*;
31 import org.jfree.chart.axis.*;
32 import org.jfree.chart.renderer.*;
33 import org.jfree.chart.renderer.xy.*;
34 import org.jfree.chart.labels.*;
35 import org.jfree.data.xy.*;
36 import org.jfree.data.*;
38 class AltosVoltage extends AltosUnits {
40 public double value(double v) {
44 public String show_units() {
48 public String say_units() {
52 public int show_fraction(int width) {
57 class AltosNsat extends AltosUnits {
59 public double value(double v) {
63 public String show_units() {
67 public String say_units() {
71 public int show_fraction(int width) {
76 class AltosDbm extends AltosUnits {
78 public double value(double v) {
82 public String show_units() {
86 public String say_units() {
90 public int show_fraction(int width) {
95 public class AltosGraph extends AltosUIGraph {
97 static final private Color height_color = new Color(194,31,31);
98 static final private Color gps_height_color = new Color(150,31,31);
99 static final private Color range_color = new Color(100, 31, 31);
100 static final private Color distance_color = new Color(100, 31, 194);
101 static final private Color speed_color = new Color(31,194,31);
102 static final private Color accel_color = new Color(31,31,194);
103 static final private Color voltage_color = new Color(194, 194, 31);
104 static final private Color battery_voltage_color = new Color(194, 194, 31);
105 static final private Color drogue_voltage_color = new Color(150, 150, 31);
106 static final private Color main_voltage_color = new Color(100, 100, 31);
107 static final private Color gps_nsat_color = new Color (194, 31, 194);
108 static final private Color gps_nsat_solution_color = new Color (194, 31, 194);
109 static final private Color gps_nsat_view_color = new Color (150, 31, 150);
110 static final private Color temperature_color = new Color (31, 194, 194);
111 static final private Color dbm_color = new Color(31, 100, 100);
112 static final private Color state_color = new Color(0,0,0);
114 static AltosVoltage voltage_units = new AltosVoltage();
115 static AltosNsat nsat_units = new AltosNsat();
116 static AltosDbm dbm_units = new AltosDbm();
118 AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis;
119 AltosUIAxis distance_axis;
121 public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) {
124 height_axis = newAxis("Height", AltosConvert.height, height_color);
125 speed_axis = newAxis("Speed", AltosConvert.speed, speed_color);
126 accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color);
127 voltage_axis = newAxis("Voltage", voltage_units, voltage_color);
128 temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0);
129 nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color,
130 AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer);
131 dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0);
132 distance_axis = newAxis("Distance", AltosConvert.distance, range_color);
134 addMarker("State", AltosGraphDataPoint.data_state, state_color);
136 AltosGraphDataPoint.data_height,
142 AltosGraphDataPoint.data_speed,
147 addSeries("Acceleration",
148 AltosGraphDataPoint.data_accel,
155 AltosGraphDataPoint.data_range,
156 AltosConvert.distance,
160 addSeries("Distance",
161 AltosGraphDataPoint.data_distance,
162 AltosConvert.distance,
166 addSeries("GPS Height",
167 AltosGraphDataPoint.data_gps_height,
172 addSeries("GPS Satellites in Solution",
173 AltosGraphDataPoint.data_gps_nsat_solution,
175 gps_nsat_solution_color,
178 addSeries("GPS Satellites in View",
179 AltosGraphDataPoint.data_gps_nsat_view,
186 addSeries("Received Signal Strength",
187 AltosGraphDataPoint.data_rssi,
192 if (stats.has_other_adc) {
193 addSeries("Temperature",
194 AltosGraphDataPoint.data_temperature,
195 AltosConvert.temperature,
199 addSeries("Battery Voltage",
200 AltosGraphDataPoint.data_battery_voltage,
202 battery_voltage_color,
205 addSeries("Drogue Voltage",
206 AltosGraphDataPoint.data_drogue_voltage,
208 drogue_voltage_color,
211 addSeries("Main Voltage",
212 AltosGraphDataPoint.data_main_voltage,