- Timestamp:
- 2016-02-03T00:27:12+01:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r9576 r9719 1690 1690 TMSCachedTileLoader.getNewThreadPoolExecutor("Precache downloader")); 1691 1691 } 1692 1693 1692 } 1694 1693 … … 1718 1717 @Override 1719 1718 public void tileLoadingFinished(Tile tile, boolean success) { 1719 int processed = this.processedCount.incrementAndGet(); 1720 1720 if (success) { 1721 int processed = this.processedCount.incrementAndGet();1722 1721 this.progressMonitor.worked(1); 1723 1722 this.progressMonitor.setCustomText(tr("Downloaded {0}/{1} tiles", processed, totalCount)); 1723 } else { 1724 Main.warn("Tile loading failure: " + tile + " - " + tile.getErrorMessage()); 1724 1725 } 1725 1726 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java
r9576 r9719 36 36 37 37 /** 38 * Class downloading WMS and TMS along the GPX track 39 * 38 * Class downloading WMS and TMS along the GPX track. 39 * @since 5715 40 40 */ 41 41 public class DownloadWmsAlongTrackAction extends AbstractAction { … … 51 51 } 52 52 53 @Override 54 public void actionPerformed(ActionEvent e) { 55 final List<LatLon> points = new ArrayList<>(); 53 static class PrecacheWmsTask extends PleaseWaitRunnable { 54 55 private final AbstractTileSourceLayer layer; 56 private final List<LatLon> points; 57 private PrecacheTask precacheTask; 58 59 protected PrecacheWmsTask(AbstractTileSourceLayer layer, List<LatLon> points) { 60 super(tr("Precaching WMS")); 61 this.layer = layer; 62 this.points = points; 63 } 64 65 @Override 66 protected void realRun() throws SAXException, IOException, OsmTransferException { 67 precacheTask = layer.new PrecacheTask(progressMonitor); 68 layer.downloadAreaToCache(precacheTask, points, 0, 0); 69 while (!precacheTask.isFinished() && !progressMonitor.isCanceled()) { 70 synchronized (this) { 71 try { 72 wait(200); 73 } catch (InterruptedException ex) { 74 Main.warn("InterruptedException in "+getClass().getSimpleName()+" while precaching WMS"); 75 } 76 } 77 } 78 } 79 80 @Override 81 protected void finish() { 82 // Do nothing 83 } 84 85 @Override 86 protected void cancel() { 87 precacheTask.cancel(); 88 } 89 90 @Override 91 public ProgressTaskId canRunInBackground() { 92 return ProgressTaskIds.PRECACHE_WMS; 93 } 94 } 95 96 PrecacheWmsTask createTask() { 97 List<LatLon> points = new ArrayList<>(); 56 98 for (GpxTrack trk : data.tracks) { 57 99 for (GpxTrackSegment segment : trk.getSegments()) { … … 64 106 points.add(p.getCoor()); 65 107 } 66 final AbstractTileSourceLayer layer = askedLayer(); 67 if (layer != null) { 68 PleaseWaitRunnable task = new PleaseWaitRunnable(tr("Precaching WMS")) { 69 private PrecacheTask precacheTask; 108 AbstractTileSourceLayer layer = askedLayer(); 109 return layer != null ? new PrecacheWmsTask(layer, points) : null; 110 } 70 111 71 @Override 72 protected void realRun() throws SAXException, IOException, OsmTransferException { 73 precacheTask = layer.new PrecacheTask(progressMonitor); 74 layer.downloadAreaToCache(precacheTask, points, 0, 0); 75 while (!precacheTask.isFinished() && !progressMonitor.isCanceled()) { 76 synchronized (this) { 77 try { 78 wait(200); 79 } catch (InterruptedException ex) { 80 Main.warn("InterruptedException in "+getClass().getSimpleName()+" while precaching WMS"); 81 } 82 } 83 } 84 } 85 86 @Override 87 protected void finish() { 88 } 89 90 @Override 91 protected void cancel() { 92 precacheTask.cancel(); 93 } 94 95 @Override 96 public ProgressTaskId canRunInBackground() { 97 return ProgressTaskIds.PRECACHE_WMS; 98 } 99 }; 112 @Override 113 public void actionPerformed(ActionEvent e) { 114 PrecacheWmsTask task = createTask(); 115 if (task != null) { 100 116 Main.worker.execute(task); 101 117 } … … 103 119 104 120 protected AbstractTileSourceLayer askedLayer() { 121 if (!Main.isDisplayingMapView()) { 122 return null; 123 } 105 124 List<AbstractTileSourceLayer> targetLayers = Main.map.mapView.getLayersOfType(AbstractTileSourceLayer.class); 106 125 if (targetLayers.isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.