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