altosui: Make flight monitor font size configurable
authorKeith Packard <keithp@keithp.com>
Thu, 25 Aug 2011 02:13:03 +0000 (19:13 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 25 Aug 2011 02:35:11 +0000 (19:35 -0700)
Tiny netbooks aren't tall enough for the 'usual' font size, so provide
a smaller option. Then provide a bigger option, just because.

Signed-off-by: Keith Packard <keithp@keithp.com>
17 files changed:
altosui/Altos.java
altosui/AltosAscent.java
altosui/AltosCompanionInfo.java
altosui/AltosConfigureUI.java
altosui/AltosDescent.java
altosui/AltosFlightDisplay.java
altosui/AltosFlightStatus.java
altosui/AltosFlightUI.java
altosui/AltosFontListener.java [new file with mode: 0644]
altosui/AltosIdleMonitorUI.java
altosui/AltosInfoTable.java
altosui/AltosLanded.java
altosui/AltosPad.java
altosui/AltosPreferences.java
altosui/AltosSiteMap.java
altosui/Makefile.am
doc/altusmetrum.xsl

index ddf1005a3ed2aad1703a7290ab8905f86b9c79a4..e4f974f9bedd22dc43b6aaf74a99052cc3133aa6 100644 (file)
@@ -97,9 +97,45 @@ public class Altos {
 
        static final int tab_elt_pad = 5;
 
 
        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 Font label_font;
+       static Font value_font;
+       static Font status_font;
+       static Font table_label_font;
+       static Font table_value_font;
+
+       final static int font_size_small = 1;
+       final static int font_size_medium = 2;
+       final static int font_size_large = 3;
+
+       static void set_fonts(int size) {
+               int     brief_size;
+               int     table_size;
+               int     status_size;
+
+               switch (size) {
+               case font_size_small:
+                       brief_size = 16;
+                       status_size = 18;
+                       table_size = 11;
+                       break;
+               default:
+               case font_size_medium:
+                       brief_size = 22;
+                       status_size = 24;
+                       table_size = 14;
+                       break;
+               case font_size_large:
+                       brief_size = 26;
+                       status_size = 30;
+                       table_size = 17;
+                       break;
+               }
+               label_font = new Font("Dialog", Font.PLAIN, brief_size);
+               value_font = new Font("Monospaced", Font.PLAIN, brief_size);
+               status_font = new Font("SansSerif", Font.BOLD, status_size);
+               table_label_font = new Font("SansSerif", Font.PLAIN, table_size);
+               table_value_font = new Font("Monospaced", Font.PLAIN, table_size);
+       }
 
        static final int text_width = 20;
 
 
        static final int text_width = 20;
 
index d607b0c50aeff986137282c43fa4aeaef2e41da7..c8e5f3af07ea61fee1e21f4b8297fd22227d91d2 100644 (file)
@@ -30,6 +30,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosAscent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
 
 public class AltosAscent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
+       JLabel                  cur, max;
 
        public class AscentStatus {
                JLabel          label;
 
        public class AscentStatus {
                JLabel          label;
@@ -54,6 +55,11 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        lights.set(false);
                }
 
                        lights.set(false);
                }
 
+               void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+               }
+
                public AscentStatus (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
                public AscentStatus (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
@@ -109,6 +115,11 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        label.setVisible(false);
                        value.setVisible(false);
                }
                        label.setVisible(false);
                        value.setVisible(false);
                }
+               void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+               }
+
                public AscentValue (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
                public AscentValue (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
@@ -151,6 +162,12 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        max = AltosRecord.MISSING;
                }
 
                        max = AltosRecord.MISSING;
                }
 
+               void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+                       max_value.setFont(Altos.value_font);
+               }
+
                void show(String format, double v) {
                        if (v == AltosRecord.MISSING) {
                                value.setText("Missing");
                void show(String format, double v) {
                        if (v == AltosRecord.MISSING) {
                                value.setText("Missing");
@@ -314,6 +331,18 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                accel.reset();
        }
 
                accel.reset();
        }
 
+       public void set_font() {
+               cur.setFont(Altos.label_font);
+               max.setFont(Altos.label_font);
+               lat.set_font();
+               lon.set_font();
+               main.set_font();
+               apogee.set_font();
+               height.set_font();
+               speed.set_font();
+               accel.set_font();
+       }
+
        public void show(AltosState state, int crc_errors) {
                if (state.gps != null && state.gps.connected) {
                        lat.show(state, crc_errors);
        public void show(AltosState state, int crc_errors) {
                if (state.gps != null && state.gps.connected) {
                        lat.show(state, crc_errors);
@@ -337,7 +366,6 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
 
        public void labels(GridBagLayout layout, int y) {
                GridBagConstraints      c;
 
        public void labels(GridBagLayout layout, int y) {
                GridBagConstraints      c;
-               JLabel                  cur, max;
 
                cur = new JLabel("Current");
                cur.setFont(Altos.label_font);
 
                cur = new JLabel("Current");
                cur.setFont(Altos.label_font);
index f287a8ea3348cb375b39d1595018c23467e446b9..82bde62355345da96feca7b7a1d27d57ef21e533 100644 (file)
@@ -31,25 +31,26 @@ import java.util.concurrent.LinkedBlockingQueue;
 public class AltosCompanionInfo extends JTable {
        private AltosFlightInfoTableModel model;
 
 public class AltosCompanionInfo extends JTable {
        private AltosFlightInfoTableModel model;
 
-       private Font infoLabelFont = new Font("SansSerif", Font.PLAIN, 14);
-       private Font infoValueFont = new Font("Monospaced", Font.PLAIN, 14);
-
        static final int info_columns = 2;
        static final int info_rows = 17;
 
        int desired_row_height() {
        static final int info_columns = 2;
        static final int info_rows = 17;
 
        int desired_row_height() {
-               FontMetrics     infoValueMetrics = getFontMetrics(infoValueFont);
+               FontMetrics     infoValueMetrics = getFontMetrics(Altos.table_value_font);
                return (infoValueMetrics.getHeight() + infoValueMetrics.getLeading()) * 18 / 10;
        }
 
                return (infoValueMetrics.getHeight() + infoValueMetrics.getLeading()) * 18 / 10;
        }
 
+       public void set_font() {
+               setFont(Altos.table_value_font);
+               setRowHeight(desired_row_height());
+               doLayout();
+       }
+
        public AltosCompanionInfo() {
                super(new AltosFlightInfoTableModel(info_rows, info_columns));
                model = (AltosFlightInfoTableModel) getModel();
        public AltosCompanionInfo() {
                super(new AltosFlightInfoTableModel(info_rows, info_columns));
                model = (AltosFlightInfoTableModel) getModel();
-               setFont(infoValueFont);
                setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS);
                setShowGrid(true);
                setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS);
                setShowGrid(true);
-               setRowHeight(desired_row_height());
-               doLayout();
+               set_font();
        }
 
        public Dimension getPreferredScrollableViewportSize() {
        }
 
        public Dimension getPreferredScrollableViewportSize() {
index 0c865d0e350324de418dcf3db5a38090b11f3514..bcb9636bd3e176be858479e2d753fde299435c70 100644 (file)
@@ -47,12 +47,17 @@ public class AltosConfigureUI
        JLabel          callsign_label;
        JTextField      callsign_value;
 
        JLabel          callsign_label;
        JTextField      callsign_value;
 
+       JLabel          font_size_label;
+       JComboBox       font_size_value;
+
        JRadioButton    serial_debug;
 
 // BLUETOOTH
 //     JButton         manage_bluetooth;
        JButton         manage_frequencies;
 
        JRadioButton    serial_debug;
 
 // BLUETOOTH
 //     JButton         manage_bluetooth;
        JButton         manage_frequencies;
 
+       final static String[] font_size_names = { "Small", "Medium", "Large" };
+
        /* DocumentListener interface methods */
        public void changedUpdate(DocumentEvent e) {
                AltosPreferences.set_callsign(callsign_value.getText());
        /* DocumentListener interface methods */
        public void changedUpdate(DocumentEvent e) {
                AltosPreferences.set_callsign(callsign_value.getText());
@@ -73,6 +78,8 @@ public class AltosConfigureUI
 
                Insets insets = new Insets(4, 4, 4, 4);
 
 
                Insets insets = new Insets(4, 4, 4, 4);
 
+               int row = 0;
+
                owner = in_owner;
                voice = in_voice;
                pane = getContentPane();
                owner = in_owner;
                voice = in_voice;
                pane = getContentPane();
@@ -85,14 +92,14 @@ public class AltosConfigureUI
 
                /* Nice label at the top */
                c.gridx = 0;
 
                /* Nice label at the top */
                c.gridx = 0;
-               c.gridy = 0;
+               c.gridy = row++;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
                pane.add(new JLabel ("Configure AltOS UI"), c);
 
                c.gridx = 0;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
                pane.add(new JLabel ("Configure AltOS UI"), c);
 
                c.gridx = 0;
-               c.gridy = 1;
+               c.gridy = row++;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
@@ -100,7 +107,7 @@ public class AltosConfigureUI
 
                /* Voice settings */
                c.gridx = 0;
 
                /* Voice settings */
                c.gridx = 0;
-               c.gridy = 2;
+               c.gridy = row;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -119,7 +126,7 @@ public class AltosConfigureUI
                                }
                        });
                c.gridx = 1;
                                }
                        });
                c.gridx = 1;
-               c.gridy = 2;
+               c.gridy = row;
                c.gridwidth = 1;
                c.weightx = 1;
                c.fill = GridBagConstraints.NONE;
                c.gridwidth = 1;
                c.weightx = 1;
                c.fill = GridBagConstraints.NONE;
@@ -128,7 +135,7 @@ public class AltosConfigureUI
                enable_voice.setToolTipText("Enable/Disable all audio in-flight announcements");
 
                c.gridx = 2;
                enable_voice.setToolTipText("Enable/Disable all audio in-flight announcements");
 
                c.gridx = 2;
-               c.gridy = 2;
+               c.gridy = row++;
                c.gridwidth = 1;
                c.weightx = 1;
                c.fill = GridBagConstraints.NONE;
                c.gridwidth = 1;
                c.weightx = 1;
                c.fill = GridBagConstraints.NONE;
@@ -144,7 +151,7 @@ public class AltosConfigureUI
 
                /* Log directory settings */
                c.gridx = 0;
 
                /* Log directory settings */
                c.gridx = 0;
-               c.gridy = 3;
+               c.gridy = row;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -158,7 +165,7 @@ public class AltosConfigureUI
                                }
                        });
                c.gridx = 1;
                                }
                        });
                c.gridx = 1;
-               c.gridy = 3;
+               c.gridy = row++;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.BOTH;
                c.anchor = GridBagConstraints.WEST;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.BOTH;
                c.anchor = GridBagConstraints.WEST;
@@ -167,7 +174,7 @@ public class AltosConfigureUI
 
                /* Callsign setting */
                c.gridx = 0;
 
                /* Callsign setting */
                c.gridx = 0;
-               c.gridy = 4;
+               c.gridy = row;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -176,16 +183,42 @@ public class AltosConfigureUI
                callsign_value = new JTextField(AltosPreferences.callsign());
                callsign_value.getDocument().addDocumentListener(this);
                c.gridx = 1;
                callsign_value = new JTextField(AltosPreferences.callsign());
                callsign_value.getDocument().addDocumentListener(this);
                c.gridx = 1;
-               c.gridy = 4;
+               c.gridy = row++;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.BOTH;
                c.anchor = GridBagConstraints.WEST;
                pane.add(callsign_value, c);
                callsign_value.setToolTipText("Callsign sent in packet mode");
 
                c.gridwidth = 2;
                c.fill = GridBagConstraints.BOTH;
                c.anchor = GridBagConstraints.WEST;
                pane.add(callsign_value, c);
                callsign_value.setToolTipText("Callsign sent in packet mode");
 
+               /* Font size setting */
+               c.gridx = 0;
+               c.gridy = row;
+               c.gridwidth = 1;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.WEST;
+               pane.add(new JLabel("Font size"), c);
+
+               font_size_value = new JComboBox(font_size_names);
+               int font_size = AltosPreferences.font_size();
+               font_size_value.setSelectedIndex(font_size - Altos.font_size_small);
+               font_size_value.addActionListener(new ActionListener() {
+                               public void actionPerformed(ActionEvent e) {
+                                       int     size = font_size_value.getSelectedIndex() + Altos.font_size_small;
+
+                                       AltosPreferences.set_font_size(size);
+                               }
+                       });
+               c.gridx = 1;
+               c.gridy = row++;
+               c.gridwidth = 2;
+               c.fill = GridBagConstraints.BOTH;
+               c.anchor = GridBagConstraints.WEST;
+               pane.add(font_size_value, c);
+               font_size_value.setToolTipText("Font size used in telemetry window");
+
                /* Serial debug setting */
                c.gridx = 0;
                /* Serial debug setting */
                c.gridx = 0;
-               c.gridy = 5;
+               c.gridy = row;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -202,7 +235,7 @@ public class AltosConfigureUI
                serial_debug.setToolTipText("Enable/Disable USB I/O getting sent to the console");
 
                c.gridx = 1;
                serial_debug.setToolTipText("Enable/Disable USB I/O getting sent to the console");
 
                c.gridx = 1;
-               c.gridy = 5;
+               c.gridy = row++;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -216,7 +249,7 @@ public class AltosConfigureUI
 //                             }
 //                     });
 //             c.gridx = 0;
 //                             }
 //                     });
 //             c.gridx = 0;
-//             c.gridy = 6;
+//             c.gridy = row++;
 //             c.gridwidth = 2;
 //             c.fill = GridBagConstraints.NONE;
 //             c.anchor = GridBagConstraints.WEST;
 //             c.gridwidth = 2;
 //             c.fill = GridBagConstraints.NONE;
 //             c.anchor = GridBagConstraints.WEST;
@@ -232,7 +265,7 @@ public class AltosConfigureUI
 // BLUETOOTH
 //             c.gridx = 2;
                c.gridx = 1;
 // BLUETOOTH
 //             c.gridx = 2;
                c.gridx = 1;
-               c.gridy = 6;
+               c.gridy = row++;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -246,7 +279,7 @@ public class AltosConfigureUI
                                }
                        });
                c.gridx = 0;
                                }
                        });
                c.gridx = 0;
-               c.gridy = 7;
+               c.gridy = row++;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
index 2a9e7eef3bf728d834d62b87021da6fd9d71b653..0fcd690b781180548e31c8d5f13cdcd209a414c0 100644 (file)
@@ -55,6 +55,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        lights.set(false);
                }
 
                        lights.set(false);
                }
 
+               void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+               }
+
                public DescentStatus (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
                public DescentStatus (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
@@ -121,6 +126,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        value.setText(v);
                }
 
                        value.setText(v);
                }
 
+               void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+               }
+
                public DescentValue (GridBagLayout layout, int x, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
                public DescentValue (GridBagLayout layout, int x, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
@@ -169,6 +179,12 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        value2.setVisible(false);
                }
 
                        value2.setVisible(false);
                }
 
+               void set_font() {
+                       label.setFont(Altos.label_font);
+                       value1.setFont(Altos.value_font);
+                       value2.setFont(Altos.value_font);
+               }
+
                abstract void show(AltosState state, int crc_errors);
 
                void show(String v1, String v2) {
                abstract void show(AltosState state, int crc_errors);
 
                void show(String v1, String v2) {
@@ -361,6 +377,18 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                apogee.reset();
        }
 
                apogee.reset();
        }
 
+       public void set_font() {
+               lat.set_font();
+               lon.set_font();
+               height.set_font();
+               speed.set_font();
+               bearing.set_font();
+               range.set_font();
+               elevation.set_font();
+               main.set_font();
+               apogee.set_font();
+       }
+
        public void show(AltosState state, int crc_errors) {
                height.show(state, crc_errors);
                speed.show(state, crc_errors);
        public void show(AltosState state, int crc_errors) {
                height.show(state, crc_errors);
                speed.show(state, crc_errors);
index d18d1d1fe043c05969410aed564e537187edbaf7..f633c8e6c0411da307137d8516c89754a411ebbe 100644 (file)
@@ -21,4 +21,6 @@ public interface AltosFlightDisplay {
        void reset();
 
        void show(AltosState state, int crc_errors);
        void reset();
 
        void show(AltosState state, int crc_errors);
+
+       void set_font();
 }
 }
index 59c9e9dbbfbae1f56bf39f940b33f25bec865ed6..ed27338432564682dcfa327a8e11abc5a044edff 100644 (file)
@@ -40,6 +40,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
                void reset() {
                        value.setText("");
                }
                void reset() {
                        value.setText("");
                }
+
+               void set_font() {
+                       label.setFont(Altos.status_font);
+                       value.setFont(Altos.status_font);
+               }
+
                public FlightValue (GridBagLayout layout, int x, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.insets = new Insets(5, 5, 5, 5);
                public FlightValue (GridBagLayout layout, int x, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.insets = new Insets(5, 5, 5, 5);
@@ -127,6 +133,14 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
                rssi.reset();
        }
 
                rssi.reset();
        }
 
+       public void set_font () {
+               call.set_font();
+               serial.set_font();
+               flight.set_font();
+               flight_state.set_font();
+               rssi.set_font();
+       }
+
        public void show (AltosState state, int crc_errors) {
                call.show(state, crc_errors);
                serial.show(state, crc_errors);
        public void show (AltosState state, int crc_errors) {
                call.show(state, crc_errors);
                serial.show(state, crc_errors);
index abe08a182a04d4e6cae8deaf6b1bdad6779cfeea..b44b9d43b84c4a7f3f511120a4c2e183c68f028d 100644 (file)
@@ -28,7 +28,7 @@ import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
 
 import java.util.prefs.*;
 import java.util.concurrent.*;
 
-public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
+public class AltosFlightUI extends JFrame implements AltosFlightDisplay, AltosFontListener {
        AltosVoice              voice;
        AltosFlightReader       reader;
        AltosDisplayThread      thread;
        AltosVoice              voice;
        AltosFlightReader       reader;
        AltosDisplayThread      thread;
@@ -83,6 +83,21 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                sitemap.reset();
        }
 
                sitemap.reset();
        }
 
+       public void set_font() {
+               pad.set_font();
+               ascent.set_font();
+               descent.set_font();
+               landed.set_font();
+               flightStatus.set_font();
+               flightInfo.set_font();
+               sitemap.set_font();
+               companion.set_font();
+       }
+
+       public void font_size_changed(int font_size) {
+               set_font();
+       }
+
        public void show(AltosState state, int crc_errors) {
                JComponent tab = which_tab(state);
                try {
        public void show(AltosState state, int crc_errors) {
                JComponent tab = which_tab(state);
                try {
@@ -254,12 +269,16 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                bag.add(pane, c);
 
                setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                bag.add(pane, c);
 
                setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+
+               AltosPreferences.register_font_listener(this);
+
                addWindowListener(new WindowAdapter() {
                                @Override
                                public void windowClosing(WindowEvent e) {
                                        disconnect();
                                        setVisible(false);
                                        dispose();
                addWindowListener(new WindowAdapter() {
                                @Override
                                public void windowClosing(WindowEvent e) {
                                        disconnect();
                                        setVisible(false);
                                        dispose();
+                                       AltosPreferences.unregister_font_listener(AltosFlightUI.this);
                                        if (exit_on_close)
                                                System.exit(0);
                                }
                                        if (exit_on_close)
                                                System.exit(0);
                                }
diff --git a/altosui/AltosFontListener.java b/altosui/AltosFontListener.java
new file mode 100644 (file)
index 0000000..0dda0f2
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright Â© 2011 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package altosui;
+
+public interface AltosFontListener {
+       void font_size_changed(int font_size);
+}
index 142f02784259d40b65ed349521006152ce66e382..988a797c963a85cdad456e530d16286983fd7fdc 100644 (file)
@@ -284,6 +284,11 @@ public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay {
                flightInfo.clear();
        }
 
                flightInfo.clear();
        }
 
+       public void set_font() {
+               pad.set_font();
+               flightInfo.set_font();
+       }
+
        public void show(AltosState state, int crc_errors) {
                try {
                        pad.show(state, crc_errors);
        public void show(AltosState state, int crc_errors) {
                try {
                        pad.show(state, crc_errors);
index 8ebeaba10760c1de4fd98fda5898ab65caa311f5..c023369e55c3678bd0fad2fe00ab3864f092387b 100644 (file)
@@ -31,27 +31,29 @@ import java.util.concurrent.LinkedBlockingQueue;
 public class AltosInfoTable extends JTable {
        private AltosFlightInfoTableModel model;
 
 public class AltosInfoTable extends JTable {
        private AltosFlightInfoTableModel model;
 
-       private Font infoLabelFont = new Font("SansSerif", Font.PLAIN, 14);
-       private Font infoValueFont = new Font("Monospaced", Font.PLAIN, 14);
-
        static final int info_columns = 3;
        static final int info_rows = 17;
 
        int desired_row_height() {
        static final int info_columns = 3;
        static final int info_rows = 17;
 
        int desired_row_height() {
-               FontMetrics     infoValueMetrics = getFontMetrics(infoValueFont);
+               FontMetrics     infoValueMetrics = getFontMetrics(Altos.table_value_font);
                return (infoValueMetrics.getHeight() + infoValueMetrics.getLeading()) * 18 / 10;
        }
 
        public AltosInfoTable() {
                super(new AltosFlightInfoTableModel(info_rows, info_columns));
                model = (AltosFlightInfoTableModel) getModel();
                return (infoValueMetrics.getHeight() + infoValueMetrics.getLeading()) * 18 / 10;
        }
 
        public AltosInfoTable() {
                super(new AltosFlightInfoTableModel(info_rows, info_columns));
                model = (AltosFlightInfoTableModel) getModel();
-               setFont(infoValueFont);
+               setFont(Altos.table_value_font);
                setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS);
                setShowGrid(true);
                setRowHeight(desired_row_height());
                doLayout();
        }
 
                setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS);
                setShowGrid(true);
                setRowHeight(desired_row_height());
                doLayout();
        }
 
+       public void set_font() {
+               setFont(Altos.table_value_font);
+               doLayout();
+       }
+
        public Dimension getPreferredScrollableViewportSize() {
                return getPreferredSize();
        }
        public Dimension getPreferredScrollableViewportSize() {
                return getPreferredSize();
        }
index 71c1066318bad9c0410e994d7b76429ab41937c5..50e6b542f0501093938614b2b4bc4794f0558a8e 100644 (file)
@@ -30,8 +30,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener {
        GridBagLayout   layout;
 
 public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener {
        GridBagLayout   layout;
-       Font            label_font;
-       Font            value_font;
 
        public class LandedValue {
                JLabel          label;
 
        public class LandedValue {
                JLabel          label;
@@ -47,6 +45,11 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                        value.setVisible(true);
                }
 
                        value.setVisible(true);
                }
 
+               public void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+               }
+
                void hide() {
                        label.setVisible(false);
                        value.setVisible(false);
                void hide() {
                        label.setVisible(false);
                        value.setVisible(false);
@@ -63,7 +66,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                        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;
                        c.insets = new Insets(10, 10, 10, 10);
                        label.setHorizontalAlignment(SwingConstants.LEFT);
                        c.gridx = 0; c.gridy = y;
                        c.insets = new Insets(10, 10, 10, 10);
@@ -74,7 +77,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                        add(label);
 
                        value = new JTextField(Altos.text_width);
                        add(label);
 
                        value = new JTextField(Altos.text_width);
-                       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;
@@ -199,6 +202,16 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                accel.reset();
        }
 
                accel.reset();
        }
 
+       public void set_font() {
+               lat.set_font();
+               lon.set_font();
+               bearing.set_font();
+               distance.set_font();
+               height.set_font();
+               speed.set_font();
+               accel.set_font();
+       }
+
        public void show(AltosState state, int crc_errors) {
                if (state.gps != null && state.gps.connected) {
                        bearing.show(state, crc_errors);
        public void show(AltosState state, int crc_errors) {
                if (state.gps != null && state.gps.connected) {
                        bearing.show(state, crc_errors);
@@ -259,8 +272,6 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
 
                reader = in_reader;
 
 
                reader = in_reader;
 
-               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 3a8d04fea365347269d89066d93c642d9ac1f468..6ef66f7a937484eb11b8a24872dcc44e34d7c3c5 100644 (file)
@@ -54,6 +54,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                        lights.setVisible(false);
                }
 
                        lights.setVisible(false);
                }
 
+               public void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+               }
+
                public LaunchStatus (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
                public LaunchStatus (GridBagLayout layout, int y, String text) {
                        GridBagConstraints      c = new GridBagConstraints();
                        c.weighty = 1;
@@ -105,6 +110,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                        value.setVisible(false);
                }
 
                        value.setVisible(false);
                }
 
+               public void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+               }
+
                void reset() {
                        value.setText("");
                }
                void reset() {
                        value.setText("");
                }
@@ -282,6 +292,18 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                pad_alt.reset();
        }
 
                pad_alt.reset();
        }
 
+       public void set_font() {
+               battery.set_font();
+               apogee.set_font();
+               main.set_font();
+               logging_ready.set_font();
+               gps_locked.set_font();
+               gps_ready.set_font();
+               pad_lat.set_font();
+               pad_lon.set_font();
+               pad_alt.set_font();
+       }
+       
        public void show(AltosState state, int crc_errors) {
                battery.show(state, crc_errors);
                if (state.drogue_sense == AltosRecord.MISSING)
        public void show(AltosState state, int crc_errors) {
                battery.show(state, crc_errors);
                if (state.drogue_sense == AltosRecord.MISSING)
index de926b38ca2abca9dfbd5a6fc78b3651c39682a4..716559ab7e0a9dc06e7c94f5a18a225eb6baa044 100644 (file)
@@ -55,6 +55,9 @@ class AltosPreferences {
        /* scanning telemetry preferences name */
        final static String scanningTelemetryPreference = "SCANNING-TELEMETRY";
 
        /* scanning telemetry preferences name */
        final static String scanningTelemetryPreference = "SCANNING-TELEMETRY";
 
+       /* font size preferences name */
+       final static String fontSizePreference = "FONT-SIZE";
+
        /* Default logdir is ~/TeleMetrum */
        final static String logdirName = "TeleMetrum";
 
        /* Default logdir is ~/TeleMetrum */
        final static String logdirName = "TeleMetrum";
 
@@ -88,6 +91,10 @@ class AltosPreferences {
        /* Scanning telemetry */
        static int scanning_telemetry;
 
        /* Scanning telemetry */
        static int scanning_telemetry;
 
+       static LinkedList<AltosFontListener> font_listeners;
+
+       static int font_size = Altos.font_size_medium;
+
        /* List of frequencies */
        final static String common_frequencies_node_name = "COMMON-FREQUENCIES";
        static AltosFrequency[] common_frequencies;
        /* List of frequencies */
        final static String common_frequencies_node_name = "COMMON-FREQUENCIES";
        static AltosFrequency[] common_frequencies;
@@ -164,6 +171,11 @@ class AltosPreferences {
 
                scanning_telemetry = preferences.getInt(scanningTelemetryPreference,(1 << Altos.ao_telemetry_standard));
 
 
                scanning_telemetry = preferences.getInt(scanningTelemetryPreference,(1 << Altos.ao_telemetry_standard));
 
+               font_listeners = new LinkedList<AltosFontListener>();
+
+               font_size = preferences.getInt(fontSizePreference, Altos.font_size_medium);
+               Altos.set_fonts(font_size);
+
                String firmwaredir_string = preferences.get(firmwaredirPreference, null);
                if (firmwaredir_string != null)
                        firmwaredir = new File(firmwaredir_string);
                String firmwaredir_string = preferences.get(firmwaredirPreference, null);
                if (firmwaredir_string != null)
                        firmwaredir = new File(firmwaredir_string);
@@ -335,6 +347,36 @@ class AltosPreferences {
                return firmwaredir;
        }
 
                return firmwaredir;
        }
 
+       public static int font_size() {
+               return font_size;
+       }
+
+       static void set_fonts() {
+       }
+
+       public static void set_font_size(int new_font_size) {
+               font_size = new_font_size;
+               synchronized (preferences) {
+                       preferences.putInt(fontSizePreference, font_size);
+                       flush_preferences();
+                       Altos.set_fonts(font_size);
+                       for (AltosFontListener l : font_listeners)
+                               l.font_size_changed(font_size);
+               }
+       }
+
+       public static void register_font_listener(AltosFontListener l) {
+               synchronized (preferences) {
+                       font_listeners.add(l);
+               }
+       }
+
+       public static void unregister_font_listener(AltosFontListener l) {
+               synchronized (preferences) {
+                       font_listeners.remove(l);
+               }
+       }
+
        public static void set_serial_debug(boolean new_serial_debug) {
                serial_debug = new_serial_debug;
                AltosSerial.set_debug(serial_debug);
        public static void set_serial_debug(boolean new_serial_debug) {
                serial_debug = new_serial_debug;
                AltosSerial.set_debug(serial_debug);
index b3fb3c5470db9824d94e59ca329a377415c158e8..c258b3e5559728f364105d0794f89f4c8eba9784 100644 (file)
@@ -146,6 +146,10 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                // nothing
        }
 
                // nothing
        }
 
+       public void set_font() {
+               // nothing
+       }
+
        private void loadMap(final AltosSiteMapTile tile,
                             File pngfile, String pngurl)
        {
        private void loadMap(final AltosSiteMapTile tile,
                             File pngfile, String pngurl)
        {
index f626d3fa2703a80a7bf6484da75887436c451167..ba1c830c6c72c42c16281a9768a2175d489eb3f6 100644 (file)
@@ -57,6 +57,7 @@ altosui_JAVA = \
        AltosFlightStatsTable.java \
        AltosFlightStatus.java \
        AltosFlightUI.java \
        AltosFlightStatsTable.java \
        AltosFlightStatus.java \
        AltosFlightUI.java \
+       AltosFontListener.java \
        AltosFrequency.java \
        AltosFreqList.java \
        AltosGPS.java \
        AltosFrequency.java \
        AltosFreqList.java \
        AltosGPS.java \
index 601b62eb16af5f8d891440194691f7db2028bb05..df1e663502a34321b3c0447d5cf9494328fe3779 100644 (file)
@@ -1537,6 +1537,13 @@ NAR #88757, TRA #12200
           your local radio regulations.
         </para>
       </section>
           your local radio regulations.
         </para>
       </section>
+      <section>
+       <title>Font Size</title>
+       <para>
+         Selects the set of fonts used in the flight monitor
+         window. Choose between the small, medium and large sets.
+       </para>
+      </section>
       <section>
         <title>Serial Debug</title>
         <para>
       <section>
         <title>Serial Debug</title>
         <para>