Ignore:
Timestamp:
2016-10-30T22:59:14+01:00 (7 years ago)
Author:
Don-vip
Message:

extract some classes from AbstractTileSourceLayer

File:
1 edited

Legend:

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

    r11197 r11199  
    4242import java.util.function.Function;
    4343import java.util.stream.Collectors;
    44 import java.util.stream.IntStream;
    4544import java.util.stream.Stream;
    4645
     
    9392import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings.FilterChangeListener;
    9493import org.openstreetmap.josm.gui.layer.imagery.TileCoordinateConverter;
     94import org.openstreetmap.josm.gui.layer.imagery.TilePosition;
     95import org.openstreetmap.josm.gui.layer.imagery.TileRange;
    9596import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings;
    9697import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings.DisplaySettingsChangeEvent;
     
    12691270    private final TileSet nullTileSet = new TileSet();
    12701271
    1271     /**
    1272      * This is a rectangular range of tiles.
    1273      */
    1274     private static class TileRange {
    1275         int minX;
    1276         int maxX;
    1277         int minY;
    1278         int maxY;
    1279         int zoom;
    1280 
    1281         private TileRange() {
    1282         }
    1283 
    1284         protected TileRange(TileXY t1, TileXY t2, int zoom) {
    1285             minX = (int) Math.floor(Math.min(t1.getX(), t2.getX()));
    1286             minY = (int) Math.floor(Math.min(t1.getY(), t2.getY()));
    1287             maxX = (int) Math.ceil(Math.max(t1.getX(), t2.getX()));
    1288             maxY = (int) Math.ceil(Math.max(t1.getY(), t2.getY()));
    1289             this.zoom = zoom;
    1290         }
    1291 
    1292         protected double tilesSpanned() {
    1293             return Math.sqrt(1.0 * this.size());
    1294         }
    1295 
    1296         protected int size() {
    1297             int xSpan = maxX - minX + 1;
    1298             int ySpan = maxY - minY + 1;
    1299             return xSpan * ySpan;
    1300         }
    1301 
    1302         /**
    1303          * Gets a stream of all tile positions in this set
    1304          * @return A stream of all positions
    1305          */
    1306         public Stream<TilePosition> tilePositions() {
    1307             if (zoom == 0) {
    1308                 return Stream.empty();
    1309             } else {
    1310                 return IntStream.rangeClosed(minX, maxX).mapToObj(
    1311                         x -> IntStream.rangeClosed(minY, maxY).mapToObj(y -> new TilePosition(x, y, zoom))
    1312                         ).flatMap(Function.identity());
    1313             }
    1314         }
    1315     }
    1316 
    1317     /**
    1318      * The position of a single tile.
    1319      * @author Michael Zangl
    1320      */
    1321     private static class TilePosition {
    1322         private final int x;
    1323         private final int y;
    1324         private final int zoom;
    1325         TilePosition(int x, int y, int zoom) {
    1326             this.x = x;
    1327             this.y = y;
    1328             this.zoom = zoom;
    1329         }
    1330 
    1331         TilePosition(Tile tile) {
    1332             this(tile.getXtile(), tile.getYtile(), tile.getZoom());
    1333         }
    1334 
    1335         /**
    1336          * @return the x position
    1337          */
    1338         public int getX() {
    1339             return x;
    1340         }
    1341 
    1342         /**
    1343          * @return the y position
    1344          */
    1345         public int getY() {
    1346             return y;
    1347         }
    1348 
    1349         /**
    1350          * @return the zoom
    1351          */
    1352         public int getZoom() {
    1353             return zoom;
    1354         }
    1355 
    1356         @Override
    1357         public String toString() {
    1358             return "TilePosition [x=" + x + ", y=" + y + ", zoom=" + zoom + ']';
    1359         }
    1360     }
    1361 
    13621272    private class TileSet extends TileRange {
    13631273
Note: See TracChangeset for help on using the changeset viewer.