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

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

update javadoc

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