Ignore:
Timestamp:
2017-08-22T22:26:32+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - deprecate all Main logging methods and introduce suitable replacements in Logging for most of them

File:
1 edited

Legend:

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

    r12603 r12620  
    115115import org.openstreetmap.josm.io.WMSLayerImporter;
    116116import org.openstreetmap.josm.tools.GBC;
     117import org.openstreetmap.josm.tools.Logging;
    117118import org.openstreetmap.josm.tools.MemoryManager;
    118119import org.openstreetmap.josm.tools.MemoryManager.MemoryHandle;
     
    275276        } catch (MalformedURLException e) {
    276277            // ignore, assume that this is not a file
    277             if (Main.isDebugEnabled()) {
    278                 Main.debug(e.getMessage());
    279             }
     278            Logging.log(Logging.LEVEL_DEBUG, e);
    280279        }
    281280
     
    294293        tile.setLoaded(success);
    295294        invalidateLater();
    296         if (Main.isDebugEnabled()) {
    297             Main.debug("tileLoadingFinished() tile: " + tile + " success: " + success);
    298         }
     295        Logging.debug("tileLoadingFinished() tile: {0} success: {1}", tile, success);
    299296    }
    300297
     
    437434                } catch (IOException e) {
    438435                    // silence exceptions
    439                     Main.trace(e);
     436                    Logging.trace(e);
    440437                }
    441438
     
    595592                Math.pow(2d, ZOOM_OFFSET.get()) * visibileTiles // use offset to decide, how many tiles are visible
    596593                * 4);
    597         Main.info("AbstractTileSourceLayer: estimated visible tiles: {0}, estimated cache size: {1}", visibileTiles, ret);
     594        Logging.info("AbstractTileSourceLayer: estimated visible tiles: {0}, estimated cache size: {1}", visibileTiles, ret);
    598595        return ret;
    599596    }
     
    702699
    703700    private void zoomChanged(boolean invalidate) {
    704         if (Main.isDebugEnabled()) {
    705             Main.debug("zoomChanged(): " + currentZoomLevel);
    706         }
     701        Logging.debug("zoomChanged(): {0}", currentZoomLevel);
    707702        if (tileLoader instanceof TMSCachedTileLoader) {
    708703            ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks();
     
    733728    public boolean zoomIncreaseAllowed() {
    734729        boolean zia = currentZoomLevel < this.getMaxZoomLvl();
    735         if (Main.isDebugEnabled()) {
    736             Main.debug("zoomIncreaseAllowed(): " + zia + ' ' + currentZoomLevel + " vs. " + this.getMaxZoomLvl());
    737         }
     730        Logging.debug("zoomIncreaseAllowed(): {0} {1} vs. {2}", zia, currentZoomLevel, this.getMaxZoomLvl());
    738731        return zia;
    739732    }
     
    747740        if (zoomIncreaseAllowed()) {
    748741            currentZoomLevel++;
    749             if (Main.isDebugEnabled()) {
    750                 Main.debug("increasing zoom level to: " + currentZoomLevel);
    751             }
     742            Logging.debug("increasing zoom level to: {0}", currentZoomLevel);
    752743            zoomChanged();
    753744        } else {
    754             Main.warn("Current zoom level ("+currentZoomLevel+") could not be increased. "+
     745            Logging.warn("Current zoom level ("+currentZoomLevel+") could not be increased. "+
    755746                    "Max.zZoom Level "+this.getMaxZoomLvl()+" reached.");
    756747            return false;
     
    793784    public boolean zoomDecreaseAllowed() {
    794785        boolean zda = currentZoomLevel > this.getMinZoomLvl();
    795         if (Main.isDebugEnabled()) {
    796             Main.debug("zoomDecreaseAllowed(): " + zda + ' ' + currentZoomLevel + " vs. " + this.getMinZoomLvl());
    797         }
     786        Logging.debug("zoomDecreaseAllowed(): {0} {1} vs. {2}", zda, currentZoomLevel, this.getMinZoomLvl());
    798787        return zda;
    799788    }
     
    806795    public boolean decreaseZoomLevel() {
    807796        if (zoomDecreaseAllowed()) {
    808             if (Main.isDebugEnabled()) {
    809                 Main.debug("decreasing zoom level to: " + currentZoomLevel);
    810             }
     797            Logging.debug("decreasing zoom level to: {0}", currentZoomLevel);
    811798            currentZoomLevel--;
    812799            zoomChanged();
     
    879866        // if there is more than 18 tiles on screen in any direction, do not load all tiles!
    880867        if (ts.tooLarge()) {
    881             Main.warn("Not downloading all tiles because there is more than 18 tiles on an axis!");
     868            Logging.warn("Not downloading all tiles because there is more than 18 tiles on an axis!");
    882869            return;
    883870        }
     
    900887    public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
    901888        boolean done = (infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0;
    902         if (Main.isDebugEnabled()) {
    903             Main.debug("imageUpdate() done: " + done + " calling repaint");
    904         }
     889        Logging.debug("imageUpdate() done: {0} calling repaint", done);
    905890
    906891        if (done) {
     
    11361121        }
    11371122
    1138         if (Main.isDebugEnabled()) {
     1123        if (Logging.isDebugEnabled()) {
    11391124            // draw tile outline in semi-transparent red
    11401125            g.setColor(new Color(255, 0, 0, 50));
     
    14951480            missedTiles = newlyMissedTiles;
    14961481        }
    1497         if (Main.isDebugEnabled() && !missedTiles.isEmpty()) {
    1498             Main.debug("still missed "+missedTiles.size()+" in the end");
     1482        if (Logging.isDebugEnabled() && !missedTiles.isEmpty()) {
     1483            Logging.debug("still missed {0} in the end", missedTiles.size());
    14991484        }
    15001485        g.setColor(Color.red);
     
    15231508            myDrawString(g, tr("No tiles at this zoom level"), 120, 120);
    15241509        }
    1525         if (Main.isDebugEnabled()) {
     1510        if (Logging.isDebugEnabled()) {
    15261511            myDrawString(g, tr("Current zoom: {0}", currentZoomLevel), 50, 140);
    15271512            myDrawString(g, tr("Display zoom: {0}", displayZoomLevel), 50, 155);
     
    15471532     */
    15481533    private Tile getTileForPixelpos(int px, int py) {
    1549         if (Main.isDebugEnabled()) {
    1550             Main.debug("getTileForPixelpos("+px+", "+py+')');
    1551         }
     1534        Logging.debug("getTileForPixelpos({0}, {1})", px, py);
    15521535        TileXY xy = coordinateConverter.getTileforPixel(px, py, currentZoomLevel);
    15531536        return getTile(xy.getXIndex(), xy.getYIndex(), currentZoomLevel);
     
    17291712                this.progressMonitor.setCustomText(tr("Downloaded {0}/{1} tiles", processed, totalCount));
    17301713            } else {
    1731                 Main.warn("Tile loading failure: " + tile + " - " + tile.getErrorMessage());
     1714                Logging.warn("Tile loading failure: " + tile + " - " + tile.getErrorMessage());
    17321715            }
    17331716        }
     
    18251808                        memory = manager.allocateMemory("tile source layer", getEstimatedCacheSize(), Object::new);
    18261809                    } catch (NotEnoughMemoryException e) {
    1827                         Main.warn("Could not allocate tile source memory", e);
     1810                        Logging.warn("Could not allocate tile source memory", e);
    18281811                    }
    18291812                }
Note: See TracChangeset for help on using the changeset viewer.