Changeset 19239 in osm for applications


Ignore:
Timestamp:
2009-12-30T14:16:56+01:00 (15 years ago)
Author:
petrdlouhy
Message:

Improvements to offline usability:

fix bookmarks
grab tiles from cache, while in not automatic downloading mode
show which tiles are not in cache

Location:
applications/editors/josm/plugins/wmsplugin/src/wmsplugin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java

    r18942 r19239  
    7373        image.flushedResizedCachedInstance();
    7474        image.failed = true;
     75        image.downloadingStarted = false;
     76        g.setFont(font);
     77    }
     78
     79    protected void grabNotInCache(){ // report not in cache
     80        BufferedImage img = new BufferedImage(width(), height(), BufferedImage.TYPE_INT_ARGB);
     81        Graphics g = img.getGraphics();
     82        g.setColor(Color.GRAY);
     83        g.fillRect(0, 0, width(), height());
     84        Font font = g.getFont();
     85        Font tempFont = font.deriveFont(Font.PLAIN).deriveFont(36.0f);
     86        g.setFont(tempFont);
     87        g.setColor(Color.BLACK);
     88        g.drawString(tr("Not in cache"), 10, height()/2);
     89        image.image = img;
     90        image.flushedResizedCachedInstance();
     91        image.failed = true;
     92        image.downloadingStarted = false;
    7593        g.setFont(font);
    7694    }
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java

    r18761 r19239  
    6666
    6767            if(image.isVisible(mv, layer.getDx(), layer.getDy())) { //don't download, if the image isn't visible already
    68                 image.image = grab(url);
     68                BufferedImage img = grab(url);
     69                if(img == null)return;
     70                image.image = img;
    6971                image.flushedResizedCachedInstance();
    7072            }
     
    154156    protected BufferedImage grab(URL url) throws IOException, OsmTransferException {
    155157        BufferedImage cached = cache.getImg(url.toString());
    156         if(cached != null) return cached;
     158        if(!layer.hasAutoDownload() || cached != null){
     159           if(cached == null) grabNotInCache();
     160           return cached;
     161        }
    157162
    158163        System.out.println("Grabbing WMS " + url);
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java

    r18949 r19239  
    9696        }
    9797        resolution = mv.getDist100PixelText();
    98         pixelPerDegree = getPPD();
    9998
    10099        executor = Executors.newFixedThreadPool(3);
     
    113112    }
    114113
     114    public boolean hasAutoDownload(){
     115        return startstop.isSelected();
     116    }
     117
    115118    public double getDx(){
    116119        return dx;
     
    177180        if (usesInvalidUrl && !isInvalidUrlConfirmed) return;
    178181
    179         if( !startstop.isSelected() || (pixelPerDegree / getPPD() > minZoom) ){ //don't download when it's too outzoomed
     182        if(pixelPerDegree / getPPD() > minZoom){ //don't download when it's too outzoomed
    180183            for(int x = 0; x<dax; ++x) {
    181184                for(int y = 0; y<day; ++y) {
     
    461464            }
    462465            Main.pref.put("wmsplugin.url."+ i +".url",baseURL );
    463             Main.pref.put("wmsplugin.url."+String.valueOf(i)+".name", baseName + "#" + getPPD() );
     466            Main.pref.put("wmsplugin.url."+String.valueOf(i)+".name", baseName + "#PPD=" + getPPD() );
    464467            WMSPlugin.refreshMenu();
    465468        }
Note: See TracChangeset for help on using the changeset viewer.