Changeset 31439 in osm for applications/viewer/jmapviewer/src/org
- Timestamp:
- 2015-08-02T23:21:30+02:00 (9 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r31438 r31439 250 250 /** 251 251 * Sets the displayed map pane and zoom level so that all chosen map elements are visible. 252 * @param markers whether to consider markers 253 * @param rectangles whether to consider rectangles 254 * @param polygons whether to consider polygons 252 255 */ 253 256 public void setDisplayToFitMapElements(boolean markers, boolean rectangles, boolean polygons) { … … 262 265 return; 263 266 264 int x _min = Integer.MAX_VALUE;265 int y _min = Integer.MAX_VALUE;266 int x _max = Integer.MIN_VALUE;267 int y _max = Integer.MIN_VALUE;267 int xMin = Integer.MAX_VALUE; 268 int yMin = Integer.MAX_VALUE; 269 int xMax = Integer.MIN_VALUE; 270 int yMax = Integer.MIN_VALUE; 268 271 int mapZoomMax = tileController.getTileSource().getMaxZoom(); 269 272 … … 273 276 if (marker.isVisible()) { 274 277 Point p = tileSource.latLonToXY(marker.getCoordinate(), mapZoomMax); 275 x _max = Math.max(x_max, p.x);276 y _max = Math.max(y_max, p.y);277 x _min = Math.min(x_min, p.x);278 y _min = Math.min(y_min, p.y);278 xMax = Math.max(xMax, p.x); 279 yMax = Math.max(yMax, p.y); 280 xMin = Math.min(xMin, p.x); 281 yMin = Math.min(yMin, p.y); 279 282 } 280 283 } … … 288 291 Point bottomRight = tileSource.latLonToXY(rectangle.getBottomRight(), mapZoomMax); 289 292 Point topLeft = tileSource.latLonToXY(rectangle.getTopLeft(), mapZoomMax); 290 x _max = Math.max(x_max, bottomRight.x);291 y _max = Math.max(y_max, topLeft.y);292 x _min = Math.min(x_min, topLeft.x);293 y _min = Math.min(y_min, bottomRight.y);293 xMax = Math.max(xMax, bottomRight.x); 294 yMax = Math.max(yMax, topLeft.y); 295 xMin = Math.min(xMin, topLeft.x); 296 yMin = Math.min(yMin, bottomRight.y); 294 297 } 295 298 } … … 303 306 for (ICoordinate c : polygon.getPoints()) { 304 307 Point p = tileSource.latLonToXY(c, mapZoomMax); 305 x _max = Math.max(x_max, p.x);306 y _max = Math.max(y_max, p.y);307 x _min = Math.min(x_min, p.x);308 y _min = Math.min(y_min, p.y);308 xMax = Math.max(xMax, p.x); 309 yMax = Math.max(yMax, p.y); 310 xMin = Math.min(xMin, p.x); 311 yMin = Math.min(yMin, p.y); 309 312 } 310 313 } … … 316 319 int width = Math.max(0, getWidth()); 317 320 int newZoom = mapZoomMax; 318 int x = x _max - x_min;319 int y = y _max - y_min;321 int x = xMax - xMin; 322 int y = yMax - yMin; 320 323 while (x > width || y > height) { 321 324 newZoom--; … … 323 326 y >>= 1; 324 327 } 325 x = x _min + (x_max - x_min) / 2;326 y = y _min + (y_max - y_min) / 2;328 x = xMin + (xMax - xMin) / 2; 329 y = yMin + (yMax - yMin) / 2; 327 330 int z = 1 << (mapZoomMax - newZoom); 328 331 x /= z; … … 416 419 p.translate(-(center.x - getWidth() / 2), -(center.y - getHeight() /2)); 417 420 418 if (checkOutside) { 419 if (p.x < 0 || p.y < 0 || p.x > getWidth() || p.y > getHeight()) 420 return null; 421 if (checkOutside && (p.x < 0 || p.y < 0 || p.x > getWidth() || p.y > getHeight())) { 422 return null; 421 423 } 422 424 return p; 425 } 426 427 /** 428 * Calculates the position on the map of a given coordinate 429 * 430 * @param lat latitude 431 * @param lon longitude 432 * @return point on the map or <code>null</code> if the point is not visible 433 */ 434 public Point getMapPosition(double lat, double lon) { 435 return getMapPosition(lat, lon, true); 423 436 } 424 437 … … 435 448 Point p = tileSource.latLonToXY(lat, lon, zoom); 436 449 int y = p.y - center.y - getHeight() / 2; 437 if (checkOutside) { 438 if (y < 0 || y > getHeight()) 439 return null; 450 if (checkOutside && (y < 0 || y > getHeight())) { 451 return null; 440 452 } 441 453 return y; … … 455 467 int y = tileSource.latToY(lat + offset, zoom); 456 468 y -= center.y - getHeight() / 2; 457 if (checkOutside) { 458 if (y < 0 || y > getHeight()) 459 return null; 469 if (checkOutside && (y < 0 || y > getHeight())) { 470 return null; 460 471 } 461 472 return y; … … 465 476 * Calculates the position on the map of a given coordinate 466 477 * 467 * @param lat latitude468 * @param lon longitude469 * @return point on the map or <code>null</code> if the point is not visible470 */471 public Point getMapPosition(double lat, double lon) {472 return getMapPosition(lat, lon, true);473 }474 475 /**476 * Calculates the position on the map of a given coordinate477 *478 478 * @param marker MapMarker object that define the x,y coordinate 479 * @param p coordinate 479 480 * @return Integer the radius in pixels 480 481 */ … … 669 670 /** 670 671 * Paint a single marker. 672 * @param g Graphics used for painting 673 * @param marker marker to paint 671 674 */ 672 675 protected void paintMarker(Graphics g, MapMarker marker) { … … 702 705 /** 703 706 * Paint a single rectangle. 707 * @param g Graphics used for painting 708 * @param rectangle rectangle to paint 704 709 */ 705 710 protected void paintRectangle(Graphics g, MapRectangle rectangle) { … … 732 737 rectangle.paint(g, pTopLeft, pBottomRight); 733 738 } 734 735 739 } 736 740 } … … 740 744 /** 741 745 * Paint a single polygon. 746 * @param g Graphics used for painting 747 * @param polygon polygon to paint 742 748 */ 743 749 protected void paintPolygon(Graphics g, MapPolygon polygon) { … … 1087 1093 /** 1088 1094 * Return tile information caching class 1095 * @return tile cache 1089 1096 * @see TileController#getTileCache() 1090 1097 */ -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java
r31438 r31439 90 90 * Tries to get tiles of a lower or higher zoom level (one or two level 91 91 * difference) from cache and use it as a placeholder until the tile has been loaded. 92 * @param cache Tile cache 92 93 */ 93 94 public void loadPlaceholderFromCache(TileCache cache) { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileJob.java
r31429 r31439 26 26 /** 27 27 * submits download job to backend. 28 * @param force true if the load should skip all the caches (local & remote)28 * @param force true if the load should skip all the caches (local & remote) 29 29 */ 30 30 void submit(boolean force); -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
r31434 r31439 59 59 /** 60 60 * Constructs a new {@code BingAerialTileSource}. 61 * @param info imagery info 61 62 */ 62 63 public BingAerialTileSource(TileSourceInfo info) {
Note:
See TracChangeset
for help on using the changeset viewer.