2 * Copyright © 2014 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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.altosuilib_9;
22 import java.awt.event.*;
24 import org.altusmetrum.altoslib_9.*;
26 public abstract class AltosUIFlightTab extends JComponent implements AltosFlightDisplay, HierarchyListener {
27 public GridBagLayout layout;
29 AltosState last_state;
30 AltosListenerState last_listener_state;
32 LinkedList<AltosUIIndicator> indicators = new LinkedList<AltosUIIndicator>();
34 public void add (AltosUIIndicator indicator) {
35 indicators.add(indicator);
38 public void remove(AltosUIIndicator indicator) {
39 indicators.remove(indicator);
43 for (AltosUIIndicator i : indicators)
47 public void font_size_changed(int font_size) {
48 for (AltosUIIndicator i : indicators)
49 i.font_size_changed(font_size);
52 public void units_changed(boolean imperial_units) {
53 for (AltosUIIndicator i : indicators)
54 i.units_changed(imperial_units);
57 public void show(AltosState state, AltosListenerState listener_state) {
60 last_listener_state = listener_state;
64 for (AltosUIIndicator i : indicators)
65 i.show(state, listener_state);
68 public void hierarchyChanged(HierarchyEvent e) {
69 if (last_state != null && isShowing()) {
70 AltosState state = last_state;
71 AltosListenerState listener_state = last_listener_state;
74 last_listener_state = null;
75 show(state, listener_state);
79 abstract public String getName();
81 public AltosUIFlightTab() {
82 layout = new GridBagLayout();
86 addHierarchyListener(this);