altosuilib: Start creating new graph interface that takes time series data
[fw/altos] / altosuilib / AltosUIFlightSeries.java
1 /*
2  * Copyright © 2017 Keith Packard <keithp@keithp.com>
3  *
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.
8  *
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.
13  */
14
15 package org.altusmetrum.altosuilib_11;
16
17 import java.util.*;
18 import java.awt.*;
19 import javax.swing.*;
20 import org.altusmetrum.altoslib_11.*;
21
22 class AltosUITimeSeriesExtra {
23         Color           color;
24         boolean         enabled;
25         AltosUIAxis     axis;
26
27         public AltosUITimeSeriesExtra(Color color, boolean enabled, AltosUIAxis axis) {
28                 this.color = color;
29                 this.enabled = enabled;
30                 this.axis = axis;
31         }
32 }
33
34 public class AltosUIFlightSeries extends AltosFlightSeries {
35
36         Hashtable<String,AltosUITimeSeriesExtra> extra;
37
38         public void register_extra(String label,
39                                    Color color,
40                                    boolean enabled,
41                                    AltosUIAxis axis) {
42
43                 AltosUITimeSeriesExtra e = new AltosUITimeSeriesExtra(color,
44                                                                       enabled,
45                                                                       axis);
46                 System.out.printf("register extra label %s extra %s\n", label, e);
47                 extra.put(label, e);
48         }
49
50         public AltosTimeSeries make_series(String label, AltosUnits units) {
51
52                 AltosUITimeSeriesExtra e = extra.get(label);
53
54                 if (e == null)
55                         e = extra.get("default");
56                 return new AltosUITimeSeries(label, units,
57                                              e.color, e.enabled, e.axis);
58         }
59
60         public AltosUITimeSeries[] series() {
61                 return series.toArray(new AltosUITimeSeries[0]);
62         }
63
64         public AltosUIFlightSeries () {
65                 super();
66                 extra = new Hashtable<String,AltosUITimeSeriesExtra>();
67         }
68 }