Changeset 11961 in josm
 Timestamp:
 20170419T22:25:12+02:00 (9 months ago)
 Location:
 trunk/src/org/openstreetmap/josm/gui/layer
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r11958 r11961 965 965 } 966 966 g.drawImage(toDrawImg, (int) Math.round(screen0.getX()), (int) Math.round(screen0.getY()), 967 (int) Math.round(screen1.getX()  screen0.getX()), (int) Math.round(screen1.getY()  screen0.getY()), this); 967 (int) Math.round(screen1.getX())  (int) Math.round(screen0.getX()), 968 (int) Math.round(screen1.getY())  (int) Math.round(screen0.getY()), this); 968 969 if (clip != null) { 969 970 g.setClip(oldClip); … … 1027 1028 private List<Tile> paintTileImages(Graphics2D g, TileSet ts, int zoom, Tile border) { 1028 1029 if (zoom <= 0) return Collections.emptyList(); 1029 Shape borderClip = coordinateConverter.get ScreenQuadrilateralForTile(border);1030 Shape borderClip = coordinateConverter.getTileShapeScreen(border); 1030 1031 List<Tile> missedTiles = new LinkedList<>(); 1031 1032 // The callers of this code *require* that we return any tiles that we do not draw in missedTiles. … … 1140 1141 // draw tile outline in semitransparent red 1141 1142 g.setColor(new Color(255, 0, 0, 50)); 1142 g.draw(coordinateConverter.get ScreenQuadrilateralForTile(tile));1143 g.draw(coordinateConverter.getTileShapeScreen(tile)); 1143 1144 } 1144 1145 } 
trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java
r11910 r11961 2 2 package org.openstreetmap.josm.gui.layer.imagery; 3 3 4 import java.awt.Polygon; 5 import java.awt.Rectangle; 4 6 import java.awt.Shape; 5 import java.awt.geom.Path2D;6 7 import java.awt.geom.Point2D; 7 8 import java.awt.geom.Rectangle2D; … … 121 122 122 123 /** 123 * Returns a quadrilateral formed by the 4 cornersof the tile in screen coordinates.124 * Returns a shape that approximates the outline of the tile in screen coordinates. 124 125 * 125 126 * If the tile is rectangular, this will be the exact border of the tile. … … 127 128 * of the tile outline. 128 129 * @param tile the tile 129 * @return quadrilateral tile outline in screen coordinates 130 */ 131 public Shape getScreenQuadrilateralForTile(Tile tile) { 132 Point2D p00 = this.getPixelForTile(tile.getXtile(), tile.getYtile(), tile.getZoom()); 133 Point2D p10 = this.getPixelForTile(tile.getXtile() + 1, tile.getYtile(), tile.getZoom()); 134 Point2D p11 = this.getPixelForTile(tile.getXtile() + 1, tile.getYtile() + 1, tile.getZoom()); 135 Point2D p01 = this.getPixelForTile(tile.getXtile(), tile.getYtile() + 1, tile.getZoom()); 136 137 Path2D pth = new Path2D.Double(); 138 pth.moveTo(p00.getX(), p00.getY()); 139 pth.lineTo(p01.getX(), p01.getY()); 140 pth.lineTo(p11.getX(), p11.getY()); 141 pth.lineTo(p10.getX(), p10.getY()); 142 pth.closePath(); 143 return pth; 130 * @return tile outline in screen coordinates 131 */ 132 public Shape getTileShapeScreen(Tile tile) { 133 if (requiresReprojection()) { 134 Point2D p00 = this.getPixelForTile(tile.getXtile(), tile.getYtile(), tile.getZoom()); 135 Point2D p10 = this.getPixelForTile(tile.getXtile() + 1, tile.getYtile(), tile.getZoom()); 136 Point2D p11 = this.getPixelForTile(tile.getXtile() + 1, tile.getYtile() + 1, tile.getZoom()); 137 Point2D p01 = this.getPixelForTile(tile.getXtile(), tile.getYtile() + 1, tile.getZoom()); 138 return new Polygon(new int[] { 139 (int) Math.round(p00.getX()), 140 (int) Math.round(p01.getX()), 141 (int) Math.round(p11.getX()), 142 (int) Math.round(p10.getX())}, 143 new int[] { 144 (int) Math.round(p00.getY()), 145 (int) Math.round(p01.getY()), 146 (int) Math.round(p11.getY()), 147 (int) Math.round(p10.getY())}, 4); 148 } else { 149 Point2D p00 = this.getPixelForTile(tile.getXtile(), tile.getYtile(), tile.getZoom()); 150 Point2D p11 = this.getPixelForTile(tile.getXtile() + 1, tile.getYtile() + 1, tile.getZoom()); 151 return new Rectangle((int) Math.round(p00.getX()), (int) Math.round(p00.getY()), 152 (int) Math.round(p11.getX())  (int) Math.round(p00.getX()), 153 (int) Math.round(p11.getY())  (int) Math.round(p00.getY())); 154 } 144 155 } 145 156
Note: See TracChangeset
for help on using the changeset viewer.