- Timestamp:
- 2015-06-25T00:05:23+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r8526 r8530 499 499 */ 500 500 public void cancelOutstandingTasks() { 501 for (Runnable r: downloadJobExecutor.getQueue()) {501 for (Runnable r: downloadJobExecutor.getQueue()) { 502 502 if (downloadJobExecutor.remove(r) && r instanceof JCSCachedTileLoaderJob) { 503 503 ((JCSCachedTileLoaderJob<?, ?>) r).handleJobCancellation(); -
trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java
r8526 r8530 20 20 * 21 21 * @author Wiktor Niesiobędzki 22 * @since TODO 23 * 22 * @since 8526 24 23 */ 25 24 public class CachedAttributionBingAerialTileSource extends BingAerialTileSource { … … 71 70 } 72 71 } 73 -
trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java
r8526 r8530 17 17 * 18 18 * @author Wiktor Niesiobędzki 19 * @since TODO 20 * 19 * @since 8526 21 20 */ 22 21 public abstract class CachedTileLoaderFactory implements TileLoaderFactory { … … 59 58 try { 60 59 return getLoader(listener, cacheName, 61 Main.pref.getInteger("socket.timeout.connect", 15) * 1000,60 Main.pref.getInteger("socket.timeout.connect", 15) * 1000, 62 61 Main.pref.getInteger("socket.timeout.read", 30) * 1000, 63 62 headers, … … 69 68 } 70 69 71 protected abstract TileLoader getLoader(TileLoaderListener listener, String cacheName, int connectTimeout, int readTimeout, Map<String, String> headers, String cacheDir) throws IOException; 70 protected abstract TileLoader getLoader(TileLoaderListener listener, String cacheName, int connectTimeout, int readTimeout, 71 Map<String, String> headers, String cacheDir) throws IOException; 72 72 } -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java
r8526 r8530 160 160 * queue from default. 161 161 * 162 * @param downloadExecutor 162 * @param downloadExecutor download executor that will be used to download tiles 163 163 */ 164 164 public void setDownloadExecutor(ThreadPoolExecutor downloadExecutor) { … … 172 172 return downloadExecutor; 173 173 } 174 175 174 } -
trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java
r8526 r8530 34 34 * 35 35 * @author Wiktor Niesiobędzki 36 * @since TODO 37 * 36 * @since 8526 38 37 */ 39 38 public class TemplatedWMSTileSource extends TMSTileSource implements TemplatedTileSource { … … 53 52 private static final String PATTERN_HEIGHT = "\\{height\\}"; 54 53 55 56 54 private static final NumberFormat latLonFormat = new DecimalFormat("###0.0000000", new DecimalFormatSymbols(Locale.US)); 57 55 … … 62 60 /** 63 61 * Creates a tile source based on imagery info 64 * @param info 62 * @param info imagery info 65 63 */ 66 64 public TemplatedWMSTileSource(ImageryInfo info) { … … 106 104 double s = se.getY(); 107 105 double e = se.getX(); 108 109 106 110 107 if (!serverProjections.contains(myProjCode) && serverProjections.contains("EPSG:4326") && "EPSG:3857".equals(myProjCode)) { … … 167 164 168 165 @Override 169 public int LonToX(double lon, int zoom) {170 throw new UnsupportedOperationException("Not implemented"); 171 } 172 173 @Override 174 public int LatToY(double lat, int zoom) {166 public int lonToX(double lon, int zoom) { 167 throw new UnsupportedOperationException("Not implemented"); 168 } 169 170 @Override 171 public int latToY(double lat, int zoom) { 175 172 throw new UnsupportedOperationException("Not implemented"); 176 173 } … … 298 295 /** 299 296 * Checks if url is acceptable by this Tile Source 300 * @param url 297 * @param url URL to check 301 298 */ 302 299 public static void checkUrl(String url) { … … 324 321 Matcher matcher = pattern.matcher(this.baseUrl); 325 322 while (matcher.find()) { 326 headers.put(matcher.group(1), matcher.group(2));323 headers.put(matcher.group(1), matcher.group(2)); 327 324 matcher.appendReplacement(output, ""); 328 325 } … … 337 334 topLeftCorner.north() - y * scale 338 335 ); 339 340 336 } 341 337 … … 372 368 return (int) Math.ceil(Math.abs(max.getX() - min.getX()) / scale); 373 369 } 374 375 376 370 } -
trunk/src/org/openstreetmap/josm/data/imagery/TileLoaderFactory.java
r8526 r8530 11 11 * 12 12 * @author Wiktor Niesiobędzki 13 * @since TODO 14 * 13 * @since 8526 15 14 */ 16 15 public interface TileLoaderFactory { … … 28 27 */ 29 28 TileLoader makeTileLoader(TileLoaderListener listener, Map<String, String> headers); 30 31 29 } -
trunk/src/org/openstreetmap/josm/data/imagery/WMSCachedTileLoader.java
r8526 r8530 15 15 * 16 16 * @author Wiktor Niesiobędzki 17 * @since TODO 18 * 17 * @since 8526 19 18 */ 20 19 public class WMSCachedTileLoader extends TMSCachedTileLoader { 21 20 22 21 /** limit of concurrent connections to WMS tile source (per source) */ 23 public static IntegerProperty THREAD_LIMIT = new IntegerProperty("imagery.wms.simultaneousConnections", 3);22 public static final IntegerProperty THREAD_LIMIT = new IntegerProperty("imagery.wms.simultaneousConnections", 3); 24 23 25 24 /** -
trunk/src/org/openstreetmap/josm/data/imagery/WMSCachedTileLoaderJob.java
r8526 r8530 15 15 * 16 16 * @author Wiktor Niesiobędzki 17 * @since TODO 18 * 17 * @since 8526 19 18 */ 20 19 public class WMSCachedTileLoaderJob extends TMSCachedTileLoaderJob { … … 45 44 return null; 46 45 } 47 48 46 } -
trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java
r8510 r8530 681 681 max = null; 682 682 } else { 683 int y1 = tileSource. LatToY(bbox.getMinLat(), MAX_ZOOM);684 int y2 = tileSource. LatToY(bbox.getMaxLat(), MAX_ZOOM);685 int x1 = tileSource. LonToX(bbox.getMinLon(), MAX_ZOOM);686 int x2 = tileSource. LonToX(bbox.getMaxLon(), MAX_ZOOM);683 int y1 = tileSource.latToY(bbox.getMinLat(), MAX_ZOOM); 684 int y2 = tileSource.latToY(bbox.getMaxLat(), MAX_ZOOM); 685 int x1 = tileSource.lonToX(bbox.getMinLon(), MAX_ZOOM); 686 int x2 = tileSource.lonToX(bbox.getMaxLon(), MAX_ZOOM); 687 687 688 688 min = new Point(Math.min(x1, x2), Math.min(y1, y2)); -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r8526 r8530 80 80 81 81 /** 82 *83 82 * Base abstract class that supports displaying images provided by TileSource. It might be TMS source, WMS or WMTS 84 83 * 85 84 * It implements all standard functions of tilesource based layers: autozoom, tile reloads, layer saving, loading,etc. 86 85 * 86 * @author Upliner 87 87 * @author Wiktor Niesiobędzki 88 * @since TODO89 * 88 * @since 3715 89 * @since 8526 (copied from TMSLayer) 90 90 */ 91 91 public abstract class AbstractTileSourceLayer extends ImageryLayer implements ImageObserver, TileLoaderListener, ZoomChangeListener { … … 135 135 /** 136 136 * Creates Tile Source based Imagery Layer based on Imagery Info 137 * @param info 138 * @param tileSource 137 * @param info imagery info 139 138 */ 140 139 public AbstractTileSourceLayer(ImageryInfo info) { 141 140 super(info); 142 141 143 if (!isProjectionSupported(Main.getProjection())) {142 if (!isProjectionSupported(Main.getProjection())) { 144 143 JOptionPane.showMessageDialog(Main.parent, 145 144 tr("This layer do not support the projection {0}.\n{1}\n" … … 160 159 /** 161 160 * 162 * @param info 161 * @param info imagery info 163 162 * @return TileSource for specified ImageryInfo 164 163 * @throws IllegalArgumentException when Imagery is not supported by layer … … 185 184 tileLoader = new OsmTileLoader(this); 186 185 } 187 188 189 186 190 187 @Override … … 219 216 tileCache.clear(); 220 217 if (tileLoader instanceof CachedTileLoader) { 221 ((CachedTileLoader)tileLoader).clearCache(tileSource); 222 } 223 } 224 218 ((CachedTileLoader) tileLoader).clearCache(tileSource); 219 } 220 } 225 221 226 222 /** … … 262 258 } 263 259 264 private finalint getBestZoom() {260 private int getBestZoom() { 265 261 double factor = getScaleFactor(1); // check the ratio between area of tilesize at zoom 1 to current view 266 262 double result = Math.log(factor)/Math.log(2)/2+1; … … 275 271 * getScaleFactor(...) is supposed to be between 0.75 and 3 276 272 */ 277 int intResult = (int) Math.floor(result);273 int intResult = (int) Math.floor(result); 278 274 if (intResult > getMaxZoomLvl()) 279 275 return getMaxZoomLvl(); … … 283 279 } 284 280 285 286 private final static boolean actionSupportLayers(List<Layer> layers) { 281 private static boolean actionSupportLayers(List<Layer> layers) { 287 282 return layers.size() == 1 && layers.get(0) instanceof TMSLayer; 283 } 284 285 private final class ShowTileInfoAction extends AbstractAction { 286 private final TileHolder clickedTileHolder; 287 288 private ShowTileInfoAction(TileHolder clickedTileHolder) { 289 super(tr("Show Tile Info")); 290 this.clickedTileHolder = clickedTileHolder; 291 } 292 293 private String getSizeString(int size) { 294 StringBuilder ret = new StringBuilder(); 295 return ret.append(size).append("x").append(size).toString(); 296 } 297 298 private JTextField createTextField(String text) { 299 JTextField ret = new JTextField(text); 300 ret.setEditable(false); 301 ret.setBorder(BorderFactory.createEmptyBorder()); 302 return ret; 303 } 304 305 @Override 306 public void actionPerformed(ActionEvent ae) { 307 Tile clickedTile = clickedTileHolder.getTile(); 308 if (clickedTile != null) { 309 ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Tile Info"), new String[]{tr("OK")}); 310 JPanel panel = new JPanel(new GridBagLayout()); 311 Rectangle displaySize = tileToRect(clickedTile); 312 String url = ""; 313 try { 314 url = clickedTile.getUrl(); 315 } catch (IOException e) { 316 // silence exceptions 317 if (Main.isTraceEnabled()) { 318 Main.trace(e.getMessage()); 319 } 320 } 321 322 String[][] content = { 323 {"Tile name", clickedTile.getKey()}, 324 {"Tile url", url}, 325 {"Tile size", getSizeString(clickedTile.getTileSource().getTileSize()) }, 326 {"Tile display size", new StringBuilder().append(displaySize.width).append("x").append(displaySize.height).toString()}, 327 }; 328 329 for (String[] entry: content) { 330 panel.add(new JLabel(tr(entry[0]) + ":"), GBC.std()); 331 panel.add(GBC.glue(5, 0), GBC.std()); 332 panel.add(createTextField(entry[1]), GBC.eol().fill(GBC.HORIZONTAL)); 333 } 334 335 for (Entry<String, String> e: clickedTile.getMetadata().entrySet()) { 336 panel.add(new JLabel(tr("Metadata ") + tr(e.getKey()) + ":"), GBC.std()); 337 panel.add(GBC.glue(5, 0), GBC.std()); 338 String value = e.getValue(); 339 if ("lastModification".equals(e.getKey()) || "expirationTime".equals(e.getKey())) { 340 value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.parseLong(value))); 341 } 342 panel.add(createTextField(value), GBC.eol().fill(GBC.HORIZONTAL)); 343 344 } 345 ed.setIcon(JOptionPane.INFORMATION_MESSAGE); 346 ed.setContent(panel); 347 ed.showDialog(); 348 } 349 } 288 350 } 289 351 … … 292 354 super(tr("Auto Zoom")); 293 355 } 356 294 357 @Override 295 358 public void actionPerformed(ActionEvent ae) { … … 302 365 return item; 303 366 } 367 304 368 @Override 305 369 public boolean supportLayers(List<Layer> layers) { 306 370 return actionSupportLayers(layers); 307 371 } 308 309 372 } 310 373 … … 313 376 super(tr("Auto load tiles")); 314 377 } 378 315 379 @Override 316 380 public void actionPerformed(ActionEvent ae) { 317 autoLoad = !autoLoad;381 autoLoad = !autoLoad; 318 382 } 319 383 … … 323 387 return item; 324 388 } 389 325 390 @Override 326 391 public boolean supportLayers(List<Layer> layers) { … … 333 398 super(tr("Load All Tiles")); 334 399 } 400 335 401 @Override 336 402 public void actionPerformed(ActionEvent ae) { … … 356 422 super(tr("Zoom to native resolution")); 357 423 } 424 358 425 @Override 359 426 public void actionPerformed(ActionEvent ae) { … … 368 435 super(tr("Change resolution")); 369 436 } 437 370 438 @Override 371 439 public void actionPerformed(ActionEvent ae) { … … 374 442 } 375 443 376 /* 444 /** 377 445 * Simple class to keep clickedTile within hookUpMapView 378 446 */ 379 private class TileHolder {447 private static final class TileHolder { 380 448 private Tile t = null; 381 449 … … 432 500 })); 433 501 434 tileOptionMenu.add(new JMenuItem(new AbstractAction( 435 tr("Show Tile Info")) { 436 private String getSizeString(int size) { 437 StringBuilder ret = new StringBuilder(); 438 return ret.append(size).append("x").append(size).toString(); 439 } 440 441 private JTextField createTextField(String text) { 442 JTextField ret = new JTextField(text); 443 ret.setEditable(false); 444 ret.setBorder(BorderFactory.createEmptyBorder()); 445 return ret; 446 } 447 448 @Override 449 public void actionPerformed(ActionEvent ae) { 450 Tile clickedTile = clickedTileHolder.getTile(); 451 if (clickedTile != null) { 452 ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Tile Info"), new String[]{tr("OK")}); 453 JPanel panel = new JPanel(new GridBagLayout()); 454 Rectangle displaySize = tileToRect(clickedTile); 455 String url = ""; 456 try { 457 url = clickedTile.getUrl(); 458 } catch (IOException e) { 459 // silence exceptions 460 } 461 462 String[][] content = { 463 {"Tile name", clickedTile.getKey()}, 464 {"Tile url", url}, 465 {"Tile size", getSizeString(clickedTile.getTileSource().getTileSize()) }, 466 {"Tile display size", new StringBuilder().append(displaySize.width).append("x").append(displaySize.height).toString()}, 467 }; 468 469 for (String[] entry: content) { 470 panel.add(new JLabel(tr(entry[0]) + ":"), GBC.std()); 471 panel.add(GBC.glue(5,0), GBC.std()); 472 panel.add(createTextField(entry[1]), GBC.eol().fill(GBC.HORIZONTAL)); 473 } 474 475 for (Entry<String, String> e: clickedTile.getMetadata().entrySet()) { 476 panel.add(new JLabel(tr("Metadata ") + tr(e.getKey()) + ":"), GBC.std()); 477 panel.add(GBC.glue(5,0), GBC.std()); 478 String value = e.getValue(); 479 if ("lastModification".equals(e.getKey()) || "expirationTime".equals(e.getKey())) { 480 value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.parseLong(value))); 481 } 482 panel.add(createTextField(value), GBC.eol().fill(GBC.HORIZONTAL)); 483 484 } 485 ed.setIcon(JOptionPane.INFORMATION_MESSAGE); 486 ed.setContent(panel); 487 ed.showDialog(); 488 } 489 } 490 })); 502 tileOptionMenu.add(new JMenuItem(new ShowTileInfoAction(clickedTileHolder))); 491 503 492 504 tileOptionMenu.add(new JMenuItem(new LoadAllTilesAction())); … … 586 598 */ 587 599 public static int checkMaxZoomLvl(int maxZoomLvl, TileSource ts) { 588 if (maxZoomLvl > MAX_ZOOM) {600 if (maxZoomLvl > MAX_ZOOM) { 589 601 maxZoomLvl = MAX_ZOOM; 590 602 } 591 if (maxZoomLvl < PROP_MIN_ZOOM_LVL.get()) {603 if (maxZoomLvl < PROP_MIN_ZOOM_LVL.get()) { 592 604 maxZoomLvl = PROP_MIN_ZOOM_LVL.get(); 593 605 } … … 605 617 */ 606 618 public static int checkMinZoomLvl(int minZoomLvl, TileSource ts) { 607 if (minZoomLvl < MIN_ZOOM) {619 if (minZoomLvl < MIN_ZOOM) { 608 620 minZoomLvl = MIN_ZOOM; 609 621 } 610 if (minZoomLvl > PROP_MAX_ZOOM_LVL.get()) {622 if (minZoomLvl > PROP_MAX_ZOOM_LVL.get()) { 611 623 minZoomLvl = getMaxZoomLvl(ts); 612 624 } … … 617 629 } 618 630 619 620 631 /** 621 632 * @param ts TileSource for which we want to know maximum zoom level … … 634 645 } 635 646 636 637 647 /** 638 648 * Sets maximum zoom level, that layer will attempt show 639 * @param maxZoomLvl 649 * @param maxZoomLvl maximum zoom level 640 650 */ 641 651 public static void setMaxZoomLvl(int maxZoomLvl) { … … 646 656 /** 647 657 * Sets minimum zoom level, that layer will attempt show 648 * @param minZoomLvl 658 * @param minZoomLvl minimum zoom level 649 659 */ 650 660 public static void setMinZoomLvl(int minZoomLvl) { … … 652 662 PROP_MIN_ZOOM_LVL.put(minZoomLvl); 653 663 } 654 655 664 656 665 /** … … 664 673 } 665 674 if (tileLoader instanceof TMSCachedTileLoader) { 666 ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks();675 ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks(); 667 676 } 668 677 needRedraw = true; … … 687 696 boolean zia = currentZoomLevel < this.getMaxZoomLvl(); 688 697 if (Main.isDebugEnabled()) { 689 Main.debug("zoomIncreaseAllowed(): " + zia + " " + currentZoomLevel + " vs. " + this.getMaxZoomLvl() 698 Main.debug("zoomIncreaseAllowed(): " + zia + " " + currentZoomLevel + " vs. " + this.getMaxZoomLvl()); 690 699 } 691 700 return zia; … … 812 821 TileSet ts = getVisibleTileSet(); 813 822 814 // if there is more than 18 tiles on screen in any direction, do not 815 // load all tiles! 823 // if there is more than 18 tiles on screen in any direction, do not load all tiles! 816 824 if (ts.tooLarge()) { 817 825 Main.warn("Not downloading all tiles because there is more than 18 tiles on an axis!"); … … 884 892 885 893 // If a border is specified, only draw the intersection 886 // if what we have combined with what we are supposed 887 // to draw. 894 // if what we have combined with what we are supposed to draw. 888 895 if (border != null) { 889 896 target = source.intersection(border); … … 906 913 int screen_x_offset = target.x - source.x; 907 914 int screen_y_offset = target.y - source.y; 908 // And how many pixels into the image itself does that 909 // correlate to? 910 int img_x_offset = (int)(screen_x_offset * imageXScaling + 0.5); 911 int img_y_offset = (int)(screen_y_offset * imageYScaling + 0.5); 915 // And how many pixels into the image itself does that correlate to? 916 int img_x_offset = (int) (screen_x_offset * imageXScaling + 0.5); 917 int img_y_offset = (int) (screen_y_offset * imageYScaling + 0.5); 912 918 // Now calculate the other corner of the image that we need 913 919 // by scaling the 'target' rectangle's dimensions. 914 int img_x_end = img_x_offset + (int) (target.getWidth() * imageXScaling + 0.5);915 int img_y_end = img_y_offset + (int) (target.getHeight() * imageYScaling + 0.5);920 int img_x_end = img_x_offset + (int) (target.getWidth() * imageXScaling + 0.5); 921 int img_y_end = img_y_offset + (int) (target.getHeight() * imageYScaling + 0.5); 916 922 917 923 if (Main.isDebugEnabled()) { … … 951 957 // that we do not draw in missedTiles. ts.allExistingTiles() by 952 958 // default will only return already-existing tiles. However, we 953 // need to return *all* tiles to the callers, so force creation 954 // here. 955 //boolean forceTileCreation = true; 959 // need to return *all* tiles to the callers, so force creation here. 956 960 for (Tile tile : ts.allTilesCreate()) { 957 961 Image img = getLoadedTileImage(tile); … … 975 979 Color oldColor = g.getColor(); 976 980 g.setColor(Color.black); 977 g.drawString(text, x+1,y+1);981 g.drawString(text, x+1, y+1); 978 982 g.setColor(oldColor); 979 g.drawString(text, x,y);983 g.drawString(text, x, y); 980 984 } 981 985 … … 1004 1008 if (tile.hasError() && showErrors) { 1005 1009 myDrawString(g, tr("Error") + ": " + tr(tile.getErrorMessage()), p.x + 2, texty); 1006 texty += 1 + fontHeight;1010 //texty += 1 + fontHeight; 1007 1011 } 1008 1012 … … 1048 1052 private Coordinate getShiftedCoord(EastNorth en) { 1049 1053 LatLon ll = getShiftedLatLon(en); 1050 return new Coordinate(ll.lat(), ll.lon());1051 } 1052 1053 private final TileSet nullTileSet = new TileSet((LatLon) null, (LatLon)null, 0);1054 return new Coordinate(ll.lat(), ll.lon()); 1055 } 1056 1057 private final TileSet nullTileSet = new TileSet((LatLon) null, (LatLon) null, 0); 1054 1058 private final class TileSet { 1055 1059 int x0, x1, y0, y1; … … 1060 1064 */ 1061 1065 private TileSet(EastNorth topLeft, EastNorth botRight, int zoom) { 1062 this(getShiftedLatLon(topLeft), getShiftedLatLon(botRight), zoom);1066 this(getShiftedLatLon(topLeft), getShiftedLatLon(botRight), zoom); 1063 1067 } 1064 1068 … … 1178 1182 return Math.abs(t.getXtile() - centerX) + Math.abs(t.getYtile() - centerY); 1179 1183 } 1184 1180 1185 @Override 1181 1186 public int compare(Tile o1, Tile o2) { … … 1186 1191 }; 1187 1192 } 1188 1189 1193 1190 1194 private void loadAllTiles(boolean force) { … … 1208 1212 } 1209 1213 } 1210 1211 1214 1212 1215 private static class TileSetInfo { … … 1248 1251 this.tileSetInfos = new TileSetInfo[maxZoom - minZoom + 1]; 1249 1252 } 1253 1250 1254 public TileSet getTileSet(int zoom) { 1251 1255 if (zoom < minZoom) … … 1316 1320 } 1317 1321 // Do binary search between currentZoomLevel and displayZoomLevel 1318 while (zoom > displayZoomLevel && !tsi.hasVisibleTiles && tsi.hasOverzoomedTiles) {1322 while (zoom > displayZoomLevel && !tsi.hasVisibleTiles && tsi.hasOverzoomedTiles) { 1319 1323 zoom = (zoom + displayZoomLevel)/2; 1320 1324 tsi = dts.getTileSetInfo(zoom); … … 1422 1426 myDrawString(g, tr("Pixel scale: {0}", getScaleFactor(currentZoomLevel)), 50, 170); 1423 1427 myDrawString(g, tr("Best zoom: {0}", getBestZoom()), 50, 185); 1424 if (tileLoader instanceof TMSCachedTileLoader) {1425 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader) tileLoader;1428 if (tileLoader instanceof TMSCachedTileLoader) { 1429 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader) tileLoader; 1426 1430 int offset = 185; 1427 for (String part: cachedTileLoader.getStats().split("\n")) {1428 myDrawString(g, tr("Cache stats: {0}", part), 50, offset +=15);1431 for (String part: cachedTileLoader.getStats().split("\n")) { 1432 myDrawString(g, tr("Cache stats: {0}", part), 50, offset += 15); 1429 1433 } 1430 1434 … … 1495 1499 @Override 1496 1500 public String getToolTipText() { 1497 if (autoLoad) {1501 if (autoLoad) { 1498 1502 return tr("{0} ({1}), automatically downloading in zoom {2}", this.getClass().getSimpleName(), getName(), currentZoomLevel); 1499 1503 } else { … … 1553 1557 public void cancel() { 1554 1558 if (tileLoader instanceof TMSCachedTileLoader) { 1555 ((TMSCachedTileLoader)tileLoader).cancelOutstandingTasks(); 1556 } 1557 } 1558 1559 ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks(); 1560 } 1561 } 1559 1562 1560 1563 @Override … … 1581 1584 * To prevent accidental clear of the queue, new download executor is created with separate queue 1582 1585 * 1583 * @param precacheTask 1584 * @param points 1586 * @param precacheTask Task responsible for precaching imagery 1587 * @param points lat/lon coordinates to download 1585 1588 * @param bufferX how many units in current Coordinate Reference System to cover in X axis in both sides 1586 1589 * @param bufferY how many units in current Coordinate Reference System to cover in Y axis in both sides 1587 1590 */ 1588 1591 public void downloadAreaToCache(final PrecacheTask precacheTask, List<LatLon> points, double bufferX, double bufferY) { 1589 final Set<Tile> requestedTiles = new ConcurrentSkipListSet 1592 final Set<Tile> requestedTiles = new ConcurrentSkipListSet<>(new Comparator<Tile>() { 1590 1593 public int compare(Tile o1, Tile o2) { 1591 1594 return String.CASE_INSENSITIVE_ORDER.compare(o1.getKey(), o2.getKey()); … … 1604 1607 int maxX = Math.min(curTile.getXIndex() + 1, minTile.getXIndex()); 1605 1608 1606 for (int x = minX; x<=maxX; x++) {1607 for (int y = minY; y<=maxY; y++) {1609 for (int x = minX; x <= maxX; x++) { 1610 for (int y = minY; y <= maxY; y++) { 1608 1611 requestedTiles.add(new Tile(tileSource, x, y, currentZoomLevel)); 1609 1612 } -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r8510 r8530 79 79 /** 80 80 * Constructs a new {@code ImageryLayer}. 81 * @param info imagery info 81 82 */ 82 83 public ImageryLayer(ImageryInfo info) { -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r8526 r8530 23 23 import org.openstreetmap.josm.data.projection.Projection; 24 24 25 26 25 /** 27 26 * Class that displays a slippy map layer. … … 34 33 */ 35 34 public class TMSLayer extends AbstractTileSourceLayer { 36 private static final String PREFERENCE_PREFIX 35 private static final String PREFERENCE_PREFIX = "imagery.tms"; 37 36 38 37 /** minimum zoom level for TMS layer */ 39 public static final IntegerProperty PROP_MIN_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".min_zoom_lvl", AbstractTileSourceLayer.PROP_MIN_ZOOM_LVL.get()); 38 public static final IntegerProperty PROP_MIN_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".min_zoom_lvl", 39 AbstractTileSourceLayer.PROP_MIN_ZOOM_LVL.get()); 40 40 /** maximum zoom level for TMS layer */ 41 public static final IntegerProperty PROP_MAX_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".max_zoom_lvl", AbstractTileSourceLayer.PROP_MAX_ZOOM_LVL.get()); 41 public static final IntegerProperty PROP_MAX_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".max_zoom_lvl", 42 AbstractTileSourceLayer.PROP_MAX_ZOOM_LVL.get()); 42 43 /** shall TMS layers be added to download dialog */ 43 44 public static final BooleanProperty PROP_ADD_TO_SLIPPYMAP_CHOOSER = new BooleanProperty(PREFERENCE_PREFIX + ".add_to_slippymap_chooser", true); … … 79 80 protected Map<String, String> getHeaders(TileSource tileSource) { 80 81 if (tileSource instanceof TemplatedTMSTileSource) { 81 return ((TemplatedTMSTileSource) tileSource).getHeaders();82 return ((TemplatedTMSTileSource) tileSource).getHeaders(); 82 83 } 83 84 return null; -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r8526 r8530 58 58 public void projectionChanged(Projection oldValue, Projection newValue) { 59 59 if (!oldValue.equals(newValue) && tileSource instanceof TemplatedWMSTileSource) { 60 ((TemplatedWMSTileSource) tileSource).initProjection(newValue);60 ((TemplatedWMSTileSource) tileSource).initProjection(newValue); 61 61 } 62 62 … … 96 96 } 97 97 98 99 98 @Override 100 99 protected TileSource getTileSource(ImageryInfo info) throws IllegalArgumentException { … … 127 126 } 128 127 129 130 128 /** 131 129 * Checks that WMS layer is a grabber-compatible one (HTML or WMS). … … 153 151 protected Map<String, String> getHeaders(TileSource tileSource) { 154 152 if (tileSource instanceof TemplatedWMSTileSource) { 155 return ((TemplatedWMSTileSource) tileSource).getHeaders();153 return ((TemplatedWMSTileSource) tileSource).getHeaders(); 156 154 } 157 155 return null; -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r8513 r8530 145 145 activeSourcesModel = new ActiveSourcesModel(selectionModel); 146 146 tblActiveSources = new JTable(activeSourcesModel) { 147 // some kind of hack to prevent the table from scrolling slightly to the 148 // right when clicking on the text 147 // some kind of hack to prevent the table from scrolling slightly to the right when clicking on the text 149 148 @Override 150 149 public void scrollRectToVisible(Rectangle aRect) { -
trunk/src/org/openstreetmap/josm/io/WMSLayerImporter.java
r8526 r8530 41 41 } 42 42 43 44 43 @Override 45 44 public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException { … … 61 60 double pixelPerDegree = ois.readDouble(); 62 61 63 String name = (String) ois.readObject();64 String extendedUrl = (String) ois.readObject();62 String name = (String) ois.readObject(); 63 String extendedUrl = (String) ois.readObject(); 65 64 66 65 info = new ImageryInfo(name); … … 68 67 info.setPixelPerDegree(pixelPerDegree); 69 68 info.setTileSize(imageSize); 70 } else if (sfv == WMSLayerExporter.CURRENT_FILE_VERSION) {69 } else if (sfv == WMSLayerExporter.CURRENT_FILE_VERSION) { 71 70 zoomTo = (EastNorth) ois.readObject(); 72 71 73 72 @SuppressWarnings("unchecked") 74 73 ImageryPreferenceEntry entry = Preferences.deserializeStruct( 75 (Map<String, String>) ois.readObject(),74 (Map<String, String>) ois.readObject(), 76 75 ImageryPreferenceEntry.class); 77 76 info = new ImageryInfo(entry); -
trunk/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java
r8526 r8530 49 49 AbstractTileSourceLayer tsLayer = (AbstractTileSourceLayer) layer; 50 50 if (attributes.containsKey("automatic-downloading")) { 51 tsLayer.autoLoad = new Boolean(attributes.get("automatic-downloading")).booleanValue();51 tsLayer.autoLoad = Boolean.valueOf(attributes.get("automatic-downloading")); 52 52 } 53 53 54 54 if (attributes.containsKey("automatically-change-resolution")) { 55 tsLayer.autoZoom = new Boolean(attributes.get("automatically-change-resolution")).booleanValue();55 tsLayer.autoZoom = Boolean.valueOf(attributes.get("automatically-change-resolution")); 56 56 } 57 57 58 58 if (attributes.containsKey("show-errors")) { 59 tsLayer.showErrors = new Boolean(attributes.get("show-errors")).booleanValue();59 tsLayer.showErrors = Boolean.valueOf(attributes.get("show-errors")); 60 60 } 61 61 }
Note:
See TracChangeset
for help on using the changeset viewer.