2 * Copyright © 2017 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, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
15 package org.altusmetrum.altosuilib_14;
20 import org.altusmetrum.altoslib_14.*;
22 import org.jfree.ui.*;
23 import org.jfree.chart.*;
24 import org.jfree.chart.plot.*;
25 import org.jfree.chart.axis.*;
26 import org.jfree.chart.renderer.*;
27 import org.jfree.chart.renderer.xy.*;
28 import org.jfree.chart.labels.*;
29 import org.jfree.data.xy.*;
30 import org.jfree.data.*;
32 class AltosUITimeSeriesAxis {
33 AltosUILineStyle line_style;
40 public AltosUITimeSeriesAxis(AltosUILineStyle line_style, boolean enabled,
41 AltosUIAxis axis, XYPlot plot, boolean marker, boolean marker_top) {
42 this.line_style = line_style;
43 this.enabled = enabled;
47 this.marker_top = marker_top;
51 public class AltosUIFlightSeries extends AltosFlightSeries {
53 Hashtable<String,AltosUITimeSeriesAxis> axes;
55 void fill_axes(String label, AltosUITimeSeriesAxis axis) {
56 for (AltosTimeSeries ts : series) {
57 AltosUITimeSeries uts = (AltosUITimeSeries) ts;
59 if (label.equals(ts.label) || (label.equals("default") && uts.line_style == null)) {
60 uts.custom_axis_set = true;
62 uts.set_marker(axis.line_style, axis.enabled, axis.plot, axis.marker_top);
64 uts.set_axis(axis.line_style, axis.enabled, axis.axis);
70 for (AltosTimeSeries ts : series) {
71 AltosUITimeSeries uts = (AltosUITimeSeries) ts;
73 if (!uts.custom_axis_set)
74 System.out.printf("%s using default axis\n", ts.label);
78 public void register_axis(String label,
79 AltosUILineStyle line_style,
82 AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(line_style,
89 fill_axes(label, tsa);
92 public void register_marker(String label,
93 AltosUILineStyle line_style,
97 AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(line_style,
103 axes.put(label, tsa);
104 fill_axes(label, tsa);
107 public AltosTimeSeries make_series(String label, AltosUnits units) {
109 AltosUITimeSeries time_series = new AltosUITimeSeries(label, units);
111 AltosUITimeSeriesAxis tsa = axes.get(label);
113 tsa = axes.get("default");
115 time_series.custom_axis_set = true;
118 time_series.set_marker(tsa.line_style, tsa.enabled, tsa.plot, tsa.marker_top);
120 time_series.set_axis(tsa.line_style, tsa.enabled, tsa.axis);
125 public AltosUITimeSeries[] series(AltosCalData cal_data) {
127 return series.toArray(new AltosUITimeSeries[0]);
130 public AltosUIFlightSeries (AltosCalData cal_data) {
132 axes = new Hashtable<String,AltosUITimeSeriesAxis>();