2 * Copyright © 2010 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.
22 import java.awt.event.*;
24 import org.altusmetrum.altoslib_4.*;
25 import org.altusmetrum.altosuilib_2.*;
27 public class AltosAscent extends AltosUIFlightTab {
30 class Height extends AltosUIUnitsIndicator {
32 public double value(AltosState state, int i) {
34 return state.height();
36 return state.max_height();
39 public Height(Container container, int y) {
40 super(container, y, AltosConvert.height, "Height", 2, false, 1);
44 class Speed extends AltosUIUnitsIndicator {
45 public double value(AltosState state, int i) {
49 return state.max_speed();
52 public Speed(Container container, int y) {
53 super(container, y, AltosConvert.speed, "Speed", 2, false, 1);
57 class Accel extends AltosUIUnitsIndicator {
58 public boolean hide(double v) { return v == AltosLib.MISSING; }
60 public double value(AltosState state, int i) {
62 return state.acceleration();
64 return state.max_acceleration();
67 public Accel(Container container, int y) {
68 super(container, y, AltosConvert.accel, "Acceleration", 2, false, 1);
72 class Orient extends AltosUIUnitsIndicator {
74 public boolean hide(double v) { return v == AltosLib.MISSING; }
76 public double value(AltosState state, int i) {
78 return state.orient();
80 return state.max_orient();
83 public Orient(Container container, int y) {
84 super(container, y, AltosConvert.orient, "Tilt Angle", 2, false, 1);
89 class Apogee extends AltosUIUnitsIndicator {
91 public double value(AltosState state, int i) {
92 return state.apogee_voltage;
95 public boolean good(double v) { return v >= AltosLib.ao_igniter_good; }
96 public boolean hide(double v) { return v == AltosLib.MISSING; }
98 public Apogee (Container container, int y) {
99 super(container, y, AltosConvert.voltage, "Apogee Igniter Voltage", 1, true, 2);
103 class Main extends AltosUIUnitsIndicator {
104 public double value(AltosState state, int i) {
105 return state.main_voltage;
108 public boolean good(double v) { return v >= AltosLib.ao_igniter_good; }
109 public boolean hide(double v) { return v == AltosLib.MISSING; }
111 public Main (Container container, int y) {
112 super(container, y, AltosConvert.voltage, "Main Igniter Voltage", 1, true, 2);
116 class Lat extends AltosUIUnitsIndicator {
118 public boolean hide(AltosState state, int i) {
119 return state.gps == null || !state.gps.connected;
122 public double value(AltosState state, int i) {
123 if (state.gps == null)
124 return AltosLib.MISSING;
125 if (!state.gps.connected)
126 return AltosLib.MISSING;
127 return state.gps.lat;
130 Lat (Container container, int y) {
131 super (container, y, AltosConvert.latitude, "Latitude", 1, false, 2);
135 class Lon extends AltosUIUnitsIndicator {
137 public boolean hide(AltosState state, int i) {
138 return state.gps == null || !state.gps.connected;
141 public double value(AltosState state, int i) {
142 if (state.gps == null)
143 return AltosLib.MISSING;
144 if (!state.gps.connected)
145 return AltosLib.MISSING;
146 return state.gps.lon;
149 Lon (Container container, int y) {
150 super (container, y, AltosConvert.longitude, "Longitude", 1, false, 2);
154 public void font_size_changed(int font_size) {
155 super.font_size_changed(font_size);
156 cur.setFont(AltosUILib.label_font);
157 max.setFont(AltosUILib.label_font);
160 public void labels(GridBagLayout layout, int y) {
161 GridBagConstraints c;
163 cur = new JLabel("Current");
164 cur.setFont(AltosUILib.label_font);
165 c = new GridBagConstraints();
166 c.gridx = 2; c.gridy = y;
167 c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
168 layout.setConstraints(cur, c);
171 max = new JLabel("Maximum");
172 max.setFont(AltosUILib.label_font);
173 c.gridx = 3; c.gridy = y;
174 layout.setConstraints(max, c);
178 public String getName() {
182 public AltosAscent() {
185 add(new Height(this, y++));
186 add(new Speed(this, y++));
187 add(new Accel(this, y++));
188 add(new Orient(this, y++));
189 add(new Lat(this, y++));
190 add(new Lon(this, y++));
191 add(new Apogee(this, y++));
192 add(new Main(this, y++));