Changeset 8643 in josm


Ignore:
Timestamp:
2015-08-05T23:51:30+02:00 (9 years ago)
Author:
wiktorn
Message:

Fix behaviour when exception is thrown during download.

  • fix endless download, when exception is thrown during download
  • draw multiline error text on tile if error string is longer than tile width
Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r8640 r8643  
    276276                return false;
    277277            }
    278         } else {
     278        } else if (attributes.getLastModification() > 0 &&
     279                now - attributes.getLastModification() > DEFAULT_EXPIRE_TIME) {
    279280            // check by file modification date
    280             if (now - attributes.getLastModification() > DEFAULT_EXPIRE_TIME) {
    281                 log.log(Level.FINE, "JCS - Object has expired, maximum file age reached {0}", getUrl());
    282                 return false;
    283             }
     281            log.log(Level.FINE, "JCS - Object has expired, maximum file age reached {0}", getUrl());
     282            return false;
     283        } else if (now - attributes.getCreateTime() > DEFAULT_EXPIRE_TIME) {
     284            log.log(Level.FINE, "JCS - Object has expired, maximum time since object creation reached {0}", getUrl());
     285            return false;
    284286        }
    285287        return true;
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r8640 r8643  
    188188                    }
    189189                    int httpStatusCode = attributes.getResponseCode();
    190                     if (!isNoTileAtZoom() && httpStatusCode >= 400 && httpStatusCode != 499) {
     190                    if (!isNoTileAtZoom() && httpStatusCode >= 400) {
    191191                        if (attributes.getErrorMessage() == null) {
    192192                            tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode));
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r8636 r8643  
    10371037    private void myDrawString(Graphics g, String text, int x, int y) {
    10381038        Color oldColor = g.getColor();
    1039         g.setColor(Color.black);
    1040         g.drawString(text, x+1, y+1);
    1041         g.setColor(oldColor);
    1042         g.drawString(text, x, y);
     1039        String textToDraw = text;
     1040        if (g.getFontMetrics().stringWidth(text) > tileSource.getTileSize()) {
     1041            // text longer than tile size, split it
     1042            StringBuilder line = new StringBuilder();
     1043            StringBuilder ret = new StringBuilder();
     1044            for(String s: text.split(" ")) {
     1045                if (g.getFontMetrics().stringWidth(line.toString() + s) > tileSource.getTileSize()) {
     1046                    ret.append(line).append("\n");
     1047                    line.setLength(0);
     1048                }
     1049                line.append(s).append(" ");
     1050            }
     1051            ret.append(line);
     1052            textToDraw = ret.toString();
     1053        }
     1054        int offset = 0;
     1055        for (String s: textToDraw.split("\n")) {
     1056            g.setColor(Color.black);
     1057            g.drawString(s, x + 1, y + offset + 1);
     1058            g.setColor(oldColor);
     1059            g.drawString(s, x, y + offset);
     1060            offset += g.getFontMetrics().getHeight() + 3;
     1061        }
    10431062    }
    10441063
Note: See TracChangeset for help on using the changeset viewer.