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; 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.
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.
19 package org.altusmetrum.altosuilib_11;
23 import java.awt.event.*;
25 import org.altusmetrum.altoslib_11.*;
27 public abstract class AltosUIFlightTab extends JComponent implements AltosFlightDisplay, HierarchyListener {
28 public GridBagLayout layout;
30 AltosState last_state;
31 AltosListenerState last_listener_state;
33 LinkedList<AltosUIIndicator> indicators = new LinkedList<AltosUIIndicator>();
35 public void add (AltosUIIndicator indicator) {
36 indicators.add(indicator);
39 public void remove(AltosUIIndicator indicator) {
40 indicators.remove(indicator);
44 for (AltosUIIndicator i : indicators)
48 public void font_size_changed(int font_size) {
49 for (AltosUIIndicator i : indicators)
50 i.font_size_changed(font_size);
53 public void units_changed(boolean imperial_units) {
54 for (AltosUIIndicator i : indicators)
55 i.units_changed(imperial_units);
58 public void show(AltosState state, AltosListenerState listener_state) {
61 last_listener_state = listener_state;
65 for (AltosUIIndicator i : indicators)
66 i.show(state, listener_state);
69 public void hierarchyChanged(HierarchyEvent e) {
70 if (last_state != null && isShowing()) {
71 AltosState state = last_state;
72 AltosListenerState listener_state = last_listener_state;
75 last_listener_state = null;
76 show(state, listener_state);
80 abstract public String getName();
82 public AltosUIFlightTab() {
83 layout = new GridBagLayout();
87 addHierarchyListener(this);