Ignore:
Timestamp:
2009-12-30T16:59:35+01:00 (16 years ago)
Author:
petrdlouhy
Message:

search in cache is not threaded

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

Legend:

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

    r19239 r19240  
    113113        return (int)(Math.random() * ((max+1)-min) ) + min;
    114114    }
     115
     116    abstract public boolean loadFromCache();
    115117}
  • TabularUnified applications/editors/josm/plugins/wmsplugin/src/wmsplugin/HTMLGrabber.java

    r17334 r19240  
    2727        System.out.println("Grabbing HTML " + url);
    2828
    29         BufferedImage cached = cache.getImg(urlstring);
    30         if(cached != null) return cached;
    31 
    3229        ArrayList<String> cmdParams = new ArrayList<String>();
    3330        StringTokenizer st = new StringTokenizer(MessageFormat.format(
  • TabularUnified applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java

    r19239 r19240  
    6666
    6767            if(image.isVisible(mv, layer.getDx(), layer.getDy())) { //don't download, if the image isn't visible already
    68                 BufferedImage img = grab(url);
    69                 if(img == null)return;
    70                 image.image = img;
     68                image.image = grab(url);
    7169                image.flushedResizedCachedInstance();
    7270            }
     
    154152    }
    155153
    156     protected BufferedImage grab(URL url) throws IOException, OsmTransferException {
     154    public boolean loadFromCache(){
     155        URL url = null;
     156        try{
     157           url = getURL(
     158              b.min.east(), b.min.north(),
     159              b.max.east(), b.max.north(),
     160              width(), height());
     161        } catch(Exception e) {
     162           return false;
     163        }
    157164        BufferedImage cached = cache.getImg(url.toString());
    158165        if(!layer.hasAutoDownload() || cached != null){
    159            if(cached == null) grabNotInCache();
    160            return cached;
    161         }
    162 
     166           image.min = b.min;
     167           image.max = b.max;
     168           if(cached == null){
     169              grabNotInCache();
     170              return true;
     171           }
     172           image.image = cached;
     173           image.flushedResizedCachedInstance();
     174           image.downloadingStarted = false;
     175           return true;
     176        }
     177        return false;
     178    }
     179
     180    protected BufferedImage grab(URL url) throws IOException, OsmTransferException {
    163181        System.out.println("Grabbing WMS " + url);
    164182
  • TabularUnified applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java

    r19239 r19240  
    252252                    img.flushedResizedCachedInstance();
    253253                    Grabber gr = WMSPlugin.getGrabber(XYtoBounds(x,y), img, mv, this);
    254                     gr.setPriority(1);
    255                     executor.submit(gr);
     254                    if(!gr.loadFromCache()){
     255                       gr.setPriority(1);
     256                       executor.submit(gr);
     257                    }
    256258                }
    257259            }
Note: See TracChangeset for help on using the changeset viewer.