1 | package org.openstreetmap.josm.gui.preferences;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 |
|
---|
5 | import java.awt.event.ActionEvent;
|
---|
6 | import java.awt.event.ActionListener;
|
---|
7 |
|
---|
8 | import javax.swing.Box;
|
---|
9 | import javax.swing.JCheckBox;
|
---|
10 | import javax.swing.JLabel;
|
---|
11 | import javax.swing.JTextField;
|
---|
12 |
|
---|
13 | import org.openstreetmap.josm.Main;
|
---|
14 | import org.openstreetmap.josm.tools.GBC;
|
---|
15 |
|
---|
16 | /*
|
---|
17 | * marker.audiosampleminsecs
|
---|
18 | * marker.audiosampleminmetres
|
---|
19 | * marker.buttonlabels
|
---|
20 | * markers.namedtrackpoints
|
---|
21 | * audio.forwardbackamount
|
---|
22 | * audio.leadin
|
---|
23 | * audio.menuinvisible
|
---|
24 | * marker.audiotraceVisible
|
---|
25 | * audio.toolbar ??
|
---|
26 | */
|
---|
27 |
|
---|
28 | public class AudioPreference implements PreferenceSetting {
|
---|
29 | private JCheckBox audioMenuVisible = new JCheckBox(tr("Display the Audio menu."));
|
---|
30 | private JCheckBox markerButtonLabels = new JCheckBox(tr("Label audio (and image and web) markers."));
|
---|
31 | private JCheckBox markerAudioTraceVisible = new JCheckBox(tr("Display live audio trace."));
|
---|
32 | private JCheckBox makeAutoMarkers = new JCheckBox(tr("Create non-audio markers when reading GPX."));
|
---|
33 |
|
---|
34 | // various methods of making markers on import audio
|
---|
35 | private JCheckBox audioMarkersFromExplicitWaypoints = new JCheckBox(tr("Explicit waypoints with valid timestamps."));
|
---|
36 | private JCheckBox audioMarkersFromUntimedWaypoints = new JCheckBox(tr("Explicit waypoints with time estimated from track position."));
|
---|
37 | private JCheckBox audioMarkersFromNamedTrackpoints = new JCheckBox(tr("Named trackpoints."));
|
---|
38 | private JCheckBox audioMarkersFromStart = new JCheckBox(tr("Start of track (will always do this if no other markers available)."));
|
---|
39 |
|
---|
40 | private JTextField audioLeadIn = new JTextField(8);
|
---|
41 | private JTextField audioForwardBackAmount = new JTextField(8);
|
---|
42 | private JTextField audioFastForwardMultiplier = new JTextField(8);
|
---|
43 | private JTextField audioCalibration = new JTextField(8);
|
---|
44 |
|
---|
45 | public void addGui(PreferenceDialog gui) {
|
---|
46 | // audioMenuVisible
|
---|
47 | audioMenuVisible.addActionListener(new ActionListener(){
|
---|
48 | public void actionPerformed(ActionEvent e) {
|
---|
49 | if (!audioMenuVisible.isSelected())
|
---|
50 | audioMenuVisible.setSelected(false);
|
---|
51 | audioMenuVisible.setEnabled(audioMenuVisible.isSelected());
|
---|
52 | }
|
---|
53 | });
|
---|
54 | audioMenuVisible.setSelected(! Main.pref.getBoolean("audio.menuinvisible"));
|
---|
55 | audioMenuVisible.setToolTipText(tr("Show or hide the audio menu entry on the main menu bar."));
|
---|
56 | gui.audio.add(audioMenuVisible, GBC.eol().insets(0,0,0,0));
|
---|
57 |
|
---|
58 | // audioTraceVisible
|
---|
59 | markerAudioTraceVisible.addActionListener(new ActionListener(){
|
---|
60 | public void actionPerformed(ActionEvent e) {
|
---|
61 | if (!markerAudioTraceVisible.isSelected())
|
---|
62 | markerAudioTraceVisible.setSelected(false);
|
---|
63 | }
|
---|
64 | });
|
---|
65 | markerAudioTraceVisible.setSelected(Main.pref.getBoolean("marker.traceaudio", true));
|
---|
66 | markerAudioTraceVisible.setToolTipText(tr("Display a moving icon representing the point on the synchronized track where the audio currently playing was recorded."));
|
---|
67 | gui.audio.add(markerAudioTraceVisible, GBC.eol().insets(0,0,0,0));
|
---|
68 |
|
---|
69 | // buttonLabels
|
---|
70 | markerButtonLabels.addActionListener(new ActionListener(){
|
---|
71 | public void actionPerformed(ActionEvent e) {
|
---|
72 | if (!markerButtonLabels.isSelected())
|
---|
73 | markerButtonLabels.setSelected(false);
|
---|
74 | }
|
---|
75 | });
|
---|
76 | markerButtonLabels.setSelected(Main.pref.getBoolean("marker.buttonlabels"));
|
---|
77 | markerButtonLabels.setToolTipText(tr("Put text labels against audio (and image and web) markers as well as their button icons."));
|
---|
78 | gui.audio.add(markerButtonLabels, GBC.eol().insets(0,0,0,0));
|
---|
79 |
|
---|
80 | // makeAutoMarkers
|
---|
81 | makeAutoMarkers.addActionListener(new ActionListener(){
|
---|
82 | public void actionPerformed(ActionEvent e) {
|
---|
83 | if (!makeAutoMarkers.isSelected())
|
---|
84 | makeAutoMarkers.setSelected(false);
|
---|
85 | }
|
---|
86 | });
|
---|
87 | makeAutoMarkers.setSelected(Main.pref.getBoolean("marker.makeautomarkers", true));
|
---|
88 | makeAutoMarkers.setToolTipText(tr("Automatically make a marker layer from any waypoints when opening a GPX layer."));
|
---|
89 | gui.audio.add(makeAutoMarkers, GBC.eol().insets(0,0,0,0));
|
---|
90 |
|
---|
91 | gui.audio.add(new JLabel(tr("When importing audio, make markers from...")), GBC.eol());
|
---|
92 |
|
---|
93 | // audioMarkersFromExplicitWaypoints
|
---|
94 | audioMarkersFromExplicitWaypoints.addActionListener(new ActionListener(){
|
---|
95 | public void actionPerformed(ActionEvent e) {
|
---|
96 | if (!audioMarkersFromExplicitWaypoints.isSelected())
|
---|
97 | audioMarkersFromExplicitWaypoints.setSelected(false);
|
---|
98 | }
|
---|
99 | });
|
---|
100 | audioMarkersFromExplicitWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromexplicitwaypoints", true));
|
---|
101 | audioMarkersFromExplicitWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
|
---|
102 | gui.audio.add(audioMarkersFromExplicitWaypoints, GBC.eol().insets(10,0,0,0));
|
---|
103 |
|
---|
104 | // audioMarkersFromUntimedWaypoints
|
---|
105 | audioMarkersFromUntimedWaypoints.addActionListener(new ActionListener(){
|
---|
106 | public void actionPerformed(ActionEvent e) {
|
---|
107 | if (!audioMarkersFromUntimedWaypoints.isSelected())
|
---|
108 | audioMarkersFromUntimedWaypoints.setSelected(false);
|
---|
109 | }
|
---|
110 | });
|
---|
111 | audioMarkersFromUntimedWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromuntimedwaypoints", true));
|
---|
112 | audioMarkersFromUntimedWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
|
---|
113 | gui.audio.add(audioMarkersFromUntimedWaypoints, GBC.eol().insets(10,0,0,0));
|
---|
114 |
|
---|
115 | // audioMarkersFromNamedTrackpoints
|
---|
116 | audioMarkersFromNamedTrackpoints.addActionListener(new ActionListener(){
|
---|
117 | public void actionPerformed(ActionEvent e) {
|
---|
118 | if (!audioMarkersFromNamedTrackpoints.isSelected())
|
---|
119 | audioMarkersFromNamedTrackpoints.setSelected(false);
|
---|
120 | }
|
---|
121 | });
|
---|
122 | audioMarkersFromNamedTrackpoints.setSelected(Main.pref.getBoolean("marker.audiofromnamedtrackpoints", false));
|
---|
123 | audioMarkersFromNamedTrackpoints.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
|
---|
124 | gui.audio.add(audioMarkersFromNamedTrackpoints, GBC.eol().insets(10,0,0,0));
|
---|
125 |
|
---|
126 | // audioMarkersFromStart
|
---|
127 | audioMarkersFromStart.addActionListener(new ActionListener(){
|
---|
128 | public void actionPerformed(ActionEvent e) {
|
---|
129 | if (!audioMarkersFromStart.isSelected())
|
---|
130 | audioMarkersFromStart.setSelected(false);
|
---|
131 | }
|
---|
132 | });
|
---|
133 | audioMarkersFromStart.setSelected(Main.pref.getBoolean("marker.audiofromstart"));
|
---|
134 | audioMarkersFromStart.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
|
---|
135 | gui.audio.add(audioMarkersFromStart, GBC.eol().insets(10,0,0,0));
|
---|
136 |
|
---|
137 | audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10.0"));
|
---|
138 | audioForwardBackAmount.setToolTipText(tr("The number of seconds to jump forward or back when the relevant button is pressed"));
|
---|
139 | gui.audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
|
---|
140 | gui.audio.add(audioForwardBackAmount, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
|
---|
141 |
|
---|
142 | audioFastForwardMultiplier.setText(Main.pref.get("audio.fastfwdmultiplier", "1.3"));
|
---|
143 | audioFastForwardMultiplier.setToolTipText(tr("The amount by which the speed is multiplied for fast forwarding"));
|
---|
144 | gui.audio.add(new JLabel(tr("Fast forward multiplier")), GBC.std());
|
---|
145 | gui.audio.add(audioFastForwardMultiplier, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
|
---|
146 |
|
---|
147 | audioLeadIn.setText(Main.pref.get("audio.leadin", "1"));
|
---|
148 | audioLeadIn.setToolTipText(tr("Playback starts this number of seconds before (or after, if negative) the audio track position requested"));
|
---|
149 | gui.audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std());
|
---|
150 | gui.audio.add(audioLeadIn, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
|
---|
151 |
|
---|
152 | audioCalibration.setText(Main.pref.get("audio.calibration", "1.0"));
|
---|
153 | audioCalibration.setToolTipText(tr("The ratio of voice recorder elapsed time to true elapsed time"));
|
---|
154 | gui.audio.add(new JLabel(tr("Voice recorder calibration")), GBC.std());
|
---|
155 | gui.audio.add(audioCalibration, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
|
---|
156 |
|
---|
157 | gui.audio.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
|
---|
158 | }
|
---|
159 |
|
---|
160 | public void ok() {
|
---|
161 | Main.pref.put("audio.menuinvisible", ! audioMenuVisible.isSelected());
|
---|
162 | Main.pref.put("marker.traceaudio", markerAudioTraceVisible.isSelected());
|
---|
163 | Main.pref.put("marker.buttonlabels", markerButtonLabels.isSelected());
|
---|
164 | Main.pref.put("marker.makeautomarkers", makeAutoMarkers.isSelected());
|
---|
165 | Main.pref.put("marker.audiofromexplicitwaypoints", audioMarkersFromExplicitWaypoints.isSelected());
|
---|
166 | Main.pref.put("marker.audiofromuntimedwaypoints", audioMarkersFromUntimedWaypoints.isSelected());
|
---|
167 | Main.pref.put("marker.audiofromnamedtrackpoints", audioMarkersFromNamedTrackpoints.isSelected());
|
---|
168 | Main.pref.put("marker.audiofromstart", audioMarkersFromStart.isSelected());
|
---|
169 | Main.pref.put("audio.forwardbackamount", audioForwardBackAmount.getText());
|
---|
170 | Main.pref.put("audio.fastfwdmultiplier", audioFastForwardMultiplier.getText());
|
---|
171 | Main.pref.put("audio.leadin", audioLeadIn.getText());
|
---|
172 | Main.pref.put("audio.calibration", audioCalibration.getText());
|
---|
173 | }
|
---|
174 | }
|
---|