Ignore:
Timestamp:
2015-09-01T22:57:30+02:00 (11 years ago)
Author:
wiktorn
Message:

Do not block in EDT thread, when waiting for attribution download. Closes: #11821

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r8602 r8714  
    1010import org.openstreetmap.gui.jmapviewer.tilesources.TMSTileSource;
    1111import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
     12import org.openstreetmap.josm.Main;
    1213import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
    1314import org.openstreetmap.josm.data.imagery.CachedAttributionBingAerialTileSource;
     
    6768    @Override
    6869    protected AbstractTMSTileSource getTileSource(ImageryInfo info) throws IllegalArgumentException {
    69         return getTileSourceStatic(info);
     70        return getTileSourceStatic(info, new Runnable() {
     71            @Override
     72            public void run() {
     73                Main.debug("Attribution loaded, running loadAllErrorTiles");
     74                TMSLayer.this.loadAllErrorTiles(true);
     75            }
     76        });
    7077    }
    7178
     
    97104     */
    98105    public static AbstractTMSTileSource getTileSourceStatic(ImageryInfo info) throws IllegalArgumentException {
     106        return getTileSourceStatic(info, null);
     107    }
     108
     109    /**
     110     * Creates and returns a new TileSource instance depending on the {@link ImageryType}
     111     * of the passed ImageryInfo object.
     112     *
     113     * If no appropriate TileSource is found, null is returned.
     114     * Currently supported ImageryType are {@link ImageryType#TMS},
     115     * {@link ImageryType#BING}, {@link ImageryType#SCANEX}.
     116     *
     117     * @param info imagery info
     118     * @param attributionLoadedTask task to be run once attribution is loaded, might be null, if nothing special shall happen
     119     * @return a new TileSource instance or null if no TileSource for the ImageryInfo/ImageryType could be found.
     120     * @throws IllegalArgumentException if url from imagery info is null or invalid
     121     */
     122    public static AbstractTMSTileSource getTileSourceStatic(ImageryInfo info, Runnable attributionLoadedTask) throws IllegalArgumentException {
    99123        if (info.getImageryType() == ImageryType.TMS) {
    100124            TemplatedTMSTileSource.checkUrl(info.getUrl());
     
    103127            return t;
    104128        } else if (info.getImageryType() == ImageryType.BING)
    105             return new CachedAttributionBingAerialTileSource(info);
     129            return new CachedAttributionBingAerialTileSource(info, attributionLoadedTask);
    106130        else if (info.getImageryType() == ImageryType.SCANEX) {
    107131            return new ScanexTileSource(info);
Note: See TracChangeset for help on using the changeset viewer.