Changeset 6615 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2014-01-03T19:32:18+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
-
gui/MainApplet.java (modified) (2 diffs)
-
gui/layer/gpx/ImportAudioAction.java (modified) (3 diffs)
-
gui/layer/markerlayer/Marker.java (modified) (2 diffs)
-
gui/mappaint/mapcss/ExpressionFactory.java (modified) (2 diffs)
-
plugins/Plugin.java (modified) (1 diff)
-
plugins/PluginHandler.java (modified) (1 diff)
-
plugins/PluginInformation.java (modified) (6 diffs)
-
tools/ImageProvider.java (modified) (3 diffs)
-
tools/Utils.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplet.java
r6471 r6615 32 32 import org.openstreetmap.josm.tools.I18n; 33 33 import org.openstreetmap.josm.tools.Shortcut; 34 import org.openstreetmap.josm.tools.Utils; 34 35 35 36 public class MainApplet extends JApplet { … … 180 181 @Override 181 182 public URL getCodeBase() { 182 try { 183 return new File(".").toURI().toURL(); 184 } catch (Exception e) { 185 e.printStackTrace(); 186 return null; 187 } 183 return Utils.fileToURL(new File(".")); 188 184 } 189 185 -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r6248 r6615 7 7 import java.awt.event.ActionEvent; 8 8 import java.io.File; 9 import java.net.MalformedURLException;10 9 import java.net.URL; 11 10 import java.util.ArrayList; … … 32 31 import org.openstreetmap.josm.tools.AudioUtil; 33 32 import org.openstreetmap.josm.tools.ImageProvider; 33 import org.openstreetmap.josm.tools.Utils; 34 34 35 35 /** … … 125 125 */ 126 126 private void importAudio(File wavFile, MarkerLayer ml, double firstStartTime, Markers markers) { 127 URL url = null;127 URL url = Utils.fileToURL(wavFile); 128 128 boolean hasTracks = layer.data.tracks != null && !layer.data.tracks.isEmpty(); 129 129 boolean hasWaypoints = layer.data.waypoints != null && !layer.data.waypoints.isEmpty(); 130 try {131 url = wavFile.toURI().toURL();132 } catch (MalformedURLException e) {133 Main.error("Unable to convert filename " + wavFile.getAbsolutePath() + " to URL");134 }135 130 Collection<WayPoint> waypoints = new ArrayList<WayPoint>(); 136 131 boolean timedMarkersOmitted = false; 137 132 boolean untimedMarkersOmitted = false; 138 double snapDistance = Main.pref.getDouble("marker.audiofromuntimedwaypoints.distance", 1.0e-3); /* 139 * about 140 * 25 141 * m 142 */ 133 double snapDistance = Main.pref.getDouble("marker.audiofromuntimedwaypoints.distance", 1.0e-3); 134 // about 25 m 143 135 WayPoint wayPointFromTimeStamp = null; 144 136 -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r6380 r6615 39 39 import org.openstreetmap.josm.gui.MapView; 40 40 import org.openstreetmap.josm.tools.ImageProvider; 41 import org.openstreetmap.josm.tools.Utils; 41 42 import org.openstreetmap.josm.tools.template_engine.ParseError; 42 43 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; … … 210 211 // Try a relative file:// url, if the link is not in an URL-compatible form 211 212 if (relativePath != null) { 212 try { 213 url = new File(relativePath.getParentFile(), uri).toURI().toURL(); 214 } catch (MalformedURLException e1) { 215 Main.warn("Unable to convert uri {0} to URL: {1}", uri, e1.getMessage()); 216 } 213 url = Utils.fileToURL(new File(relativePath.getParentFile(), uri)); 217 214 } 218 215 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r6611 r6615 471 471 final String text = args[0]; 472 472 System.arraycopy(args, 1, args, 0, args.length - 1); 473 return org.openstreetmap.josm.tools.I18n.tr(text, args); 473 return org.openstreetmap.josm.tools.I18n.tr(text, (Object[])args); 474 474 } 475 475 476 476 /** 477 477 * Returns the substring of {@code s} starting at index {@code begin} (inclusive, 0-indexed). 478 * @param s The base string 479 * @param begin The start index 480 * @return the substring 478 481 * @see String#substring(int) 479 482 */ … … 485 488 * Returns the substring of {@code s} starting at index {@code begin} (inclusive) 486 489 * and ending at index {@code end}, (exclusive, 0-indexed). 490 * @param s The base string 491 * @param begin The start index 492 * @param end The end index 493 * @return the substring 487 494 * @see String#substring(int, int) 488 495 */ -
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r6380 r6615 144 144 File pluginDir = Main.pref.getPluginsDirectory(); 145 145 File pluginJar = new File(pluginDir, info.name + ".jar"); 146 final URL pluginJarUrl = PluginInformation.fileToURL(pluginJar);146 final URL pluginJarUrl = Utils.fileToURL(pluginJar); 147 147 return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { 148 148 public ClassLoader run() { -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r6544 r6615 527 527 File pluginJar = new File(pluginDir, info.name + ".jar"); 528 528 I18n.addTexts(pluginJar); 529 URL pluginJarUrl = PluginInformation.fileToURL(pluginJar);529 URL pluginJarUrl = Utils.fileToURL(pluginJar); 530 530 allPluginLibraries.add(pluginJarUrl); 531 531 } -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r6571 r6615 99 99 throw new PluginException(name, tr("The plugin file ''{0}'' does not include a Manifest.", file.toString())); 100 100 scanManifest(manifest, false); 101 libraries.add(0, fileToURL(file)); 101 libraries.add(0, Utils.fileToURL(file)); 102 102 } catch (IOException e) { 103 103 throw new PluginException(name, e); … … 206 206 } 207 207 } else { 208 //noinspection NullArgumentToVariableArgMethod 209 s = MessageFormat.format(s, null); 208 s = MessageFormat.format(s, (Object[]) null); 210 209 } 211 210 description = s; … … 263 262 } 264 263 265 libraries.add(fileToURL(entryFile)); 264 libraries.add(Utils.fileToURL(entryFile)); 266 265 } 267 266 } … … 333 332 } 334 333 335 public static URL fileToURL(File f) { 336 try { 337 return f.toURI().toURL(); 338 } catch (MalformedURLException ex) { 339 return null; 340 } 341 } 334 342 335 343 336 /** … … 395 388 } 396 389 390 /** 391 * Returns all possible plugin locations. 392 * @return all possible plugin locations. 393 */ 397 394 public static Collection<String> getPluginLocations() { 398 395 Collection<String> locations = Main.pref.getAllPossiblePreferenceDirs(); … … 462 459 463 460 /** 464 * Replies the name of the plugin 461 * Replies the name of the plugin. 462 * @return The plugin name 465 463 */ 466 464 public String getName() { -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r6380 r6615 517 517 switch (type) { 518 518 case SVG: 519 URI uri = getSvgUniverse().loadSVG(is, is.getFile() .toURI().toURL().toString());519 URI uri = getSvgUniverse().loadSVG(is, Utils.fileToURL(is.getFile()).toString()); 520 520 SVGDiagram svg = getSvgUniverse().getDiagram(uri); 521 521 return svg == null ? null : new ImageResource(svg); … … 523 523 BufferedImage img = null; 524 524 try { 525 img = ImageIO.read(is.getFile() .toURI().toURL());525 img = ImageIO.read(Utils.fileToURL(is.getFile())); 526 526 } catch (IOException e) { 527 527 Main.warn("IOException while reading HTTP image: "+e.getMessage()); … … 654 654 } 655 655 } else { 656 try { 657 File f = new File(path, name); 658 if ((path != null || f.isAbsolute()) && f.exists()) 659 return f.toURI().toURL(); 660 } catch (MalformedURLException e) { 661 Main.warn(e); 662 } 656 File f = new File(path, name); 657 if ((path != null || f.isAbsolute()) && f.exists()) 658 return Utils.fileToURL(f); 663 659 } 664 660 return null; -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6610 r6615 24 24 import java.io.OutputStream; 25 25 import java.net.HttpURLConnection; 26 import java.net.MalformedURLException; 26 27 import java.net.URL; 27 28 import java.net.URLConnection; … … 373 374 } 374 375 } 376 377 /** 378 * Converts the given file to its URL. 379 * @param f The file to get URL from 380 * @return The URL of the given file, or {@code null} if not possible. 381 * @since 6615 382 */ 383 public static URL fileToURL(File f) { 384 if (f != null) { 385 try { 386 return f.toURI().toURL(); 387 } catch (MalformedURLException ex) { 388 Main.error("Unable to convert filename " + f.getAbsolutePath() + " to URL"); 389 } 390 } 391 return null; 392 } 375 393 376 394 private final static double EPSILON = 1e-11;
Note:
See TracChangeset
for help on using the changeset viewer.
