Changeset 5871 in josm for trunk


Ignore:
Timestamp:
2013-04-15T23:12:33+02:00 (11 years ago)
Author:
Don-vip
Message:

fix #8611 (audio slower broken) + update all audio javadoc

Location:
trunk/src/org/openstreetmap/josm
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java

    r5780 r5871  
    150150     */
    151151    public SequenceCommand simplifyWay(Way w, DataSet ds) {
    152         double threshold = Main.pref.getDouble("simplify-way.max-error", "3");
     152        double threshold = Main.pref.getDouble("simplify-way.max-error", 3.0);
    153153        int lower = 0;
    154154        int i = 0;
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioBackAction.java

    r4982 r5871  
    1515import org.openstreetmap.josm.tools.Shortcut;
    1616
     17/**
     18 * Jump the audio backward 10 seconds and start playing if paused.
     19 * @since 547
     20 */
    1721public class AudioBackAction extends JosmAction {
    1822
     23    /**
     24     * Constructs a new {@code AudioBackAction}.
     25     */
    1926    public AudioBackAction() {
    2027        super(trc("audio", "Back"), "audio-back", trc("audio", "Jump back."),
     
    2734            if (AudioPlayer.playing() || AudioPlayer.paused())
    2835                AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position()
    29                 - Main.pref.getDouble("audio.forwardbackamount","10.0"));
     36                - Main.pref.getDouble("audio.forwardbackamount", 10.0));
    3037            else
    3138                MarkerLayer.playAudio();
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioFastSlowAction.java

    r1245 r5871  
    99import org.openstreetmap.josm.tools.Shortcut;
    1010
     11/**
     12 * Abstract superclass of {@link AudioFasterAction} and {@link AudioSlowerAction}.
     13 * @since 563
     14 */
    1115abstract public class AudioFastSlowAction extends JosmAction {
    1216
    1317    private double multiplier;
    1418
     19    /**
     20     * Constructs a new {@code AudioFastSlowAction}.
     21     *
     22     * @param name the action's text as displayed on the menu (if it is added to a menu)
     23     * @param iconName the filename of the icon to use
     24     * @param tooltip  a longer description of the action that will be displayed in the tooltip.
     25     * @param shortcut a ready-created shortcut object.
     26     * @param fast {@code true} to increase speed (faster audio), {@code false} to decrease it (slower audio).
     27     */
    1528    public AudioFastSlowAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean fast) {
    1629        super(name, iconName, tooltip, shortcut, true);
    17         multiplier = Main.pref.getDouble("audio.fastfwdmultiplier","1.3");
     30        multiplier = Main.pref.getDouble("audio.fastfwdmultiplier", 1.3);
    1831        if (! fast)
    1932            multiplier = 1.0 / multiplier;
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioFasterAction.java

    r4982 r5871  
    1010import org.openstreetmap.josm.tools.Shortcut;
    1111
     12/**
     13 * Increase the speed of audio playback.
     14 * Each use increases the speed further until one of the other controls is used.
     15 * @since 563
     16 */
    1217public class AudioFasterAction extends AudioFastSlowAction {
    1318
     19    /**
     20     * Constructs a new {@code AudioFasterAction}.
     21     */
    1422    public AudioFasterAction() {
    1523        super(trc("audio", "Faster"), "audio-faster", trc("audio", "Faster Forward"),
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioFwdAction.java

    r4982 r5871  
    1414import org.openstreetmap.josm.tools.Shortcut;
    1515
     16/**
     17 * Jump the audio forward 10 seconds.
     18 * @since 547
     19 */
    1620public class AudioFwdAction extends JosmAction {
     21   
     22    /**
     23     * Constructs a new {@code AudioFwdAction}.
     24     */
    1725    public AudioFwdAction() {
    1826        super(trc("audio", "Forward"), "audio-fwd", trc("audio", "Jump forward"),
     
    2432            if (AudioPlayer.playing() || AudioPlayer.paused())
    2533                AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position()
    26                 + Main.pref.getDouble("audio.forwardbackamount","10.0"));
     34                + Main.pref.getDouble("audio.forwardbackamount", 10.0));
    2735            else
    2836                MarkerLayer.playAudio();
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioNextAction.java

    r4982 r5871  
    1212import org.openstreetmap.josm.tools.Shortcut;
    1313
     14/**
     15 * Play the sound track from the Audio Marker after the one most recently played.<br/>
     16 * Play from the first such Marker if none has been played, or repeat the last marker if at the end.
     17 * @since 547
     18 */
    1419public class AudioNextAction extends JosmAction {
    1520
     21    /**
     22     * Constructs a new {@code AudioNextAction}.
     23     */
    1624    public AudioNextAction() {
    1725        super(trc("audio", "Next Marker"), "audio-next", trc("audio", "Play next marker."),
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioPlayPauseAction.java

    r4982 r5871  
    1313import org.openstreetmap.josm.tools.Shortcut;
    1414
     15/**
     16 * If not playing, play the sound track from the first Audio Marker, or from the point at which it was paused.<br/>
     17 * If playing, pause the sound.<br/>
     18 * If fast forwarding or slow forwarding, resume normal speed.
     19 * @since 547
     20 */
    1521public class AudioPlayPauseAction extends JosmAction {
    1622
     23    /**
     24     * Constructs a new {@code AudioPlayPauseAction}.
     25     */
    1726    public AudioPlayPauseAction() {
    1827        super(trc("audio", "Play/Pause"), "audio-playpause", tr("Play/pause audio."),
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioPrevAction.java

    r4982 r5871  
    1212import org.openstreetmap.josm.tools.Shortcut;
    1313
     14/**
     15 * Play the sound track from the Audio Marker before the one most recently played.<br/>
     16 * Play from the first such Marker if none has been played or already at the first marker.
     17 * @since 547
     18 */
    1419public class AudioPrevAction extends JosmAction {
    1520
     21    /**
     22     * Constructs a new {@code AudioPrevAction}.
     23     */
    1624    public AudioPrevAction() {
    1725        super(trc("audio", "Previous Marker"), "audio-prev", trc("audio", "Play previous marker."),
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioSlowerAction.java

    r4982 r5871  
    1010import org.openstreetmap.josm.tools.Shortcut;
    1111
     12/**
     13 * Decrease the speed of audio playback.
     14 * Each use decreases the speed further until one of the other controls is used.
     15 * @since 563
     16 */
    1217public class AudioSlowerAction extends AudioFastSlowAction {
    1318
     19    /**
     20     * Constructs a new {@code AudioSlowerAction}.
     21     */
    1422    public AudioSlowerAction() {
    1523        super(trc("audio", "Slower"), "audio-slower", trc("audio", "Slower Forward"),
    16         Shortcut.registerShortcut("audio:slower", tr("Audio: {0}", trc("audio", "Slower")), KeyEvent.VK_F4, Shortcut.DIRECT), true);
     24        Shortcut.registerShortcut("audio:slower", tr("Audio: {0}", trc("audio", "Slower")), KeyEvent.VK_F4, Shortcut.DIRECT), false);
    1725        this.putValue("help", ht("/Action/AudioSlower"));
    1826    }
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r5865 r5871  
    824824    }
    825825
    826     synchronized public double getDouble(String key, String def) {
    827         putDefault(key, def);
    828         String v = get(key);
    829         if(v != null && v.length() != 0) {
    830             try { return Double.parseDouble(v); } catch(NumberFormatException e) {}
    831         }
    832         try { return Double.parseDouble(def); } catch(NumberFormatException e) {}
    833         return 0.0;
    834     }
    835 
    836826    /**
    837827     * Get a list of values for a certain key
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java

    r5715 r5871  
    3131import static org.openstreetmap.josm.tools.I18n.tr;
    3232
     33/**
     34 * Import audio files into a GPX layer to enable audio playback functions.
     35 * @since 5715
     36 */
    3337public class ImportAudioAction extends AbstractAction {
    3438    private final GpxLayer layer;
     
    3943    }
    4044
     45    /**
     46     * Constructs a new {@code ImportAudioAction}.
     47     * @param layer The associated GPX layer
     48     */
    4149    public ImportAudioAction(final GpxLayer layer) {
    4250        super(tr("Import Audio"), ImageProvider.get("importaudio"));
     
    105113    }
    106114   
    107         /**
     115    /**
    108116     * Makes a new marker layer derived from this GpxLayer containing at least one audio marker
    109117     * which the given audio file is associated with. Markers are derived from the following (a)
     
    213221            double startTime = lastModified - duration;
    214222            startTime = firstStartTime + (startTime - firstStartTime)
    215                     / Main.pref.getDouble("audio.calibration", "1.0" /* default, ratio */);
     223                    / Main.pref.getDouble("audio.calibration", 1.0 /* default, ratio */);
    216224            WayPoint w1 = null;
    217225            WayPoint w2 = null;
     
    314322        }
    315323    }
    316 
    317    
    318324}
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r5781 r5871  
    3232 *
    3333 * @author David Earl<david@frankieandshadow.com>
    34  *
     34 * @since 572
    3535 */
    3636public class PlayHeadMarker extends Marker {
     
    4747    private int dropTolerance; /* pixels */
    4848
     49    /**
     50     * Returns the unique instance of {@code PlayHeadMarker}.
     51     * @return The unique instance of {@code PlayHeadMarker}.
     52     */
    4953    public static PlayHeadMarker create() {
    5054        if (playHead == null) {
     
    264268    }
    265269
    266     public void paint(Graphics g, MapView mv /*, boolean mousePressed */) {
     270    /**
     271     * Paint the marker icon in the given graphics context.
     272     * @param g The graphics context
     273     * @param mv The map
     274     */
     275    public void paint(Graphics g, MapView mv) {
    267276        if (time < 0.0) return;
    268277        Point screen = mv.getPoint(getEastNorth());
     
    270279    }
    271280
     281    /**
     282     * Animates the marker along the track.
     283     */
    272284    public void animate() {
    273285        if (! enabled) return;
    274286        if (timer == null) {
    275             animationInterval = Main.pref.getDouble("marker.audioanimationinterval", "1"); //milliseconds
     287            animationInterval = Main.pref.getDouble("marker.audioanimationinterval", 1.0); //milliseconds
    276288            timer = new Timer((int)(animationInterval * 1000.0), new ActionListener() {
    277289                public void actionPerformed(ActionEvent e) {
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r3264 r5871  
    2020 *
    2121 * @author David Earl <david@frankieandshadow.com>
    22  *
     22 * @since 547
    2323 */
    2424public class AudioPlayer extends Thread {
     
    104104     * start at the beginning of the stream
    105105     * @param url The resource to play, which must be a WAV file or stream
    106      * @throws audio fault exception, e.g. can't open stream,  unhandleable audio format
     106     * @throws Exception audio fault exception, e.g. can't open stream,  unhandleable audio format
    107107     */
    108108    public static void play(URL url) throws Exception {
     
    114114     * @param url The resource to play, which must be a WAV file or stream
    115115     * @param seconds The number of seconds into the audio to start playing
    116      * @throws audio fault exception, e.g. can't open stream,  unhandleable audio format
     116     * @throws Exception audio fault exception, e.g. can't open stream,  unhandleable audio format
    117117     */
    118118    public static void play(URL url, double seconds) throws Exception {
     
    125125     * @param seconds The number of seconds into the audio to start playing
    126126     * @param speed Rate at which audio playes (1.0 = real time, > 1 is faster)
    127      * @throws audio fault exception, e.g. can't open stream,  unhandleable audio format
     127     * @throws Exception audio fault exception, e.g. can't open stream,  unhandleable audio format
    128128     */
    129129    public static void play(URL url, double seconds, double speed) throws Exception {
     
    133133    /**
    134134     * Pauses the currently playing audio stream. Does nothing if nothing playing.
    135      * @throws audio fault exception, e.g. can't open stream,  unhandleable audio format
     135     * @throws Exception audio fault exception, e.g. can't open stream,  unhandleable audio format
    136136     */
    137137    public static void pause() throws Exception {
     
    194194    }
    195195
     196    /**
     197     * Resets the audio player.
     198     */
    196199    public static void reset() {
    197200        if(audioPlayer != null)
     
    208211        command = new Execute();
    209212        playingUrl = null;
    210         leadIn = Main.pref.getDouble("audio.leadin", "1.0" /* default, seconds */);
    211         calibration = Main.pref.getDouble("audio.calibration", "1.0" /* default, ratio */);
     213        leadIn = Main.pref.getDouble("audio.leadin", 1.0 /* default, seconds */);
     214        calibration = Main.pref.getDouble("audio.calibration", 1.0 /* default, ratio */);
    212215        start();
    213216        while (state == State.INITIALIZING) { yield(); }
     
    338341    }
    339342
     343    /**
     344     * Shows a popup audio error message for the given exception.
     345     * @param ex The exception used as error reason. Cannot be {@code null}.
     346     */
    340347    public static void audioMalfunction(Exception ex) {
    341348        String msg = ex.getMessage();
  • trunk/src/org/openstreetmap/josm/tools/AudioUtil.java

    r3083 r5871  
    1212
    1313/**
    14  * Returns calibrated length of recording in seconds.
     14 * Utils functions for audio.
    1515 *
    1616 * @author David Earl <david@frankieandshadow.com>
    17  *
     17 * @since 1462
    1818 */
    1919public class AudioUtil {
     20   
     21    /**
     22     * Returns calibrated length of recording in seconds.
     23     * @param wavFile the recording file (WAV format)
     24     * @return the calibrated length of recording in seconds.
     25     */
    2026    static public double getCalibratedDuration(File wavFile) {
    2127        try {
     
    2834            double naturalLength = filesize / bytesPerSecond;
    2935            audioInputStream.close();
    30             double calibration = Main.pref.getDouble("audio.calibration", "1.0" /* default, ratio */);
     36            double calibration = Main.pref.getDouble("audio.calibration", 1.0 /* default, ratio */);
    3137            return naturalLength / calibration;
    3238        } catch (Exception e) {
Note: See TracChangeset for help on using the changeset viewer.