Logo Search packages:      
Sourcecode: josm version File versions  Download package

AudioPreference.java

package org.openstreetmap.josm.gui.preferences;

import static org.openstreetmap.josm.tools.I18n.tr;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextField;

import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.tools.GBC;

/*
 * marker.audiosampleminsecs
 * marker.audiosampleminmetres
 * marker.buttonlabels
 * markers.namedtrackpoints
 * audio.forwardbackamount
 * audio.leadin
 * audio.menuinvisible
 * marker.audiotraceVisible
 * audio.toolbar ??
 */

public class AudioPreference implements PreferenceSetting {
      private JCheckBox audioMenuVisible = new JCheckBox(tr("Display the Audio menu."));
      private JCheckBox markerButtonLabels = new JCheckBox(tr("Label audio (and image and web) markers."));
      private JCheckBox markerAudioTraceVisible = new JCheckBox(tr("Display live audio trace."));
      private JCheckBox makeAutoMarkers = new JCheckBox(tr("Create non-audio markers when reading GPX."));

      // various methods of making markers on import audio
      private JCheckBox audioMarkersFromExplicitWaypoints = new JCheckBox(tr("Explicit waypoints with valid timestamps."));
      private JCheckBox audioMarkersFromUntimedWaypoints = new JCheckBox(tr("Explicit waypoints with time estimated from track position."));
      private JCheckBox audioMarkersFromNamedTrackpoints = new JCheckBox(tr("Named trackpoints."));
      private JCheckBox audioMarkersFromStart = new JCheckBox(tr("Start of track (will always do this if no other markers available)."));

      private JTextField audioLeadIn = new JTextField(8);
      private JTextField audioForwardBackAmount = new JTextField(8);
      private JTextField audioFastForwardMultiplier = new JTextField(8);
      private JTextField audioCalibration = new JTextField(8);

      public void addGui(PreferenceDialog gui) {
            // audioMenuVisible
            audioMenuVisible.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) {
                        if (!audioMenuVisible.isSelected())
                              audioMenuVisible.setSelected(false);
                        audioMenuVisible.setEnabled(audioMenuVisible.isSelected());
                  }
            });
            audioMenuVisible.setSelected(! Main.pref.getBoolean("audio.menuinvisible"));
            audioMenuVisible.setToolTipText(tr("Show or hide the audio menu entry on the main menu bar."));
            gui.audio.add(audioMenuVisible, GBC.eol().insets(0,0,0,0));

            // audioTraceVisible
            markerAudioTraceVisible.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) {
                        if (!markerAudioTraceVisible.isSelected())
                              markerAudioTraceVisible.setSelected(false);
                  }
            });
            markerAudioTraceVisible.setSelected(Main.pref.getBoolean("marker.traceaudio", true));
            markerAudioTraceVisible.setToolTipText(tr("Display a moving icon representing the point on the synchronized track where the audio currently playing was recorded."));
            gui.audio.add(markerAudioTraceVisible, GBC.eol().insets(0,0,0,0));
            
            // buttonLabels
            markerButtonLabels.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) {
                        if (!markerButtonLabels.isSelected())
                              markerButtonLabels.setSelected(false);
                  }
            });
            markerButtonLabels.setSelected(Main.pref.getBoolean("marker.buttonlabels"));
            markerButtonLabels.setToolTipText(tr("Put text labels against audio (and image and web) markers as well as their button icons."));
            gui.audio.add(markerButtonLabels, GBC.eol().insets(0,0,0,0));
            
            // makeAutoMarkers
            makeAutoMarkers.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) {
                        if (!makeAutoMarkers.isSelected())
                              makeAutoMarkers.setSelected(false);
                  }
            });
            makeAutoMarkers.setSelected(Main.pref.getBoolean("marker.makeautomarkers", true));
            makeAutoMarkers.setToolTipText(tr("Automatically make a marker layer from any waypoints when opening a GPX layer."));
            gui.audio.add(makeAutoMarkers, GBC.eol().insets(0,0,0,0));
            
            gui.audio.add(new JLabel(tr("When importing audio, make markers from...")), GBC.eol());

            // audioMarkersFromExplicitWaypoints
            audioMarkersFromExplicitWaypoints.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) {
                        if (!audioMarkersFromExplicitWaypoints.isSelected())
                              audioMarkersFromExplicitWaypoints.setSelected(false);
                  }
            });
            audioMarkersFromExplicitWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromexplicitwaypoints", true));
            audioMarkersFromExplicitWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
            gui.audio.add(audioMarkersFromExplicitWaypoints, GBC.eol().insets(10,0,0,0));
            
            // audioMarkersFromUntimedWaypoints
            audioMarkersFromUntimedWaypoints.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) {
                        if (!audioMarkersFromUntimedWaypoints.isSelected())
                              audioMarkersFromUntimedWaypoints.setSelected(false);
                  }
            });
            audioMarkersFromUntimedWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromuntimedwaypoints", true));
            audioMarkersFromUntimedWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
            gui.audio.add(audioMarkersFromUntimedWaypoints, GBC.eol().insets(10,0,0,0));
            
            // audioMarkersFromNamedTrackpoints
            audioMarkersFromNamedTrackpoints.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) {
                        if (!audioMarkersFromNamedTrackpoints.isSelected())
                              audioMarkersFromNamedTrackpoints.setSelected(false);
                  }
            });
            audioMarkersFromNamedTrackpoints.setSelected(Main.pref.getBoolean("marker.audiofromnamedtrackpoints", Main.pref.getBoolean("marker.namedtrackpoints")));
            audioMarkersFromNamedTrackpoints.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
            gui.audio.add(audioMarkersFromNamedTrackpoints, GBC.eol().insets(10,0,0,0));
            
            // audioMarkersFromStart
            audioMarkersFromStart.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) {
                        if (!audioMarkersFromStart.isSelected())
                              audioMarkersFromStart.setSelected(false);
                  }
            });
            audioMarkersFromStart.setSelected(Main.pref.getBoolean("marker.audiofromstart"));
            audioMarkersFromStart.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
            gui.audio.add(audioMarkersFromStart, GBC.eol().insets(10,0,0,0));
            
            audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10"));
            audioForwardBackAmount.setToolTipText(tr("The number of seconds to jump forward or back when the relevant button is pressed"));
            gui.audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
            gui.audio.add(audioForwardBackAmount, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));

            audioFastForwardMultiplier.setText(Main.pref.get("audio.fastfwdmultiplier", "1.3"));
            audioFastForwardMultiplier.setToolTipText(tr("The amount by which the speed is multiplied for fast forwarding"));
            gui.audio.add(new JLabel(tr("Fast forward multiplier")), GBC.std());
            gui.audio.add(audioFastForwardMultiplier, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));

            audioLeadIn.setText(Main.pref.get("audio.leadin", "1"));
            audioLeadIn.setToolTipText(tr("Playback starts this number of seconds before (or after, if negative) the audio track position requested"));
            gui.audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std());
            gui.audio.add(audioLeadIn, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));

            audioCalibration.setText(Main.pref.get("audio.calibration", "1.0"));
            audioCalibration.setToolTipText(tr("The ratio of voice recorder elapsed time to true elapsed time"));
            gui.audio.add(new JLabel(tr("Voice recorder calibration")), GBC.std());
            gui.audio.add(audioCalibration, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));

            gui.audio.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
      }

      public void ok() {
            Main.pref.put("audio.menuinvisible", ! audioMenuVisible.isSelected());
            Main.pref.put("marker.traceaudio", markerAudioTraceVisible.isSelected());
            Main.pref.put("marker.buttonlabels", markerButtonLabels.isSelected());
            Main.pref.put("marker.makeautomarkers", makeAutoMarkers.isSelected());
            Main.pref.put("marker.audiofromexplicitwaypoints", audioMarkersFromExplicitWaypoints.isSelected());
            Main.pref.put("marker.audiofromuntimedwaypoints", audioMarkersFromUntimedWaypoints.isSelected());
            Main.pref.put("marker.audiofromnamedtrackpoints", audioMarkersFromNamedTrackpoints.isSelected());
            Main.pref.put("marker.audiofromstart", audioMarkersFromStart.isSelected());
            Main.pref.put("audio.forwardbackamount", audioForwardBackAmount.getText());         
            Main.pref.put("audio.fastfwdmultiplier", audioFastForwardMultiplier.getText());           
            Main.pref.put("audio.leadin", audioLeadIn.getText());       
            Main.pref.put("audio.calibration", audioCalibration.getText());         
    }
}

Generated by  Doxygen 1.6.0   Back to index