Changeset 12620 in josm for trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
- Timestamp:
- 2017-08-22T22:26:32+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r12524 r12620 642 642 } else { 643 643 if (!suppressWarnings) { 644 Main.error(tr("Failed to locate image ''{0}''", name));644 Logging.error(tr("Failed to locate image ''{0}''", name)); 645 645 } 646 646 return null; … … 917 917 img = read(Utils.fileToURL(cf.getFile()), false, false); 918 918 } catch (IOException e) { 919 Main.warn(e, "IOException while reading HTTP image:");919 Logging.log(Logging.LEVEL_WARN, "IOException while reading HTTP image:", e); 920 920 } 921 921 return img == null ? null : new ImageResource(img); … … 924 924 } 925 925 } catch (IOException e) { 926 Main.debug(e);926 Logging.debug(e); 927 927 return null; 928 928 } … … 947 947 bytes = Utils.decodeUrl(data).getBytes(StandardCharsets.UTF_8); 948 948 } catch (IllegalArgumentException ex) { 949 Main.warn(ex, "Unable to decode URL data part: "+ex.getMessage() + " (" + data + ')');949 Logging.log(Logging.LEVEL_WARN, "Unable to decode URL data part: "+ex.getMessage() + " (" + data + ')', ex); 950 950 return null; 951 951 } … … 960 960 } 961 961 if (svg == null) { 962 Main.warn("Unable to process svg: "+s);962 Logging.warn("Unable to process svg: "+s); 963 963 return null; 964 964 } … … 974 974 return img == null ? null : new ImageResource(img); 975 975 } catch (IOException e) { 976 Main.warn(e, "IOException while reading image:");976 Logging.log(Logging.LEVEL_WARN, "IOException while reading image:", e); 977 977 } 978 978 } … … 1059 1059 img = read(new ByteArrayInputStream(buf), false, false); 1060 1060 } catch (IOException e) { 1061 Main.warn(e);1061 Logging.warn(e); 1062 1062 } 1063 1063 return img == null ? null : new ImageResource(img); … … 1068 1068 } 1069 1069 } catch (IOException e) { 1070 Main.warn(e, tr("Failed to handle zip file ''{0}''. Exception was: {1}", archive.getName(), e.toString()));1070 Logging.log(Logging.LEVEL_WARN, tr("Failed to handle zip file ''{0}''. Exception was: {1}", archive.getName(), e.toString()), e); 1071 1071 } 1072 1072 return null; … … 1096 1096 // hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/dc4322602480/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java#l656 1097 1097 img = read(path, false, true); 1098 if ( Main.isDebugEnabled() && isTransparencyForced(img)) {1099 Main.debug("Transparency has been forced for image "+path.toExternalForm());1098 if (Logging.isDebugEnabled() && isTransparencyForced(img)) { 1099 Logging.debug("Transparency has been forced for image {0}", path); 1100 1100 } 1101 1101 } catch (IOException e) { 1102 Main.warn(e);1102 Logging.warn(e); 1103 1103 } 1104 1104 return img == null ? null : new ImageResource(img); … … 1139 1139 return u; 1140 1140 } catch (SecurityException e) { 1141 Main.warn(e, tr(1141 Logging.log(Logging.LEVEL_WARN, tr( 1142 1142 "Failed to access directory ''{0}'' for security reasons. Exception was: {1}", 1143 name, e.toString()) );1143 name, e.toString()), e); 1144 1144 } 1145 1145 … … 1154 1154 return u; 1155 1155 } catch (SecurityException e) { 1156 Main.warn(e, tr(1156 Logging.log(Logging.LEVEL_WARN, tr( 1157 1157 "Failed to access directory ''{0}'' for security reasons. Exception was: {1}", dir, e 1158 .toString()) );1158 .toString()), e); 1159 1159 } 1160 1160 } … … 1226 1226 } 1227 1227 } catch (SAXReturnException e) { 1228 Main.trace(e);1228 Logging.trace(e); 1229 1229 return e.getResult(); 1230 1230 } catch (IOException | SAXException | ParserConfigurationException e) { 1231 Main.warn("Parsing " + base + fn + " failed:\n" + e);1231 Logging.warn("Parsing " + base + fn + " failed:\n" + e); 1232 1232 return null; 1233 1233 } 1234 Main.warn("Parsing " + base + fn + " failed: Unexpected content.");1234 Logging.warn("Parsing " + base + fn + " failed: Unexpected content."); 1235 1235 return null; 1236 1236 } … … 1251 1251 } 1252 1252 if (GraphicsEnvironment.isHeadless()) { 1253 if (Main.isDebugEnabled()) { 1254 Main.debug("Cursors are not available in headless mode. Returning null for '"+name+'\''); 1255 } 1253 Logging.debug("Cursors are not available in headless mode. Returning null for '{0}'", name); 1256 1254 return null; 1257 1255 } … … 1465 1463 */ 1466 1464 public static BufferedImage createImageFromSvg(SVGDiagram svg, Dimension dim) { 1467 if ( Main.isTraceEnabled()) {1468 Main.trace(String.format("createImageFromSvg: %s %s", svg.getXMLBase(), dim));1465 if (Logging.isTraceEnabled()) { 1466 Logging.trace("createImageFromSvg: {0} {1}", svg.getXMLBase(), dim); 1469 1467 } 1470 1468 float sourceWidth = svg.getWidth(); … … 1504 1502 } 1505 1503 } catch (SVGException ex) { 1506 Main.error(ex, "Unable to load svg:");1504 Logging.log(Logging.LEVEL_ERROR, "Unable to load svg:", ex); 1507 1505 return null; 1508 1506 } … … 1724 1722 bi = new BufferedImage(bi.getColorModel(), bi.getRaster(), bi.isAlphaPremultiplied(), properties); 1725 1723 if (enforceTransparency) { 1726 if (Main.isTraceEnabled()) { 1727 Main.trace("Enforcing image transparency of "+stream+" for "+color); 1728 } 1724 Logging.trace("Enforcing image transparency of {0} for {1}", stream, color); 1729 1725 bi = makeImageTransparent(bi, color); 1730 1726 } … … 1734 1730 // On Windows, ComponentColorModel.getRGBComponent can fail with "UnsatisfiedLinkError: no awt in java.library.path", see #13973 1735 1731 // Then it can leads to "NoClassDefFoundError: Could not initialize class sun.awt.image.ShortInterleavedRaster", see #15079 1736 Main.error(e);1732 Logging.error(e); 1737 1733 } finally { 1738 1734 reader.dispose(); … … 1781 1777 return new Color(r, g, b); 1782 1778 } else { 1783 Main.warn("Unable to translate TransparentColor '"+value+"' with color model "+model);1779 Logging.warn("Unable to translate TransparentColor '"+value+"' with color model "+model); 1784 1780 } 1785 1781 } … … 1794 1790 } catch (IIOException | NumberFormatException e) { 1795 1791 // JAI doesn't like some JPEG files with error "Inconsistent metadata read from stream" (see #10267) 1796 Main.warn(e);1792 Logging.warn(e); 1797 1793 } 1798 1794 return null; … … 1807 1803 return new Color(rgb[0], rgb[1], rgb[2]); 1808 1804 } catch (IllegalArgumentException e) { 1809 Main.error(e);1805 Logging.error(e); 1810 1806 return null; 1811 1807 }
Note:
See TracChangeset
for help on using the changeset viewer.