altosuilib: Adapt to AltosFlightSeries data processing plan
authorKeith Packard <keithp@keithp.com>
Fri, 26 May 2017 00:26:49 +0000 (17:26 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 26 May 2017 00:26:49 +0000 (17:26 -0700)
Replace use of list of AltosState with AltosFlightSeries to improve
data analysis.

Signed-off-by: Keith Packard <keithp@keithp.com>
13 files changed:
altosuilib/AltosCSVUI.java
altosuilib/AltosDataChooser.java
altosuilib/AltosFlightStatsTable.java
altosuilib/AltosGraph.java
altosuilib/AltosGraphNew.java
altosuilib/AltosInfoTable.java
altosuilib/AltosScanUI.java
altosuilib/AltosUIAxis.java
altosuilib/AltosUIFlightSeries.java
altosuilib/AltosUIGraphNew.java
altosuilib/AltosUIMap.java
altosuilib/AltosUITimeSeries.java
altosuilib/Makefile.am

index 1b769740cbadb6343fb9a307fe104055e7161cc0..49d6ea6817231e363a8d3ace202ef463558d5aac 100644 (file)
@@ -31,7 +31,8 @@ public class AltosCSVUI
        JFileChooser            csv_chooser;
        JPanel                  accessory;
        JComboBox<String>       combo_box;
        JFileChooser            csv_chooser;
        JPanel                  accessory;
        JComboBox<String>       combo_box;
-       Iterable<AltosState>    states;
+       AltosFlightSeries       series;
+       AltosCalData            cal_data;
        AltosWriter             writer;
 
        static String[]         combo_box_items = { "Comma Separated Values (.CSV)", "Googleearth Data (.KML)" };
        AltosWriter             writer;
 
        static String[]         combo_box_items = { "Comma Separated Values (.CSV)", "Googleearth Data (.KML)" };
@@ -55,8 +56,9 @@ public class AltosCSVUI
                        set_default_file();
        }
 
                        set_default_file();
        }
 
-       public AltosCSVUI(JFrame frame, AltosStateIterable states, File source_file) {
-               this.states = states;
+       public AltosCSVUI(JFrame frame, AltosFlightSeries series, AltosCalData cal_data, File source_file) {
+               this.series = series;
+               this.cal_data = cal_data;
                csv_chooser = new JFileChooser(source_file);
 
                accessory = new JPanel();
                csv_chooser = new JFileChooser(source_file);
 
                accessory = new JPanel();
@@ -91,7 +93,7 @@ public class AltosCSVUI
                                        writer = new AltosCSV(file);
                                else
                                        writer = new AltosKML(file);
                                        writer = new AltosCSV(file);
                                else
                                        writer = new AltosKML(file);
-                               writer.write(states);
+                               writer.write(series);
                                writer.close();
                        } catch (FileNotFoundException ee) {
                                JOptionPane.showMessageDialog(frame,
                                writer.close();
                        } catch (FileNotFoundException ee) {
                                JOptionPane.showMessageDialog(frame,
index a8c74926381482d0b108575377253c1e5994484c..c6d53a311eaf37c8110d73b9e38c6e6251878208 100644 (file)
@@ -36,7 +36,7 @@ public class AltosDataChooser extends JFileChooser {
                return file;
        }
 
                return file;
        }
 
-       public AltosStateIterable runDialog() {
+       public AltosRecordSet runDialog() {
                int     ret;
 
                ret = showOpenDialog(frame);
                int     ret;
 
                ret = showOpenDialog(frame);
index 2f46f231cbc0221dc9ffb1a3520f854eeb23bbb5..8a104a3cc30834a27bc766aada7a0d34d29ebd14 100644 (file)
@@ -116,10 +116,12 @@ public class AltosFlightStatsTable extends JComponent implements AltosFontListen
                                       String.format("%5.0f m", stats.max_gps_height),
                                       String.format("%5.0f ft", AltosConvert.meters_to_feet(stats.max_gps_height)));
                }
                                       String.format("%5.0f m", stats.max_gps_height),
                                       String.format("%5.0f ft", AltosConvert.meters_to_feet(stats.max_gps_height)));
                }
-               new FlightStat(layout, y++, "Maximum speed",
-                              String.format("%5.0f m/s", stats.max_speed),
-                              String.format("%5.0f fps", AltosConvert.mps_to_fps(stats.max_speed)),
-                              String.format("Mach %4.1f", AltosConvert.meters_to_mach(stats.max_speed)));
+               if (stats.max_speed != AltosLib.MISSING) {
+                       new FlightStat(layout, y++, "Maximum speed",
+                                      String.format("%5.0f m/s", stats.max_speed),
+                                      String.format("%5.0f fps", AltosConvert.mps_to_fps(stats.max_speed)),
+                                      String.format("Mach %4.1f", AltosConvert.meters_to_mach(stats.max_speed)));
+               }
                if (stats.max_acceleration != AltosLib.MISSING)
                        new FlightStat(layout, y++, "Maximum boost acceleration",
                                       String.format("%5.0f m/s²", stats.max_acceleration),
                if (stats.max_acceleration != AltosLib.MISSING)
                        new FlightStat(layout, y++, "Maximum boost acceleration",
                                       String.format("%5.0f m/s²", stats.max_acceleration),
index 880fc8a21c791c7ebc37b6d910c14114a374353e..987c461e5836ee7afe074f259574786c77c9a97f 100644 (file)
@@ -163,8 +163,6 @@ public class AltosGraph extends AltosUIGraph {
        static final private Color mag_z_color = new Color(0, 0, 128);
        static final private Color orient_color = new Color(31, 31, 31);
 
        static final private Color mag_z_color = new Color(0, 0, 128);
        static final private Color orient_color = new Color(31, 31, 31);
 
-       static AltosVoltage voltage_units = new AltosVoltage();
-       static AltosPressure pressure_units = new AltosPressure();
        static AltosNsat nsat_units = new AltosNsat();
        static AltosDbm dbm_units = new AltosDbm();
        static AltosRotationRate gyro_units = new AltosRotationRate();
        static AltosNsat nsat_units = new AltosNsat();
        static AltosDbm dbm_units = new AltosDbm();
        static AltosRotationRate gyro_units = new AltosRotationRate();
@@ -181,10 +179,10 @@ public class AltosGraph extends AltosUIGraph {
                super(enable);
 
                height_axis = newAxis("Height", AltosConvert.height, height_color);
                super(enable);
 
                height_axis = newAxis("Height", AltosConvert.height, height_color);
-               pressure_axis = newAxis("Pressure", pressure_units, pressure_color, 0);
+               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);
                speed_axis = newAxis("Speed", AltosConvert.speed, speed_color);
                accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color);
-               voltage_axis = newAxis("Voltage", voltage_units, voltage_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);
                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);
@@ -208,7 +206,7 @@ public class AltosGraph extends AltosUIGraph {
                                  height_axis);
                        addSeries("Pressure",
                                  AltosGraphDataPoint.data_pressure,
                                  height_axis);
                        addSeries("Pressure",
                                  AltosGraphDataPoint.data_pressure,
-                                 pressure_units,
+                                 AltosConvert.pressure,
                                  pressure_color,
                                  false,
                                  pressure_axis);
                                  pressure_color,
                                  false,
                                  pressure_axis);
@@ -321,7 +319,7 @@ public class AltosGraph extends AltosUIGraph {
                if (stats.has_battery)
                        addSeries("Battery Voltage",
                                  AltosGraphDataPoint.data_battery_voltage,
                if (stats.has_battery)
                        addSeries("Battery Voltage",
                                  AltosGraphDataPoint.data_battery_voltage,
-                                 voltage_units,
+                                 AltosConvert.voltage,
                                  battery_voltage_color,
                                  false,
                                  voltage_axis);
                                  battery_voltage_color,
                                  false,
                                  voltage_axis);
@@ -335,13 +333,13 @@ public class AltosGraph extends AltosUIGraph {
                                  temperature_axis);
                        addSeries("Drogue Voltage",
                                  AltosGraphDataPoint.data_drogue_voltage,
                                  temperature_axis);
                        addSeries("Drogue Voltage",
                                  AltosGraphDataPoint.data_drogue_voltage,
-                                 voltage_units,
+                                 AltosConvert.voltage,
                                  drogue_voltage_color,
                                  false,
                                  voltage_axis);
                        addSeries("Main Voltage",
                                  AltosGraphDataPoint.data_main_voltage,
                                  drogue_voltage_color,
                                  false,
                                  voltage_axis);
                        addSeries("Main Voltage",
                                  AltosGraphDataPoint.data_main_voltage,
-                                 voltage_units,
+                                 AltosConvert.voltage,
                                  main_voltage_color,
                                  false,
                                  voltage_axis);
                                  main_voltage_color,
                                  false,
                                  voltage_axis);
@@ -416,7 +414,7 @@ public class AltosGraph extends AltosUIGraph {
                        for (int i = 0; i < stats.num_ignitor; i++)
                                addSeries(AltosLib.ignitor_name(i),
                                          AltosGraphDataPoint.data_ignitor_0 + i,
                        for (int i = 0; i < stats.num_ignitor; i++)
                                addSeries(AltosLib.ignitor_name(i),
                                          AltosGraphDataPoint.data_ignitor_0 + i,
-                                         voltage_units,
+                                         AltosConvert.voltage,
                                          main_voltage_color,
                                          false,
                                          voltage_axis);
                                          main_voltage_color,
                                          false,
                                          voltage_axis);
index 2c01c466e76ac123baa8cdbd6b0fbace0e9ac0f4..dc5b7e47d5cb6457c0bfb4897929baeb62f32361 100644 (file)
@@ -38,13 +38,16 @@ import org.jfree.data.*;
 public class AltosGraphNew extends AltosUIGraphNew {
 
        static final private Color height_color = new Color(194,31,31);
 public class AltosGraphNew extends AltosUIGraphNew {
 
        static final private Color height_color = new Color(194,31,31);
+       static final private Color kalman_height_color = new Color(255,0,0);
        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 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 kalman_speed_color = new Color(0,255,0);
        static final private Color thrust_color = new Color(31,194,31);
        static final private Color accel_color = new Color(31,31,194);
        static final private Color thrust_color = new Color(31,194,31);
        static final private Color accel_color = new Color(31,31,194);
+       static final private Color kalman_accel_color = new Color(0,0,255);
        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 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);
@@ -54,6 +57,7 @@ public class AltosGraphNew extends AltosUIGraphNew {
        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_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_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_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);
@@ -72,15 +76,19 @@ public class AltosGraphNew extends AltosUIGraphNew {
        static final private Color mag_z_color = new Color(0, 0, 128);
        static final private Color orient_color = new Color(31, 31, 31);
 
        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 AltosNsat nsat_units = new AltosNsat();
+       static AltosUnits nsat_units = null;
+//     static AltosDbm dbm_units = new AltosDbm();
+       static AltosUnits dbm_units = null;
        static AltosOrient orient_units = new AltosOrient();
        static AltosOrient orient_units = new AltosOrient();
-       static AltosMagUnits mag_units = new AltosMagUnits();
-       static AltosDopUnits dop_units = new AltosDopUnits();
+//     static AltosMagUnits mag_units = new AltosMagUnits();
+       static AltosUnits mag_units = null;
+//     static AltosDopUnits dop_units = new AltosDopUnits();
+       static AltosUnits dop_units = null;
 
        AltosUIFlightSeries flight_series;
 
 
        AltosUIFlightSeries flight_series;
 
-       AltosUITimeSeries[] setup(AltosFlightStats stats, AltosRecordSet record_set) {
+       AltosUITimeSeries[] setup(AltosFlightStats stats, AltosUIFlightSeries flight_series, AltosCalData cal_data) {
 
                AltosUIAxis     height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis;
                AltosUIAxis     distance_axis, pressure_axis, thrust_axis;
 
                AltosUIAxis     height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis;
                AltosUIAxis     distance_axis, pressure_axis, thrust_axis;
@@ -105,33 +113,109 @@ public class AltosGraphNew extends AltosUIGraphNew {
                course_axis = newAxis("Course", orient_units, gps_course_color, 0);
                dop_axis = newAxis("Dilution of Precision", dop_units, gps_pdop_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_axis("default",
+                                           speed_color,
+                                           false,
+                                           speed_axis);
 
 
-               flight_series.register_extra("default",
-                                            speed_color,
-                                            false,
-                                            speed_axis);
+               flight_series.register_marker(AltosUIFlightSeries.state_name,
+                                             state_color,
+                                             true,
+                                             plot);
 
 
-               flight_series.register_extra(AltosUIFlightSeries.accel_name,
-                                            accel_color,
-                                            true,
-                                            accel_axis);
+               flight_series.register_axis(AltosUIFlightSeries.accel_name,
+                                           accel_color,
+                                           true,
+                                           accel_axis);
 
 
-               flight_series.register_extra(AltosUIFlightSeries.pressure_name,
-                                            pressure_color,
-                                            true,
-                                            pressure_axis);
+               flight_series.register_axis(AltosUIFlightSeries.kalman_accel_name,
+                                           kalman_accel_color,
+                                           false,
+                                           accel_axis);
 
 
-               flight_series.register_extra(AltosUIFlightSeries.thrust_name,
-                                            thrust_color,
-                                            true,
-                                            thrust_axis);
+               flight_series.register_axis(AltosUIFlightSeries.rssi_name,
+                                           dbm_color,
+                                           false,
+                                           dbm_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.speed_name,
+                                           speed_color,
+                                           true,
+                                           speed_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.kalman_speed_name,
+                                           kalman_speed_color,
+                                           true,
+                                           speed_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.pressure_name,
+                                           pressure_color,
+                                           false,
+                                           pressure_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.height_name,
+                                           height_color,
+                                           true,
+                                           height_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.kalman_height_name,
+                                           kalman_height_color,
+                                           false,
+                                           height_axis);
+
+
+               flight_series.register_axis(AltosUIFlightSeries.sats_in_view_name,
+                                           gps_nsat_view_color,
+                                           false,
+                                           nsat_axis);
+
+
+               flight_series.register_axis(AltosUIFlightSeries.sats_in_soln_name,
+                                           gps_nsat_solution_color,
+                                           false,
+                                           nsat_axis);
 
 
-//             addMarker("State", AltosGraphDataPoint.data_state, state_color);
 
 
-               record_set.capture_series(flight_series);
+               flight_series.register_axis(AltosUIFlightSeries.gps_altitude_name,
+                                           gps_height_color,
+                                           false,
+                                           height_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.gps_height_name,
+                                           gps_height_color,
+                                           false,
+                                           height_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.gps_ground_speed_name,
+                                           gps_ground_speed_color,
+                                           false,
+                                           speed_axis);
+
+
+               flight_series.register_axis(AltosUIFlightSeries.gps_ascent_rate_name,
+                                           gps_climb_rate_color,
+                                           false,
+                                           speed_axis);
+
+
+               flight_series.register_axis(AltosUIFlightSeries.gps_course_name,
+                                           gps_course_color,
+                                           false,
+                                           course_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.gps_speed_name,
+                                           gps_speed_color,
+                                           false,
+                                           speed_axis);
+
+               flight_series.register_axis(AltosUIFlightSeries.thrust_name,
+                                           thrust_color,
+                                           true,
+                                           thrust_axis);
+
+//             addMarker("State", AltosGraphDataPoint.data_state, state_color);
 
 
-               return flight_series.series();
+               return flight_series.series(cal_data);
 /*
                if (stats.has_flight_data) {
                        addSeries("Height",
 /*
                if (stats.has_flight_data) {
                        addSeries("Height",
@@ -366,9 +450,9 @@ public class AltosGraphNew extends AltosUIGraphNew {
 */
        }
 
 */
        }
 
-       public AltosGraphNew(AltosUIEnable enable, AltosFlightStats stats, AltosRecordSet record_set) {
+       public AltosGraphNew(AltosUIEnable enable, AltosFlightStats stats, AltosUIFlightSeries flight_series, AltosCalData cal_data) {
                super(enable, "Flight");
 
                super(enable, "Flight");
 
-               set_series(setup(stats, record_set));
+               set_series(setup(stats, flight_series, cal_data));
        }
 }
        }
 }
index 7ede28244e5f8748e0ba3b800b8a0c313883fb0f..c1ac774e6c09c618a088bf24c6d8945aedc55ff0 100644 (file)
@@ -128,6 +128,8 @@ public class AltosInfoTable extends JTable implements AltosFlightDisplay, Hierar
 
        public void show(AltosState state, AltosListenerState listener_state) {
 
 
        public void show(AltosState state, AltosListenerState listener_state) {
 
+               AltosCalData    cal_data = state.cal_data;
+
                if (!isShowing()) {
                        last_state = state;
                        last_listener_state = listener_state;
                if (!isShowing()) {
                        last_state = state;
                        last_listener_state = listener_state;
@@ -136,14 +138,14 @@ public class AltosInfoTable extends JTable implements AltosFlightDisplay, Hierar
 
                reset();
                if (state != null) {
 
                reset();
                if (state != null) {
-                       if (state.device_type != AltosLib.MISSING)
-                               info_add_row(0, "Device", "%s", AltosLib.product_name(state.device_type));
-                       else if (state.product != null)
-                               info_add_row(0, "Device", "%s", state.product);
+                       if (cal_data.device_type != AltosLib.MISSING)
+                               info_add_row(0, "Device", "%s", AltosLib.product_name(cal_data.device_type));
+                       else if (cal_data.product != null)
+                               info_add_row(0, "Device", "%s", cal_data.product);
                        if (state.altitude() != AltosLib.MISSING)
                                info_add_row(0, "Altitude", "%6.0f    m", state.altitude());
                        if (state.altitude() != AltosLib.MISSING)
                                info_add_row(0, "Altitude", "%6.0f    m", state.altitude());
-                       if (state.ground_altitude() != AltosLib.MISSING)
-                               info_add_row(0, "Pad altitude", "%6.0f    m", state.ground_altitude());
+                       if (cal_data.ground_altitude != AltosLib.MISSING)
+                               info_add_row(0, "Pad altitude", "%6.0f    m", cal_data.ground_altitude);
                        if (state.height() != AltosLib.MISSING)
                                info_add_row(0, "Height", "%6.0f    m", state.height());
                        if (state.max_height() != AltosLib.MISSING)
                        if (state.height() != AltosLib.MISSING)
                                info_add_row(0, "Height", "%6.0f    m", state.height());
                        if (state.max_height() != AltosLib.MISSING)
index 8843429a6113b6be45d2cc8f1a974f11fec82561..ad53f66ba20c63cce431c76863b3c7570f013b9f 100644 (file)
@@ -213,10 +213,10 @@ public class AltosScanUI
                                                if (state == null)
                                                        continue;
                                                packet_count++;
                                                if (state == null)
                                                        continue;
                                                packet_count++;
-                                               if (state.flight != AltosLib.MISSING) {
-                                                       final AltosScanResult   result = new AltosScanResult(state.callsign,
-                                                                                                            state.serial,
-                                                                                                            state.flight,
+                                               if (reader.cal_data.flight != AltosLib.MISSING) {
+                                                       final AltosScanResult   result = new AltosScanResult(reader.cal_data.callsign,
+                                                                                                            reader.cal_data.serial,
+                                                                                                            reader.cal_data.flight,
                                                                                                             frequencies[frequency_index],
                                                                                                             telemetry,
                                                                                                             rate);
                                                                                                             frequencies[frequency_index],
                                                                                                             telemetry,
                                                                                                             rate);
index e41667ef906f4f038b9325623ca050ba0638f318..40ee51615789f3d131bc1beb1f5d09dc729622a3 100644 (file)
@@ -49,14 +49,18 @@ public class AltosUIAxis extends NumberAxis {
        public final static int axis_default = axis_include_zero;
 
        public void set_units() {
        public final static int axis_default = axis_include_zero;
 
        public void set_units() {
-               String u = units.parse_units();
-               if (u != null)
-                       setLabel(String.format("%s (%s)", label, u));
-               else
-                       setLabel(label);
+               if (units != null) {
+                       String u = units.parse_units();
+                       if (u != null) {
+                               setLabel(String.format("%s (%s)", label, u));
+                               return;
+                       }
+               }
+               setLabel(label);
        }
 
        public void set_enable(boolean enable) {
        }
 
        public void set_enable(boolean enable) {
+               System.out.printf("axis %s set enable visible %d ref %d\n", label, visible, ref);
                if (enable) {
                        visible++;
                        if (visible > ref)
                if (enable) {
                        visible++;
                        if (visible > ref)
index d15c40718ca1187b57ff86d177cb6e147947aeaa..1840761e11b80d5993b96b5573901e111c071dde 100644 (file)
@@ -19,50 +19,101 @@ import java.awt.*;
 import javax.swing.*;
 import org.altusmetrum.altoslib_11.*;
 
 import javax.swing.*;
 import org.altusmetrum.altoslib_11.*;
 
-class AltosUITimeSeriesExtra {
+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.*;
+
+class AltosUITimeSeriesAxis {
        Color           color;
        boolean         enabled;
        Color           color;
        boolean         enabled;
+       boolean         marker;
        AltosUIAxis     axis;
        AltosUIAxis     axis;
+       XYPlot          plot;
 
 
-       public AltosUITimeSeriesExtra(Color color, boolean enabled, AltosUIAxis axis) {
+       public AltosUITimeSeriesAxis(Color color, boolean enabled, AltosUIAxis axis, XYPlot plot, boolean marker) {
                this.color = color;
                this.enabled = enabled;
                this.axis = axis;
                this.color = color;
                this.enabled = enabled;
                this.axis = axis;
+               this.plot = plot;
+               this.marker = marker;
        }
 }
 
 public class AltosUIFlightSeries extends AltosFlightSeries {
 
        }
 }
 
 public class AltosUIFlightSeries extends AltosFlightSeries {
 
-       Hashtable<String,AltosUITimeSeriesExtra> extra;
+       Hashtable<String,AltosUITimeSeriesAxis> axes;
+
+       AltosUIFlightSeries flight_series;
+
+       void fill_axes(String label, AltosUITimeSeriesAxis axis) {
+               for (AltosTimeSeries ts : series) {
+                       AltosUITimeSeries uts = (AltosUITimeSeries) ts;
+
+                       if (label.equals(ts.label) || (label.equals("default") && uts.color == null)) {
+                               if (axis.marker)
+                                       uts.set_marker(axis.color, axis.enabled, axis.plot);
+                               else
+                                       uts.set_axis(axis.color, axis.enabled, axis.axis);
+                       }
+               }
+       }
 
 
-       public void register_extra(String label,
-                                  Color color,
-                                  boolean enabled,
-                                  AltosUIAxis axis) {
+       public void register_axis(String label,
+                                 Color color,
+                                 boolean enabled,
+                                 AltosUIAxis axis) {
+               AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(color,
+                                                                     enabled,
+                                                                     axis,
+                                                                     null,
+                                                                     false);
+               axes.put(label, tsa);
+               fill_axes(label, tsa);
+       }
 
 
-               AltosUITimeSeriesExtra e = new AltosUITimeSeriesExtra(color,
+       public void register_marker(String label,
+                                   Color color,
+                                   boolean enabled,
+                                   XYPlot plot) {
+               AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(color,
                                                                      enabled,
                                                                      enabled,
-                                                                     axis);
-               System.out.printf("register extra label %s extra %s\n", label, e);
-               extra.put(label, e);
+                                                                     null,
+                                                                     plot,
+                                                                     true);
+               axes.put(label, tsa);
+               fill_axes(label, tsa);
        }
 
        public AltosTimeSeries make_series(String label, AltosUnits units) {
 
        }
 
        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);
+               AltosUITimeSeries time_series = new AltosUITimeSeries(label, units);
+
+               AltosUITimeSeriesAxis tsa = axes.get(label);
+               if (tsa == null)
+                       tsa = axes.get("default");
+               if (tsa != null) {
+                       if (tsa.marker)
+                               time_series.set_marker(tsa.color, tsa.enabled, tsa.plot);
+                       else
+                               time_series.set_axis(tsa.color, tsa.enabled, tsa.axis);
+               }
+               return time_series;
        }
 
        }
 
-       public AltosUITimeSeries[] series() {
+       public AltosUITimeSeries[] series(AltosCalData cal_data) {
+               fill_in();
                return series.toArray(new AltosUITimeSeries[0]);
        }
 
                return series.toArray(new AltosUITimeSeries[0]);
        }
 
-       public AltosUIFlightSeries () {
-               super();
-               extra = new Hashtable<String,AltosUITimeSeriesExtra>();
+       public AltosUIFlightSeries (AltosCalData cal_data) {
+               super(cal_data);
+               axes = new Hashtable<String,AltosUITimeSeriesAxis>();
        }
 }
        }
 }
index acfcd23ddd00478e381d18b09c2f9b9283a7a7a8..709541ffab5e8d2558e71cc80a78fa951d94b81c 100644 (file)
@@ -68,7 +68,6 @@ public class AltosUIGraphNew implements AltosUnitsListener {
 
        void addAxis(AltosUIAxis axis) {
                if (!axes_added.containsKey(axis.index)) {
 
        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);
                }
                        axes_added.put(axis.index, true);
                        plot.setRangeAxis(axis.index, axis);
                }
@@ -88,12 +87,8 @@ public class AltosUIGraphNew implements AltosUnitsListener {
                series_index++;
        }
 
                series_index++;
        }
 
-/*
-       public void addMarker(String label, int fetch, Color color) {
-               AltosUIMarker           marker = new AltosUIMarker(fetch, color, plot);
-               this.graphers.add(marker);
+       public void addMarker(AltosUITimeSeries series) {
        }
        }
-*/
 
        public void units_changed(boolean imperial_units) {
                for (AltosUITimeSeries s : series)
 
        public void units_changed(boolean imperial_units) {
                for (AltosUITimeSeries s : series)
index 3e4cbe9b8a3e657860c308a52e7a5210313904b0..05c99a126fc3776ec05efbc99767b5d3bd2761bc 100644 (file)
@@ -413,6 +413,10 @@ public class AltosUIMap extends JComponent implements AltosFlightDisplay, AltosM
                map.show(state, listener_state);
        }
 
                map.show(state, listener_state);
        }
 
+       public void show(AltosGPS gps, int state) {
+               map.show(gps, state);
+       }
+
        public String getName() {
                return "Map";
        }
        public String getName() {
                return "Map";
        }
@@ -422,6 +426,10 @@ public class AltosUIMap extends JComponent implements AltosFlightDisplay, AltosM
                map.centre(state);
        }
 
                map.centre(state);
        }
 
+       public void centre(AltosGPS gps) {
+               map.centre(gps);
+       }
+
        /* internal layout bits */
        private GridBagLayout layout = new GridBagLayout();
 
        /* internal layout bits */
        private GridBagLayout layout = new GridBagLayout();
 
index fbee312580a151972ec59a212e6a4e97f700923a..0f5e35ebd8f9aed74e0950c7ba78f66d7076c6e2 100644 (file)
@@ -46,8 +46,12 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher
        Color           color;
        boolean         enable;
        AltosUIAxis     axis;
        Color           color;
        boolean         enable;
        AltosUIAxis     axis;
+       boolean         marker;
        XYItemRenderer  renderer;
        XYItemRenderer  renderer;
+       XYPlot          plot;
        AltosXYSeries   xy_series;
        AltosXYSeries   xy_series;
+       ArrayList<ValueMarker>  markers;
+
 
        /* AltosUIGrapher interface */
        public boolean need_reset() {
 
        /* AltosUIGrapher interface */
        public boolean need_reset() {
@@ -67,13 +71,32 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher
        }
 
        void set_data() {
        }
 
        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);
+               if (marker) {
+                       if (markers != null) {
+                               for (ValueMarker marker : markers)
+                                       plot.removeDomainMarker(marker);
+                       }
+                       markers = new ArrayList<ValueMarker>();
+                       for (AltosTimeValue v : this) {
+                               String s = units.string_value(v.value);
+                               ValueMarker marker = new ValueMarker(v.time);
+                               marker.setLabel(s);
+                               marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
+                               marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
+                               marker.setPaint(color);
+                               if (enable)
+                                       plot.addDomainMarker(marker);
+                               markers.add(marker);
+                       }
+               } else {
+                       xy_series.clear();
+
+                       for (AltosTimeValue v : this) {
+                               double value = v.value;
+                               if (units != null)
+                                       value = units.graph_value(value);
+                               xy_series.add(v.time, value);
+                       }
                }
        }
 
                }
        }
 
@@ -101,19 +124,25 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher
        public void set_enable(boolean enable) {
                if (this.enable != enable) {
                        this.enable = enable;
        public void set_enable(boolean enable) {
                if (this.enable != enable) {
                        this.enable = enable;
-                       renderer.setSeriesVisible(0, enable);
-                       axis.set_enable(enable);
+                       if (marker) {
+                               for (ValueMarker marker : markers) {
+                                       if (enable)
+                                               plot.addDomainMarker(marker);
+                                       else
+                                               plot.removeDomainMarker(marker);
+                               }
+                       } else {
+                               renderer.setSeriesVisible(0, enable);
+                               axis.set_enable(enable);
+                       }
                }
        }
 
                }
        }
 
-       public AltosUITimeSeries(String label, AltosUnits units,
-                                Color color, boolean enable,
-                                AltosUIAxis axis) {
-               super(label, units);
-               System.out.printf("time series %s units %s\n", label, units);
+       public void set_axis(Color color, boolean enable, AltosUIAxis axis) {
                this.color = color;
                this.enable = enable;
                this.axis = axis;
                this.color = color;
                this.enable = enable;
                this.axis = axis;
+               this.marker = false;
 
                axis.ref(this.enable);
 
 
                axis.ref(this.enable);
 
@@ -123,4 +152,22 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher
                renderer.setSeriesVisible(0, enable);
                xy_series = new AltosXYSeries(label);
        }
                renderer.setSeriesVisible(0, enable);
                xy_series = new AltosXYSeries(label);
        }
+
+       public void set_marker(Color color, boolean enable, XYPlot plot) {
+               this.color = color;
+               this.enable = enable;
+               this.marker = true;
+               this.plot = plot;
+       }
+
+       public AltosUITimeSeries(String label, AltosUnits units) {
+               super(label, units);
+       }
+
+       public AltosUITimeSeries(String label, AltosUnits units,
+                                Color color, boolean enable,
+                                AltosUIAxis axis) {
+               this(label, units);
+               set_axis(color, enable, axis);
+       }
 }
 }
index d868ef25fa0ea973537dcab15777f5ad80307cb1..b7cfedc0a9dfec7c035e4f97f067e55e365212f6 100644 (file)
@@ -53,9 +53,6 @@ altosuilib_JAVA = \
        AltosInfoTable.java \
        AltosFlightInfoTableModel.java \
        AltosFlightStatsTable.java \
        AltosInfoTable.java \
        AltosFlightInfoTableModel.java \
        AltosFlightStatsTable.java \
-       AltosGraph.java \
-       AltosGraphDataPoint.java \
-       AltosGraphDataSet.java \
        AltosBTDevice.java \
        AltosBTDeviceIterator.java \
        AltosBTManage.java \
        AltosBTDevice.java \
        AltosBTDeviceIterator.java \
        AltosBTManage.java \