public void setBackingUrl(String aBackingUrl) { String oldBackingUrl = getBackingUrl(); if (oldBackingUrl == null) { oldBackingUrl = ""; } if (aBackingUrl == null) { aBackingUrl = ""; } if (!oldBackingUrl.equals(aBackingUrl)) { removeLayersListeners(); MapContent generalMapContext = getGeneralMapContext(); assert cache instanceof AsyncMapTilesCache; ((AsyncMapTilesCache) cache).shutdown(); if (aBackingUrl.isEmpty()) { cache = new AsyncMapTilesCache(generalMapContext, cacheLock, cartesian2Screen); } else { cache = GeoPaneUtils.createWebTilesCache( generalMapContext, cacheLock, cartesian2Screen, aBackingUrl); } cache.setBackground(getBackground()); ((AsyncMapTilesCache) cache).addRenderingTaskListener(new TileRenderedRepainter()); cache.scaleChanged(); lightweightCache.scaleChanged(); addLayersListeners(); } repaint(); }
public JGeoPane( MapContent aContext, MapContent aLightweightContext, MapContent aScreenContext, String aBackingUrl) { super(); setLayout(new GeoLayout()); screenContext = aScreenContext; cartesian2Screen = new AffineTransform(); cacheLock = new ReentrantReadWriteLock(); lightweightCacheLock = new ReentrantReadWriteLock(); if (aBackingUrl != null && !aBackingUrl.isEmpty()) { cache = GeoPaneUtils.createWebTilesCache(aContext, cacheLock, cartesian2Screen, aBackingUrl); lightweightCache = new AsyncMapTilesCache(aLightweightContext, lightweightCacheLock, cartesian2Screen); } else { cache = new AsyncMapTilesCache(aContext, cacheLock, cartesian2Screen); lightweightCache = new AsyncMapTilesCache(aLightweightContext, lightweightCacheLock, cartesian2Screen); } assert cache instanceof AsyncMapTilesCache; ((AsyncMapTilesCache) cache).addRenderingTaskListener(new TileRenderedRepainter()); if (lightweightCache instanceof AsyncMapTilesCache) { ((AsyncMapTilesCache) lightweightCache).addRenderingTaskListener(new TileRenderedRepainter()); } cache.setBackground(getBackground()); lightweightCache.setImageType(BufferedImage.TYPE_INT_ARGB); addLayersListeners(); }