Changeset 8349 in josm for trunk/src/org/openstreetmap/josm/gui/bbox
- Timestamp:
- 2015-05-14T13:26:49+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r8308 r8349 125 125 126 126 // upper left and lower right corners of the selection rectangle (x/y on ZOOM_MAX) 127 private PointiSelectionRectStart;128 private PointiSelectionRectEnd;127 private Coordinate iSelectionRectStart; 128 private Coordinate iSelectionRectEnd; 129 129 130 130 /** … … 210 210 // draw selection rectangle 211 211 if (iSelectionRectStart != null && iSelectionRectEnd != null) { 212 213 int zoomDiff = MAX_ZOOM - zoom; 214 Point tlc = getTopLeftCoordinates(); 215 int x_min = (iSelectionRectStart.x >> zoomDiff) - tlc.x; 216 int y_min = (iSelectionRectStart.y >> zoomDiff) - tlc.y; 217 int x_max = (iSelectionRectEnd.x >> zoomDiff) - tlc.x; 218 int y_max = (iSelectionRectEnd.y >> zoomDiff) - tlc.y; 219 220 int w = x_max - x_min; 221 int h = y_max - y_min; 212 Rectangle box = new Rectangle(getMapPosition(iSelectionRectStart, false)); 213 box.add(getMapPosition(iSelectionRectEnd, false)); 214 222 215 g.setColor(new Color(0.9f, 0.7f, 0.7f, 0.6f)); 223 g.fillRect( x_min, y_min, w, h);216 g.fillRect(box.x, box.y, box.width, box.height); 224 217 225 218 g.setColor(Color.BLACK); 226 g.drawRect( x_min, y_min, w, h);219 g.drawRect(box.x, box.y, box.width, box.height); 227 220 } 228 221 } catch (Exception e) { … … 257 250 Point p_min = new Point(Math.min(aEnd.x, aStart.x), Math.min(aEnd.y, aStart.y)); 258 251 259 Point tlc = getTopLeftCoordinates(); 260 int zoomDiff = MAX_ZOOM - zoom; 261 Point pEnd = new Point(p_max.x + tlc.x, p_max.y + tlc.y); 262 Point pStart = new Point(p_min.x + tlc.x, p_min.y + tlc.y); 263 264 pEnd.x <<= zoomDiff; 265 pEnd.y <<= zoomDiff; 266 pStart.x <<= zoomDiff; 267 pStart.y <<= zoomDiff; 268 269 iSelectionRectStart = pStart; 270 iSelectionRectEnd = pEnd; 271 272 Coordinate l1 = getPosition(p_max); // lon may be outside [-180,180] 273 Coordinate l2 = getPosition(p_min); // lon may be outside [-180,180] 252 iSelectionRectStart = getPosition(p_min); 253 iSelectionRectEnd = getPosition(p_max); 254 274 255 Bounds b = new Bounds( 275 256 new LatLon( 276 Math.min( l2.getLat(), l1.getLat()),277 LatLon.toIntervalLon(Math.min( l1.getLon(), l2.getLon()))257 Math.min(iSelectionRectStart.getLat(), iSelectionRectEnd.getLat()), 258 LatLon.toIntervalLon(Math.min(iSelectionRectStart.getLon(), iSelectionRectEnd.getLon())) 278 259 ), 279 260 new LatLon( 280 Math.max( l2.getLat(), l1.getLat()),281 LatLon.toIntervalLon(Math.max( l1.getLon(), l2.getLon())))261 Math.max(iSelectionRectStart.getLat(), iSelectionRectEnd.getLat()), 262 LatLon.toIntervalLon(Math.max(iSelectionRectStart.getLon(), iSelectionRectEnd.getLon()))) 282 263 ); 283 264 Bounds oldValue = this.bbox; … … 332 313 } 333 314 334 int y1 = tileSource.LatToY(bbox.getMinLat(), MAX_ZOOM); 335 int y2 = tileSource.LatToY(bbox.getMaxLat(), MAX_ZOOM); 336 int x1 = tileSource.LonToX(minLon, MAX_ZOOM); 337 int x2 = tileSource.LonToX(maxLon, MAX_ZOOM); 338 339 iSelectionRectStart = new Point(Math.min(x1, x2), Math.min(y1, y2)); 340 iSelectionRectEnd = new Point(Math.max(x1, x2), Math.max(y1, y2)); 315 iSelectionRectStart = new Coordinate(bbox.getMinLat(), bbox.getMinLon()); 316 iSelectionRectEnd = new Coordinate(bbox.getMaxLat(), bbox.getMaxLon()); 341 317 342 318 // calc the screen coordinates for the new selection rectangle
Note:
See TracChangeset
for help on using the changeset viewer.