Changeset 5871 in josm
- Timestamp:
- 2013-04-15T23:12:33+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r5780 r5871 150 150 */ 151 151 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); 153 153 int lower = 0; 154 154 int i = 0; -
trunk/src/org/openstreetmap/josm/actions/audio/AudioBackAction.java
r4982 r5871 15 15 import org.openstreetmap.josm.tools.Shortcut; 16 16 17 /** 18 * Jump the audio backward 10 seconds and start playing if paused. 19 * @since 547 20 */ 17 21 public class AudioBackAction extends JosmAction { 18 22 23 /** 24 * Constructs a new {@code AudioBackAction}. 25 */ 19 26 public AudioBackAction() { 20 27 super(trc("audio", "Back"), "audio-back", trc("audio", "Jump back."), … … 27 34 if (AudioPlayer.playing() || AudioPlayer.paused()) 28 35 AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position() 29 - Main.pref.getDouble("audio.forwardbackamount", "10.0"));36 - Main.pref.getDouble("audio.forwardbackamount", 10.0)); 30 37 else 31 38 MarkerLayer.playAudio(); -
trunk/src/org/openstreetmap/josm/actions/audio/AudioFastSlowAction.java
r1245 r5871 9 9 import org.openstreetmap.josm.tools.Shortcut; 10 10 11 /** 12 * Abstract superclass of {@link AudioFasterAction} and {@link AudioSlowerAction}. 13 * @since 563 14 */ 11 15 abstract public class AudioFastSlowAction extends JosmAction { 12 16 13 17 private double multiplier; 14 18 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 */ 15 28 public AudioFastSlowAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean fast) { 16 29 super(name, iconName, tooltip, shortcut, true); 17 multiplier = Main.pref.getDouble("audio.fastfwdmultiplier", "1.3");30 multiplier = Main.pref.getDouble("audio.fastfwdmultiplier", 1.3); 18 31 if (! fast) 19 32 multiplier = 1.0 / multiplier; -
trunk/src/org/openstreetmap/josm/actions/audio/AudioFasterAction.java
r4982 r5871 10 10 import org.openstreetmap.josm.tools.Shortcut; 11 11 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 */ 12 17 public class AudioFasterAction extends AudioFastSlowAction { 13 18 19 /** 20 * Constructs a new {@code AudioFasterAction}. 21 */ 14 22 public AudioFasterAction() { 15 23 super(trc("audio", "Faster"), "audio-faster", trc("audio", "Faster Forward"), -
trunk/src/org/openstreetmap/josm/actions/audio/AudioFwdAction.java
r4982 r5871 14 14 import org.openstreetmap.josm.tools.Shortcut; 15 15 16 /** 17 * Jump the audio forward 10 seconds. 18 * @since 547 19 */ 16 20 public class AudioFwdAction extends JosmAction { 21 22 /** 23 * Constructs a new {@code AudioFwdAction}. 24 */ 17 25 public AudioFwdAction() { 18 26 super(trc("audio", "Forward"), "audio-fwd", trc("audio", "Jump forward"), … … 24 32 if (AudioPlayer.playing() || AudioPlayer.paused()) 25 33 AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position() 26 + Main.pref.getDouble("audio.forwardbackamount", "10.0"));34 + Main.pref.getDouble("audio.forwardbackamount", 10.0)); 27 35 else 28 36 MarkerLayer.playAudio(); -
trunk/src/org/openstreetmap/josm/actions/audio/AudioNextAction.java
r4982 r5871 12 12 import org.openstreetmap.josm.tools.Shortcut; 13 13 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 */ 14 19 public class AudioNextAction extends JosmAction { 15 20 21 /** 22 * Constructs a new {@code AudioNextAction}. 23 */ 16 24 public AudioNextAction() { 17 25 super(trc("audio", "Next Marker"), "audio-next", trc("audio", "Play next marker."), -
trunk/src/org/openstreetmap/josm/actions/audio/AudioPlayPauseAction.java
r4982 r5871 13 13 import org.openstreetmap.josm.tools.Shortcut; 14 14 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 */ 15 21 public class AudioPlayPauseAction extends JosmAction { 16 22 23 /** 24 * Constructs a new {@code AudioPlayPauseAction}. 25 */ 17 26 public AudioPlayPauseAction() { 18 27 super(trc("audio", "Play/Pause"), "audio-playpause", tr("Play/pause audio."), -
trunk/src/org/openstreetmap/josm/actions/audio/AudioPrevAction.java
r4982 r5871 12 12 import org.openstreetmap.josm.tools.Shortcut; 13 13 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 */ 14 19 public class AudioPrevAction extends JosmAction { 15 20 21 /** 22 * Constructs a new {@code AudioPrevAction}. 23 */ 16 24 public AudioPrevAction() { 17 25 super(trc("audio", "Previous Marker"), "audio-prev", trc("audio", "Play previous marker."), -
trunk/src/org/openstreetmap/josm/actions/audio/AudioSlowerAction.java
r4982 r5871 10 10 import org.openstreetmap.josm.tools.Shortcut; 11 11 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 */ 12 17 public class AudioSlowerAction extends AudioFastSlowAction { 13 18 19 /** 20 * Constructs a new {@code AudioSlowerAction}. 21 */ 14 22 public AudioSlowerAction() { 15 23 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); 17 25 this.putValue("help", ht("/Action/AudioSlower")); 18 26 } -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r5865 r5871 824 824 } 825 825 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 836 826 /** 837 827 * Get a list of values for a certain key -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r5715 r5871 31 31 import static org.openstreetmap.josm.tools.I18n.tr; 32 32 33 /** 34 * Import audio files into a GPX layer to enable audio playback functions. 35 * @since 5715 36 */ 33 37 public class ImportAudioAction extends AbstractAction { 34 38 private final GpxLayer layer; … … 39 43 } 40 44 45 /** 46 * Constructs a new {@code ImportAudioAction}. 47 * @param layer The associated GPX layer 48 */ 41 49 public ImportAudioAction(final GpxLayer layer) { 42 50 super(tr("Import Audio"), ImageProvider.get("importaudio")); … … 105 113 } 106 114 107 115 /** 108 116 * Makes a new marker layer derived from this GpxLayer containing at least one audio marker 109 117 * which the given audio file is associated with. Markers are derived from the following (a) … … 213 221 double startTime = lastModified - duration; 214 222 startTime = firstStartTime + (startTime - firstStartTime) 215 / Main.pref.getDouble("audio.calibration", "1.0"/* default, ratio */);223 / Main.pref.getDouble("audio.calibration", 1.0 /* default, ratio */); 216 224 WayPoint w1 = null; 217 225 WayPoint w2 = null; … … 314 322 } 315 323 } 316 317 318 324 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r5781 r5871 32 32 * 33 33 * @author David Earl<david@frankieandshadow.com> 34 * 34 * @since 572 35 35 */ 36 36 public class PlayHeadMarker extends Marker { … … 47 47 private int dropTolerance; /* pixels */ 48 48 49 /** 50 * Returns the unique instance of {@code PlayHeadMarker}. 51 * @return The unique instance of {@code PlayHeadMarker}. 52 */ 49 53 public static PlayHeadMarker create() { 50 54 if (playHead == null) { … … 264 268 } 265 269 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) { 267 276 if (time < 0.0) return; 268 277 Point screen = mv.getPoint(getEastNorth()); … … 270 279 } 271 280 281 /** 282 * Animates the marker along the track. 283 */ 272 284 public void animate() { 273 285 if (! enabled) return; 274 286 if (timer == null) { 275 animationInterval = Main.pref.getDouble("marker.audioanimationinterval", "1"); //milliseconds287 animationInterval = Main.pref.getDouble("marker.audioanimationinterval", 1.0); //milliseconds 276 288 timer = new Timer((int)(animationInterval * 1000.0), new ActionListener() { 277 289 public void actionPerformed(ActionEvent e) { -
trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
r3264 r5871 20 20 * 21 21 * @author David Earl <david@frankieandshadow.com> 22 * 22 * @since 547 23 23 */ 24 24 public class AudioPlayer extends Thread { … … 104 104 * start at the beginning of the stream 105 105 * @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 format106 * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format 107 107 */ 108 108 public static void play(URL url) throws Exception { … … 114 114 * @param url The resource to play, which must be a WAV file or stream 115 115 * @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 format116 * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format 117 117 */ 118 118 public static void play(URL url, double seconds) throws Exception { … … 125 125 * @param seconds The number of seconds into the audio to start playing 126 126 * @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 format127 * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format 128 128 */ 129 129 public static void play(URL url, double seconds, double speed) throws Exception { … … 133 133 /** 134 134 * Pauses the currently playing audio stream. Does nothing if nothing playing. 135 * @throws audio fault exception, e.g. can't open stream, unhandleable audio format135 * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format 136 136 */ 137 137 public static void pause() throws Exception { … … 194 194 } 195 195 196 /** 197 * Resets the audio player. 198 */ 196 199 public static void reset() { 197 200 if(audioPlayer != null) … … 208 211 command = new Execute(); 209 212 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 */); 212 215 start(); 213 216 while (state == State.INITIALIZING) { yield(); } … … 338 341 } 339 342 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 */ 340 347 public static void audioMalfunction(Exception ex) { 341 348 String msg = ex.getMessage(); -
trunk/src/org/openstreetmap/josm/tools/AudioUtil.java
r3083 r5871 12 12 13 13 /** 14 * Returns calibrated length of recording in seconds.14 * Utils functions for audio. 15 15 * 16 16 * @author David Earl <david@frankieandshadow.com> 17 * 17 * @since 1462 18 18 */ 19 19 public 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 */ 20 26 static public double getCalibratedDuration(File wavFile) { 21 27 try { … … 28 34 double naturalLength = filesize / bytesPerSecond; 29 35 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 */); 31 37 return naturalLength / calibration; 32 38 } catch (Exception e) {
Note:
See TracChangeset
for help on using the changeset viewer.