- public class LaunchValue {
- JLabel label;
- JTextField value;
- void show(AltosState state, AltosListenerState listener_state) {}
-
- void show() {
- label.setVisible(true);
- value.setVisible(true);
- }
-
- void hide() {
- label.setVisible(false);
- value.setVisible(false);
- }
-
- public void set_font() {
- label.setFont(Altos.label_font);
- value.setFont(Altos.value_font);
- }
-
- void show(String s) {
- show();
- value.setText(s);
- }
-
- void show(AltosUnits units, double v) {
- show(units.show(8, v));
- }
-
- void show(String format, double v) {
- show(String.format(format, v));
- }
-
- public void set_label(String text) {
- label.setText(text);
- }
-
- void reset() {
- value.setText("");
- }
-
- public LaunchValue (GridBagLayout layout, int y, String text) {
- GridBagConstraints c = new GridBagConstraints();
- c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
- c.weighty = 1;
-
- label = new JLabel(text);
- label.setFont(Altos.label_font);
- label.setHorizontalAlignment(SwingConstants.LEFT);
- c.gridx = 1; c.gridy = y;
- c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.VERTICAL;
- c.weightx = 0;
- layout.setConstraints(label, c);
- add(label);
-
- value = new JTextField(Altos.text_width);
- value.setFont(Altos.value_font);
- value.setHorizontalAlignment(SwingConstants.RIGHT);
- c.gridx = 2; c.gridy = y;
- c.anchor = GridBagConstraints.EAST;
- c.fill = GridBagConstraints.BOTH;
- c.weightx = 1;
- layout.setConstraints(value, c);
- add(value);
- }
- }
-
- class Battery extends LaunchStatus {
- void show (AltosState state, AltosListenerState listener_state) {
- if (state == null || state.battery_voltage == AltosLib.MISSING)
- hide();
- else {
- show("%4.2f V", state.battery_voltage);
- lights.set(state.battery_voltage > 3.7);
- }
- }
- public Battery (GridBagLayout layout, int y) {
- super(layout, y, "Battery Voltage");
- }