Bump java lib versions in preparation for 1.9.2
[fw/altos] / altosuilib / AltosUIFlightTab.java
1 /*
2  * Copyright © 2014 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  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 package org.altusmetrum.altosuilib_14;
20
21 import java.util.*;
22 import java.awt.*;
23 import java.awt.event.*;
24 import javax.swing.*;
25 import org.altusmetrum.altoslib_14.*;
26
27 public abstract class AltosUIFlightTab extends JComponent implements AltosFlightDisplay, HierarchyListener {
28         public GridBagLayout    layout;
29
30         AltosState              last_state;
31         AltosListenerState      last_listener_state;
32
33         LinkedList<AltosUIIndicator>    indicators = new LinkedList<AltosUIIndicator>();
34
35         public void add (AltosUIIndicator indicator) {
36                 indicators.add(indicator);
37         }
38
39         public void remove(AltosUIIndicator indicator) {
40                 indicators.remove(indicator);
41         }
42
43         public void reset() {
44                 for (AltosUIIndicator i : indicators)
45                         i.reset();
46         }
47
48         public void font_size_changed(int font_size) {
49                 for (AltosUIIndicator i : indicators)
50                         i.font_size_changed(font_size);
51         }
52
53         public void units_changed(boolean imperial_units) {
54                 for (AltosUIIndicator i : indicators)
55                         i.units_changed(imperial_units);
56         }
57
58         public void show(AltosState state, AltosListenerState listener_state) {
59                 if (!isShowing()) {
60                         last_state = state;
61                         last_listener_state = listener_state;
62                         return;
63                 }
64
65                 for (AltosUIIndicator i : indicators)
66                         i.show(state, listener_state);
67         }
68
69         public void hierarchyChanged(HierarchyEvent e) {
70                 if (last_state != null && isShowing()) {
71                         AltosState              state = last_state;
72                         AltosListenerState      listener_state = last_listener_state;
73
74                         last_state = null;
75                         last_listener_state = null;
76                         show(state, listener_state);
77                 }
78         }
79
80         abstract public String getName();
81
82         public AltosUIFlightTab() {
83                 layout = new GridBagLayout();
84
85                 setLayout(layout);
86
87                 addHierarchyListener(this);
88         }
89 }