- Timestamp:
- 2011-01-04T16:10:43+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r3740 r3773 17 17 import java.awt.font.TextAttribute; 18 18 import java.awt.geom.Rectangle2D; 19 import java.awt.image.BufferedImage;20 19 import java.awt.image.ImageObserver; 21 20 import java.io.IOException; … … 76 75 public static final int MAX_ZOOM = 30; 77 76 public static final int MIN_ZOOM = 2; 78 public static final int DEFAULT_MAX_ZOOM = 18;77 public static final int DEFAULT_MAX_ZOOM = 20; 79 78 public static final int DEFAULT_MIN_ZOOM = 2; 80 79 … … 101 100 public synchronized void tileLoadingFinished(Tile tile, boolean success) 102 101 { 103 if (!success) { 104 BufferedImage img = new BufferedImage(tileSource.getTileSize(),tileSource.getTileSize(), BufferedImage.TYPE_INT_RGB); 105 drawErrorTile(img); 106 tile.setImage(img); 102 if (tile.hasError()) { 103 success = false; 104 tile.setImage(null); 105 } 106 if (sharpenLevel != 0 && success) { 107 tile.setImage(sharpenImage(tile.getImage())); 107 108 } 108 109 tile.setLoaded(true); … … 110 111 Main.map.repaint(100); 111 112 tileRequestsOutstanding.remove(tile); 112 if (s harpenLevel != 0 && success) {113 tile.setImage(sharpenImage(tile.getImage()));113 if (success) { 114 displayZoomLevel = tile.getZoom(); 114 115 } 115 116 if (debug) { … … 135 136 */ 136 137 public int currentZoomLevel; 138 public int bestZoomLevel; 139 public int displayZoomLevel = 0; 137 140 138 141 private Tile clickedTile; … … 242 245 } 243 246 244 currentZoomLevel = getBestZoom(); 245 if (currentZoomLevel > getMaxZoomLvl()) { 246 currentZoomLevel = getMaxZoomLvl(); 247 } 248 if (currentZoomLevel < getMinZoomLvl()) { 249 currentZoomLevel = getMinZoomLvl(); 250 } 247 updateBestZoom(); 248 currentZoomLevel = bestZoomLevel; 249 251 250 clearTileCache(); 252 251 //tileloader = new OsmTileLoader(this); … … 269 268 double ret = Math.log(getPPDeg()*360/tileSource.getTileSize())/Math.log(2); 270 269 return (int)Math.round(ret); 270 } 271 272 private void updateBestZoom() { 273 bestZoomLevel = getBestZoom(); 274 if (bestZoomLevel > getMaxZoomLvl()) { 275 bestZoomLevel = getMaxZoomLvl(); 276 } 277 if (bestZoomLevel < getMinZoomLvl()) { 278 bestZoomLevel = getMinZoomLvl(); 279 } 271 280 } 272 281 … … 508 517 } 509 518 519 public boolean setZoomLevel(int zoom) 520 { 521 if (zoom > this.getMaxZoomLvl()) return false; 522 if (zoom < this.getMinZoomLvl()) return false; 523 currentZoomLevel = zoom; 524 lastImageScale = null; 525 zoomChanged(); 526 return true; 527 } 528 510 529 /** 511 530 * Zoom out from map. … … 813 832 for (Tile tile : ts.allTiles()) { 814 833 Image img = getLoadedTileImage(tile); 815 if (img == null ) {834 if (img == null || tile.hasError()) { 816 835 if (debug) { 817 836 out("missed tile: " + tile); … … 875 894 if (!tile.isLoaded() && PROP_DRAW_DEBUG.get()) { 876 895 myDrawString(g, tr("image " + tileStatus), p.x + 2, texty); 896 texty += 1 + fontHeight; 897 } 898 899 if (tile.hasError() && (displayZoomLevel == 0 || !"no-tile".equals(tile.getValue("tile-info")))) { 900 myDrawString(g, tr("Error") + ": " + tr(tile.getErrorMessage()), p.x + 2, texty); 877 901 texty += 1 + fontHeight; 878 902 } … … 1168 1192 1169 1193 g.setFont(ATTR_FONT); 1170 String attributionText = tileSource.getAttributionText( currentZoomLevel,1194 String attributionText = tileSource.getAttributionText(displayZoomLevel, 1171 1195 getShiftedCoord(topLeft), getShiftedCoord(botRight)); 1172 1196 Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g); … … 1200 1224 } 1201 1225 //g.drawString("currentZoomLevel=" + currentZoomLevel, 120, 120); 1202 g.setColor(Color. black);1226 g.setColor(Color.lightGray); 1203 1227 if (ts.insane()) { 1204 1228 myDrawString(g, "zoom in to load any tiles", 120, 120);
Note:
See TracChangeset
for help on using the changeset viewer.