Prepare to create library shared with android application.
Signed-off-by: Keith Packard <keithp@keithp.com>
public class AltosBTKnown implements Iterable<AltosBTDevice> {
LinkedList<AltosBTDevice> devices = new LinkedList<AltosBTDevice>();
- Preferences bt_pref = AltosPreferences.bt_devices();
+ Preferences bt_pref = AltosUIPreferences.bt_devices();
private String get_address(String name) {
return bt_pref.get(name, "");
}
private void flush() {
- AltosPreferences.flush_preferences();
+ AltosUIPreferences.flush_preferences();
}
public void set(Iterable<AltosBTDevice> new_devices) {
public AltosBTKnown() {
devices = new LinkedList<AltosBTDevice>();
- bt_pref = AltosPreferences.bt_devices();
+ bt_pref = AltosUIPreferences.bt_devices();
load();
}
}
\ No newline at end of file
if (remote) {
serial_line.stop_remote();
serial_line.set_radio_frequency(frequency);
- AltosPreferences.set_frequency(device.getSerial(), frequency);
+ AltosUIPreferences.set_frequency(device.getSerial(), frequency);
serial_line.start_remote();
}
serial_line.printf("c c %s\n", callsign.get());
FrequencyList frequencies;
void save_frequencies() {
- AltosPreferences.set_common_frequencies(frequencies.frequencies());
+ AltosUIPreferences.set_common_frequencies(frequencies.frequencies());
}
JButton add, edit, remove;
Frame frame = JOptionPane.getFrameForComponent(frameComp);
AltosConfigFreqUI dialog;
- dialog = new AltosConfigFreqUI(frame, AltosPreferences.common_frequencies());
+ dialog = new AltosConfigFreqUI(frame, AltosUIPreferences.common_frequencies());
dialog.setVisible(true);
}
c.anchor = GridBagConstraints.LINE_START;
c.insets = ir;
c.ipady = 5;
- callsign_value = new JTextField(AltosPreferences.callsign());
+ callsign_value = new JTextField(AltosUIPreferences.callsign());
callsign_value.getDocument().addDocumentListener(this);
pane.add(callsign_value, c);
callsign_value.setToolTipText("Callsign reported in telemetry data");
product_value.getText(),
serial_value.getText());
AltosFrequency new_frequency = new AltosFrequency(new_radio_frequency, description);
- AltosPreferences.add_common_frequency(new_frequency);
+ AltosUIPreferences.add_common_frequency(new_frequency);
radio_frequency_value.insertItemAt(new_frequency, i);
radio_frequency_value.setSelectedIndex(i);
}
/* DocumentListener interface methods */
public void changedUpdate(DocumentEvent e) {
- AltosPreferences.set_callsign(callsign_value.getText());
+ AltosUIPreferences.set_callsign(callsign_value.getText());
}
public void insertUpdate(DocumentEvent e) {
c.anchor = GridBagConstraints.WEST;
pane.add(new JLabel("Voice"), c);
- enable_voice = new JRadioButton("Enable", AltosPreferences.voice());
+ enable_voice = new JRadioButton("Enable", AltosUIPreferences.voice());
enable_voice.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JRadioButton item = (JRadioButton) e.getSource();
boolean enabled = item.isSelected();
- AltosPreferences.set_voice(enabled);
+ AltosUIPreferences.set_voice(enabled);
if (enabled)
voice.speak_always("Enable voice.");
else
c.anchor = GridBagConstraints.WEST;
pane.add(new JLabel("Log Directory"), c);
- configure_log = new JButton(AltosPreferences.logdir().getPath());
+ configure_log = new JButton(AltosUIPreferences.logdir().getPath());
configure_log.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- AltosPreferences.ConfigureLog();
- configure_log.setText(AltosPreferences.logdir().getPath());
+ AltosUIPreferences.ConfigureLog();
+ configure_log.setText(AltosUIPreferences.logdir().getPath());
}
});
c.gridx = 1;
c.anchor = GridBagConstraints.WEST;
pane.add(new JLabel("Callsign"), c);
- callsign_value = new JTextField(AltosPreferences.callsign());
+ callsign_value = new JTextField(AltosUIPreferences.callsign());
callsign_value.getDocument().addDocumentListener(this);
c.gridx = 1;
c.gridy = row++;
pane.add(new JLabel("Font size"), c);
font_size_value = new JComboBox(font_size_names);
- int font_size = AltosPreferences.font_size();
+ int font_size = AltosUIPreferences.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);
+ AltosUIPreferences.set_font_size(size);
}
});
c.gridx = 1;
DelegatingRenderer.install(look_and_feel_value);
- String look_and_feel = AltosPreferences.look_and_feel();
+ String look_and_feel = AltosUIPreferences.look_and_feel();
for (int i = 0; i < look_and_feels.length; i++)
if (look_and_feel.equals(look_and_feels[i].getClassName()))
look_and_feel_value.setSelectedIndex(i);
public void actionPerformed(ActionEvent e) {
int id = look_and_feel_value.getSelectedIndex();
- AltosPreferences.set_look_and_feel(look_and_feels[id].getClassName());
+ AltosUIPreferences.set_look_and_feel(look_and_feels[id].getClassName());
}
});
c.gridx = 1;
c.anchor = GridBagConstraints.WEST;
pane.add(new JLabel("Serial Debug"), c);
- serial_debug = new JRadioButton("Enable", AltosPreferences.serial_debug());
+ serial_debug = new JRadioButton("Enable", AltosUIPreferences.serial_debug());
serial_debug.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JRadioButton item = (JRadioButton) e.getSource();
boolean enabled = item.isSelected();
- AltosPreferences.set_serial_debug(enabled);
+ AltosUIPreferences.set_serial_debug(enabled);
}
});
serial_debug.setToolTipText("Enable/Disable USB I/O getting sent to the console");
setDialogTitle("Select Flight Record File");
setFileFilter(new FileNameExtensionFilter("Flight data file",
"telem", "eeprom"));
- setCurrentDirectory(AltosPreferences.logdir());
+ setCurrentDirectory(AltosUIPreferences.logdir());
}
}
class AltosDialogListener extends WindowAdapter {
public void windowClosing (WindowEvent e) {
- AltosPreferences.unregister_ui_listener((AltosDialog) e.getWindow());
+ AltosUIPreferences.unregister_ui_listener((AltosDialog) e.getWindow());
}
}
}
public AltosDialog() {
- AltosPreferences.register_ui_listener(this);
+ AltosUIPreferences.register_ui_listener(this);
addWindowListener(new AltosDialogListener());
}
public AltosDialog(Frame frame, String label, boolean modal) {
super(frame, label, modal);
- AltosPreferences.register_ui_listener(this);
+ AltosUIPreferences.register_ui_listener(this);
addWindowListener(new AltosDialogListener());
}
public AltosDialog(Frame frame, boolean modal) {
super(frame, modal);
- AltosPreferences.register_ui_listener(this);
+ AltosUIPreferences.register_ui_listener(this);
addWindowListener(new AltosDialogListener());
}
}
class AltosFile extends File {
public AltosFile(int year, int month, int day, int serial, int flight, String extension) {
- super (AltosPreferences.logdir(),
+ super (AltosUIPreferences.logdir(),
String.format("%04d-%02d-%02d-serial-%03d-flight-%03d.%s",
year, month, day, serial, flight, extension));
}
boolean select_source_file() {
JFileChooser hexfile_chooser = new JFileChooser();
- File firmwaredir = AltosPreferences.firmwaredir();
+ File firmwaredir = AltosUIPreferences.firmwaredir();
if (firmwaredir != null)
hexfile_chooser.setCurrentDirectory(firmwaredir);
file = hexfile_chooser.getSelectedFile();
if (file == null)
return false;
- AltosPreferences.set_firmwaredir(file.getParentFile());
+ AltosUIPreferences.set_firmwaredir(file.getParentFile());
return true;
}
ActionListener show_timer;
public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
- AltosPreferences.set_component(this);
+ AltosUIPreferences.set_component(this);
voice = in_voice;
reader = in_reader;
/* Stick channel selector at top of table for telemetry monitoring */
if (serial >= 0) {
// Channel menu
- frequencies = new AltosFreqList(AltosPreferences.frequency(serial));
+ frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial));
frequencies.set_product("Monitor");
frequencies.set_serial(serial);
frequencies.addActionListener(new ActionListener() {
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- AltosPreferences.register_font_listener(this);
+ AltosUIPreferences.register_font_listener(this);
addWindowListener(new WindowAdapter() {
@Override
disconnect();
setVisible(false);
dispose();
- AltosPreferences.unregister_font_listener(AltosFlightUI.this);
+ AltosUIPreferences.unregister_font_listener(AltosFlightUI.this);
if (exit_on_close)
System.exit(0);
}
class AltosFrameListener extends WindowAdapter {
public void windowClosing (WindowEvent e) {
- AltosPreferences.unregister_ui_listener((AltosFrame) e.getWindow());
+ AltosUIPreferences.unregister_ui_listener((AltosFrame) e.getWindow());
}
}
}
public AltosFrame() {
- AltosPreferences.register_ui_listener(this);
+ AltosUIPreferences.register_ui_listener(this);
addWindowListener(new AltosFrameListener());
}
public AltosFrame(String name) {
super(name);
- AltosPreferences.register_ui_listener(this);
+ AltosUIPreferences.register_ui_listener(this);
addWindowListener(new AltosFrameListener());
}
}
}
String description = String.format("%s serial %d", product, serial);
AltosFrequency frequency = new AltosFrequency(new_frequency, description);
- AltosPreferences.add_common_frequency(frequency);
+ AltosUIPreferences.add_common_frequency(frequency);
insertItemAt(frequency, i);
setMaximumRowCount(getItemCount());
}
}
public AltosFreqList () {
- super(AltosPreferences.common_frequencies());
+ super(AltosUIPreferences.common_frequencies());
setMaximumRowCount(getItemCount());
setEditable(false);
product = "Unknown";
/* Stick frequency selector at top of table for telemetry monitoring */
if (remote && serial >= 0) {
// Frequency menu
- frequencies = new AltosFreqList(AltosPreferences.frequency(serial));
+ frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial));
frequencies.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
double frequency = frequencies.frequency();
thread.set_frequency(frequency);
- AltosPreferences.set_frequency(device.getSerial(),
+ AltosUIPreferences.set_frequency(device.getSerial(),
frequency);
}
});
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- AltosPreferences.register_font_listener(this);
+ AltosUIPreferences.register_font_listener(this);
addWindowListener(new WindowAdapter() {
@Override
disconnect();
setVisible(false);
dispose();
- AltosPreferences.unregister_font_listener(AltosIdleMonitorUI.this);
+ AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this);
}
});
void set_serial() {
try {
launcher_serial = Integer.parseInt(launcher_serial_text.getText());
- AltosPreferences.set_launcher_serial(launcher_serial);
+ AltosUIPreferences.set_launcher_serial(launcher_serial);
send_command("set_remote");
} catch (NumberFormatException ne) {
launcher_serial_text.setText(String.format("%d", launcher_serial));
void set_channel() {
try {
launcher_channel = Integer.parseInt(launcher_channel_text.getText());
- AltosPreferences.set_launcher_serial(launcher_channel);
+ AltosUIPreferences.set_launcher_serial(launcher_channel);
send_command("set_remote");
} catch (NumberFormatException ne) {
launcher_channel_text.setText(String.format("%d", launcher_channel));
public AltosLaunchUI(JFrame in_owner) {
- launcher_channel = AltosPreferences.launcher_channel();
- launcher_serial = AltosPreferences.launcher_serial();
+ launcher_channel = AltosUIPreferences.launcher_channel();
+ launcher_serial = AltosUIPreferences.launcher_serial();
owner = in_owner;
armed_status = AltosLaunch.Unknown;
igniter_status = AltosLaunch.Unknown;
import javax.swing.filechooser.FileSystemView;
class AltosPreferences {
- static Preferences preferences;
+ public static Preferences preferences;
/* logdir preference name */
final static String logdirPreference = "LOGDIR";
/* scanning telemetry preferences name */
final static String scanningTelemetryPreference = "SCANNING-TELEMETRY";
- /* font size preferences name */
- final static String fontSizePreference = "FONT-SIZE";
-
/* Launcher serial preference name */
final static String launcherSerialPreference = "LAUNCHER-SERIAL";
/* Launcher channel preference name */
final static String launcherChannelPreference = "LAUNCHER-CHANNEL";
- /* Look&Feel preference name */
- final static String lookAndFeelPreference = "LOOK-AND-FEEL";
-
/* Default logdir is ~/TeleMetrum */
final static String logdirName = "TeleMetrum";
- /* UI Component to pop dialogs up */
- static Component component;
-
/* Log directory */
static File logdir;
/* Scanning telemetry */
static int scanning_telemetry;
- static LinkedList<AltosFontListener> font_listeners;
-
- static int font_size = Altos.font_size_medium;
-
- static LinkedList<AltosUIListener> ui_listeners;
-
- static String look_and_feel = null;
-
/* 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);
-
launcher_serial = preferences.getInt(launcherSerialPreference, 0);
launcher_channel = preferences.getInt(launcherChannelPreference, 0);
common_frequencies = load_common_frequencies();
- look_and_feel = preferences.get(lookAndFeelPreference, UIManager.getSystemLookAndFeelClassName());
-
- ui_listeners = new LinkedList<AltosUIListener>();
}
static { init(); }
- static void set_component(Component in_component) {
- component = in_component;
- }
-
static void flush_preferences() {
try {
preferences.flush();
} catch (BackingStoreException ee) {
+/*
if (component != null)
JOptionPane.showMessageDialog(component,
preferences.absolutePath(),
"Cannot save prefernces",
JOptionPane.ERROR_MESSAGE);
else
+*/
System.err.printf("Cannot save preferences\n");
}
}
}
}
- private static boolean check_dir(File dir) {
- if (!dir.exists()) {
- if (!dir.mkdirs()) {
- JOptionPane.showMessageDialog(component,
- dir.getName(),
- "Cannot create directory",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
- } else if (!dir.isDirectory()) {
- JOptionPane.showMessageDialog(component,
- dir.getName(),
- "Is not a directory",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
- return true;
- }
-
- /* Configure the log directory. This is where all telemetry and eeprom files
- * will be written to, and where replay will look for telemetry files
- */
- public static void ConfigureLog() {
- JFileChooser logdir_chooser = new JFileChooser(logdir.getParentFile());
-
- logdir_chooser.setDialogTitle("Configure Data Logging Directory");
- logdir_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
-
- if (logdir_chooser.showDialog(component, "Select Directory") == JFileChooser.APPROVE_OPTION) {
- File dir = logdir_chooser.getSelectedFile();
- if (check_dir(dir))
- set_logdir(dir);
- }
- }
-
public static File logdir() {
return logdir;
}
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_look_and_feel(String new_look_and_feel) {
- look_and_feel = new_look_and_feel;
- try {
- UIManager.setLookAndFeel(look_and_feel);
- } catch (Exception e) {
- }
- synchronized(preferences) {
- preferences.put(lookAndFeelPreference, look_and_feel);
- flush_preferences();
- for (AltosUIListener l : ui_listeners)
- l.ui_changed(look_and_feel);
- }
- }
-
- public static String look_and_feel() {
- return look_and_feel;
- }
-
- public static void register_ui_listener(AltosUIListener l) {
- synchronized(preferences) {
- ui_listeners.add(l);
- }
- }
-
- public static void unregister_ui_listener(AltosUIListener l) {
- synchronized (preferences) {
- ui_listeners.remove(l);
- }
- }
public static void set_serial_debug(boolean new_serial_debug) {
serial_debug = new_serial_debug;
AltosSerial.set_debug(serial_debug);
scanning_telemetry |= (1 << Altos.ao_telemetry_standard);
telemetry_boxes[Altos.ao_telemetry_standard - Altos.ao_telemetry_min].setSelected(true);
}
- AltosPreferences.set_scanning_telemetry(scanning_telemetry);
+ AltosUIPreferences.set_scanning_telemetry(scanning_telemetry);
}
if (cmd.equals("monitor")) {
owner = in_owner;
- frequencies = AltosPreferences.common_frequencies();
+ frequencies = AltosUIPreferences.common_frequencies();
frequency_index = 0;
telemetry = Altos.ao_telemetry_min;
c.gridy = 2;
pane.add(telemetry_label, c);
- int scanning_telemetry = AltosPreferences.scanning_telemetry();
+ int scanning_telemetry = AltosUIPreferences.scanning_telemetry();
telemetry_boxes = new JCheckBox[Altos.ao_telemetry_max - Altos.ao_telemetry_min + 1];
for (int k = Altos.ao_telemetry_min; k <= Altos.ao_telemetry_max; k++) {
int j = k - Altos.ao_telemetry_min;
if (debug)
System.out.printf("start remote %7.3f\n", frequency);
if (frequency == 0.0)
- frequency = AltosPreferences.frequency(device.getSerial());
+ frequency = AltosUIPreferences.frequency(device.getSerial());
set_radio_frequency(frequency);
- set_callsign(AltosPreferences.callsign());
+ set_callsign(AltosUIPreferences.callsign());
printf("p\nE 0\n");
flush_input();
remote = true;
char chlng = lng < 0 ? 'W' : 'E';
if (lat < 0) lat = -lat;
if (lng < 0) lng = -lng;
- return new File(AltosPreferences.mapdir(),
+ return new File(AltosUIPreferences.mapdir(),
String.format("map-%c%.6f,%c%.6f-%d.png",
chlat, lat, chlng, lng, zoom));
}
}
void save_frequency() {
- AltosPreferences.set_frequency(device.getSerial(), frequency);
+ AltosUIPreferences.set_frequency(device.getSerial(), frequency);
}
void set_telemetry(int in_telemetry) {
}
void save_telemetry() {
- AltosPreferences.set_telemetry(device.getSerial(), telemetry);
+ AltosUIPreferences.set_telemetry(device.getSerial(), telemetry);
}
File backing_file() {
previous = null;
telem = new LinkedBlockingQueue<AltosLine>();
- frequency = AltosPreferences.frequency(device.getSerial());
+ frequency = AltosUIPreferences.frequency(device.getSerial());
set_frequency(frequency);
- telemetry = AltosPreferences.telemetry(device.getSerial());
+ telemetry = AltosUIPreferences.telemetry(device.getSerial());
set_telemetry(telemetry);
- serial.set_callsign(AltosPreferences.callsign());
+ serial.set_callsign(AltosUIPreferences.callsign());
serial.add_monitor(telem);
}
}
if (imgURL != null)
setIconImage(new ImageIcon(imgURL).getImage());
- AltosPreferences.set_component(this);
+ AltosUIPreferences.set_component(this);
pane = getContentPane();
gridbag = new GridBagLayout();
String result;
result = JOptionPane.showInputDialog(AltosUI.this,
"Configure Callsign",
- AltosPreferences.callsign());
+ AltosUIPreferences.callsign());
if (result != null)
- AltosPreferences.set_callsign(result);
+ AltosUIPreferences.set_callsign(result);
}
void ConfigureTeleMetrum() {
public static void main(final String[] args) {
try {
- UIManager.setLookAndFeel(AltosPreferences.look_and_feel());
+ UIManager.setLookAndFeel(AltosUIPreferences.look_and_feel());
} catch (Exception e) {
}
/* Handle batch-mode */
--- /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;
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import java.util.prefs.*;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.awt.Component;
+import javax.swing.*;
+import javax.swing.filechooser.FileSystemView;
+
+/* import org.altusmetrum.AltosLib.*; */
+
+class AltosUIPreferences extends AltosPreferences {
+
+ /* font size preferences name */
+ final static String fontSizePreference = "FONT-SIZE";
+
+ /* Look&Feel preference name */
+ final static String lookAndFeelPreference = "LOOK-AND-FEEL";
+
+ /* UI Component to pop dialogs up */
+ static Component component;
+
+ static LinkedList<AltosFontListener> font_listeners;
+
+ static int font_size = Altos.font_size_medium;
+
+ static LinkedList<AltosUIListener> ui_listeners;
+
+ static String look_and_feel = null;
+
+ public static void init() {
+ font_listeners = new LinkedList<AltosFontListener>();
+
+ font_size = preferences.getInt(fontSizePreference, Altos.font_size_medium);
+ Altos.set_fonts(font_size);
+ look_and_feel = preferences.get(lookAndFeelPreference, UIManager.getSystemLookAndFeelClassName());
+
+ ui_listeners = new LinkedList<AltosUIListener>();
+ }
+
+ static { init(); }
+
+ static void set_component(Component in_component) {
+ component = in_component;
+ }
+
+ private static boolean check_dir(File dir) {
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ JOptionPane.showMessageDialog(component,
+ dir.getName(),
+ "Cannot create directory",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ } else if (!dir.isDirectory()) {
+ JOptionPane.showMessageDialog(component,
+ dir.getName(),
+ "Is not a directory",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ return true;
+ }
+
+ /* Configure the log directory. This is where all telemetry and eeprom files
+ * will be written to, and where replay will look for telemetry files
+ */
+ public static void ConfigureLog() {
+ JFileChooser logdir_chooser = new JFileChooser(logdir.getParentFile());
+
+ logdir_chooser.setDialogTitle("Configure Data Logging Directory");
+ logdir_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+
+ if (logdir_chooser.showDialog(component, "Select Directory") == JFileChooser.APPROVE_OPTION) {
+ File dir = logdir_chooser.getSelectedFile();
+ if (check_dir(dir))
+ set_logdir(dir);
+ }
+ }
+ 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_look_and_feel(String new_look_and_feel) {
+ look_and_feel = new_look_and_feel;
+ try {
+ UIManager.setLookAndFeel(look_and_feel);
+ } catch (Exception e) {
+ }
+ synchronized(preferences) {
+ preferences.put(lookAndFeelPreference, look_and_feel);
+ flush_preferences();
+ for (AltosUIListener l : ui_listeners)
+ l.ui_changed(look_and_feel);
+ }
+ }
+
+ public static String look_and_feel() {
+ return look_and_feel;
+ }
+
+ public static void register_ui_listener(AltosUIListener l) {
+ synchronized(preferences) {
+ ui_listeners.add(l);
+ }
+ }
+
+ public static void unregister_ui_listener(AltosUIListener l) {
+ synchronized (preferences) {
+ ui_listeners.remove(l);
+ }
+ }
+}
\ No newline at end of file
}
public void speak(String s) {
- if (AltosPreferences.voice())
+ if (AltosUIPreferences.voice())
speak_always(s);
}
-SUBDIRS=libaltos
+SUBDIRS=libaltos altoslib
JAVAROOT=classes
AM_JAVACFLAGS=-encoding UTF-8 -Xlint:deprecation
AltosLog.java \
AltosPad.java \
AltosParse.java \
+ AltosUIPreferences.java \
AltosPreferences.java \
+ AltosUIPreferences.java \
AltosReader.java \
AltosRecord.java \
AltosRecordCompanion.java \