Changeset 4065 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2011-05-01T21:56:49+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapSlider.java
r3754 r4065 35 35 ProjectionBounds current = this.mv.getProjectionBounds(); 36 36 37 double cur_e = current.max .east()-current.min.east();38 double cur_n = current.max .north()-current.min.north();39 double e = world.max .east()-world.min.east();40 double n = world.max .north()-world.min.north();37 double cur_e = current.maxEast-current.minEast; 38 double cur_n = current.maxNorth-current.minNorth; 39 double e = world.maxEast-world.minEast; 40 double n = world.maxNorth-world.minNorth; 41 41 int zoom = 0; 42 42 … … 59 59 ProjectionBounds world = this.mv.getMaxProjectionBounds(); 60 60 double fact = Math.pow(1.1, getValue()); 61 double es = world.max .east()-world.min.east();62 double n = world.max .north()-world.min.north();61 double es = world.maxEast-world.minEast; 62 double n = world.maxNorth-world.minNorth; 63 63 64 64 this.mv.zoomTo(new ProjectionBounds(this.mv.getCenter(), es/fact, n/fact)); -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r3919 r4065 24 24 25 25 import javax.swing.JComponent; 26 import javax.swing.SwingUtilities;27 26 28 27 import org.openstreetmap.josm.Main; … … 367 366 368 367 /** 369 * Create a thread that moves the viewport to the given center in an 368 * Create a thread that moves the viewport to the given center in an 370 369 * animated fashion. 371 370 */ … … 382 381 383 382 new Thread( 384 new Runnable() { 385 public void run() { 386 for (int i=0; i<frames; i++) 387 { 388 // fixme - not use zoom history here 389 zoomTo(oldCenter.interpolate(finalNewCenter, (double) (i+1) / (double) frames)); 390 try { Thread.sleep(1000 / fps); } catch (InterruptedException ex) { }; 383 new Runnable() { 384 public void run() { 385 for (int i=0; i<frames; i++) 386 { 387 // fixme - not use zoom history here 388 zoomTo(oldCenter.interpolate(finalNewCenter, (i+1) / frames)); 389 try { Thread.sleep(1000 / fps); } catch (InterruptedException ex) { }; 390 } 391 391 } 392 392 } 393 }394 393 ).start(); 395 394 } … … 425 424 } 426 425 427 double scaleX = (box.max .east()-box.min.east())/w;428 double scaleY = (box.max .north()-box.min.north())/h;426 double scaleX = (box.maxEast-box.minEast)/w; 427 double scaleY = (box.maxNorth-box.minNorth)/h; 429 428 double newScale = Math.max(scaleX, scaleY); 430 429 … … 1231 1230 if(Cursors.size() > 0) { 1232 1231 CursorInfo l = Cursors.getLast(); 1233 if(l != null && l.cursor == cursor && l.object == reference) {1232 if(l != null && l.cursor == cursor && l.object == reference) 1234 1233 return; 1235 }1236 1234 stripCursors(reference); 1237 1235 } … … 1253 1251 stripCursors(reference); 1254 1252 if(l != null && l.object == reference) { 1255 if(Cursors.size() == 0) 1253 if(Cursors.size() == 0) { 1256 1254 setCursor(null); 1257 else1255 } else { 1258 1256 setCursor(Cursors.getLast().cursor); 1257 } 1259 1258 } 1260 1259 } … … 1263 1262 LinkedList<CursorInfo> c = new LinkedList<CursorInfo>(); 1264 1263 for(CursorInfo i : Cursors) { 1265 if(i.object != reference) 1264 if(i.object != reference) { 1266 1265 c.add(i); 1266 } 1267 1267 } 1268 1268 Cursors = c; -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r3878 r4065 85 85 if (Main.map == null || Main.map.mapView == null) return Main.proj.getDefaultZoomInPPD(); 86 86 ProjectionBounds bounds = Main.map.mapView.getProjectionBounds(); 87 return Main.map.mapView.getWidth() / (bounds.max .east() - bounds.min.east());87 return Main.map.mapView.getWidth() / (bounds.maxEast - bounds.minEast); 88 88 } 89 89 -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r4043 r4065 16 16 import java.util.ArrayList; 17 17 import java.util.Collections; 18 import java.util.HashSet; 18 19 import java.util.Iterator; 19 20 import java.util.List; 21 import java.util.Set; 20 22 import java.util.concurrent.locks.Condition; 21 23 import java.util.concurrent.locks.Lock; … … 41 43 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 42 44 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; 45 import org.openstreetmap.josm.data.imagery.WmsCache; 43 46 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 44 47 import org.openstreetmap.josm.data.preferences.BooleanProperty; … … 47 50 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 48 51 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 49 import org.openstreetmap.josm.io.CacheFiles;50 52 import org.openstreetmap.josm.io.imagery.Grabber; 51 53 import org.openstreetmap.josm.io.imagery.HTMLGrabber; … … 79 81 protected ImageryInfo info; 80 82 protected final MapView mv; 83 public WmsCache cache; 84 81 85 82 86 // Image index boundary for current view … … 118 122 setBackgroundLayer(true); /* set global background variable */ 119 123 initializeImages(); 124 if (info.getUrl() != null) { 125 for (WMSLayer layer: Main.map.mapView.getLayersOfType(WMSLayer.class)) { 126 if (layer.getInfo().getUrl().equals(info.getUrl())) { 127 cache = layer.cache; 128 break; 129 } 130 } 131 if (cache == null) { 132 cache = new WmsCache(info.getUrl(), imageSize); 133 cache.loadIndex(); 134 } 135 } 120 136 this.info = new ImageryInfo(info); 121 137 if(this.info.getPixelPerDegree() == 0.0) { … … 157 173 cancelGrabberThreads(false); 158 174 Main.pref.removePreferenceChangeListener(this); 175 if (cache != null) { 176 cache.saveIndex(); 177 } 159 178 } 160 179 … … 205 224 206 225 ProjectionBounds bounds = mv.getProjectionBounds(); 207 bminx= getImageXIndex(bounds.min .east());208 bminy= getImageYIndex(bounds.min .north());209 bmaxx= getImageXIndex(bounds.max .east());210 bmaxy= getImageYIndex(bounds.max .north());211 212 leftEdge = (int)(bounds.min .east()* getPPD());213 bottomEdge = (int)(bounds.min .north()* getPPD());226 bminx= getImageXIndex(bounds.minEast); 227 bminy= getImageYIndex(bounds.minNorth); 228 bmaxx= getImageXIndex(bounds.maxEast); 229 bmaxy= getImageYIndex(bounds.maxNorth); 230 231 leftEdge = (int)(bounds.minEast * getPPD()); 232 bottomEdge = (int)(bounds.minNorth * getPPD()); 214 233 215 234 if (zoomIsTooBig()) { 216 for(int x = bminx; x<=bmaxx; ++x) { 217 for(int y = bminy; y<=bmaxy; ++y) { 218 images[modulo(x,dax)][modulo(y,day)].paint(g, mv, x, y, leftEdge, bottomEdge); 235 for(int x = 0; x<images.length; ++x) { 236 for(int y = 0; y<images[0].length; ++y) { 237 GeorefImage image = images[x][y]; 238 image.paint(g, mv, image.getXIndex(), image.getYIndex(), leftEdge, bottomEdge); 219 239 } 220 240 } … … 305 325 } 306 326 327 public boolean isOverlapEnabled() { 328 return WMSLayer.PROP_OVERLAP.get() && (WMSLayer.PROP_OVERLAP_EAST.get() > 0 || WMSLayer.PROP_OVERLAP_NORTH.get() > 0); 329 } 330 307 331 /** 308 332 * … … 310 334 */ 311 335 public BufferedImage normalizeImage(BufferedImage img) { 312 if ( WMSLayer.PROP_OVERLAP.get() && (WMSLayer.PROP_OVERLAP_EAST.get() > 0 || WMSLayer.PROP_OVERLAP_NORTH.get() > 0)) {336 if (isOverlapEnabled()) { 313 337 BufferedImage copy = img; 314 338 img = new BufferedImage(imageSize, imageSize, copy.getType()); … … 357 381 358 382 gatherFinishedRequests(); 383 Set<ProjectionBounds> areaToCache = new HashSet<ProjectionBounds>(); 359 384 360 385 for(int x = bminx; x<=bmaxx; ++x) { … … 362 387 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 363 388 if (!img.paint(g, mv, x, y, leftEdge, bottomEdge)) { 364 WMSRequest request = new WMSRequest(x, y, info.getPixelPerDegree(), real );389 WMSRequest request = new WMSRequest(x, y, info.getPixelPerDegree(), real, true); 365 390 addRequest(request); 366 } 367 } 368 } 391 areaToCache.add(new ProjectionBounds(getEastNorth(x, y), getEastNorth(x + 1, y + 1))); 392 } else if (img.getState() == State.PARTLY_IN_CACHE && autoDownloadEnabled) { 393 WMSRequest request = new WMSRequest(x, y, info.getPixelPerDegree(), real, false); 394 addRequest(request); 395 areaToCache.add(new ProjectionBounds(getEastNorth(x, y), getEastNorth(x + 1, y + 1))); 396 } 397 } 398 } 399 cache.setAreaToCache(areaToCache); 369 400 } 370 401 … … 548 579 @Override 549 580 public void actionPerformed(ActionEvent ev) { 550 initializeImages();551 581 resolution = mv.getDist100PixelText(); 552 582 info.setPixelPerDegree(getPPD()); 553 583 settingsChanged = true; 584 for(int x = 0; x<dax; ++x) { 585 for(int y = 0; y<day; ++y) { 586 images[x][y].changePosition(-1, -1); 587 } 588 } 554 589 mv.repaint(); 555 590 } … … 564 599 // Delete small files, because they're probably blank tiles. 565 600 // See https://josm.openstreetmap.de/ticket/2307 566 Grabber.cache.customCleanUp(CacheFiles.CLEAN_SMALL_FILES,4096);601 cache.cleanSmallFiles(4096); 567 602 568 603 for (int x = 0; x < dax; ++x) { … … 570 605 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 571 606 if(img.getState() == State.FAILED){ 572 addRequest(new WMSRequest(img.getXIndex(), img.getYIndex(), info.getPixelPerDegree(), true)); 573 mv.repaint(); 607 addRequest(new WMSRequest(img.getXIndex(), img.getYIndex(), info.getPixelPerDegree(), true, false)); 574 608 } 575 609 } … … 680 714 settingsChanged = true; 681 715 mv.repaint(); 716 if (cache != null) { 717 cache.saveIndex(); 718 cache = null; 719 } 682 720 if(info.getUrl() != null) 683 721 { 722 cache = new WmsCache(info.getUrl(), imageSize); 684 723 startGrabberThreads(); 685 724 } … … 737 776 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 738 777 if(img.getState() == State.NOT_IN_CACHE){ 739 addRequest(new WMSRequest(img.getXIndex(), img.getYIndex(), info.getPixelPerDegree(), false ));778 addRequest(new WMSRequest(img.getXIndex(), img.getYIndex(), info.getPixelPerDegree(), false, true)); 740 779 } 741 780 }
Note:
See TracChangeset
for help on using the changeset viewer.