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

Last change on this file since 2599 was 1742, checked in by stoecker, 15 years ago

fixed #2849 - patch by jttt - fix memory leak

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