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.
22 import java.awt.event.*;
24 import org.altusmetrum.altoslib_11.*;
25 import org.altusmetrum.altosuilib_11.*;
27 public class AltosIgnitor extends AltosUIFlightTab {
29 public class Ignitor extends AltosUIUnitsIndicator {
32 public double value(AltosState state, int i) {
33 if (state.igniter_voltage == null ||
34 state.igniter_voltage.length < igniter)
35 return AltosLib.MISSING;
36 return state.igniter_voltage[igniter];
39 public double good() { return AltosLib.ao_igniter_good; }
41 public Ignitor (AltosUIFlightTab container, int y) {
42 super(container, y, AltosConvert.voltage, String.format ("%s Voltage", AltosLib.igniter_name(y)), 1, true, 1);
49 public void show(AltosState state, AltosListenerState listener_state) {
52 super.show(state, listener_state);
55 public boolean should_show(AltosState state) {
58 if (state.igniter_voltage == null)
60 return state.igniter_voltage.length > 0;
63 void make_igniters(AltosState state) {
64 int n = (state == null || state.igniter_voltage == null) ? 0 : state.igniter_voltage.length;
65 int old_n = igniters == null ? 0 : igniters.length;
69 if (igniters != null) {
70 for (int i = 0; i < igniters.length; i++) {
72 igniters[i].remove(this);
79 igniters = new Ignitor[n];
80 for (int i = 0; i < n; i++) {
81 igniters[i] = new Ignitor(this, i);
89 public String getName() {