Changeset 16153 in osm for applications/editors/josm/plugins/slippymap/src
- Timestamp:
- 2009-06-26T20:27:43+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapKey.java
r14732 r16153 12 12 * @author LuVar <lubomir.varga@freemap.sk> 13 13 * @author Dave Hansen <dave@sr71.net> 14 * @author Dave Hansen <dave@linux.vnet.ibm.com> 14 15 * 15 16 */ … … 29 30 */ 30 31 public final boolean valid; 31 public SlippyMapKey(int level, int x, int y) {32 public SlippyMapKey(int x, int y, int level) { 32 33 this.x = x; 33 34 this.y = y; -
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java
r15707 r16153 40 40 * @author LuVar <lubomir.varga@freemap.sk> 41 41 * @author Dave Hansen <dave@sr71.net> 42 * 42 * @author Dave Hansen <dave@linux.vnet.ibm.com> 43 * 43 44 */ 44 45 public class SlippyMapLayer extends Layer implements ImageObserver, … … 279 280 for (int x = z12x0 - 1; x <= z12x1; x++) { 280 281 for (int y = z12y0 - 1; y <= z12y1; y++) { 281 SlippyMapKey key = new SlippyMapKey( currentZoomLevel, x, y);282 SlippyMapKey key = new SlippyMapKey(x, y, currentZoomLevel); 282 283 SlippyMapTile tile = tileStorage.get(key); 283 284 if (!key.valid) { … … 295 296 } 296 297 297 /* 298 * Attempt to approximate how much the image is 299 * being scaled. For instance, a 100x100 image 300 * being scaled to 50x50 would return 0.25. 301 */ 302 double getImageScaling(Image img, Point p0, Point p1) 303 { 304 int realWidth = img.getWidth(this); 305 int realHeight = img.getHeight(this); 306 if (realWidth == -1 || realHeight == -1) 307 return 1.0; 308 int drawWidth = p1.x - p0.x; 309 int drawHeight = p1.x - p0.x; 310 311 double drawArea = drawWidth * drawHeight; 298 /* 299 * Attempt to approximate how much the image is being scaled. For instance, 300 * a 100x100 image being scaled to 50x50 would return 0.25. 301 */ 302 Image lastScaledImage = null; 303 304 double getImageScaling(Image img, Point p0, Point p1) { 305 int realWidth = img.getWidth(this); 306 int realHeight = img.getHeight(this); 307 if (realWidth == -1 || realHeight == -1) { 308 /* 309 * We need a good image against which to work. If 310 * the current one isn't loaded, then try the last one. 311 * Should be good enough. If we've never seen one, then 312 * guess. 313 */ 314 if (lastScaledImage != null) { 315 return getImageScaling(lastScaledImage, p0, p1); 316 } 317 realWidth = 256; 318 realHeight = 256; 319 } else { 320 lastScaledImage = img; 321 } 322 /* 323 * If the zoom scale gets really, really off, these can get into 324 * the millions, so make this a double to prevent integer 325 * overflows. 326 */ 327 double drawWidth = p1.x - p0.x; 328 double drawHeight = p1.x - p0.x; 329 // stem.out.println("drawWidth: " + drawWidth + " drawHeight: " + 330 // drawHeight); 331 332 double drawArea = drawWidth * drawHeight; 312 333 double realArea = realWidth * realHeight; 313 334 … … 384 405 for (int x = z12x0 - 1; x <= z12x1; x++) { 385 406 for (int y = z12y0 - 1; y <= z12y1; y++) { 386 SlippyMapKey key = new SlippyMapKey( currentZoomLevel, x, y);407 SlippyMapKey key = new SlippyMapKey(x, y, currentZoomLevel); 387 408 SlippyMapTile tile; 388 409 tile = tileStorage.get(key); … … 532 553 } 533 554 534 SlippyMapKey key = new SlippyMapKey( currentZoomLevel, tilex, tiley);555 SlippyMapKey key = new SlippyMapKey(tilex, tiley, currentZoomLevel); 535 556 if (!key.valid) { 536 557 System.err.println("getTileForPixelpos("+px+","+py+") made invalid key"); … … 561 582 new JSeparator(), 562 583 // color, 563 new JMenuItem(new RenameLayerAction( getAssociatedFile(), this)),584 new JMenuItem(new RenameLayerAction(this.getAssociatedFile(), this)), 564 585 new JSeparator(), 565 586 new JMenuItem(new LayerListPopup.InfoAction(this)) }; -
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapTile.java
r14732 r16153 17 17 * @author LuVar <lubomir.varga@freemap.sk> 18 18 * @author Dave Hansen <dave@sr71.net> 19 * @author Dave Hansen <dave@linux.vnet.ibm.com> 19 20 * 20 21 */ … … 22 23 { 23 24 private Image tileImage; 24 long timestamp;25 private long timestamp; 25 26 26 int x; 27 int y; 28 int z; 27 private int x; 28 private int y; 29 private int z; 30 31 private boolean imageDownloaded = false; 29 32 30 33 private String metadata; … … 65 68 } 66 69 70 public Image getImageNoTimestamp() { 71 return tileImage; 72 } 73 67 74 public Image getImage() 68 75 { … … 71 78 } 72 79 80 public int getZoom() { 81 return z; 82 } 83 73 84 public void dropImage() 74 85 { 86 if(tileImage != null) { 87 tileImage.flush(); 88 } 75 89 tileImage = null; 76 90 // This should work in theory but doesn't seem to actually 77 91 // reduce the X server memory usage 78 92 //tileImage.flush(); 93 } 94 95 public void markAsDownloaded() { 96 imageDownloaded = true; 97 } 98 99 public boolean isDownloaded() { 100 return imageDownloaded; 101 } 102 103 public void abortDownload() { 104 if (imageDownloaded) { 105 return; 106 } 107 dropImage(); 79 108 } 80 109
Note:
See TracChangeset
for help on using the changeset viewer.