Changeset 36292 in osm for applications/viewer
- Timestamp:
- 2024-07-16T17:33:01+02:00 (6 months ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/FeatureAdapter.java
r36223 r36292 217 217 218 218 /** 219 * Reads an image using the current {@link ImageAdapter}. 220 * @param url image URI to read 221 * @return a <code>BufferedImage</code> containing the decoded contents of the input, or <code>null</code>. 222 * @throws java.net.MalformedURLException if the URI could not be converted to a URL 223 * @throws IOException if an error occurs during reading. 224 */ 225 public static BufferedImage readImage(URI url) throws IOException { 226 return imageAdapter.read(url.toURL(), false, false); 227 } 228 229 /** 219 230 * Translates a text using the current {@link TranslationAdapter}. 220 231 * @param text the text to translate. -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
r36223 r36292 5 5 import java.io.IOException; 6 6 import java.net.MalformedURLException; 7 import java.net.URI; 8 import java.net.URISyntaxException; 7 9 import java.net.URL; 8 10 import java.util.ArrayList; … … 128 130 129 131 protected URL getAttributionUrl() throws MalformedURLException { 130 return new URL(FeatureAdapter.getSetting(METADATA_API_SETTING, METADATA_API_URL) 131 .replace(API_KEY_PLACEHOLDER, FeatureAdapter.getSetting(API_KEY_SETTING, API_KEY)) 132 .replace(API_KEY_LAYER, this.layer)); 132 try { 133 return new URI(FeatureAdapter.getSetting(METADATA_API_SETTING, METADATA_API_URL) 134 .replace(API_KEY_PLACEHOLDER, FeatureAdapter.getSetting(API_KEY_SETTING, API_KEY)) 135 .replace(API_KEY_LAYER, this.layer)).toURL(); 136 } catch (URISyntaxException e) { 137 MalformedURLException malformedURLException = new MalformedURLException(e.getMessage()); 138 malformedURLException.initCause(e); 139 throw malformedURLException; 140 } 133 141 } 134 142 … … 233 241 if (brandLogoUri != null && !brandLogoUri.isEmpty()) { 234 242 LOG.log(Level.FINE, "Reading Bing logo from {0}", brandLogoUri); 235 return FeatureAdapter.readImage(new UR L(brandLogoUri));236 } 237 } 238 } catch ( IOException e) {239 LOG.log(Level.SEVERE, "Error while retrieving Bing logo: "+e.getMessage());243 return FeatureAdapter.readImage(new URI(brandLogoUri)); 244 } 245 } 246 } catch (URISyntaxException | IOException e) { 247 LOG.log(Level.SEVERE, String.format("Error while retrieving Bing logo: %s", e.getMessage())); 240 248 } 241 249 return null; … … 267 275 return r; 268 276 } catch (IOException ex) { 269 LOG.log(Level.SEVERE, "Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");277 LOG.log(Level.SEVERE, String.format("Could not connect to Bing API. Will retry in %d seconds.", waitTimeSec)); 270 278 LOG.log(Level.FINE, ex.getMessage(), ex); 271 279 Thread.sleep(TimeUnit.SECONDS.toMillis(waitTimeSec)); … … 276 284 } 277 285 286 /** 287 * Get the attribution data that is currently loaded 288 * @return The list of {@link Attribution} data or {@code null}, if no attribution data has been loaded yet. 289 */ 278 290 protected List<Attribution> getAttribution() { 279 291 if (attributions == null) { … … 287 299 } 288 300 } 289 try { 290 return attributions.get(); 291 } catch (ExecutionException ex) { 292 throw new JMapViewerRuntimeException(ex); 293 } catch (InterruptedException ign) { 294 LOG.log(Level.SEVERE, "InterruptedException: {0}", ign.getMessage()); 295 LOG.log(Level.FINE, ign.getMessage(), ign); 296 Thread.currentThread().interrupt(); 301 if (attributions.isDone()) { 302 try { 303 return attributions.get(); 304 } catch (ExecutionException ex) { 305 throw new JMapViewerRuntimeException(ex); 306 } catch (InterruptedException ign) { 307 LOG.log(Level.SEVERE, "InterruptedException: {0}", ign.getMessage()); 308 LOG.log(Level.FINE, ign.getMessage(), ign); 309 Thread.currentThread().interrupt(); 310 } 297 311 } 298 312 return null;
Note:
See TracChangeset
for help on using the changeset viewer.