- Timestamp:
- 2023-12-27T19:52:41+01:00 (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r18871 r18926 2 2 package org.openstreetmap.josm.gui.layer; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 10 11 import java.awt.Graphics; 11 12 import java.awt.Graphics2D; 13 import java.awt.GridBagConstraints; 12 14 import java.awt.GridBagLayout; 13 15 import java.awt.Image; … … 179 181 180 182 private static final BooleanProperty POPUP_MENU_ENABLED = new BooleanProperty(PREFERENCE_PREFIX + ".popupmenu", true); 183 private static final String ERROR_STRING = marktr("Error"); 181 184 182 185 /* … … 343 346 panel.add(new JLabel(entry.get(0) + ':'), GBC.std()); 344 347 panel.add(GBC.glue(5, 0), GBC.std()); 345 panel.add(createTextField(entry.get(1)), GBC.eol().fill(G BC.HORIZONTAL));348 panel.add(createTextField(entry.get(1)), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 346 349 } 347 350 return panel; … … 469 472 content.add(Arrays.asList(tr("Loaded"), tr(Boolean.toString(tile.isLoaded())))); 470 473 content.add(Arrays.asList(tr("Loading"), tr(Boolean.toString(tile.isLoading())))); 471 content.add(Arrays.asList(tr( "Error"), tr(Boolean.toString(tile.hasError()))));474 content.add(Arrays.asList(tr(ERROR_STRING), tr(Boolean.toString(tile.hasError())))); 472 475 for (List<String> entry: content) { 473 476 panel.add(new JLabel(entry.get(0) + ':'), GBC.std()); 474 477 panel.add(GBC.glue(5, 0), GBC.std()); 475 panel.add(layer.createTextField(entry.get(1)), GBC.eol().fill(G BC.HORIZONTAL));478 panel.add(layer.createTextField(entry.get(1)), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 476 479 } 477 480 … … 483 486 value = Instant.ofEpochMilli(Long.parseLong(value)).toString(); 484 487 } 485 panel.add(layer.createTextField(value), GBC.eol().fill(G BC.HORIZONTAL));488 panel.add(layer.createTextField(value), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 486 489 487 490 } … … 559 562 560 563 event.getMapView().addMouseListener(adapter); 561 MapView.addZoomChangeListener(this);564 NavigatableComponent.addZoomChangeListener(this); 562 565 563 566 if (this instanceof NativeScaleLayer && Boolean.TRUE.equals(NavigatableComponent.PROP_ZOOM_SCALE_FOLLOW_NATIVE_RES_AT_LOAD.get())) { … … 1206 1209 Logging.debug(e); 1207 1210 } 1208 if (!errorMessage.startsWith( "Error") && !errorMessage.startsWith(tr("Error"))) {1209 errorMessage = tr( "Error") + ": " + errorMessage;1211 if (!errorMessage.startsWith(ERROR_STRING) && !errorMessage.startsWith(tr(ERROR_STRING))) { 1212 errorMessage = tr(ERROR_STRING) + ": " + errorMessage; 1210 1213 } 1211 1214 myDrawString(g, errorMessage, x + 2, texty); … … 1264 1267 1265 1268 private boolean tooLarge() { 1266 return tileCache == null || size() > tileCache.getCacheSize(); 1269 try { 1270 return tileCache == null || size() > tileCache.getCacheSize(); 1271 } catch (ArithmeticException arithmeticException) { 1272 Logging.trace(arithmeticException); 1273 return true; 1274 } 1267 1275 } 1268 1276 … … 1424 1432 List<Tile> allTiles = this.allExistingTiles(); 1425 1433 TileSetInfo newInfo = new TileSetInfo(); 1426 newInfo.hasLoadingTiles = allTiles.size() < this.size(); 1434 try { 1435 newInfo.hasLoadingTiles = allTiles.size() < this.size(); 1436 } catch (ArithmeticException arithmeticException) { 1437 Logging.trace(arithmeticException); 1438 newInfo.hasLoadingTiles = false; 1439 } 1427 1440 newInfo.hasAllLoadedTiles = true; 1428 1441 for (Tile t : allTiles) { … … 1450 1463 @Override 1451 1464 public String toString() { 1452 return getClass().getName() + ": zoom: " + zoom + " X(" + minX + ", " + maxX + ") Y(" + minY + ", " + maxY + ") size: " + size(); 1465 int size; 1466 try { 1467 size = size(); 1468 } catch (ArithmeticException arithmeticException) { 1469 Logging.trace(arithmeticException); 1470 size = Integer.MIN_VALUE; 1471 } 1472 return getClass().getName() 1473 + ": zoom: " + zoom 1474 + " X(" + minX + ", " + maxX 1475 + ") Y(" + minY + ", " + maxY 1476 + ") size: " + (size >= 0 ? size : "Integer Overflow"); 1453 1477 } 1454 1478 } … … 1473 1497 if (zoom == 0) 1474 1498 return new TileSet(); 1475 TileXY t1, t2; 1499 TileXY t1; 1500 TileXY t2; 1476 1501 IProjected topLeftUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMin()); 1477 1502 IProjected botRightUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMax()); … … 1496 1521 private class DeepTileSet { 1497 1522 private final ProjectionBounds bounds; 1498 private final int minZoom, maxZoom; 1523 private final int minZoom; 1524 private final int maxZoom; 1499 1525 private final TileSet[] tileSets; 1500 1526 … … 1993 2019 public synchronized void destroy() { 1994 2020 super.destroy(); 1995 MapView.removeZoomChangeListener(this);2021 NavigatableComponent.removeZoomChangeListener(this); 1996 2022 adjustAction.destroy(); 1997 2023 if (tileLoader instanceof TMSCachedTileLoader) { … … 2053 2079 public void detachFromMapView(MapViewEvent event) { 2054 2080 event.getMapView().removeMouseListener(adapter); 2055 MapView.removeZoomChangeListener(AbstractTileSourceLayer.this);2081 NavigatableComponent.removeZoomChangeListener(AbstractTileSourceLayer.this); 2056 2082 super.detachFromMapView(event); 2057 2083 if (memory != null) {
Note:
See TracChangeset
for help on using the changeset viewer.