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 ddf1005..e4f974f 100644 (file)
@@ -97,9 +97,45 @@ public class Altos {
 
        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;
 
index d607b0c..c8e5f3a 100644 (file)
@@ -30,6 +30,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosAscent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
+       JLabel                  cur, max;
 
        public class AscentStatus {
                JLabel          label;
@@ -54,6 +55,11 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        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;
@@ -109,6 +115,11 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        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;
@@ -151,6 +162,12 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        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");
@@ -314,6 +331,18 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                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);
@@ -337,7 +366,6 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
 
        public void labels(GridBagLayout layout, int y) {
                GridBagConstraints      c;
-               JLabel                  cur, max;
 
                cur = new JLabel("Current");
                cur.setFont(Altos.label_font);
index f287a8e..82bde62 100644 (file)
@@ -31,25 +31,26 @@ import java.util.concurrent.LinkedBlockingQueue;
 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() {
-               FontMetrics     infoValueMetrics = getFontMetrics(infoValueFont);
+               FontMetrics     infoValueMetrics = getFontMetrics(Altos.table_value_font);
                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();
-               setFont(infoValueFont);
                setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS);
                setShowGrid(true);
-               setRowHeight(desired_row_height());
-               doLayout();
+               set_font();
        }
 
        public Dimension getPreferredScrollableViewportSize() {
index 0c865d0..bcb9636 100644 (file)
@@ -47,12 +47,17 @@ public class AltosConfigureUI
        JLabel          callsign_label;
        JTextField      callsign_value;
 
+       JLabel          font_size_label;
+       JComboBox       font_size_value;
+
        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());
@@ -73,6 +78,8 @@ public class AltosConfigureUI
 
                Insets insets = new Insets(4, 4, 4, 4);
 
+               int row = 0;
+
                owner = in_owner;
                voice = in_voice;
                pane = getContentPane();
@@ -85,14 +92,14 @@ public class AltosConfigureUI
 
                /* 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.gridy = 1;
+               c.gridy = row++;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
@@ -100,7 +107,7 @@ public class AltosConfigureUI
 
                /* Voice settings */
                c.gridx = 0;
-               c.gridy = 2;
+               c.gridy = row;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -119,7 +126,7 @@ public class AltosConfigureUI
                                }
                        });
                c.gridx = 1;
-               c.gridy = 2;
+               c.gridy = row;
                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;
-               c.gridy = 2;
+               c.gridy = row++;
                c.gridwidth = 1;
                c.weightx = 1;
                c.fill = GridBagConstraints.NONE;
@@ -144,7 +151,7 @@ public class AltosConfigureUI
 
                /* Log directory settings */
                c.gridx = 0;
-               c.gridy = 3;
+               c.gridy = row;
                c.gridwidth = 1;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -158,7 +165,7 @@ public class AltosConfigureUI
                                }
                        });
                c.gridx = 1;
-               c.gridy = 3;
+               c.gridy = row++;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.BOTH;
                c.anchor = GridBagConstraints.WEST;
@@ -167,7 +174,7 @@ public class AltosConfigureUI
 
                /* Callsign setting */
                c.gridx = 0;
-               c.gridy = 4;
+               c.gridy = row;
                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;
-               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");
 
+               /* 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;
-               c.gridy = 5;
+               c.gridy = row;
                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;
-               c.gridy = 5;
+               c.gridy = row++;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -216,7 +249,7 @@ public class AltosConfigureUI
 //                             }
 //                     });
 //             c.gridx = 0;
-//             c.gridy = 6;
+//             c.gridy = row++;
 //             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;
-               c.gridy = 6;
+               c.gridy = row++;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.WEST;
@@ -246,7 +279,7 @@ public class AltosConfigureUI
                                }
                        });
                c.gridx = 0;
-               c.gridy = 7;
+               c.gridy = row++;
                c.gridwidth = 3;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
index 2a9e7ee..0fcd690 100644 (file)
@@ -55,6 +55,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        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;
@@ -121,6 +126,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        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;
@@ -169,6 +179,12 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        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) {
@@ -361,6 +377,18 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                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);
index d18d1d1..f633c8e 100644 (file)
@@ -21,4 +21,6 @@ public interface AltosFlightDisplay {
        void reset();
 
        void show(AltosState state, int crc_errors);
+
+       void set_font();
 }
index 59c9e9d..ed27338 100644 (file)
@@ -40,6 +40,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
                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);
@@ -127,6 +133,14 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
                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);
index abe08a1..b44b9d4 100644 (file)
@@ -28,7 +28,7 @@ import java.text.*;
 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;
@@ -83,6 +83,21 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                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 {
@@ -254,12 +269,16 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                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();
+                                       AltosPreferences.unregister_font_listener(AltosFlightUI.this);
                                        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 142f027..988a797 100644 (file)
@@ -284,6 +284,11 @@ public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay {
                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);
index 8ebeaba..c023369 100644 (file)
@@ -31,27 +31,29 @@ import java.util.concurrent.LinkedBlockingQueue;
 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() {
-               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();
-               setFont(infoValueFont);
+               setFont(Altos.table_value_font);
                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();
        }
index 71c1066..50e6b54 100644 (file)
@@ -30,8 +30,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener {
        GridBagLayout   layout;
-       Font            label_font;
-       Font            value_font;
 
        public class LandedValue {
                JLabel          label;
@@ -47,6 +45,11 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                        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);
@@ -63,7 +66,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                        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);
@@ -74,7 +77,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                        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;
@@ -199,6 +202,16 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                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);
@@ -259,8 +272,6 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
 
                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 */
index 3a8d04f..6ef66f7 100644 (file)
@@ -54,6 +54,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                        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;
@@ -105,6 +110,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                        value.setVisible(false);
                }
 
+               public void set_font() {
+                       label.setFont(Altos.label_font);
+                       value.setFont(Altos.value_font);
+               }
+
                void reset() {
                        value.setText("");
                }
@@ -282,6 +292,18 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                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)
index de926b3..716559a 100644 (file)
@@ -55,6 +55,9 @@ class AltosPreferences {
        /* 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";
 
@@ -88,6 +91,10 @@ class AltosPreferences {
        /* 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;
@@ -164,6 +171,11 @@ class AltosPreferences {
 
                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);
@@ -335,6 +347,36 @@ class AltosPreferences {
                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);
index b3fb3c5..c258b3e 100644 (file)
@@ -146,6 +146,10 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                // nothing
        }
 
+       public void set_font() {
+               // nothing
+       }
+
        private void loadMap(final AltosSiteMapTile tile,
                             File pngfile, String pngurl)
        {
index f626d3f..ba1c830 100644 (file)
@@ -57,6 +57,7 @@ altosui_JAVA = \
        AltosFlightStatsTable.java \
        AltosFlightStatus.java \
        AltosFlightUI.java \
+       AltosFontListener.java \
        AltosFrequency.java \
        AltosFreqList.java \
        AltosGPS.java \
index 601b62e..df1e663 100644 (file)
@@ -1537,6 +1537,13 @@ NAR #88757, TRA #12200
           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>