Changeset 6615 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-01-03T19:32:18+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.