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

Last change on this file since 12841 was 12841, checked in by bastiK, 7 years ago

see #15229 - fix deprecations caused by [12840]

  • Property svn:eol-style set to native
File size: 8.5 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.Main;
14import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
15import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
16import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
17import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
18import org.openstreetmap.josm.gui.widgets.JosmTextField;
19import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
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(!Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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(Main.pref.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 Main.pref.putBoolean("audio.menuinvisible", !audioMenuVisible.isSelected());
136 Main.pref.putBoolean("marker.traceaudio", markerAudioTraceVisible.isSelected());
137 Main.pref.putBoolean("marker.buttonlabels", markerButtonLabels.isSelected());
138 Main.pref.putBoolean("marker.audiofromexplicitwaypoints", audioMarkersFromExplicitWaypoints.isSelected());
139 Main.pref.putBoolean("marker.audiofromuntimedwaypoints", audioMarkersFromUntimedWaypoints.isSelected());
140 Main.pref.putBoolean("marker.audiofromnamedtrackpoints", audioMarkersFromNamedTrackpoints.isSelected());
141 Main.pref.putBoolean("marker.audiofromwavtimestamps", audioMarkersFromWavTimestamps.isSelected());
142 Main.pref.putBoolean("marker.audiofromstart", audioMarkersFromStart.isSelected());
143 Main.pref.put("audio.forwardbackamount", audioForwardBackAmount.getText());
144 Main.pref.put("audio.fastfwdmultiplier", audioFastForwardMultiplier.getText());
145 Main.pref.put("audio.leadin", audioLeadIn.getText());
146 Main.pref.put("audio.calibration", audioCalibration.getText());
147 return false;
148 }
149}
Note: See TracBrowser for help on using the repository browser.