altosui: Cleanup flight UI layout
[fw/altos] / ao-tools / altosui / AltosDescent.java
index 0b7c8036b29f098a2c51ed395de653d77ef8de48..ceb78e57dbbc6254c5f13c2aceeae3afc9dbe2fc 100644 (file)
@@ -30,8 +30,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosDescent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
-       Font            label_font;
-       Font            value_font;
 
        public class DescentValue {
                JLabel          label;
@@ -48,22 +46,27 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
 
                public DescentValue (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
+                       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;
-                       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;
                        layout.setConstraints(label, c);
                        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;
                        c.anchor = GridBagConstraints.WEST;
-                       c.fill = GridBagConstraints.HORIZONTAL;
+                       c.fill = GridBagConstraints.BOTH;
+                       c.weightx = 1;
                        layout.setConstraints(value, c);
                        add(value);
                }
@@ -133,15 +136,58 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
 
        Lon lon;
 
-       class Bearing extends DescentValue {
+       class Bearing {
+               JLabel          label;
+               JTextField      value;
+               JTextField      value_deg;
+               void reset () {
+                       value.setText("");
+                       value_deg.setText("");
+               }
                void show (AltosState state, int crc_errors) {
-                       if (state.from_pad != null)
-                               show("%3.0f°", state.from_pad.bearing);
-                       else
+                       if (state.from_pad != null) {
+                               value.setText(state.from_pad.bearing_words(
+                                                     AltosGreatCircle.BEARING_LONG));
+                               value_deg.setText(String.format("%3.0f°", state.from_pad.bearing));
+                       } else {
                                value.setText("???");
+                               value_deg.setText("???");
+                       }
                }
                public Bearing (GridBagLayout layout, int y) {
-                       super (layout, y, "Bearing");
+                       GridBagConstraints      c = new GridBagConstraints();
+                       c.weighty = 1;
+
+                       label = new JLabel("Bearing");
+                       label.setFont(Altos.label_font);
+                       label.setHorizontalAlignment(SwingConstants.LEFT);
+                       c.gridx = 0; c.gridy = y;
+                       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;
+                       layout.setConstraints(label, c);
+                       add(label);
+
+                       value = new JTextField(30);
+                       value.setFont(Altos.value_font);
+                       value.setHorizontalAlignment(SwingConstants.RIGHT);
+                       c.gridx = 1; c.gridy = y;
+                       c.anchor = GridBagConstraints.EAST;
+                       c.weightx = 1;
+                       c.fill = GridBagConstraints.BOTH;
+                       layout.setConstraints(value, c);
+                       add(value);
+
+                       value_deg = new JTextField(5);
+                       value_deg.setFont(Altos.value_font);
+                       value_deg.setHorizontalAlignment(SwingConstants.RIGHT);
+                       c.gridx = 2; c.gridy = y;
+                       c.anchor = GridBagConstraints.EAST;
+                       c.weightx = 1;
+                       c.fill = GridBagConstraints.BOTH;
+                       layout.setConstraints(value_deg, c);
+                       add(value_deg);
                }
        }
 
@@ -195,8 +241,6 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        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 */