예제 #1
0
 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();
 }
예제 #2
0
 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();
 }
예제 #3
0
  public JGeoPane(
      MapContent aContext,
      MapContent aLightweightContext,
      MapContent aScreenContext,
      boolean aAsync) {
    super();
    setLayout(new GeoLayout());
    screenContext = aScreenContext;
    cartesian2Screen = new AffineTransform();
    if (aAsync) {
      cacheLock = new ReentrantReadWriteLock();
      lightweightCacheLock = new ReentrantReadWriteLock();

      cache = new AsyncMapTilesCache(aContext, cacheLock, cartesian2Screen);
      lightweightCache =
          new AsyncMapTilesCache(aLightweightContext, lightweightCacheLock, cartesian2Screen);
      ((AsyncMapTilesCache) cache).addRenderingTaskListener(new TileRenderedRepainter());
      if (lightweightCache instanceof AsyncMapTilesCache) {
        ((AsyncMapTilesCache) lightweightCache)
            .addRenderingTaskListener(new TileRenderedRepainter());
      }
    } else {
      cache = new SyncMapTilesCache(aContext, cartesian2Screen);
      lightweightCache = new SyncMapTilesCache(aLightweightContext, cartesian2Screen);
    }
    cache.setBackground(getBackground());
    lightweightCache.setImageType(BufferedImage.TYPE_INT_ARGB);
    addLayersListeners();
  }