Changeset 10683 in osm for applications/editors/josm/plugins/wmsplugin/src
- Timestamp:
- 2008-09-14T14:45:39+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/wmsplugin/src/wmsplugin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java
r10382 r10683 1 1 package wmsplugin; 2 import java.io.IOException;3 import org.openstreetmap.josm.data.Bounds;4 import org.openstreetmap.josm.data.projection.Projection;5 import java.util.ArrayList;6 import org.openstreetmap.josm.gui.MapView;7 2 8 public interface Grabber {9 public void start();3 public interface Grabber extends Runnable { 4 10 5 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java
r10382 r10683 24 24 25 25 26 public class WMSGrabber extends Thread implements Grabber{26 public class WMSGrabber implements Grabber { 27 27 protected String baseURL; 28 28 … … 43 43 mv = _mv; 44 44 layer = _layer; 45 this.setDaemon(true);46 this.setPriority(Thread.MIN_PRIORITY);47 45 } 48 46 … … 92 90 93 91 protected BufferedImage grab(URL url) throws IOException { 94 InputStream is = new ProgressInputStream( 95 url.openConnection(), null); 96 BufferedImage img; 97 synchronized (layer){ //download only one tile in one moment 98 if(!image.isVisible(mv)){ 99 return null; 100 } 101 img = ImageIO.read(is); 102 } 103 is.close(); 104 return img; 92 InputStream is = new ProgressInputStream( 93 url.openConnection(), null); 94 if(!image.isVisible(mv)) 95 return null; 96 BufferedImage img = ImageIO.read(is); 97 is.close(); 98 return img; 105 99 } 106 100 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
r10646 r10683 36 36 import org.openstreetmap.josm.gui.MapView; 37 37 import java.util.ArrayList; 38 import java.util.concurrent.ExecutorService; 39 import java.util.concurrent.Executors; 40 38 41 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 39 42 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; … … 63 66 protected String baseURL; 64 67 protected final int serializeFormatVersion = 3; 68 69 private ExecutorService executor; 65 70 66 71 public WMSLayer() { … … 73 78 initializeImages(); 74 79 this.baseURL = baseURL; 80 81 executor = Executors.newFixedThreadPool(3); 75 82 } 76 83 … … 147 154 img.image = null; 148 155 Grabber gr = WMSPlugin.getGrabber(baseURL, XYtoBounds(x,y), Main.main.proj, pixelPerDegree, img, mv, this); 149 gr.start();156 executor.submit(gr); 150 157 } 151 158 } … … 160 167 for(int x = 0; x<dax; ++x) 161 168 for(int y = 0; y<day; ++y) 162 163 164 165 169 if(images[x][y]!=null){ 170 v.visit(images[x][y].min); 171 v.visit(images[x][y].max); 172 } 166 173 } 167 174 -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/YAHOOGrabber.java
r10382 r10683 34 34 35 35 36 public class YAHOOGrabber extends Threadimplements Grabber{36 public class YAHOOGrabber implements Grabber{ 37 37 protected String baseURL; 38 38 protected String browserCmd; … … 56 56 this.mv = _mv; 57 57 this.layer = _layer; 58 this.setDaemon(true);59 this.setPriority(Thread.MIN_PRIORITY);60 58 } 61 59 … … 74 72 image.min = proj.latlon2eastNorth(b.min); 75 73 image.max = proj.latlon2eastNorth(b.max); 76 synchronized (layer) { 77 if(!image.isVisible(mv)){ 78 image.downloadingStarted = false; 79 return; 80 } 81 Process browser = browse(url.toString());; 82 image.image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 83 img = ImageIO.read(browser.getInputStream()).getScaledInstance(width, height, Image.SCALE_FAST); 74 if(!image.isVisible(mv)){ //don't download, if the image isn't visible already 75 image.downloadingStarted = false; 76 return; 84 77 } 78 Process browser = browse(url.toString());; 79 image.image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 80 img = ImageIO.read(browser.getInputStream()).getScaledInstance(width, height, Image.SCALE_FAST); 85 81 image.image.getGraphics().drawImage(img, 0 , 0, null); 86 82
Note:
See TracChangeset
for help on using the changeset viewer.