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.
21 import java.awt.event.*;
23 import org.altusmetrum.altoslib_9.*;
24 import org.altusmetrum.altosuilib_9.*;
26 public class AltosIgnitor extends AltosUIFlightTab {
28 public class Ignitor extends AltosUIUnitsIndicator {
31 public double value(AltosState state, int i) {
32 if (state.ignitor_voltage == null ||
33 state.ignitor_voltage.length < ignitor)
34 return AltosLib.MISSING;
35 return state.ignitor_voltage[ignitor];
38 public double good() { return AltosLib.ao_igniter_good; }
40 public Ignitor (AltosUIFlightTab container, int y) {
41 super(container, y, AltosConvert.voltage, String.format ("%s Voltage", AltosLib.ignitor_name(y)), 1, true, 1);
48 public void show(AltosState state, AltosListenerState listener_state) {
51 super.show(state, listener_state);
54 public boolean should_show(AltosState state) {
57 if (state.ignitor_voltage == null)
59 return state.ignitor_voltage.length > 0;
62 void make_ignitors(AltosState state) {
63 int n = (state == null || state.ignitor_voltage == null) ? 0 : state.ignitor_voltage.length;
64 int old_n = ignitors == null ? 0 : ignitors.length;
68 if (ignitors != null) {
69 for (int i = 0; i < ignitors.length; i++) {
71 ignitors[i].remove(this);
78 ignitors = new Ignitor[n];
79 for (int i = 0; i < n; i++) {
80 ignitors[i] = new Ignitor(this, i);
88 public String getName() {