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;
public class AltosAscent extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
+ JLabel cur, max;
public class AscentStatus {
JLabel label;
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;
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;
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");
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 labels(GridBagLayout layout, int y) {
GridBagConstraints c;
- JLabel cur, max;
cur = new JLabel("Current");
cur.setFont(Altos.label_font);
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() {
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());
Insets insets = new Insets(4, 4, 4, 4);
+ int row = 0;
+
owner = in_owner;
voice = in_voice;
pane = getContentPane();
/* 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;
/* Voice settings */
c.gridx = 0;
- c.gridy = 2;
+ c.gridy = row;
c.gridwidth = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
}
});
c.gridx = 1;
- c.gridy = 2;
+ c.gridy = row;
c.gridwidth = 1;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
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;
/* Log directory settings */
c.gridx = 0;
- c.gridy = 3;
+ c.gridy = row;
c.gridwidth = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
}
});
c.gridx = 1;
- c.gridy = 3;
+ c.gridy = row++;
c.gridwidth = 2;
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.WEST;
/* Callsign setting */
c.gridx = 0;
- c.gridy = 4;
+ c.gridy = row;
c.gridwidth = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
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;
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.gridx = 0;
-// c.gridy = 6;
+// c.gridy = row++;
// c.gridwidth = 2;
// c.fill = GridBagConstraints.NONE;
// c.anchor = GridBagConstraints.WEST;
// 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.gridx = 0;
- c.gridy = 7;
+ c.gridy = row++;
c.gridwidth = 3;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
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;
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;
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) {
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);
void reset();
void show(AltosState state, int crc_errors);
+
+ void set_font();
}
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);
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);
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;
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 {
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);
}
--- /dev/null
+/*
+ * 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);
+}
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 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();
}
public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener {
GridBagLayout layout;
- Font label_font;
- Font value_font;
public class LandedValue {
JLabel label;
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);
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);
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;
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);
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 */
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;
value.setVisible(false);
}
+ public void set_font() {
+ label.setFont(Altos.label_font);
+ value.setFont(Altos.value_font);
+ }
+
void reset() {
value.setText("");
}
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)
/* 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";
/* 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;
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);
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);
// nothing
}
+ public void set_font() {
+ // nothing
+ }
+
private void loadMap(final AltosSiteMapTile tile,
File pngfile, String pngurl)
{
AltosFlightStatsTable.java \
AltosFlightStatus.java \
AltosFlightUI.java \
+ AltosFontListener.java \
AltosFrequency.java \
AltosFreqList.java \
AltosGPS.java \
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>