Changeset 7343 in osm for applications/editors/josm
- Timestamp:
- 2008-04-12T15:59:42+02:00 (17 years ago)
- Location:
- applications/editors/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippy_map_chooser/src/OsmMapControl.java
r7199 r7343 166 166 } 167 167 else if(e.getClickCount() == 2){ 168 iSlippyMapChooser.zoomIn(e.getPoint()); 168 169 iSlippyMapChooser.centerOnScreenPoint(e.getPoint()); 169 iSlippyMapChooser.zoomIn();170 170 } 171 171 } … … 209 209 //scroll wheel rotated away from user 210 210 if(rot < 0){ 211 iSlippyMapChooser.zoomIn( );211 iSlippyMapChooser.zoomIn(e.getPoint()); 212 212 } 213 213 //scroll wheel rotated towards the user 214 214 else if(rot > 0){ 215 iSlippyMapChooser.zoomOut( );215 iSlippyMapChooser.zoomOut(e.getPoint()); 216 216 } 217 217 } -
applications/editors/josm/plugins/slippy_map_chooser/src/OsmTile.java
r7199 r7343 1 1 // License: GPL. Copyright 2007 by Tim Haussmann 2 2 3 import java.awt.geom.AffineTransform; 3 4 import java.awt.image.BufferedImage; 4 5 import java.awt.Color; 5 6 import java.awt.Graphics; 7 import java.awt.Graphics2D; 8 import java.awt.RenderingHints; 9 import java.awt.Shape; 6 10 7 11 /** … … 48 52 } 49 53 50 public void paint(Graphics g ){54 public void paint(Graphics g,TileDB db){ 51 55 52 56 if(iMapImage != null && ! isInvalid){ … … 57 61 } 58 62 else{ 59 g.setColor(Color.RED); 60 g.drawLine(iX, iY, iX+WIDTH-1, iY+HEIGHT-1); 61 g.drawLine(iX, iY+HEIGHT-1, iX+WIDTH-1, iY); 62 g.drawRect(iX, iY, WIDTH-1, HEIGHT-1); 63 // first try to interpolate tile from parent 64 OsmTile parent = getParent(db); 65 if (parent!=null){ 66 Graphics2D g2d = (Graphics2D) g; 67 AffineTransform oldTr = g2d.getTransform(); 68 Shape oldClip = g2d.getClip(); 69 g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); 70 71 // since the parent will paint 4 tiles in the 72 // current zoom level we have to clip the drawing 73 // region to the current tile 74 g2d.clipRect(iX, iY, WIDTH, HEIGHT); 75 g2d.scale(2, 2); 76 parent.paint(g,db); 77 78 g2d.setTransform(oldTr); 79 g2d.setClip(oldClip); 80 } 81 else{ 82 // otherwise draw placeholder 83 g.setColor(Color.RED); 84 g.drawLine(iX, iY, iX+WIDTH-1, iY+HEIGHT-1); 85 g.drawLine(iX, iY+HEIGHT-1, iX+WIDTH-1, iY); 86 g.drawRect(iX, iY, WIDTH-1, HEIGHT-1); 87 } 63 88 } 64 89 } … … 93 118 } 94 119 120 public OsmTile getParent(TileDB db){ 121 return iZoomLevel == 0 ? null : db.get(parentKey()); 122 } 123 124 public String parentKey() { 125 return key(iZoomLevel - 1,iIndexX/2,iIndexY/2); 126 } 95 127 } -
applications/editors/josm/plugins/slippy_map_chooser/src/SlippyMapChooser.java
r7199 r7343 185 185 OsmTile t = iTileDB.get(OsmTile.key(iZoomlevel, (-iOffsetX + x*OsmTile.WIDTH)/OsmTile.WIDTH, ((-iOffsetY+ y*OsmTile.HEIGHT)/OsmTile.HEIGHT))); 186 186 if(t != null){ 187 t.paint(g );187 t.paint(g,iTileDB); 188 188 } 189 189 } … … 204 204 205 205 iSizeButton.paint(g); 206 207 208 if(SlippyMapChooserPlugin.DEBUG_MODE){ 209 g.setColor(Color.black); 210 g.drawString("Free Memory: " + Runtime.getRuntime().freeMemory()/1024 + "/" + Runtime.getRuntime().totalMemory()/1024 + "kB" , 5, 50); 211 g.drawString("Tiles in DB: " + iTileDB.getCachedTilesSize(), 5, 65); 212 g.drawString("Loading Queue Size: " + iTileDB.getLoadingQueueSize(), 5, 80); 213 214 } 206 215 } 207 216 … … 356 365 * Callback for OsmMapControl. Zoom out one level 357 366 */ 358 void zoomIn( ){367 void zoomIn(Point curPos){ 359 368 360 369 //cache center of screen and the selection rectangle 361 LatLon l = getLatLonOfScreenPoint( new Point(getWidth()/2, getHeight()/2));370 LatLon l = getLatLonOfScreenPoint(curPos); 362 371 LatLon selStart = null; 363 372 LatLon selEnd = null; … … 374 383 } 375 384 376 //center on cached location 377 centerOnLatLon(l); 385 setLatLonAtPoint(l, curPos); 378 386 379 387 //restore selection … … 394 402 * Callback for OsmMapControl. 395 403 */ 396 void zoomOut( ){404 void zoomOut(Point curPos){ 397 405 //cache center of screen and the selction rect 398 LatLon l = getLatLonOfScreenPoint( new Point(getWidth()/2, getHeight()/2));406 LatLon l = getLatLonOfScreenPoint(curPos); 399 407 LatLon selStart = null; 400 408 LatLon selEnd = null; … … 411 419 } 412 420 413 //center on cached location 414 centerOnLatLon(l); 421 setLatLonAtPoint(l, curPos); 415 422 416 423 //restore selection … … 485 492 * @param aLatLon the location to center on 486 493 */ 487 private void centerOnLatLon(LatLon aLatLon){ 494 private void centerOnLatLon(LatLon aLatLon){ 495 setLatLonAtPoint(aLatLon, new Point(getWidth()/2,getHeight()/2)); 496 } 497 498 /** 499 * Moves the map that the specified latLon is shown at the point on screen 500 * given 501 * @param aLatLon a position 502 * @param p a point on the screen 503 */ 504 private void setLatLonAtPoint(LatLon aLatLon, Point p){ 488 505 int x = OsmMercator.LonToX(aLatLon.lon(), iZoomlevel); 489 506 int y = OsmMercator.LatToY(aLatLon.lat(), iZoomlevel); 490 iOffsetX = - x +getWidth()/2;491 iOffsetY = - y +getHeight()/2;507 iOffsetX = - x + p.x; 508 iOffsetY = - y + p.y; 492 509 repaint(); 493 510 } -
applications/editors/josm/plugins/slippy_map_chooser/src/SlippyMapChooserPlugin.java
r7199 r7343 18 18 private static final String KEY_MAX_TILES_IN_DB = "slippy_map_chooser.max_tiles"; 19 19 private static final String KEY_MAX_TILES_REDUCE_BY = "slippy_map_chooser.max_tiles_reduce_by"; 20 public static boolean DEBUG_MODE = false; 20 21 21 static int MAX_TILES_IN_DB = 1000; 22 static int MAX_TILES_REDUCE_BY = 100; 22 23 static int MAX_TILES_IN_DB = 200; 24 static int MAX_TILES_REDUCE_BY = 40; 23 25 24 26 public SlippyMapChooserPlugin(){ … … 74 76 } 75 77 76 77 78 79 78 }
Note:
See TracChangeset
for help on using the changeset viewer.