Changeset 17968 in josm for trunk/src/org
- Timestamp:
- 2021-07-09T01:29:19+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/MapboxVectorStyle.java
r17867 r17968 218 218 } 219 219 final File toSave = new File(location, name); 220 try (OutputStream fileOutputStream = Files.newOutputStream(toSave.toPath())) { 221 if (object instanceof String) { 222 fileOutputStream.write(((String) object).getBytes(StandardCharsets.UTF_8)); 223 } else if (object instanceof MapCSSStyleSource) { 224 MapCSSStyleSource source = (MapCSSStyleSource) object; 225 try (InputStream inputStream = source.getSourceInputStream()) { 226 int byteVal = inputStream.read(); 227 do { 228 fileOutputStream.write(byteVal); 229 byteVal = inputStream.read(); 230 } while (byteVal > -1); 231 source.url = "file:/" + toSave.getAbsolutePath().replace('\\', '/'); 232 if (source.isLoaded()) { 233 source.loadStyleSource(); 220 try { 221 if (object instanceof BufferedImage) { 222 // This directory is checked first when getting images 223 if (!ImageIO.write((BufferedImage) object, "png", toSave)) { 224 Logging.warn("No appropriate PNG writer could be found"); 225 } 226 } else { 227 try (OutputStream fileOutputStream = Files.newOutputStream(toSave.toPath())) { 228 if (object instanceof String) { 229 fileOutputStream.write(((String) object).getBytes(StandardCharsets.UTF_8)); 230 } else if (object instanceof MapCSSStyleSource) { 231 MapCSSStyleSource source = (MapCSSStyleSource) object; 232 try (InputStream inputStream = source.getSourceInputStream()) { 233 int byteVal = inputStream.read(); 234 do { 235 fileOutputStream.write(byteVal); 236 byteVal = inputStream.read(); 237 } while (byteVal > -1); 238 source.url = "file:/" + toSave.getAbsolutePath().replace('\\', '/'); 239 if (source.isLoaded()) { 240 source.loadStyleSource(); 241 } 242 } 234 243 } 235 244 } 236 } else if (object instanceof BufferedImage) {237 // This directory is checked first when getting images238 ImageIO.write((BufferedImage) object, "png", toSave);239 245 } 240 246 } catch (IOException e) { 241 Logging. info(e);247 Logging.warn(e); 242 248 } 243 249 }
Note:
See TracChangeset
for help on using the changeset viewer.