Changeset 10706 in osm for applications/editors/josm/plugins/wmsplugin/src
- Timestamp:
- 2008-09-15T13:40:46+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
r10705 r10706 130 130 } 131 131 132 protected Bounds bounds(){ 133 return new Bounds( 134 mv.getLatLon(0, mv.getHeight()), 135 mv.getLatLon(mv.getWidth(), 0)); 136 } 137 132 138 @Override public void paint(Graphics g, final MapView mv) { 133 139 if(baseURL == null) return; 134 Bounds b = new Bounds( 135 mv.getLatLon(0, mv.getHeight()), 136 mv.getLatLon(mv.getWidth(), 0)); 137 int bminx= (int)Math.floor ((b.min.lat() * pixelPerDegree ) / ImageSize ); 138 int bminy= (int)Math.floor ((b.min.lon() * pixelPerDegree ) / ImageSize ); 139 int bmaxx= (int)Math.ceil ((b.max.lat() * pixelPerDegree ) / ImageSize ); 140 int bmaxy= (int)Math.ceil ((b.max.lon() * pixelPerDegree ) / ImageSize ); 141 142 143 if( !startstop.isSelected() || (pixelPerDegree / (mv.getWidth() / (b.max.lon() - b.min.lon())) > minZoom) ){ //don't download when it's too outzoomed 140 141 if( !startstop.isSelected() || (pixelPerDegree / (mv.getWidth() / (bounds().max.lon() - bounds().min.lon())) > minZoom) ){ //don't download when it's too outzoomed 144 142 for(int x = 0; x<dax; ++x) 145 143 for(int y = 0; y<day; ++y) 146 144 images[modulo(x,dax)][modulo(y,day)].paint(g, mv); 147 } else { 148 for(int x = bminx; x<bmaxx; ++x) 149 for(int y = bminy; y<bmaxy; ++y){ 150 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 151 if(!img.paint(g, mv) && !img.downloadingStarted){ 152 //System.out.println(tr("------{0}|{1}|{2}|{3}", modulo(x,dax), modulo(y,day), img.downloadingStarted, img.isVisible(mv))); 153 img.downloadingStarted = true; 154 img.image = null; 155 Grabber gr = WMSPlugin.getGrabber(baseURL, XYtoBounds(x,y), Main.main.proj, pixelPerDegree, img, mv, this); 156 executor.submit(gr); 157 } 145 } else 146 downloadAndPaintVisible(g, mv); 147 } 148 149 protected void downloadAndPaintVisible(Graphics g, final MapView mv){ 150 int bminx= (int)Math.floor ((bounds().min.lat() * pixelPerDegree ) / ImageSize ); 151 int bminy= (int)Math.floor ((bounds().min.lon() * pixelPerDegree ) / ImageSize ); 152 int bmaxx= (int)Math.ceil ((bounds().max.lat() * pixelPerDegree ) / ImageSize ); 153 int bmaxy= (int)Math.ceil ((bounds().max.lon() * pixelPerDegree ) / ImageSize ); 154 155 if((bmaxx - bminx > dax) || (bmaxy - bminy > day)){ 156 JOptionPane.showMessageDialog(Main.parent, tr("The requested area is too big. Please zoom in a little, or change resolution")); 157 return; 158 } 159 160 for(int x = bminx; x<bmaxx; ++x) 161 for(int y = bminy; y<bmaxy; ++y){ 162 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 163 if(!img.paint(g, mv) && !img.downloadingStarted){ 164 //System.out.println(tr("------{0}|{1}|{2}|{3}", modulo(x,dax), modulo(y,day), img.downloadingStarted, img.isVisible(mv))); 165 img.downloadingStarted = true; 166 img.image = null; 167 Grabber gr = WMSPlugin.getGrabber(baseURL, XYtoBounds(x,y), Main.main.proj, pixelPerDegree, img, mv, this); 168 executor.submit(gr); 158 169 } 159 170 } … … 183 194 startstop, 184 195 new JMenuItem(new changeResolutionAction()), 196 new JMenuItem(new downloadAction()), 185 197 new JSeparator(), 186 198 new JMenuItem(new LayerListPopup.InfoAction(this)) … … 195 207 return images[x][y]; 196 208 return null; 209 } 210 211 public class downloadAction extends AbstractAction { 212 public downloadAction() { 213 super(tr("Download visible tiles")); 214 } 215 public void actionPerformed(ActionEvent ev) { 216 downloadAndPaintVisible(mv.getGraphics(), mv); 217 } 197 218 } 198 219
Note:
See TracChangeset
for help on using the changeset viewer.