Changeset 15185 in osm for applications


Ignore:
Timestamp:
2009-05-23T11:58:07+02:00 (15 years ago)
Author:
stoecker
Message:

use JOSM's new cache methods - patch by xeen

Location:
applications/editors/josm/plugins/wmsplugin
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/build.xml

    r14120 r15185  
    2929                <attribute name="Plugin-Description" value="Display georeferenced images as background in JOSM (WMS servers, Yahoo, ...)."/>
    3030                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/WMSPlugin"/>
    31                 <attribute name="Plugin-Mainversion" value="1498"/>
     31                <attribute name="Plugin-Mainversion" value="1610"/>
    3232                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    3333                <attribute name="de_Plugin-Link" value="http://wiki.openstreetmap.org/wiki/DE:JOSM/Plugins/WMSPlugin"/>
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java

    r15091 r15185  
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     4
     5import java.awt.image.BufferedImage;
     6import java.awt.Graphics;
     7import java.awt.Color;
     8import java.awt.Font;
    49
    510import org.openstreetmap.josm.data.Bounds;
     
    712import org.openstreetmap.josm.gui.MapView;
    813import org.openstreetmap.josm.Main;
    9 import java.awt.image.BufferedImage;
    10 import java.awt.Graphics;
    11 import java.awt.Color;
    12 import java.awt.Font;
    13 import javax.swing.JOptionPane;
    1414import org.openstreetmap.josm.data.coor.LatLon;
     15import org.openstreetmap.josm.io.CacheFiles;
    1516
    1617abstract public class Grabber implements Runnable {
     
    2122    protected WMSLayer layer;
    2223    protected GeorefImage image;
     24    protected CacheFiles cache;
    2325
    2426    Grabber(Bounds b, Projection proj, double pixelPerDegree, GeorefImage image,
    25     MapView mv, WMSLayer layer)
     27    MapView mv, WMSLayer layer, CacheFiles cache)
    2628    {
    2729        if (b.min != null && b.max != null && WMSPlugin.doOverlap)
     
    4951        this.mv = mv;
    5052        this.layer = layer;
     53        this.cache = cache;
    5154    }
    5255
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java

    r14110 r15185  
    2828import org.openstreetmap.josm.data.projection.Projection;
    2929import org.openstreetmap.josm.gui.MapView;
     30import org.openstreetmap.josm.io.CacheFiles;
    3031import org.openstreetmap.josm.io.ProgressInputStream;
    3132
     
    3334public class WMSGrabber extends Grabber {
    3435    protected String baseURL;
    35     protected Cache cache = new wmsplugin.Cache();
    3636    private static Boolean shownWarning = false;
    3737    private boolean urlWithPatterns;
    3838
    3939    WMSGrabber(String baseURL, Bounds b, Projection proj,
    40             double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
    41         super(b, proj, pixelPerDegree, image, mv, layer);
     40            double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) {
     41        super(b, proj, pixelPerDegree, image, mv, layer, cache);
    4242        this.baseURL = baseURL;
    4343        /* URL containing placeholders? */
     
    147147        is.close();
    148148       
    149         return cache.saveImg(url.toString(), img, true);
     149        cache.saveImg(url.toString(), img);
     150        return img;
    150151    }
    151152
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java

    r15091 r15185  
    255255            // Delete small files, because they're probably blank tiles.
    256256            // See https://josm.openstreetmap.de/ticket/2307
    257             new wmsplugin.Cache().deleteSmallFiles(2048);
     257            WMSPlugin.cache.customCleanUp(WMSPlugin.cache.CLEAN_SMALL_FILES, 2048);
    258258
    259259            for (int x = 0; x < dax; ++x) {
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java

    r15091 r15185  
    2424import org.openstreetmap.josm.gui.IconToggleButton;
    2525import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     26import org.openstreetmap.josm.io.CacheFiles;
    2627import org.openstreetmap.josm.io.MirroredInputStream;
    2728import org.openstreetmap.josm.actions.JosmAction;
     
    3132
    3233public class WMSPlugin extends Plugin {
     34    static CacheFiles cache = new CacheFiles("wmsplugin");
    3335
    3436    WMSLayer wmsLayer;
     
    5456        }
    5557        refreshMenu();
     58        cache.setExpire(cache.EXPIRE_MONTHLY, false);
     59        cache.setMaxSize(70, false);
    5660    }
    5761
     
    199203                     double _pixelPerDegree, GeorefImage _image, MapView _mv, WMSLayer _layer){
    200204        if(_baseURL.startsWith("yahoo://"))
    201             return new YAHOOGrabber(_baseURL, _b, _proj, _pixelPerDegree, _image, _mv, _layer);
     205            return new YAHOOGrabber(_baseURL, _b, _proj, _pixelPerDegree, _image, _mv, _layer, cache);
    202206        else
    203             return new WMSGrabber(_baseURL, _b, _proj, _pixelPerDegree, _image, _mv, _layer);
     207            return new WMSGrabber(_baseURL, _b, _proj, _pixelPerDegree, _image, _mv, _layer, cache);
    204208        // OSBGrabber should be rewrite for thread support first
    205209        //if (wmsurl.matches("(?i).*layers=npeoocmap.*") || wmsurl.matches("(?i).*layers=npe.*") ){
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/YAHOOGrabber.java

    r13645 r15185  
    1616import org.openstreetmap.josm.data.Bounds;
    1717import org.openstreetmap.josm.data.projection.Projection;
     18import org.openstreetmap.josm.io.CacheFiles;
    1819import org.openstreetmap.josm.gui.MapView;
    1920
    2021
    21 public class YAHOOGrabber extends WMSGrabber{
     22public class YAHOOGrabber extends WMSGrabber {
    2223    protected String browserCmd;
    23     protected Cache cache = new wmsplugin.Cache();
    2424
    2525    YAHOOGrabber(String baseURL, Bounds b, Projection proj,
    26             double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
     26            double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) {
    2727        super("file:///" + WMSPlugin.getPrefsPath() + "ymap.html?"
    28         , b, proj, pixelPerDegree, image, mv, layer);
     28        , b, proj, pixelPerDegree, image, mv, layer, cache);
    2929        this.browserCmd = baseURL.replaceFirst("yahoo://", "");
    3030    }
     
    5353            throw new IOException( "Could not start browser. Please check that the executable path is correct.\n" + ioe.getMessage() );
    5454        }
    55 
    56         return cache.saveImg(urlstring, ImageIO.read(browser.getInputStream()), true);
     55       
     56        BufferedImage img = ImageIO.read(browser.getInputStream());
     57        cache.saveImg(urlstring, img);
     58        return img;
    5759    }
    5860}
Note: See TracChangeset for help on using the changeset viewer.