| 1 | // License: GPL. For details, see LICENSE file.
 | 
|---|
| 2 | package org.openstreetmap.josm.gui.preferences;
 | 
|---|
| 3 | 
 | 
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
 | 
|---|
| 5 | 
 | 
|---|
| 6 | import javax.swing.Box;
 | 
|---|
| 7 | import javax.swing.JCheckBox;
 | 
|---|
| 8 | import javax.swing.JLabel;
 | 
|---|
| 9 | import javax.swing.JTextField;
 | 
|---|
| 10 | 
 | 
|---|
| 11 | import org.openstreetmap.josm.Main;
 | 
|---|
| 12 | import org.openstreetmap.josm.tools.GBC;
 | 
|---|
| 13 | 
 | 
|---|
| 14 | /*
 | 
|---|
| 15 |  * marker.audiosampleminsecs
 | 
|---|
| 16 |  * marker.audiosampleminmetres
 | 
|---|
| 17 |  * marker.buttonlabels
 | 
|---|
| 18 |  * markers.namedtrackpoints
 | 
|---|
| 19 |  * audio.forwardbackamount
 | 
|---|
| 20 |  * audio.leadin
 | 
|---|
| 21 |  * audio.menuinvisible
 | 
|---|
| 22 |  * marker.audiotraceVisible
 | 
|---|
| 23 |  * audio.toolbar ??
 | 
|---|
| 24 |  */
 | 
|---|
| 25 | 
 | 
|---|
| 26 | public class AudioPreference implements PreferenceSetting {
 | 
|---|
| 27 | 
 | 
|---|
| 28 |     public static class Factory implements PreferenceSettingFactory {
 | 
|---|
| 29 |         public PreferenceSetting createPreferenceSetting() {
 | 
|---|
| 30 |             return new AudioPreference();
 | 
|---|
| 31 |         }
 | 
|---|
| 32 |     }
 | 
|---|
| 33 | 
 | 
|---|
| 34 |     private JCheckBox audioMenuVisible = new JCheckBox(tr("Display the Audio menu."));
 | 
|---|
| 35 |     private JCheckBox markerButtonLabels = new JCheckBox(tr("Label audio (and image and web) markers."));
 | 
|---|
| 36 |     private JCheckBox markerAudioTraceVisible = new JCheckBox(tr("Display live audio trace."));
 | 
|---|
| 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(PreferenceTabbedPane 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 |         gui.audio.add(new JLabel(tr("When importing audio, make markers from...")), GBC.eol());
 | 
|---|
| 67 | 
 | 
|---|
| 68 |         // audioMarkersFromExplicitWaypoints
 | 
|---|
| 69 |         audioMarkersFromExplicitWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromexplicitwaypoints", true));
 | 
|---|
| 70 |         audioMarkersFromExplicitWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
 | 
|---|
| 71 |         gui.audio.add(audioMarkersFromExplicitWaypoints, GBC.eol().insets(10,0,0,0));
 | 
|---|
| 72 | 
 | 
|---|
| 73 |         // audioMarkersFromUntimedWaypoints
 | 
|---|
| 74 |         audioMarkersFromUntimedWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromuntimedwaypoints", true));
 | 
|---|
| 75 |         audioMarkersFromUntimedWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
 | 
|---|
| 76 |         gui.audio.add(audioMarkersFromUntimedWaypoints, GBC.eol().insets(10,0,0,0));
 | 
|---|
| 77 | 
 | 
|---|
| 78 |         // audioMarkersFromNamedTrackpoints
 | 
|---|
| 79 |         audioMarkersFromNamedTrackpoints.setSelected(Main.pref.getBoolean("marker.audiofromnamedtrackpoints", false));
 | 
|---|
| 80 |         audioMarkersFromNamedTrackpoints.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
 | 
|---|
| 81 |         gui.audio.add(audioMarkersFromNamedTrackpoints, GBC.eol().insets(10,0,0,0));
 | 
|---|
| 82 | 
 | 
|---|
| 83 |         // audioMarkersFromWavTimestamps
 | 
|---|
| 84 |         audioMarkersFromWavTimestamps.setSelected(Main.pref.getBoolean("marker.audiofromwavtimestamps", false));
 | 
|---|
| 85 |         audioMarkersFromWavTimestamps.setToolTipText(tr("Create audio markers at the position on the track corresponding to the modified time of each audio WAV file imported."));
 | 
|---|
| 86 |         gui.audio.add(audioMarkersFromWavTimestamps, GBC.eol().insets(10,0,0,0));
 | 
|---|
| 87 | 
 | 
|---|
| 88 |         // audioMarkersFromStart
 | 
|---|
| 89 |         audioMarkersFromStart.setSelected(Main.pref.getBoolean("marker.audiofromstart"));
 | 
|---|
| 90 |         audioMarkersFromStart.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
 | 
|---|
| 91 |         gui.audio.add(audioMarkersFromStart, GBC.eol().insets(10,0,0,0));
 | 
|---|
| 92 | 
 | 
|---|
| 93 |         audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10.0"));
 | 
|---|
| 94 |         audioForwardBackAmount.setToolTipText(tr("The number of seconds to jump forward or back when the relevant button is pressed"));
 | 
|---|
| 95 |         gui.audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
 | 
|---|
| 96 |         gui.audio.add(audioForwardBackAmount, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
 | 
|---|
| 97 | 
 | 
|---|
| 98 |         audioFastForwardMultiplier.setText(Main.pref.get("audio.fastfwdmultiplier", "1.3"));
 | 
|---|
| 99 |         audioFastForwardMultiplier.setToolTipText(tr("The amount by which the speed is multiplied for fast forwarding"));
 | 
|---|
| 100 |         gui.audio.add(new JLabel(tr("Fast forward multiplier")), GBC.std());
 | 
|---|
| 101 |         gui.audio.add(audioFastForwardMultiplier, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
 | 
|---|
| 102 | 
 | 
|---|
| 103 |         audioLeadIn.setText(Main.pref.get("audio.leadin", "1.0"));
 | 
|---|
| 104 |         audioLeadIn.setToolTipText(tr("Playback starts this number of seconds before (or after, if negative) the audio track position requested"));
 | 
|---|
| 105 |         gui.audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std());
 | 
|---|
| 106 |         gui.audio.add(audioLeadIn, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
 | 
|---|
| 107 | 
 | 
|---|
| 108 |         audioCalibration.setText(Main.pref.get("audio.calibration", "1.0"));
 | 
|---|
| 109 |         audioCalibration.setToolTipText(tr("The ratio of voice recorder elapsed time to true elapsed time"));
 | 
|---|
| 110 |         gui.audio.add(new JLabel(tr("Voice recorder calibration")), GBC.std());
 | 
|---|
| 111 |         gui.audio.add(audioCalibration, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
 | 
|---|
| 112 | 
 | 
|---|
| 113 |         gui.audio.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
 | 
|---|
| 114 |     }
 | 
|---|
| 115 | 
 | 
|---|
| 116 |     public boolean ok() {
 | 
|---|
| 117 |         Main.pref.put("audio.menuinvisible", ! audioMenuVisible.isSelected());
 | 
|---|
| 118 |         Main.pref.put("marker.traceaudio", markerAudioTraceVisible.isSelected());
 | 
|---|
| 119 |         Main.pref.put("marker.buttonlabels", markerButtonLabels.isSelected());
 | 
|---|
| 120 |         Main.pref.put("marker.audiofromexplicitwaypoints", audioMarkersFromExplicitWaypoints.isSelected());
 | 
|---|
| 121 |         Main.pref.put("marker.audiofromuntimedwaypoints", audioMarkersFromUntimedWaypoints.isSelected());
 | 
|---|
| 122 |         Main.pref.put("marker.audiofromnamedtrackpoints", audioMarkersFromNamedTrackpoints.isSelected());
 | 
|---|
| 123 |         Main.pref.put("marker.audiofromwavtimestamps", audioMarkersFromWavTimestamps.isSelected());
 | 
|---|
| 124 |         Main.pref.put("marker.audiofromstart", audioMarkersFromStart.isSelected());
 | 
|---|
| 125 |         Main.pref.put("audio.forwardbackamount", audioForwardBackAmount.getText());
 | 
|---|
| 126 |         Main.pref.put("audio.fastfwdmultiplier", audioFastForwardMultiplier.getText());
 | 
|---|
| 127 |         Main.pref.put("audio.leadin", audioLeadIn.getText());
 | 
|---|
| 128 |         Main.pref.put("audio.calibration", audioCalibration.getText());
 | 
|---|
| 129 |         return false;
 | 
|---|
| 130 |     }
 | 
|---|
| 131 | }
 | 
|---|