Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r8509 r8510 118 118 ".add_to_slippymap_chooser", true); 119 119 public static final StringProperty PROP_TILECACHE_DIR; 120 121 120 static { 122 121 String defPath = null; … … 167 166 for (String[] entry: content) { 168 167 panel.add(new JLabel(tr(entry[0]) + ":"), GBC.std()); 169 panel.add(GBC.glue(5, 0), GBC.std());168 panel.add(GBC.glue(5, 0), GBC.std()); 170 169 panel.add(createTextField(entry[1]), GBC.eol().fill(GBC.HORIZONTAL)); 171 170 } … … 173 172 for (Entry<String, String> e: clickedTile.getMetadata().entrySet()) { 174 173 panel.add(new JLabel(tr("Metadata ") + tr(e.getKey()) + ":"), GBC.std()); 175 panel.add(GBC.glue(5, 0), GBC.std());174 panel.add(GBC.glue(5, 0), GBC.std()); 176 175 String value = e.getValue(); 177 176 if ("lastModification".equals(e.getKey()) || "expirationTime".equals(e.getKey())) { … … 222 221 try { 223 222 return new TMSCachedTileLoader(listener, "TMS", 224 Main.pref.getInteger("socket.timeout.connect", 15) * 1000,223 Main.pref.getInteger("socket.timeout.connect", 15) * 1000, 225 224 Main.pref.getInteger("socket.timeout.read", 30) * 1000, 226 225 headers, … … 277 276 tileCache.clear(); 278 277 if (tileLoader instanceof CachedTileLoader) { 279 ((CachedTileLoader) tileLoader).clearCache(tileSource);278 ((CachedTileLoader) tileLoader).clearCache(tileSource); 280 279 } 281 280 redraw(); … … 311 310 312 311 protected static int checkMaxZoomLvl(int maxZoomLvl, TileSource ts) { 313 if (maxZoomLvl > MAX_ZOOM) {312 if (maxZoomLvl > MAX_ZOOM) { 314 313 maxZoomLvl = MAX_ZOOM; 315 314 } 316 if (maxZoomLvl < PROP_MIN_ZOOM_LVL.get()) {315 if (maxZoomLvl < PROP_MIN_ZOOM_LVL.get()) { 317 316 maxZoomLvl = PROP_MIN_ZOOM_LVL.get(); 318 317 } … … 333 332 334 333 static int checkMinZoomLvl(int minZoomLvl, TileSource ts) { 335 if (minZoomLvl < MIN_ZOOM) {334 if (minZoomLvl < MIN_ZOOM) { 336 335 /*Main.debug("Min. zoom level should not be less than "+MIN_ZOOM+"! Setting to that.");*/ 337 336 minZoomLvl = MIN_ZOOM; 338 337 } 339 if (minZoomLvl > PROP_MAX_ZOOM_LVL.get()) {338 if (minZoomLvl > PROP_MAX_ZOOM_LVL.get()) { 340 339 /*Main.debug("Min. zoom level should not be more than Max. zoom level! Setting to Max.");*/ 341 340 minZoomLvl = getMaxZoomLvl(ts); … … 460 459 Map<String, String> headers = null; 461 460 if (tileSource instanceof TemplatedTMSTileSource) { 462 headers = (((TemplatedTMSTileSource) tileSource).getHeaders());461 headers = (((TemplatedTMSTileSource) tileSource).getHeaders()); 463 462 } 464 463 … … 513 512 * getScaleFactor(...) is supposed to be between 0.75 and 3 514 513 */ 515 int intResult = (int) Math.floor(result);514 int intResult = (int) Math.floor(result); 516 515 if (intResult > getMaxZoomLvl()) 517 516 return getMaxZoomLvl(); … … 525 524 super(info); 526 525 527 if (!isProjectionSupported(Main.getProjection())) {526 if (!isProjectionSupported(Main.getProjection())) { 528 527 JOptionPane.showMessageDialog(Main.parent, 529 528 tr("TMS layers do not support the projection {0}.\n{1}\n" … … 568 567 @Override 569 568 public void actionPerformed(ActionEvent ae) { 570 autoLoad = !autoLoad;569 autoLoad = !autoLoad; 571 570 } 572 571 }); … … 966 965 // And how many pixels into the image itself does that 967 966 // correlate to? 968 int img_x_offset = (int) (screen_x_offset * imageXScaling + 0.5);969 int img_y_offset = (int) (screen_y_offset * imageYScaling + 0.5);967 int img_x_offset = (int) (screen_x_offset * imageXScaling + 0.5); 968 int img_y_offset = (int) (screen_y_offset * imageYScaling + 0.5); 970 969 // Now calculate the other corner of the image that we need 971 970 // by scaling the 'target' rectangle's dimensions. 972 int img_x_end = img_x_offset + (int) (target.getWidth() * imageXScaling + 0.5);973 int img_y_end = img_y_offset + (int) (target.getHeight() * imageYScaling + 0.5);971 int img_x_end = img_x_offset + (int) (target.getWidth() * imageXScaling + 0.5); 972 int img_y_end = img_y_offset + (int) (target.getHeight() * imageYScaling + 0.5); 974 973 975 974 if (Main.isDebugEnabled()) { … … 1033 1032 Color oldColor = g.getColor(); 1034 1033 g.setColor(Color.black); 1035 g.drawString(text, x+1,y+1);1034 g.drawString(text, x+1, y+1); 1036 1035 g.setColor(oldColor); 1037 g.drawString(text, x,y);1036 g.drawString(text, x, y); 1038 1037 } 1039 1038 … … 1122 1121 private Coordinate getShiftedCoord(EastNorth en) { 1123 1122 LatLon ll = getShiftedLatLon(en); 1124 return new Coordinate(ll.lat(),ll.lon()); 1125 } 1126 1127 private final TileSet nullTileSet = new TileSet((LatLon)null, (LatLon)null, 0); 1123 return new Coordinate(ll.lat(), ll.lon()); 1124 } 1125 1126 private final TileSet nullTileSet = new TileSet((LatLon) null, (LatLon) null, 0); 1127 1128 1128 private final class TileSet { 1129 1129 private int x0, x1, y0, y1; … … 1135 1135 */ 1136 1136 private TileSet(EastNorth topLeft, EastNorth botRight, int zoom) { 1137 this(getShiftedLatLon(topLeft), getShiftedLatLon(botRight), zoom);1137 this(getShiftedLatLon(topLeft), getShiftedLatLon(botRight), zoom); 1138 1138 } 1139 1139 … … 1146 1146 return; 1147 1147 1148 x0 = (int) tileSource.lonToTileX(topLeft.lon(), zoom);1149 y0 = (int) tileSource.latToTileY(topLeft.lat(), zoom);1150 x1 = (int) tileSource.lonToTileX(botRight.lon(), zoom);1151 y1 = (int) tileSource.latToTileY(botRight.lat(), zoom);1148 x0 = (int) tileSource.lonToTileX(topLeft.lon(), zoom); 1149 y0 = (int) tileSource.latToTileY(topLeft.lat(), zoom); 1150 x1 = (int) tileSource.lonToTileX(botRight.lon(), zoom); 1151 y1 = (int) tileSource.latToTileY(botRight.lat(), zoom); 1152 1152 if (x0 > x1) { 1153 1153 int tmp = x0; … … 1160 1160 y1 = tmp; 1161 1161 } 1162 tileMax = (int) Math.pow(2.0, zoom);1162 tileMax = (int) Math.pow(2.0, zoom); 1163 1163 if (x0 < 0) { 1164 1164 x0 = 0; … … 1246 1246 return Math.abs(t.getXtile() - centerX) + Math.abs(t.getYtile() - centerY); 1247 1247 } 1248 1248 1249 @Override 1249 1250 public int compare(Tile o1, Tile o2) { … … 1275 1276 } 1276 1277 } 1277 1278 1278 1279 1279 private static class TileSetInfo { … … 1307 1307 private final TileSet[] tileSets; 1308 1308 private final TileSetInfo[] tileSetInfos; 1309 1309 1310 public DeepTileSet(EastNorth topLeft, EastNorth botRight, int minZoom, int maxZoom) { 1310 1311 this.topLeft = topLeft; … … 1315 1316 this.tileSetInfos = new TileSetInfo[maxZoom - minZoom + 1]; 1316 1317 } 1318 1317 1319 public TileSet getTileSet(int zoom) { 1318 1320 if (zoom < minZoom) … … 1383 1385 } 1384 1386 // Do binary search between currentZoomLevel and displayZoomLevel 1385 while (zoom > displayZoomLevel && !tsi.hasVisibleTiles && tsi.hasOverzoomedTiles) {1387 while (zoom > displayZoomLevel && !tsi.hasVisibleTiles && tsi.hasOverzoomedTiles) { 1386 1388 zoom = (zoom + displayZoomLevel)/2; 1387 1389 tsi = dts.getTileSetInfo(zoom); … … 1489 1491 myDrawString(g, tr("Pixel scale: {0}", getScaleFactor(currentZoomLevel)), 50, 170); 1490 1492 myDrawString(g, tr("Best zoom: {0}", getBestZoom()), 50, 185); 1491 if (tileLoader instanceof TMSCachedTileLoader) {1492 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader) tileLoader;1493 if (tileLoader instanceof TMSCachedTileLoader) { 1494 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader) tileLoader; 1493 1495 int offset = 185; 1494 for(String part: cachedTileLoader.getStats().split("\n")) { 1495 myDrawString(g, tr("Cache stats: {0}", part), 50, offset+=15); 1496 } 1497 1496 for (String part: cachedTileLoader.getStats().split("\n")) { 1497 myDrawString(g, tr("Cache stats: {0}", part), 50, offset += 15); 1498 } 1498 1499 } 1499 1500 }
Note:
See TracChangeset
for help on using the changeset viewer.