altosui: Cleanup flight UI layout
authorKeith Packard <keithp@keithp.com>
Tue, 16 Nov 2010 14:20:00 +0000 (22:20 +0800)
committerKeith Packard <keithp@keithp.com>
Tue, 16 Nov 2010 14:20:00 +0000 (22:20 +0800)
Use common constants for fonts and insets
Shrink fonts so that the window is < 600 pixels tall.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/altosui/Altos.java
ao-tools/altosui/AltosAscent.java
ao-tools/altosui/AltosDescent.java
ao-tools/altosui/AltosFlightInfoTableModel.java
ao-tools/altosui/AltosFlightStatus.java
ao-tools/altosui/AltosFlightUI.java
ao-tools/altosui/AltosLanded.java
ao-tools/altosui/AltosPad.java

index 997550e005ac91fc1de2cdbb03c67aad6c88355e..197e98db7956bc4645fbcadb1ec9e8fe5f596320 100644 (file)
@@ -67,6 +67,12 @@ public class Altos {
 
        static boolean map_initialized = false;
 
 
        static boolean map_initialized = false;
 
+       static final int tab_elt_pad = 5;
+
+       static final Font label_font = new Font("Dialog", Font.PLAIN, 22);
+       static final Font value_font = new Font("Monospaced", Font.PLAIN, 22);
+       static final Font status_font = new Font("SansSerif", Font.BOLD, 24);
+
        static void initialize_map()
        {
                string_to_state.put("startup", ao_flight_startup);
        static void initialize_map()
        {
                string_to_state.put("startup", ao_flight_startup);
index 7525b655e43f770acad3aafde74cebb844ad5d61..8e1b6347d5e7a054154633636da4239317f12fca 100644 (file)
@@ -30,8 +30,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosAscent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
 
 public class AltosAscent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
-       Font            label_font;
-       Font            value_font;
 
        public class AscentValue {
                JLabel          label;
 
        public class AscentValue {
                JLabel          label;
@@ -46,10 +44,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        c.weighty = 1;
 
                        label = new JLabel(text);
                        c.weighty = 1;
 
                        label = new JLabel(text);
-                       label.setFont(label_font);
+                       label.setFont(Altos.label_font);
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
-                       c.insets = new Insets(10, 10, 10, 10);
+                       c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
                        c.anchor = GridBagConstraints.WEST;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.weightx = 0;
                        c.anchor = GridBagConstraints.WEST;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.weightx = 0;
@@ -57,7 +55,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        add(label);
 
                        value = new JTextField(30);
                        add(label);
 
                        value = new JTextField(30);
-                       value.setFont(value_font);
+                       value.setFont(Altos.value_font);
                        value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 1; c.gridy = y;
                        c.anchor = GridBagConstraints.WEST;
                        value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 1; c.gridy = y;
                        c.anchor = GridBagConstraints.WEST;
@@ -95,10 +93,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        c.weighty = 1;
 
                        label = new JLabel(text);
                        c.weighty = 1;
 
                        label = new JLabel(text);
-                       label.setFont(label_font);
+                       label.setFont(Altos.label_font);
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
-                       c.insets = new Insets(10, 10, 10, 10);
+                       c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
                        c.anchor = GridBagConstraints.WEST;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.weightx = 0;
                        c.anchor = GridBagConstraints.WEST;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.weightx = 0;
@@ -106,7 +104,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        add(label);
 
                        value = new JTextField(15);
                        add(label);
 
                        value = new JTextField(15);
-                       value.setFont(value_font);
+                       value.setFont(Altos.value_font);
                        value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 1; c.gridy = y;
                        c.anchor = GridBagConstraints.EAST;
                        value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 1; c.gridy = y;
                        c.anchor = GridBagConstraints.EAST;
@@ -116,7 +114,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        add(value);
 
                        max_value = new JTextField(15);
                        add(value);
 
                        max_value = new JTextField(15);
-                       max_value.setFont(value_font);
+                       max_value.setFont(Altos.value_font);
                        max_value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 2; c.gridy = y;
                        c.anchor = GridBagConstraints.EAST;
                        max_value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 2; c.gridy = y;
                        c.anchor = GridBagConstraints.EAST;
@@ -224,15 +222,15 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                JLabel                  cur, max;
 
                cur = new JLabel("Current");
                JLabel                  cur, max;
 
                cur = new JLabel("Current");
-               cur.setFont(label_font);
+               cur.setFont(Altos.label_font);
                c = new GridBagConstraints();
                c.gridx = 1; c.gridy = y;
                c = new GridBagConstraints();
                c.gridx = 1; c.gridy = y;
-               c.insets = new Insets(10, 10, 10, 10);
+               c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
                layout.setConstraints(cur, c);
                add(cur);
 
                max = new JLabel("Maximum");
                layout.setConstraints(cur, c);
                add(cur);
 
                max = new JLabel("Maximum");
-               max.setFont(label_font);
+               max.setFont(Altos.label_font);
                c.gridx = 2; c.gridy = y;
                layout.setConstraints(max, c);
                add(max);
                c.gridx = 2; c.gridy = y;
                layout.setConstraints(max, c);
                add(max);
@@ -241,8 +239,6 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
        public AltosAscent() {
                layout = new GridBagLayout();
 
        public AltosAscent() {
                layout = new GridBagLayout();
 
-               label_font = new Font("Dialog", Font.PLAIN, 24);
-               value_font = new Font("Monospaced", Font.PLAIN, 24);
                setLayout(layout);
 
                /* Elements in ascent display:
                setLayout(layout);
 
                /* Elements in ascent display:
index b69e36b676440cdfd9afd74ce04436048f384306..ceb78e57dbbc6254c5f13c2aceeae3afc9dbe2fc 100644 (file)
@@ -30,8 +30,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosDescent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
 
 public class AltosDescent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
-       Font            label_font;
-       Font            value_font;
 
        public class DescentValue {
                JLabel          label;
 
        public class DescentValue {
                JLabel          label;
@@ -51,10 +49,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        c.weighty = 1;
 
                        label = new JLabel(text);
                        c.weighty = 1;
 
                        label = new JLabel(text);
-                       label.setFont(label_font);
+                       label.setFont(Altos.label_font);
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
-                       c.insets = new Insets(10, 10, 10, 10);
+                       c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
                        c.anchor = GridBagConstraints.WEST;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.weightx = 0;
                        c.anchor = GridBagConstraints.WEST;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.weightx = 0;
@@ -62,7 +60,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        add(label);
 
                        value = new JTextField(30);
                        add(label);
 
                        value = new JTextField(30);
-                       value.setFont(value_font);
+                       value.setFont(Altos.value_font);
                        value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 1; c.gridy = y;
                        c.gridwidth = 2;
                        value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 1; c.gridy = y;
                        c.gridwidth = 2;
@@ -161,10 +159,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        c.weighty = 1;
 
                        label = new JLabel("Bearing");
                        c.weighty = 1;
 
                        label = new JLabel("Bearing");
-                       label.setFont(label_font);
+                       label.setFont(Altos.label_font);
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
-                       c.insets = new Insets(10, 10, 10, 10);
+                       c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
                        c.anchor = GridBagConstraints.WEST;
                        c.weightx = 0;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.anchor = GridBagConstraints.WEST;
                        c.weightx = 0;
                        c.fill = GridBagConstraints.VERTICAL;
@@ -172,7 +170,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        add(label);
 
                        value = new JTextField(30);
                        add(label);
 
                        value = new JTextField(30);
-                       value.setFont(value_font);
+                       value.setFont(Altos.value_font);
                        value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 1; c.gridy = y;
                        c.anchor = GridBagConstraints.EAST;
                        value.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 1; c.gridy = y;
                        c.anchor = GridBagConstraints.EAST;
@@ -182,7 +180,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        add(value);
 
                        value_deg = new JTextField(5);
                        add(value);
 
                        value_deg = new JTextField(5);
-                       value_deg.setFont(value_font);
+                       value_deg.setFont(Altos.value_font);
                        value_deg.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 2; c.gridy = y;
                        c.anchor = GridBagConstraints.EAST;
                        value_deg.setHorizontalAlignment(SwingConstants.RIGHT);
                        c.gridx = 2; c.gridy = y;
                        c.anchor = GridBagConstraints.EAST;
@@ -243,8 +241,6 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        public AltosDescent() {
                layout = new GridBagLayout();
 
        public AltosDescent() {
                layout = new GridBagLayout();
 
-               label_font = new Font("Dialog", Font.PLAIN, 24);
-               value_font = new Font("Monospaced", Font.PLAIN, 24);
                setLayout(layout);
 
                /* Elements in descent display */
                setLayout(layout);
 
                /* Elements in descent display */
index 2a22e3e50b48b682173034455f6f26848536ca47..3355ff527beba857378aa2cd5b6e62ec211f1d03 100644 (file)
@@ -46,7 +46,7 @@ public class AltosFlightInfoTableModel extends AbstractTableModel {
        public int getColumnCount() { return columnNames.length; }
        public String getColumnName(int col) { return columnNames[col]; }
 
        public int getColumnCount() { return columnNames.length; }
        public String getColumnName(int col) { return columnNames[col]; }
 
-       public int getRowCount() { return 20; }
+       public int getRowCount() { return 17; }
 
        int     current_row = 0;
        int     prev_num_rows = 0;
 
        int     current_row = 0;
        int     prev_num_rows = 0;
index b99a532537a92c18ce9ea1f2eadf8bbd810d12bf..59c9e9dbbfbae1f56bf39f940b33f25bec865ed6 100644 (file)
@@ -31,8 +31,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 public class AltosFlightStatus extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
 
 public class AltosFlightStatus extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
 
-       private Font status_font;
-
        public class FlightValue {
                JLabel          label;
                JTextField      value;
        public class FlightValue {
                JLabel          label;
                JTextField      value;
@@ -51,14 +49,14 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
                        c.weighty = 1;
 
                        label = new JLabel(text);
                        c.weighty = 1;
 
                        label = new JLabel(text);
-                       label.setFont(status_font);
+                       label.setFont(Altos.status_font);
                        label.setHorizontalAlignment(SwingConstants.CENTER);
                        c.gridx = x; c.gridy = 0;
                        layout.setConstraints(label, c);
                        add(label);
 
                        value = new JTextField("");
                        label.setHorizontalAlignment(SwingConstants.CENTER);
                        c.gridx = x; c.gridy = 0;
                        layout.setConstraints(label, c);
                        add(label);
 
                        value = new JTextField("");
-                       value.setFont(status_font);
+                       value.setFont(Altos.status_font);
                        value.setHorizontalAlignment(SwingConstants.CENTER);
                        c.gridx = x; c.gridy = 1;
                        layout.setConstraints(value, c);
                        value.setHorizontalAlignment(SwingConstants.CENTER);
                        c.gridx = x; c.gridy = 1;
                        layout.setConstraints(value, c);
@@ -145,7 +143,6 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
        public AltosFlightStatus() {
                layout = new GridBagLayout();
 
        public AltosFlightStatus() {
                layout = new GridBagLayout();
 
-               status_font = new Font("SansSerif", Font.BOLD, 24);
                setLayout(layout);
 
                call = new Call(layout, 0);
                setLayout(layout);
 
                call = new Call(layout, 0);
index 5134a24ebd731ed09533e2c1f1e05bcf3f9866a8..78b005c0908656158496e3fe0f235c0c82651a1f 100644 (file)
@@ -187,7 +187,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                        this.setJMenuBar(menubar);
                }
 
                        this.setJMenuBar(menubar);
                }
 
-               this.setSize(new Dimension (width(), height()));
+               this.setSize(this.getPreferredSize());
                this.validate();
 
                setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                this.validate();
 
                setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
index 465c9dcea8ffc8ee7972397f54f2f6e6715502c2..0656ea6cfda717c857cfd6b9c5f42b6d18d65d91 100644 (file)
@@ -196,8 +196,8 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay {
        public AltosLanded() {
                layout = new GridBagLayout();
 
        public AltosLanded() {
                layout = new GridBagLayout();
 
-               label_font = new Font("Dialog", Font.PLAIN, 24);
-               value_font = new Font("Monospaced", Font.PLAIN, 24);
+               label_font = new Font("Dialog", Font.PLAIN, 22);
+               value_font = new Font("Monospaced", Font.PLAIN, 22);
                setLayout(layout);
 
                /* Elements in descent display */
                setLayout(layout);
 
                /* Elements in descent display */
index 650ed01238fc0a7caac9a8f0893f942a67d1514b..8b258c7d6149b199c61a0b5876724cc68f82d07d 100644 (file)
@@ -60,7 +60,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                        label.setFont(label_font);
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 1; c.gridy = y;
                        label.setFont(label_font);
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 1; c.gridy = y;
-                       c.insets = new Insets(10, 10, 10, 10);
+                       c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
                        c.anchor = GridBagConstraints.WEST;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.weightx = 0;
                        c.anchor = GridBagConstraints.WEST;
                        c.fill = GridBagConstraints.VERTICAL;
                        c.weightx = 0;
@@ -90,7 +90,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                }
                public LaunchValue (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                }
                public LaunchValue (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
-                       c.insets = new Insets(10, 10, 10, 10);
+                       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);
                        c.weighty = 1;
 
                        label = new JLabel(text);
@@ -151,17 +151,32 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
 
        Main main;
 
 
        Main main;
 
-       class GPS extends LaunchStatus {
+       class GPSLocked extends LaunchStatus {
                void show (AltosState state, int crc_errors) {
                        value.setText(String.format("%4d sats", state.gps.nsat));
                void show (AltosState state, int crc_errors) {
                        value.setText(String.format("%4d sats", state.gps.nsat));
+                       lights.set(state.gps.locked);
+               }
+               public GPSLocked (GridBagLayout layout, int y) {
+                       super (layout, y, "GPS Locked");
+               }
+       }
+
+       GPSLocked gps_locked;
+
+       class GPSReady extends LaunchStatus {
+               void show (AltosState state, int crc_errors) {
+                       if (state.gps_ready)
+                               value.setText("Ready");
+                       else
+                               value.setText(String.format("Waiting %d", state.gps_waiting));
                        lights.set(state.gps_ready);
                }
                        lights.set(state.gps_ready);
                }
-               public GPS (GridBagLayout layout, int y) {
-                       super (layout, y, "GPS Status");
+               public GPSReady (GridBagLayout layout, int y) {
+                       super (layout, y, "GPS Ready");
                }
        }
 
                }
        }
 
-       GPS gps;
+       GPSReady gps_ready;
 
        String pos(double p, String pos, String neg) {
                String  h = pos;
 
        String pos(double p, String pos, String neg) {
                String  h = pos;
@@ -211,7 +226,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                battery.reset();
                apogee.reset();
                main.reset();
                battery.reset();
                apogee.reset();
                main.reset();
-               gps.reset();
+               gps_locked.reset();
+               gps_ready.reset();
                pad_lat.reset();
                pad_lon.reset();
                pad_alt.reset();
                pad_lat.reset();
                pad_lon.reset();
                pad_alt.reset();
@@ -221,7 +237,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                battery.show(state, crc_errors);
                apogee.show(state, crc_errors);
                main.show(state, crc_errors);
                battery.show(state, crc_errors);
                apogee.show(state, crc_errors);
                main.show(state, crc_errors);
-               gps.show(state, crc_errors);
+               gps_locked.show(state, crc_errors);
+               gps_ready.show(state, crc_errors);
                pad_lat.show(state, crc_errors);
                pad_lon.show(state, crc_errors);
                pad_alt.show(state, crc_errors);
                pad_lat.show(state, crc_errors);
                pad_lon.show(state, crc_errors);
                pad_alt.show(state, crc_errors);
@@ -230,24 +247,27 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        public AltosPad() {
                layout = new GridBagLayout();
 
        public AltosPad() {
                layout = new GridBagLayout();
 
-               label_font = new Font("Dialog", Font.PLAIN, 24);
-               value_font = new Font("Monospaced", Font.PLAIN, 24);
+               label_font = new Font("Dialog", Font.PLAIN, 22);
+               value_font = new Font("Monospaced", Font.PLAIN, 22);
                setLayout(layout);
 
                /* Elements in pad display:
                 *
                 * Battery voltage
                 * Igniter continuity
                setLayout(layout);
 
                /* Elements in pad display:
                 *
                 * Battery voltage
                 * Igniter continuity
-                * GPS lock status and location
+                * GPS lock status
+                * GPS ready status
+                * GPS location
                 * Pad altitude
                 * RSSI
                 */
                battery = new Battery(layout, 0);
                apogee = new Apogee(layout, 1);
                main = new Main(layout, 2);
                 * Pad altitude
                 * RSSI
                 */
                battery = new Battery(layout, 0);
                apogee = new Apogee(layout, 1);
                main = new Main(layout, 2);
-               gps = new GPS(layout, 3);
-               pad_lat = new PadLat(layout, 4);
-               pad_lon = new PadLon(layout, 5);
-               pad_alt = new PadAlt(layout, 6);
+               gps_locked = new GPSLocked(layout, 3);
+               gps_ready = new GPSReady(layout, 4);
+               pad_lat = new PadLat(layout, 5);
+               pad_lon = new PadLon(layout, 6);
+               pad_alt = new PadAlt(layout, 7);
        }
 }
        }
 }