Changeset 3773 in josm for trunk/src


Ignore:
Timestamp:
2011-01-04T16:10:43+01:00 (13 years ago)
Author:
Upliner
Message:

don't paint dummy tiles when overzooming Bing imagery, adresses #5741

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r3740 r3773  
    1717import java.awt.font.TextAttribute;
    1818import java.awt.geom.Rectangle2D;
    19 import java.awt.image.BufferedImage;
    2019import java.awt.image.ImageObserver;
    2120import java.io.IOException;
     
    7675    public static final int MAX_ZOOM = 30;
    7776    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;
    7978    public static final int DEFAULT_MIN_ZOOM = 2;
    8079
     
    101100    public synchronized void tileLoadingFinished(Tile tile, boolean success)
    102101    {
    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()));
    107108        }
    108109        tile.setLoaded(true);
     
    110111        Main.map.repaint(100);
    111112        tileRequestsOutstanding.remove(tile);
    112         if (sharpenLevel != 0 && success) {
    113             tile.setImage(sharpenImage(tile.getImage()));
     113        if (success) {
     114            displayZoomLevel = tile.getZoom();
    114115        }
    115116        if (debug) {
     
    135136     */
    136137    public int currentZoomLevel;
     138    public int bestZoomLevel;
     139    public int displayZoomLevel = 0;
    137140
    138141    private Tile clickedTile;
     
    242245        }
    243246
    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
    251250        clearTileCache();
    252251        //tileloader = new OsmTileLoader(this);
     
    269268        double ret = Math.log(getPPDeg()*360/tileSource.getTileSize())/Math.log(2);
    270269        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        }
    271280    }
    272281
     
    508517    }
    509518
     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
    510529    /**
    511530     * Zoom out from map.
     
    813832        for (Tile tile : ts.allTiles()) {
    814833            Image img = getLoadedTileImage(tile);
    815             if (img == null) {
     834            if (img == null || tile.hasError()) {
    816835                if (debug) {
    817836                    out("missed tile: " + tile);
     
    875894        if (!tile.isLoaded() && PROP_DRAW_DEBUG.get()) {
    876895            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);
    877901            texty += 1 + fontHeight;
    878902        }
     
    11681192
    11691193            g.setFont(ATTR_FONT);
    1170             String attributionText = tileSource.getAttributionText(currentZoomLevel,
     1194            String attributionText = tileSource.getAttributionText(displayZoomLevel,
    11711195                    getShiftedCoord(topLeft), getShiftedCoord(botRight));
    11721196            Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g);
     
    12001224        }
    12011225        //g.drawString("currentZoomLevel=" + currentZoomLevel, 120, 120);
    1202         g.setColor(Color.black);
     1226        g.setColor(Color.lightGray);
    12031227        if (ts.insane()) {
    12041228            myDrawString(g, "zoom in to load any tiles", 120, 120);
Note: See TracChangeset for help on using the changeset viewer.