altosuilib: New line styles and colors for graphs. Selectable line width
authorKeith Packard <keithp@keithp.com>
Sun, 12 Nov 2017 00:08:32 +0000 (16:08 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 12 Nov 2017 00:36:56 +0000 (16:36 -0800)
Improve the readability of graphs by offering a better selection of
colors and adding line styles. Let the user configure the line width
as desired.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosuilib/AltosEepromGrapher.java [new file with mode: 0644]
altosuilib/AltosGraph.java
altosuilib/AltosShapeListener.java
altosuilib/AltosUIAxis.java
altosuilib/AltosUIEnable.java
altosuilib/AltosUIFlightSeries.java
altosuilib/AltosUIGraph.java
altosuilib/AltosUILineStyle.java [new file with mode: 0644]
altosuilib/AltosUITimeSeries.java
altosuilib/Makefile.am

diff --git a/altosuilib/AltosEepromGrapher.java b/altosuilib/AltosEepromGrapher.java
new file mode 100644 (file)
index 0000000..a29f64e
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2017 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, 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_12;
+
+import org.altusmetrum.altoslib_12.*;
+
+public interface AltosEepromGrapher {
+
+       public void graph_flights(AltosEepromList list);
+}
index 3f610285c80ab5d478e10e6b1b20a29f99827ae3..a758bcdecb284f70e37f6a647acf1617d3793ccd 100644 (file)
@@ -37,47 +37,53 @@ import org.jfree.data.*;
 
 public class AltosGraph extends AltosUIGraph {
 
-       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 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 vert_accel_color = new Color(64,164,164);
-       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 main_voltage_color = new Color(100, 100, 31);
-       static final private Color igniter_voltage_color = new Color(80, 80, 31);
-       static final private Color igniter_marker_color = new Color(255, 0, 0);
-       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_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_along_color = new Color(255, 0, 0);
-       static final private Color accel_across_color = new Color(0, 255, 0);
-       static final private Color accel_through_color = new Color(0, 0, 255);
-       static final private Color gyro_roll_color = new Color(192, 0, 0);
-       static final private Color gyro_pitch_color = new Color(0, 192, 0);
-       static final private Color gyro_yaw_color = new Color(0, 0, 192);
-       static final private Color mag_along_color = new Color(128, 0, 0);
-       static final private Color mag_across_color = new Color(0, 128, 0);
-       static final private Color mag_through_color = new Color(0, 0, 128);
-       static final private Color orient_color = new Color(31, 31, 31);
+       /* These are in 'priority' order so that earlier ones get simpler line styles,
+        * then they are grouped so that adjacent ones get sequential colors
+        */
+       static final private AltosUILineStyle height_color = new AltosUILineStyle();
+       static final private AltosUILineStyle speed_color = new AltosUILineStyle();
+       static final private AltosUILineStyle accel_color = new AltosUILineStyle();
+       static final private AltosUILineStyle vert_accel_color = new AltosUILineStyle();
+       static final private AltosUILineStyle orient_color = new AltosUILineStyle();
+
+       static final private AltosUILineStyle gps_height_color = new AltosUILineStyle();
+       static final private AltosUILineStyle altitude_color = new AltosUILineStyle();
+
+       static final private AltosUILineStyle battery_voltage_color = new AltosUILineStyle();
+       static final private AltosUILineStyle pyro_voltage_color = new AltosUILineStyle();
+       static final private AltosUILineStyle drogue_voltage_color = new AltosUILineStyle();
+       static final private AltosUILineStyle main_voltage_color = new AltosUILineStyle();
+       static final private AltosUILineStyle igniter_marker_color = new AltosUILineStyle(1);
+
+       static final private AltosUILineStyle kalman_height_color = new AltosUILineStyle();
+       static final private AltosUILineStyle kalman_speed_color = new AltosUILineStyle();
+       static final private AltosUILineStyle kalman_accel_color = new AltosUILineStyle();
+
+       static final private AltosUILineStyle gps_nsat_color = new AltosUILineStyle ();
+       static final private AltosUILineStyle gps_nsat_solution_color = new AltosUILineStyle ();
+       static final private AltosUILineStyle gps_nsat_view_color = new AltosUILineStyle ();
+       static final private AltosUILineStyle gps_course_color = new AltosUILineStyle ();
+       static final private AltosUILineStyle gps_ground_speed_color = new AltosUILineStyle ();
+       static final private AltosUILineStyle gps_speed_color = new AltosUILineStyle ();
+       static final private AltosUILineStyle gps_climb_rate_color = new AltosUILineStyle ();
+       static final private AltosUILineStyle gps_pdop_color = new AltosUILineStyle();
+       static final private AltosUILineStyle gps_hdop_color = new AltosUILineStyle();
+       static final private AltosUILineStyle gps_vdop_color = new AltosUILineStyle();
+
+       static final private AltosUILineStyle temperature_color = new AltosUILineStyle ();
+       static final private AltosUILineStyle dbm_color = new AltosUILineStyle();
+       static final private AltosUILineStyle pressure_color = new AltosUILineStyle ();
+
+       static final private AltosUILineStyle state_color = new AltosUILineStyle(0);
+       static final private AltosUILineStyle accel_along_color = new AltosUILineStyle();
+       static final private AltosUILineStyle accel_across_color = new AltosUILineStyle();
+       static final private AltosUILineStyle accel_through_color = new AltosUILineStyle();
+       static final private AltosUILineStyle gyro_roll_color = new AltosUILineStyle();
+       static final private AltosUILineStyle gyro_pitch_color = new AltosUILineStyle();
+       static final private AltosUILineStyle gyro_yaw_color = new AltosUILineStyle();
+       static final private AltosUILineStyle mag_along_color = new AltosUILineStyle();
+       static final private AltosUILineStyle mag_across_color = new AltosUILineStyle();
+       static final private AltosUILineStyle mag_through_color = new AltosUILineStyle();
 
        static AltosUnits dop_units = null;
        static AltosUnits tick_units = null;
@@ -88,7 +94,7 @@ public class AltosGraph extends AltosUIGraph {
                AltosCalData    cal_data = flight_series.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     pressure_axis, thrust_axis;
                AltosUIAxis     gyro_axis, orient_axis, mag_axis;
                AltosUIAxis     course_axis, dop_axis, tick_axis;
 
@@ -98,15 +104,14 @@ public class AltosGraph extends AltosUIGraph {
                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);
-               thrust_axis = newAxis("Thrust", AltosConvert.force, thrust_color);
+               thrust_axis = newAxis("Thrust", AltosConvert.force, accel_color);
                tick_axis = newAxis("Tick", tick_units, accel_color, 0);
                accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color);
-               voltage_axis = newAxis("Voltage", AltosConvert.voltage, voltage_color);
+               voltage_axis = newAxis("Voltage", AltosConvert.voltage, battery_voltage_color);
                temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0);
                nsat_axis = newAxis("Satellites", null, gps_nsat_color,
                                    AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer);
                dbm_axis = newAxis("Signal Strength", null, dbm_color, 0);
-               distance_axis = newAxis("Distance", AltosConvert.distance, range_color);
 
                gyro_axis = newAxis("Rotation Rate", AltosConvert.rotation_rate, gyro_roll_color, 0);
                orient_axis = newAxis("Tilt Angle", AltosConvert.orient, orient_color, 0);
@@ -177,7 +182,7 @@ public class AltosGraph extends AltosUIGraph {
                                            height_axis);
 
                flight_series.register_axis(AltosUIFlightSeries.altitude_name,
-                                           height_color,
+                                           altitude_color,
                                            false,
                                            height_axis);
 
@@ -197,6 +202,11 @@ public class AltosGraph extends AltosUIGraph {
                                            false,
                                            voltage_axis);
 
+               flight_series.register_axis(AltosUIFlightSeries.pyro_voltage_name,
+                                           pyro_voltage_color,
+                                           false,
+                                           voltage_axis);
+
                flight_series.register_axis(AltosUIFlightSeries.apogee_voltage_name,
                                            drogue_voltage_color,
                                            false,
@@ -312,17 +322,19 @@ public class AltosGraph extends AltosUIGraph {
                                            false,
                                            orient_axis);
 
-               for (int channel = 0; channel < 26; channel++) {
+               flight_series.register_axis(AltosUIFlightSeries.thrust_name,
+                                           accel_color,
+                                           true,
+                                           thrust_axis);
+
+               for (int channel = 0; channel < 8; channel++) {
                        flight_series.register_axis(flight_series.igniter_voltage_name(channel),
-                                                   igniter_voltage_color,
+                                                   new AltosUILineStyle(),
                                                    false,
                                                    voltage_axis);
                }
 
-               flight_series.register_axis(AltosUIFlightSeries.thrust_name,
-                                           thrust_color,
-                                           true,
-                                           thrust_axis);
+               flight_series.check_axes();
 
                return flight_series.series(cal_data);
        }
index 082b613521b3ff3c9ee7ad8cdc5ac3f64d862f2e..6bf52fd45663a6c48f5654cc81d0f1ddc90585cf 100644 (file)
@@ -16,4 +16,5 @@ package org.altusmetrum.altosuilib_12;
 
 public interface AltosShapeListener {
        void set_shapes_visible(boolean visible);
+       void set_line_width(float width);
 }
index fe94f161f5543beb81494080757e0af0bc4be76e..528733638a0e9cb4c4cfa7e70ecca9efd1fa6644 100644 (file)
@@ -36,12 +36,12 @@ 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;
+       String                  label;
+       AltosUnits              units;
+       AltosUILineStyle        line_style;
+       int                     ref;
+       int                     visible;
+       int                     index;
 
        public final static int axis_integer = 1;
        public final static int axis_include_zero = 2;
@@ -82,21 +82,22 @@ public class AltosUIAxis extends NumberAxis {
                }
        }
 
-       public AltosUIAxis(String label, AltosUnits units, Color color, int index, int flags) {
+       public AltosUIAxis(String label, AltosUnits units, AltosUILineStyle line_style, int index, int flags) {
                this.label = label;
                this.units = units;
+               this.line_style = line_style;
                this.index = index;
                this.visible = 0;
                this.ref = 0;
-               setLabelPaint(color);
-               setTickLabelPaint(color);
+               setLabelPaint(line_style.color);
+               setTickLabelPaint(line_style.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);
+       public AltosUIAxis(String label, AltosUnits units, AltosUILineStyle line_style, int index) {
+               this(label, units, line_style, index, axis_default);
        }
 }
index ed1e6c53b87b029eb4658bde94f7d02310c10902..851e831f43c8cd952d5df755c6e4b00853afab0d 100644 (file)
@@ -44,6 +44,8 @@ public class AltosUIEnable extends Container implements ChangeListener {
        int             x;
        JCheckBox       imperial_units;
        JCheckBox       show_shapes;
+       JLabel          line_width_label;
+       JSpinner        line_width;
        JLabel          speed_filter_label;
        JSlider         speed_filter;
        JLabel          accel_filter_label;
@@ -114,11 +116,15 @@ public class AltosUIEnable extends Container implements ChangeListener {
        }
 
        public void set_shapes_visible(boolean visible) {
-               System.out.printf("set shapes %b\n", visible);
                if (shape_listener != null)
                        shape_listener.set_shapes_visible(visible);
        }
 
+       public void set_line_width(float width) {
+               if (shape_listener != null)
+                       shape_listener.set_line_width(width);
+       }
+
        public void register_shape_listener(AltosShapeListener shape_listener) {
                this.shape_listener = shape_listener;
        }
@@ -160,6 +166,34 @@ public class AltosUIEnable extends Container implements ChangeListener {
                add(show_shapes, c);
 
 
+               line_width_label = new JLabel("Line Width");
+               c = new GridBagConstraints();
+               c.gridx = 1; c.gridy = 1001;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               add(line_width_label, c);
+
+               line_width = new JSpinner();
+               line_width.setValue(new Integer(1));
+               line_width.addChangeListener(new ChangeListener() {
+                               public void stateChanged(ChangeEvent e) {
+                                       int w = (Integer) line_width.getValue();
+                                       if (w < 1) {
+                                               w = 1;
+                                               line_width.setValue(new Integer(w));
+                                       }
+                                       System.out.printf("line width set to %d\n", w);
+                                       set_line_width(w);
+                               }
+                       });
+               c = new GridBagConstraints();
+               c.gridx = 2; c.gridy = 1001;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               add(line_width, c);
+
                speed_filter_label = new JLabel("Speed Filter(ms)");
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = 1002;
index 19bed6097a1c4326504ec0a17d79e3757e691ab9..407e5ab4c27d00559f59cc3647d910608ce98120 100644 (file)
@@ -30,15 +30,16 @@ import org.jfree.data.xy.*;
 import org.jfree.data.*;
 
 class AltosUITimeSeriesAxis {
-       Color           color;
-       boolean         enabled;
-       boolean         marker;
-       boolean         marker_top;
-       AltosUIAxis     axis;
-       XYPlot          plot;
-
-       public AltosUITimeSeriesAxis(Color color, boolean enabled, AltosUIAxis axis, XYPlot plot, boolean marker, boolean marker_top) {
-               this.color = color;
+       AltosUILineStyle        line_style;
+       boolean                 enabled;
+       boolean                 marker;
+       boolean                 marker_top;
+       AltosUIAxis             axis;
+       XYPlot                  plot;
+
+       public AltosUITimeSeriesAxis(AltosUILineStyle line_style, boolean enabled,
+                                    AltosUIAxis axis, XYPlot plot, boolean marker, boolean marker_top) {
+               this.line_style = line_style;
                this.enabled = enabled;
                this.axis = axis;
                this.plot = plot;
@@ -51,26 +52,34 @@ public class AltosUIFlightSeries extends AltosFlightSeries {
 
        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 (label.equals(ts.label) || (label.equals("default") && uts.line_style == null)) {
+                               uts.custom_axis_set = true;
                                if (axis.marker)
-                                       uts.set_marker(axis.color, axis.enabled, axis.plot, axis.marker_top);
+                                       uts.set_marker(axis.line_style, axis.enabled, axis.plot, axis.marker_top);
                                else
-                                       uts.set_axis(axis.color, axis.enabled, axis.axis);
+                                       uts.set_axis(axis.line_style, axis.enabled, axis.axis);
                        }
                }
        }
 
+       void check_axes() {
+               for (AltosTimeSeries ts : series) {
+                       AltosUITimeSeries uts = (AltosUITimeSeries) ts;
+
+                       if (!uts.custom_axis_set)
+                               System.out.printf("%s using default axis\n", ts.label);
+               }
+       }
+
        public void register_axis(String label,
-                                 Color color,
+                                 AltosUILineStyle line_style,
                                  boolean enabled,
                                  AltosUIAxis axis) {
-               AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(color,
+               AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(line_style,
                                                                      enabled,
                                                                      axis,
                                                                      null,
@@ -81,11 +90,11 @@ public class AltosUIFlightSeries extends AltosFlightSeries {
        }
 
        public void register_marker(String label,
-                                   Color color,
+                                   AltosUILineStyle line_style,
                                    boolean enabled,
                                    XYPlot plot,
                                    boolean marker_top) {
-               AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(color,
+               AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(line_style,
                                                                      enabled,
                                                                      null,
                                                                      plot,
@@ -97,17 +106,18 @@ public class AltosUIFlightSeries extends AltosFlightSeries {
 
        public AltosTimeSeries make_series(String label, AltosUnits units) {
 
-
                AltosUITimeSeries time_series = new AltosUITimeSeries(label, units);
 
                AltosUITimeSeriesAxis tsa = axes.get(label);
                if (tsa == null)
                        tsa = axes.get("default");
+               else
+                       time_series.custom_axis_set = true;
                if (tsa != null) {
                        if (tsa.marker)
-                               time_series.set_marker(tsa.color, tsa.enabled, tsa.plot, tsa.marker_top);
+                               time_series.set_marker(tsa.line_style, tsa.enabled, tsa.plot, tsa.marker_top);
                        else
-                               time_series.set_axis(tsa.color, tsa.enabled, tsa.axis);
+                               time_series.set_axis(tsa.line_style, tsa.enabled, tsa.axis);
                }
                return time_series;
        }
index 6328d40a788820e9dc7340addfd759e12ac479bc..40f415f1b6c26518bd735e8a8840dd53f4a7eb2d 100644 (file)
@@ -56,14 +56,14 @@ public class AltosUIGraph implements AltosUnitsListener, AltosShapeListener {
                return panel;
        }
 
-       public AltosUIAxis newAxis(String label, AltosUnits units, Color color, int flags) {
-               AltosUIAxis axis = new AltosUIAxis(label, units, color, axis_index++, flags);
+       public AltosUIAxis newAxis(String label, AltosUnits units, AltosUILineStyle line_style, int flags) {
+               AltosUIAxis axis = new AltosUIAxis(label, units, line_style, 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 AltosUIAxis newAxis(String label, AltosUnits units, AltosUILineStyle line_style) {
+               return newAxis(label, units, line_style, AltosUIAxis.axis_default);
        }
 
        void addAxis(AltosUIAxis axis) {
@@ -104,6 +104,11 @@ public class AltosUIGraph implements AltosUnitsListener, AltosShapeListener {
                        s.set_shapes_visible(visible);
        }
 
+       public void set_line_width(float width) {
+               for (AltosUITimeSeries s : series)
+                       s.set_line_width(width);
+       }
+
        public void setName (String name) {
                chart.setTitle(name);
        }
diff --git a/altosuilib/AltosUILineStyle.java b/altosuilib/AltosUILineStyle.java
new file mode 100644 (file)
index 0000000..387281a
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2017 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, 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_12;
+
+import java.io.*;
+import java.util.ArrayList;
+
+import java.awt.*;
+import javax.swing.*;
+import org.altusmetrum.altoslib_12.*;
+
+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 AltosUILineStyle {
+       public Color    color;
+       public float[]  dash;
+
+       static private Color color(int r, int g, int b) {
+               return new Color(r,g,b);
+       }
+
+       static final private Color[] colors = {
+               new Color(0,0,0),
+               new Color(230,0,0),     // red
+               new Color(216,103,0),   // orange
+               new Color(200,200,0),   // yellow
+               new Color(0,180,0),     // green
+               new Color(0,140,140),   // cyan
+               new Color(130,0,0),     // dark red
+               new Color(0,100,0),     // dark green
+               new Color(0,0,255),     // blue
+               new Color(140,0,140),   // magenta
+               new Color(150,150,150), // gray
+       };
+
+       static final private float[][] dashes = {
+               { 0 },
+               { 2, 4 },
+               { 4, 4 },
+               { 6, 4 },
+               { 6, 4, 2, 4 }
+       };
+
+       static int color_index, dash_index;
+
+       public AltosUILineStyle () {
+               color = colors[color_index];
+               dash = dashes[dash_index];
+               color_index = (color_index + 1) % colors.length;
+               if (color_index == 0) {
+                       dash_index = (dash_index + 1) % dashes.length;
+                       if (dash_index == 0)
+                               System.out.printf("too many line styles\n");
+               }
+       }
+
+       public AltosUILineStyle(int index) {
+               index = index % (colors.length * dashes.length);
+               int c = index % colors.length;
+               int d = index / colors.length;
+               color = colors[c];
+               dash = dashes[d];
+       }
+}
index b98c83768f057e7084c48b7fcdd55ab2cd860e19..e85e3c17774aadde406577d93e7a5cdd82cf0635 100644 (file)
@@ -61,16 +61,17 @@ class AltosXYSeries extends XYSeries {
 }
 
 public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher {
-       Color           color;
-       boolean         enable;
-       AltosUIAxis     axis;
-       boolean         marker;
-       boolean         marker_top;
+       AltosUILineStyle        line_style;
+       boolean                 enable;
+       boolean                 custom_axis_set;
+       AltosUIAxis             axis;
+       boolean                 marker;
+       boolean                 marker_top;
        XYLineAndShapeRenderer  renderer;
-       XYPlot          plot;
-       AltosXYSeries   xy_series;
+       XYPlot                  plot;
+       AltosXYSeries           xy_series;
        ArrayList<ValueMarker>  markers;
-
+       float                   width;
 
        /* AltosUIGrapher interface */
        public boolean need_reset() {
@@ -107,7 +108,8 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher
                                        marker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
                                        marker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
                                }
-                               marker.setPaint(color);
+                               marker.setPaint(line_style.color);
+                               marker.setStroke(new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
                                if (enable)
                                        plot.addDomainMarker(marker);
                                markers.add(marker);
@@ -165,23 +167,41 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher
                }
        }
 
-       public void set_axis(Color color, boolean enable, AltosUIAxis axis) {
-               this.color = color;
+       // public BasicStroke(float width, int cap, int join, float miterlimit,
+       // float dash[], float dash_phase)
+
+       public void set_line_width(float width) {
+               this.width = width;
+               if (markers != null) {
+                       for (ValueMarker marker : markers) {
+                               marker.setStroke(new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+                       }
+               } else {
+                       if (line_style.dash[0] == 0.0)
+                               renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+                       else
+                               renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, line_style.dash, 0.0f));
+               }
+       }
+
+       public void set_axis(AltosUILineStyle line_style, boolean enable, AltosUIAxis axis) {
+               this.line_style = line_style;
                this.enable = enable;
                this.axis = axis;
                this.marker = false;
+               this.width = 1.0f;
 
                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.setSeriesPaint(0, line_style.color);
+               set_line_width(this.width);
                renderer.setSeriesVisible(0, enable);
                xy_series = new AltosXYSeries(label);
        }
 
-       public void set_marker(Color color, boolean enable, XYPlot plot, boolean marker_top) {
-               this.color = color;
+       public void set_marker(AltosUILineStyle line_style, boolean enable, XYPlot plot, boolean marker_top) {
+               this.line_style = line_style;
                this.enable = enable;
                this.marker = true;
                this.plot = plot;
@@ -197,9 +217,9 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher
        }
 
        public AltosUITimeSeries(String label, AltosUnits units,
-                                Color color, boolean enable,
+                                AltosUILineStyle line_style, boolean enable,
                                 AltosUIAxis axis) {
                this(label, units);
-               set_axis(color, enable, axis);
+               set_axis(line_style, enable, axis);
        }
 }
index 0f606225341c761c43ae7f58387b1e90bac80dd5..c65a3d1516c5e80e8a1a24a4d3e4b5162f41d914 100644 (file)
@@ -41,6 +41,7 @@ altosuilib_JAVA = \
        AltosConfigFreqUI.java \
        AltosScanUI.java \
        AltosEepromDelete.java \
+       AltosEepromGrapher.java \
        AltosEepromManage.java \
        AltosEepromMonitorUI.java \
        AltosEepromSelect.java \
@@ -57,6 +58,7 @@ altosuilib_JAVA = \
        AltosBTDeviceIterator.java \
        AltosBTManage.java \
        AltosBTKnown.java \
+       AltosUILineStyle.java \
        AltosUIMap.java \
        AltosUIMapPreload.java \
        AltosUIFlightTab.java \