source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/audio/AudioPreference.java@ 13050

Last change on this file since 13050 was 13050, checked in by Don-vip, 6 years ago

fix #14602 - allow both dot and comma decimal separator everywhere possible for user-entered values

  • Property svn:eol-style set to native
File size: 8.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.audio;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagLayout;
7
8import javax.swing.Box;
9import javax.swing.JCheckBox;
10import javax.swing.JLabel;
11import javax.swing.JPanel;
12
13import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
14import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
15import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
16import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
17import org.openstreetmap.josm.gui.widgets.JosmTextField;
18import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
19import org.openstreetmap.josm.spi.preferences.Config;
20import org.openstreetmap.josm.tools.GBC;
21
22/**
23 * Audio preferences.
24 */
25public final class AudioPreference extends DefaultTabPreferenceSetting {
26
27 /**
28 * Factory used to create a new {@code AudioPreference}.
29 */
30 public static class Factory implements PreferenceSettingFactory {
31 @Override
32 public PreferenceSetting createPreferenceSetting() {
33 return new AudioPreference();
34 }
35 }
36
37 private AudioPreference() {
38 super(/* ICON(preferences/) */ "audio", tr("Audio Settings"), tr("Settings for the audio player and audio markers."));
39 }
40
41 private final JCheckBox audioMenuVisible = new JCheckBox(tr("Display the Audio menu."));
42 private final JCheckBox markerButtonLabels = new JCheckBox(tr("Label audio (and image and web) markers."));
43 private final JCheckBox markerAudioTraceVisible = new JCheckBox(tr("Display live audio trace."));
44
45 // various methods of making markers on import audio
46 private final JCheckBox audioMarkersFromExplicitWaypoints = new JCheckBox(tr("Explicit waypoints with valid timestamps."));
47 private final JCheckBox audioMarkersFromUntimedWaypoints = new JCheckBox(tr("Explicit waypoints with time estimated from track position."));
48 private final JCheckBox audioMarkersFromNamedTrackpoints = new JCheckBox(tr("Named trackpoints."));
49 private final JCheckBox audioMarkersFromWavTimestamps = new JCheckBox(tr("Modified times (time stamps) of audio files."));
50 private final JCheckBox audioMarkersFromStart = new JCheckBox(tr("Start of track (will always do this if no other markers available)."));
51
52 private final JosmTextField audioLeadIn = new JosmTextField(8);
53 private final JosmTextField audioForwardBackAmount = new JosmTextField(8);
54 private final JosmTextField audioFastForwardMultiplier = new JosmTextField(8);
55 private final JosmTextField audioCalibration = new JosmTextField(8);
56
57 @Override
58 public void addGui(PreferenceTabbedPane gui) {
59 JPanel audio = new VerticallyScrollablePanel(new GridBagLayout());
60
61 // audioMenuVisible
62 audioMenuVisible.setSelected(!Config.getPref().getBoolean("audio.menuinvisible"));
63 audioMenuVisible.setToolTipText(tr("Show or hide the audio menu entry on the main menu bar."));
64 audio.add(audioMenuVisible, GBC.eol().insets(0, 0, 0, 0));
65
66 // audioTraceVisible
67 markerAudioTraceVisible.setSelected(Config.getPref().getBoolean("marker.traceaudio", true));
68 markerAudioTraceVisible.setToolTipText(
69 tr("Display a moving icon representing the point on the synchronized track where the audio currently playing was recorded."));
70 audio.add(markerAudioTraceVisible, GBC.eol().insets(0, 0, 0, 0));
71
72 // buttonLabels
73 markerButtonLabels.setSelected(Config.getPref().getBoolean("marker.buttonlabels", true));
74 markerButtonLabels.setToolTipText(tr("Put text labels against audio (and image and web) markers as well as their button icons."));
75 audio.add(markerButtonLabels, GBC.eol().insets(0, 0, 0, 0));
76
77 audio.add(new JLabel(tr("When importing audio, make markers from...")), GBC.eol());
78
79 // audioMarkersFromExplicitWaypoints
80 audioMarkersFromExplicitWaypoints.setSelected(Config.getPref().getBoolean("marker.audiofromexplicitwaypoints", true));
81 audioMarkersFromExplicitWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
82 audio.add(audioMarkersFromExplicitWaypoints, GBC.eol().insets(10, 0, 0, 0));
83
84 // audioMarkersFromUntimedWaypoints
85 audioMarkersFromUntimedWaypoints.setSelected(Config.getPref().getBoolean("marker.audiofromuntimedwaypoints", true));
86 audioMarkersFromUntimedWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
87 audio.add(audioMarkersFromUntimedWaypoints, GBC.eol().insets(10, 0, 0, 0));
88
89 // audioMarkersFromNamedTrackpoints
90 audioMarkersFromNamedTrackpoints.setSelected(Config.getPref().getBoolean("marker.audiofromnamedtrackpoints", false));
91 audioMarkersFromNamedTrackpoints.setToolTipText(
92 tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
93 audio.add(audioMarkersFromNamedTrackpoints, GBC.eol().insets(10, 0, 0, 0));
94
95 // audioMarkersFromWavTimestamps
96 audioMarkersFromWavTimestamps.setSelected(Config.getPref().getBoolean("marker.audiofromwavtimestamps", false));
97 audioMarkersFromWavTimestamps.setToolTipText(
98 tr("Create audio markers at the position on the track corresponding to the modified time of each audio WAV file imported."));
99 audio.add(audioMarkersFromWavTimestamps, GBC.eol().insets(10, 0, 0, 0));
100
101 // audioMarkersFromStart
102 audioMarkersFromStart.setSelected(Config.getPref().getBoolean("marker.audiofromstart"));
103 audioMarkersFromStart.setToolTipText(
104 tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
105 audio.add(audioMarkersFromStart, GBC.eol().insets(10, 0, 0, 0));
106
107 audioForwardBackAmount.setText(Config.getPref().get("audio.forwardbackamount", "10.0"));
108 audioForwardBackAmount.setToolTipText(tr("The number of seconds to jump forward or back when the relevant button is pressed"));
109 audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
110 audio.add(audioForwardBackAmount, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
111
112 audioFastForwardMultiplier.setText(Config.getPref().get("audio.fastfwdmultiplier", "1.3"));
113 audioFastForwardMultiplier.setToolTipText(tr("The amount by which the speed is multiplied for fast forwarding"));
114 audio.add(new JLabel(tr("Fast forward multiplier")), GBC.std());
115 audio.add(audioFastForwardMultiplier, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
116
117 audioLeadIn.setText(Config.getPref().get("audio.leadin", "1.0"));
118 audioLeadIn.setToolTipText(
119 tr("Playback starts this number of seconds before (or after, if negative) the audio track position requested"));
120 audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std());
121 audio.add(audioLeadIn, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
122
123 audioCalibration.setText(Config.getPref().get("audio.calibration", "1.0"));
124 audioCalibration.setToolTipText(tr("The ratio of voice recorder elapsed time to true elapsed time"));
125 audio.add(new JLabel(tr("Voice recorder calibration")), GBC.std());
126 audio.add(audioCalibration, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
127
128 audio.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
129
130 createPreferenceTabWithScrollPane(gui, audio);
131 }
132
133 @Override
134 public boolean ok() {
135 Config.getPref().putBoolean("audio.menuinvisible", !audioMenuVisible.isSelected());
136 saveBoolean("marker.traceaudio", markerAudioTraceVisible);
137 saveBoolean("marker.buttonlabels", markerButtonLabels);
138 saveBoolean("marker.audiofromexplicitwaypoints", audioMarkersFromExplicitWaypoints);
139 saveBoolean("marker.audiofromuntimedwaypoints", audioMarkersFromUntimedWaypoints);
140 saveBoolean("marker.audiofromnamedtrackpoints", audioMarkersFromNamedTrackpoints);
141 saveBoolean("marker.audiofromwavtimestamps", audioMarkersFromWavTimestamps);
142 saveBoolean("marker.audiofromstart", audioMarkersFromStart);
143 saveDouble("audio.forwardbackamount", audioForwardBackAmount);
144 saveDouble("audio.fastfwdmultiplier", audioFastForwardMultiplier);
145 saveDouble("audio.leadin", audioLeadIn);
146 saveDouble("audio.calibration", audioCalibration);
147 return false;
148 }
149}
Note: See TracBrowser for help on using the repository browser.