Bump java lib versions in preparation for 1.9.2
[fw/altos] / altosuilib / AltosUIFlightSeries.java
index d15c40718ca1187b57ff86d177cb6e147947aeaa..7e64cc2e2a26230428fbb2838a942eab9f556ba7 100644 (file)
  * General Public License for more details.
  */
 
-package org.altusmetrum.altosuilib_11;
+package org.altusmetrum.altosuilib_14;
 
 import java.util.*;
 import java.awt.*;
 import javax.swing.*;
-import org.altusmetrum.altoslib_11.*;
+import org.altusmetrum.altoslib_14.*;
 
-class AltosUITimeSeriesExtra {
-       Color           color;
-       boolean         enabled;
-       AltosUIAxis     axis;
+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 AltosUITimeSeriesExtra(Color color, boolean enabled, AltosUIAxis axis) {
-               this.color = color;
+class AltosUITimeSeriesAxis {
+       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;
+               this.marker = marker;
+               this.marker_top = marker_top;
        }
 }
 
 public class AltosUIFlightSeries extends AltosFlightSeries {
 
-       Hashtable<String,AltosUITimeSeriesExtra> extra;
+       Hashtable<String,AltosUITimeSeriesAxis> axes;
+
+       void fill_axes(String label, AltosUITimeSeriesAxis axis) {
+               for (AltosTimeSeries ts : series) {
+                       AltosUITimeSeries uts = (AltosUITimeSeries) ts;
+
+                       if (label.equals(ts.label) || (label.equals("default") && uts.line_style == null)) {
+                               uts.custom_axis_set = true;
+                               if (axis.marker)
+                                       uts.set_marker(axis.line_style, axis.enabled, axis.plot, axis.marker_top);
+                               else
+                                       uts.set_axis(axis.line_style, axis.enabled, axis.axis);
+                       }
+               }
+       }
+
+       void check_axes() {
+               for (AltosTimeSeries ts : series) {
+                       AltosUITimeSeries uts = (AltosUITimeSeries) ts;
 
-       public void register_extra(String label,
-                                  Color color,
-                                  boolean enabled,
-                                  AltosUIAxis axis) {
+                       if (!uts.custom_axis_set)
+                               System.out.printf("%s using default axis\n", ts.label);
+               }
+       }
+
+       public void register_axis(String label,
+                                 AltosUILineStyle line_style,
+                                 boolean enabled,
+                                 AltosUIAxis axis) {
+               AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(line_style,
+                                                                     enabled,
+                                                                     axis,
+                                                                     null,
+                                                                     false,
+                                                                     false);
+               axes.put(label, tsa);
+               fill_axes(label, tsa);
+       }
 
-               AltosUITimeSeriesExtra e = new AltosUITimeSeriesExtra(color,
+       public void register_marker(String label,
+                                   AltosUILineStyle line_style,
+                                   boolean enabled,
+                                   XYPlot plot,
+                                   boolean marker_top) {
+               AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(line_style,
                                                                      enabled,
-                                                                     axis);
-               System.out.printf("register extra label %s extra %s\n", label, e);
-               extra.put(label, e);
+                                                                     null,
+                                                                     plot,
+                                                                     true,
+                                                                     marker_top);
+               axes.put(label, tsa);
+               fill_axes(label, tsa);
        }
 
        public AltosTimeSeries make_series(String label, AltosUnits units) {
 
-               AltosUITimeSeriesExtra e = extra.get(label);
+               AltosUITimeSeries time_series = new AltosUITimeSeries(label, units);
 
-               if (e == null)
-                       e = extra.get("default");
-               return new AltosUITimeSeries(label, units,
-                                            e.color, e.enabled, e.axis);
+               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.line_style, tsa.enabled, tsa.plot, tsa.marker_top);
+                       else
+                               time_series.set_axis(tsa.line_style, tsa.enabled, tsa.axis);
+               }
+               return time_series;
        }
 
-       public AltosUITimeSeries[] series() {
+       public AltosUITimeSeries[] series(AltosCalData cal_data) {
+               finish();
                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>();
        }
 }