Changeset 1677 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2009-06-17T10:04:22+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/AudioUtil.java
r1462 r1677 20 20 */ 21 21 public class AudioUtil { 22 23 22 23 static public double getCalibratedDuration(File wavFile) { 24 24 try { 25 26 25 AudioInputStream audioInputStream = AudioSystem.getAudioInputStream( 26 new URL("file:".concat(wavFile.getAbsolutePath()))); 27 27 AudioFormat audioFormat = audioInputStream.getFormat(); 28 28 long filesize = wavFile.length(); … … 34 34 return naturalLength / calibration; 35 35 } catch (Exception e) { 36 36 return 0.0; 37 37 } 38 } 39 38 } 40 39 } 41 -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r1486 r1677 229 229 } 230 230 231 /* from: http://www.jidesoft.com/blog/2008/02/29/rotate-an-icon-in-java/ 231 /* from: http://www.jidesoft.com/blog/2008/02/29/rotate-an-icon-in-java/ 232 232 * License: "feel free to use" 233 233 */ -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r1307 r1677 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 package org.openstreetmap.josm.tools; 3 4 import java.util.HashMap; 5 6 import org.openstreetmap.josm.data.Bounds; 7 import org.openstreetmap.josm.data.coor.LatLon; 8 9 public class OsmUrlToBounds { 10 public static Bounds parse(String url) { 11 int i = url.indexOf('?'); 12 if (i == -1) 13 return null; 14 String[] args = url.substring(i+1).split("&"); 15 HashMap<String, String> map = new HashMap<String, String>(); 16 for (String arg : args) { 17 int eq = arg.indexOf('='); 18 if (eq != -1) { 19 map.put(arg.substring(0, eq), arg.substring(eq + 1)); 20 } 21 } 22 23 Bounds b = null; 24 try { 25 if (map.containsKey("bbox")) { 26 String bbox[] = map.get("bbox").split(","); 27 b = new Bounds( 28 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])), 29 new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2]))); 30 31 } else { 32 double size = 180.0 / Math.pow(2, Integer.parseInt(map.get("zoom"))); 33 b = new Bounds( 34 new LatLon(parseDouble(map, "lat") - size/2, parseDouble(map, "lon") - size), 35 new LatLon(parseDouble(map, "lat") + size/2, parseDouble(map, "lon") + size)); 36 } 37 } catch (NumberFormatException x) { 38 } catch (NullPointerException x) { 39 } 40 return b; 41 } 42 43 private static double parseDouble(HashMap<String, String> map, String key) { 44 if (map.containsKey(key)) 45 return Double.parseDouble(map.get(key)); 46 return Double.parseDouble(map.get("m"+key)); 47 } 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 package org.openstreetmap.josm.tools; 3 4 import java.util.HashMap; 5 6 import org.openstreetmap.josm.data.Bounds; 7 import org.openstreetmap.josm.data.coor.LatLon; 8 9 public class OsmUrlToBounds { 10 public static Bounds parse(String url) { 11 int i = url.indexOf('?'); 12 if (i == -1) 13 return null; 14 String[] args = url.substring(i+1).split("&"); 15 HashMap<String, String> map = new HashMap<String, String>(); 16 for (String arg : args) { 17 int eq = arg.indexOf('='); 18 if (eq != -1) { 19 map.put(arg.substring(0, eq), arg.substring(eq + 1)); 20 } 21 } 22 23 Bounds b = null; 24 try { 25 if (map.containsKey("bbox")) { 26 String bbox[] = map.get("bbox").split(","); 27 b = new Bounds( 28 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])), 29 new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2]))); 30 31 } else { 32 double size = 180.0 / Math.pow(2, Integer.parseInt(map.get("zoom"))); 33 b = new Bounds( 34 new LatLon(parseDouble(map, "lat") - size/2, parseDouble(map, "lon") - size), 35 new LatLon(parseDouble(map, "lat") + size/2, parseDouble(map, "lon") + size)); 36 } 37 } catch (NumberFormatException x) { 38 } catch (NullPointerException x) { 39 } 40 return b; 41 } 42 43 private static double parseDouble(HashMap<String, String> map, String key) { 44 if (map.containsKey(key)) 45 return Double.parseDouble(map.get(key)); 46 return Double.parseDouble(map.get("m"+key)); 47 } 48 48 } -
trunk/src/org/openstreetmap/josm/tools/PresetTextComparator.java
r1415 r1677 6 6 7 7 public class PresetTextComparator implements Comparator<JMenuItem> { 8 9 10 11 8 //TODO add error checking and stuff 9 public int compare(JMenuItem arg0, JMenuItem arg1) { 10 return arg0.getText().compareTo(arg1.getText()); 11 } 12 12 13 13
Note:
See TracChangeset
for help on using the changeset viewer.