source: osm/applications/editors/josm/plugins/livegps/src/livegps/LiveGPSPreferences.java@ 36117

Last change on this file since 36117 was 36117, checked in by stoecker, 3 years ago

move all preferences to prefs class, allow to show distance to way, make nearest way independent from current display

File size: 4.6 KB
Line 
1// License: Public Domain. For details, see LICENSE file.
2package livegps;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagConstraints;
7import java.awt.GridBagLayout;
8
9import javax.swing.Box;
10import javax.swing.JCheckBox;
11import javax.swing.JLabel;
12import javax.swing.JPanel;
13import javax.swing.JTextField;
14
15import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
16import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
17import org.openstreetmap.josm.spi.preferences.Config;
18import org.openstreetmap.josm.tools.GBC;
19
20/**
21 * Preferences of LiveGPS
22 */
23public class LiveGPSPreferences extends DefaultTabPreferenceSetting {
24 /* option to use serial port direct access */
25 public static final String C_SERIAL = "livegps.serial.port";
26 /* default gpsd host address */
27 public static final String DEFAULT_HOST = "localhost";
28 /* option to use specify gpsd host address */
29 public static final String C_HOST = "livegps.gpsd.host";
30 /* default gpsd port number */
31 public static final int DEFAULT_PORT = 2947;
32 /* option to use specify gpsd port number */
33 public static final String C_PORT = "livegps.gpsd.port";
34 /* option to use specify gpsd disabling */
35 public static final String C_DISABLED = "livegps.gpsd.disabled";
36
37 public static final String C_LIVEGPS_COLOR_POSITION = "color.livegps.position";
38 public static final String C_LIVEGPS_COLOR_POSITION_ESTIMATE = "color.livegps.position_estimate";
39
40 /* options below are hidden/expert options */
41
42 /* option to use even duplicate positions (default false) */
43 public static final String C_ALLPOSITIONS = "livegps.positions.all";
44 /* option to show offset to next way (default false) */
45 public static final String C_WAYOFFSET = "livegps.way.offset";
46
47 public static final String C_CURSOR_H = "livegps.cursor_height"; /* in pixels */
48 public static final String C_CURSOR_W = "livegps.cursor_width"; /* in pixels */
49 public static final String C_CURSOR_T = "livegps.cursor_thickness"; /* in pixels */
50
51 public static final int DEFAULT_REFRESH_INTERVAL = 250;
52 public static final String C_REFRESH_INTERVAL = "livegps.refresh_interval_msec"; /* in msec */
53 public static final int DEFAULT_CENTER_INTERVAL = 5000;
54 public static final String C_CENTER_INTERVAL = "livegps.center_interval_msec"; /* in msec */
55 public static final int DEFAULT_CENTER_FACTOR = 80;
56 public static final String C_CENTER_FACTOR = "livegps.center_factor" /* in percent */;
57
58 private final JTextField gpsdHost = new JTextField(30);
59 private final JTextField gpsdPort = new JTextField(30);
60 private final JTextField serialDevice = new JTextField(30);
61 private final JCheckBox disableGPSD = new JCheckBox(tr("Disable GPSD"));
62
63 public LiveGPSPreferences() {
64 super("dialogs/livegps", tr("LiveGPS settings"), tr("Here you can change some preferences of LiveGPS plugin"));
65 }
66
67 @Override
68 public void addGui(PreferenceTabbedPane gui) {
69 JPanel panel = new JPanel(new GridBagLayout());
70
71 gpsdHost.setText(Config.getPref().get(C_HOST, DEFAULT_HOST));
72 gpsdHost.setToolTipText(tr("Host address of gpsd, default is {0}", DEFAULT_HOST));
73 panel.add(new JLabel(tr("Host address of gpsd")), GBC.std());
74 panel.add(gpsdHost, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 0, 0, 5));
75
76 gpsdPort.setText(String.valueOf(Config.getPref().getInt(C_PORT, DEFAULT_PORT)));
77 gpsdPort.setToolTipText(tr("Port number of gpsd, default is {0}", DEFAULT_PORT));
78 panel.add(new JLabel(tr("Port number gpsd")), GBC.std());
79 panel.add(gpsdPort, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 0, 0, 5));
80
81 serialDevice.setText(Config.getPref().get(C_SERIAL));
82 serialDevice.setToolTipText(tr("Serial device for direct NMEA input, does not exist by default"));
83 panel.add(new JLabel(tr("Serial device")), GBC.std());
84 panel.add(serialDevice, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 0, 0, 5));
85
86 disableGPSD.setSelected(Config.getPref().getBoolean(C_DISABLED));
87 panel.add(disableGPSD, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 0, 0, 5));
88
89 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GridBagConstraints.VERTICAL));
90 createPreferenceTabWithScrollPane(gui, panel);
91 }
92
93 @Override
94 public boolean ok() {
95 Config.getPref().put(C_HOST, gpsdHost.getText());
96 Config.getPref().put(C_PORT, gpsdPort.getText());
97 Config.getPref().put(C_SERIAL, serialDevice.getText());
98 Config.getPref().putBoolean(C_DISABLED, disableGPSD.isSelected());
99 return false;
100 }
101}
Note: See TracBrowser for help on using the repository browser.