Changeset 19180 in josm
- Timestamp:
- 2024-08-12T17:35:51+02:00 (6 months ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java
r19145 r19180 10 10 import java.nio.charset.StandardCharsets; 11 11 import java.util.List; 12 import java.util.Objects; 12 13 import java.util.Timer; 13 14 import java.util.TimerTask; 14 15 import java.util.concurrent.Callable; 15 import java.util.concurrent.atomic.AtomicBoolean; 16 import java.util.concurrent.CountDownLatch; 17 import java.util.concurrent.TimeUnit; 16 18 import java.util.concurrent.atomic.AtomicReference; 17 19 … … 89 91 protected Callable<List<Attribution>> getAttributionLoaderCallable() { 90 92 final AtomicReference<List<Attribution>> attributions = new AtomicReference<>(); 91 final AtomicBooleanfinished = newAtomicBoolean();93 final CountDownLatch finished = new CountDownLatch(1); 92 94 return () -> { 93 95 final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(); … … 95 97 final Timer timer = new Timer(Thread.currentThread().getName() + "-timer", true); 96 98 timer.schedule(new AttributionTimerTask(monitor, timer, 1, attributions, finished), 0); 97 synchronized (finished){98 while (! finished.get() && !monitor.isCanceled()) {99 finished.wait(1000);99 try { 100 while (!monitor.isCanceled() && !finished.await(1, TimeUnit.SECONDS)) { 101 // Do nothing; we are waiting on the CountDownLatch to hit zero. 100 102 } 103 } finally { 104 monitor.finishTask(); 105 monitor.close(); 101 106 } 102 monitor.finishTask();103 monitor.close();104 107 return attributions.get(); 105 108 }; … … 114 117 private final int waitTimeSec; 115 118 private final AtomicReference<List<Attribution>> attributions; 116 private final AtomicBooleanfinished;119 private final CountDownLatch finished; 117 120 118 121 /** … … 125 128 */ 126 129 AttributionTimerTask(ProgressMonitor monitor, Timer timer, int waitTimeSec, 127 AtomicReference<List<Attribution>> attributions, AtomicBooleanfinished) {130 AtomicReference<List<Attribution>> attributions, CountDownLatch finished) { 128 131 this.monitor = monitor; 129 132 this.timer = timer; … … 138 141 try { 139 142 String xml = attributionLoader.updateIfRequiredString(); 143 Objects.requireNonNull(xml); 140 144 List<Attribution> ret; 141 145 try (StringReader sr = new StringReader(xml)) { … … 147 151 } 148 152 this.attributions.set(ret); 149 this.finished. set(true);153 this.finished.countDown(); 150 154 } catch (IOException ex) { 151 155 final String message = tr("Could not connect to Bing API. Will retry in {0} seconds.", waitTimeSec); 152 156 Logging.log(Logging.LEVEL_WARN, message, ex); 153 157 if (this.monitor.isCanceled()) { 154 this.finished. set(true);158 this.finished.countDown(); 155 159 return; 156 160 } … … 160 164 this.timer.schedule(new AttributionTimerTask(this.monitor, this.timer, newWaitTimeSec, this.attributions, this.finished), 161 165 newWaitTimeSec * 1000L); 162 } finally {163 synchronized (this.finished) {164 this.finished.notifyAll();165 }166 166 } 167 167 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledTiledMapRenderer.java
r19176 r19180 251 251 temporaryView.zoomTo(bounds.getCenter().getEastNorth(ProjectionRegistry.getProjection()), mapState.getScale()); 252 252 BufferedImage bufferedImage = Optional.ofNullable(nc.getGraphicsConfiguration()) 253 .map(gc -> gc.createCompatibleImage(tileSize * xCount + xCount, tileSize * yCount + xCount, Transparency.TRANSLUCENT))254 .orElseGet(() -> new BufferedImage(tileSize * xCount + xCount, tileSize * yCount + xCount, BufferedImage.TYPE_INT_ARGB));253 .map(gc -> gc.createCompatibleImage(tileSize * xCount + xCount, tileSize * yCount + yCount, Transparency.TRANSLUCENT)) 254 .orElseGet(() -> new BufferedImage(tileSize * xCount + xCount, tileSize * yCount + yCount, BufferedImage.TYPE_INT_ARGB)); 255 255 Graphics2D g2d = bufferedImage.createGraphics(); 256 256 try { … … 335 335 * @param tImage The tile image for this job 336 336 */ 337 private synchronizedvoid cacheTile(BufferedImage tImage) {337 private void cacheTile(BufferedImage tImage) { 338 338 cache.put(tile, new ImageCache(tImage, null, false)); 339 339 done = true; -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r19176 r19180 1342 1342 // 256 is the "target" size, (TODO check HiDPI!) 1343 1343 final int targetSize = Config.getPref().getInt("mappaint.fast_render.tile_size", 256); 1344 CheckParameterUtil.ensureThat(targetSize > 0, "mappaint.fast_render.tile_size should be > 0 (default 256)"); 1344 1345 final double topResolution = 2 * Math.PI * OsmMercator.EARTH_RADIUS / targetSize; 1345 1346 int zoom;
Note:
See TracChangeset
for help on using the changeset viewer.