[3719] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[6529] | 2 | package org.openstreetmap.josm.gui.preferences.audio;
|
---|
[553] | 3 |
|
---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
| 5 |
|
---|
[4976] | 6 | import java.awt.GridBagLayout;
|
---|
| 7 |
|
---|
[554] | 8 | import javax.swing.Box;
|
---|
[553] | 9 | import javax.swing.JCheckBox;
|
---|
| 10 | import javax.swing.JLabel;
|
---|
[4976] | 11 | import javax.swing.JPanel;
|
---|
[553] | 12 |
|
---|
| 13 | import org.openstreetmap.josm.Main;
|
---|
[6529] | 14 | import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
|
---|
| 15 | import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
|
---|
| 16 | import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
|
---|
| 17 | import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
|
---|
[6362] | 18 | import org.openstreetmap.josm.gui.widgets.JosmTextField;
|
---|
[9778] | 19 | import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
|
---|
[553] | 20 | import org.openstreetmap.josm.tools.GBC;
|
---|
| 21 |
|
---|
[6733] | 22 | /**
|
---|
| 23 | * Audio preferences.
|
---|
[553] | 24 | */
|
---|
[6362] | 25 | public final class AudioPreference extends DefaultTabPreferenceSetting {
|
---|
[1742] | 26 |
|
---|
[6529] | 27 | /**
|
---|
| 28 | * Factory used to create a new {@code AudioPreference}.
|
---|
| 29 | */
|
---|
[1742] | 30 | public static class Factory implements PreferenceSettingFactory {
|
---|
[6084] | 31 | @Override
|
---|
[1742] | 32 | public PreferenceSetting createPreferenceSetting() {
|
---|
| 33 | return new AudioPreference();
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
[6070] | 36 |
|
---|
[4968] | 37 | private AudioPreference() {
|
---|
[7668] | 38 | super(/* ICON(preferences/) */ "audio", tr("Audio Settings"), tr("Settings for the audio player and audio markers."));
|
---|
[4968] | 39 | }
|
---|
[1742] | 40 |
|
---|
[9078] | 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."));
|
---|
[553] | 44 |
|
---|
[1169] | 45 | // various methods of making markers on import audio
|
---|
[9078] | 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)."));
|
---|
[578] | 51 |
|
---|
[9078] | 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);
|
---|
[553] | 56 |
|
---|
[6084] | 57 | @Override
|
---|
[2745] | 58 | public void addGui(PreferenceTabbedPane gui) {
|
---|
[9778] | 59 | JPanel audio = new VerticallyScrollablePanel(new GridBagLayout());
|
---|
[6070] | 60 |
|
---|
[1169] | 61 | // audioMenuVisible
|
---|
[8444] | 62 | audioMenuVisible.setSelected(!Main.pref.getBoolean("audio.menuinvisible"));
|
---|
[1169] | 63 | audioMenuVisible.setToolTipText(tr("Show or hide the audio menu entry on the main menu bar."));
|
---|
[8510] | 64 | audio.add(audioMenuVisible, GBC.eol().insets(0, 0, 0, 0));
|
---|
[553] | 65 |
|
---|
[1169] | 66 | // audioTraceVisible
|
---|
| 67 | markerAudioTraceVisible.setSelected(Main.pref.getBoolean("marker.traceaudio", true));
|
---|
[8509] | 68 | markerAudioTraceVisible.setToolTipText(
|
---|
| 69 | tr("Display a moving icon representing the point on the synchronized track where the audio currently playing was recorded."));
|
---|
[8510] | 70 | audio.add(markerAudioTraceVisible, GBC.eol().insets(0, 0, 0, 0));
|
---|
[578] | 71 |
|
---|
[1169] | 72 | // buttonLabels
|
---|
[4282] | 73 | markerButtonLabels.setSelected(Main.pref.getBoolean("marker.buttonlabels", true));
|
---|
[1169] | 74 | markerButtonLabels.setToolTipText(tr("Put text labels against audio (and image and web) markers as well as their button icons."));
|
---|
[8510] | 75 | audio.add(markerButtonLabels, GBC.eol().insets(0, 0, 0, 0));
|
---|
[553] | 76 |
|
---|
[4968] | 77 | audio.add(new JLabel(tr("When importing audio, make markers from...")), GBC.eol());
|
---|
[554] | 78 |
|
---|
[1169] | 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."));
|
---|
[8510] | 82 | audio.add(audioMarkersFromExplicitWaypoints, GBC.eol().insets(10, 0, 0, 0));
|
---|
[557] | 83 |
|
---|
[1169] | 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."));
|
---|
[8510] | 87 | audio.add(audioMarkersFromUntimedWaypoints, GBC.eol().insets(10, 0, 0, 0));
|
---|
[553] | 88 |
|
---|
[1169] | 89 | // audioMarkersFromNamedTrackpoints
|
---|
| 90 | audioMarkersFromNamedTrackpoints.setSelected(Main.pref.getBoolean("marker.audiofromnamedtrackpoints", false));
|
---|
[8509] | 91 | audioMarkersFromNamedTrackpoints.setToolTipText(
|
---|
| 92 | tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
|
---|
[8510] | 93 | audio.add(audioMarkersFromNamedTrackpoints, GBC.eol().insets(10, 0, 0, 0));
|
---|
[1169] | 94 |
|
---|
[1462] | 95 | // audioMarkersFromWavTimestamps
|
---|
| 96 | audioMarkersFromWavTimestamps.setSelected(Main.pref.getBoolean("marker.audiofromwavtimestamps", false));
|
---|
[8509] | 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."));
|
---|
[8510] | 99 | audio.add(audioMarkersFromWavTimestamps, GBC.eol().insets(10, 0, 0, 0));
|
---|
[1462] | 100 |
|
---|
[1169] | 101 | // audioMarkersFromStart
|
---|
| 102 | audioMarkersFromStart.setSelected(Main.pref.getBoolean("marker.audiofromstart"));
|
---|
[8509] | 103 | audioMarkersFromStart.setToolTipText(
|
---|
| 104 | tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
|
---|
[8510] | 105 | audio.add(audioMarkersFromStart, GBC.eol().insets(10, 0, 0, 0));
|
---|
[1169] | 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"));
|
---|
[4968] | 109 | audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
|
---|
[8510] | 110 | audio.add(audioForwardBackAmount, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
|
---|
[1169] | 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"));
|
---|
[4968] | 114 | audio.add(new JLabel(tr("Fast forward multiplier")), GBC.std());
|
---|
[8510] | 115 | audio.add(audioFastForwardMultiplier, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
|
---|
[1169] | 116 |
|
---|
[1245] | 117 | audioLeadIn.setText(Main.pref.get("audio.leadin", "1.0"));
|
---|
[8509] | 118 | audioLeadIn.setToolTipText(
|
---|
| 119 | tr("Playback starts this number of seconds before (or after, if negative) the audio track position requested"));
|
---|
[4968] | 120 | audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std());
|
---|
[8510] | 121 | audio.add(audioLeadIn, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
|
---|
[1169] | 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"));
|
---|
[4968] | 125 | audio.add(new JLabel(tr("Voice recorder calibration")), GBC.std());
|
---|
[8510] | 126 | audio.add(audioCalibration, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
|
---|
[1169] | 127 |
|
---|
[4968] | 128 | audio.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
|
---|
[4976] | 129 |
|
---|
| 130 | createPreferenceTabWithScrollPane(gui, audio);
|
---|
[553] | 131 | }
|
---|
[1169] | 132 |
|
---|
[6084] | 133 | @Override
|
---|
[1180] | 134 | public boolean ok() {
|
---|
[8444] | 135 | Main.pref.put("audio.menuinvisible", !audioMenuVisible.isSelected());
|
---|
[1169] | 136 | Main.pref.put("marker.traceaudio", markerAudioTraceVisible.isSelected());
|
---|
| 137 | Main.pref.put("marker.buttonlabels", markerButtonLabels.isSelected());
|
---|
| 138 | Main.pref.put("marker.audiofromexplicitwaypoints", audioMarkersFromExplicitWaypoints.isSelected());
|
---|
| 139 | Main.pref.put("marker.audiofromuntimedwaypoints", audioMarkersFromUntimedWaypoints.isSelected());
|
---|
| 140 | Main.pref.put("marker.audiofromnamedtrackpoints", audioMarkersFromNamedTrackpoints.isSelected());
|
---|
[1462] | 141 | Main.pref.put("marker.audiofromwavtimestamps", audioMarkersFromWavTimestamps.isSelected());
|
---|
[1169] | 142 | Main.pref.put("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());
|
---|
[1180] | 147 | return false;
|
---|
[1169] | 148 | }
|
---|
[553] | 149 | }
|
---|