Changeset 19697 in osm for applications/viewer/jmapviewer/src/org
- Timestamp:
- 2010-01-31T13:22:03+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r18890 r19697 10 10 import java.awt.event.ActionEvent; 11 11 import java.awt.event.ActionListener; 12 import java.awt.event.MouseEvent; 12 13 import java.util.LinkedList; 13 14 import java.util.List; … … 28 29 29 30 /** 30 * 31 * 31 32 * Provides a simple panel that displays pre-rendered map tiles loaded from the 32 33 * OpenStreetMap project. 33 * 34 * 34 35 * @author Jan Peter Stotz 35 * 36 * 36 37 */ 37 38 public class JMapViewer extends JPanel implements TileLoaderListener { … … 97 98 setPreferredSize(new Dimension(400, 400)); 98 99 setDisplayPositionByLatLon(50, 9, 3); 100 //setToolTipText(""); 101 } 102 103 @Override 104 public String getToolTipText(MouseEvent event) { 105 // Point screenPoint = event.getLocationOnScreen(); 106 // Coordinate c = getPosition(screenPoint); 107 return super.getToolTipText(event); 99 108 } 100 109 … … 148 157 * Changes the map pane so that it is centered on the specified coordinate 149 158 * at the given zoom level. 150 * 159 * 151 160 * @param lat 152 161 * latitude of the specified coordinate … … 164 173 * level is displayed on the map at the screen coordinate 165 174 * <code>mapPoint</code>. 166 * 175 * 167 176 * @param mapPoint 168 177 * point on the map denoted in pixels where the coordinate should … … 292 301 } 293 302 303 /** 304 * Calculates the latitude/longitude coordinate of the center of the 305 * currently displayed map area. 306 * 307 * @return latitude / longitude 308 */ 294 309 public Coordinate getPosition() { 295 310 double lon = OsmMercator.XToLon(center.x, zoom); … … 298 313 } 299 314 315 /** 316 * Converts the relative pixel coordinate (regarding the top left corner of 317 * the displayed map) into a latitude / longitude coordinate 318 * 319 * @param mapPoint 320 * relative pixel coordinate regarding the top left corner of the 321 * displayed map 322 * @return latitude / longitude 323 */ 300 324 public Coordinate getPosition(Point mapPoint) { 301 int x = center.x + mapPoint.x - getWidth() / 2; 302 int y = center.y + mapPoint.y - getHeight() / 2; 303 double lon = OsmMercator.XToLon(x, zoom); 304 double lat = OsmMercator.YToLat(y, zoom); 305 return new Coordinate(lat, lon); 306 } 307 325 return getPosition(mapPoint.x, mapPoint.y); 326 } 327 328 /** 329 * Converts the relative pixel coordinate (regarding the top left corner of 330 * the displayed map) into a latitude / longitude coordinate 331 * 332 * @param mapPointX 333 * @param mapPointY 334 * @return 335 */ 308 336 public Coordinate getPosition(int mapPointX, int mapPointY) { 309 337 int x = center.x + mapPointX - getWidth() / 2; … … 316 344 /** 317 345 * Calculates the position on the map of a given coordinate 318 * 346 * 319 347 * @param lat 320 348 * @param lon 321 349 * @param checkOutside 322 * @return point on the map or <code>null</code> if the point is not visible and checkOutside set to <code>true</code> 350 * @return point on the map or <code>null</code> if the point is not visible 351 * and checkOutside set to <code>true</code> 323 352 */ 324 353 public Point getMapPosition(double lat, double lon, boolean checkOutside) { … … 337 366 /** 338 367 * Calculates the position on the map of a given coordinate 339 * 368 * 340 369 * @param lat 341 370 * @param lon … … 348 377 /** 349 378 * Calculates the position on the map of a given coordinate 350 * 379 * 351 380 * @param coord 352 381 * @return point on the map or <code>null</code> if the point is not visible … … 362 391 /** 363 392 * Calculates the position on the map of a given coordinate 364 * 393 * 365 394 * @param coord 366 * @return point on the map or <code>null</code> if the point is not visible and checkOutside set to <code>true</code> 395 * @return point on the map or <code>null</code> if the point is not visible 396 * and checkOutside set to <code>true</code> 367 397 */ 368 398 public Point getMapPosition(Coordinate coord, boolean checkOutside) { … … 474 504 /** 475 505 * Moves the visible map pane. 476 * 506 * 477 507 * @param x 478 508 * horizontal movement in pixel. … … 539 569 * derived implementations for adapting zoom dependent values. The new zoom 540 570 * level can be obtained via {@link #getZoom()}. 541 * 571 * 542 572 * @param oldZoom 543 573 * the previous zoom level … … 566 596 /** 567 597 * Enables or disables painting of the {@link MapMarker} 568 * 598 * 569 599 * @param mapMarkersVisible 570 600 * @see #addMapMarker(MapMarker) … … 643 673 /** 644 674 * Enables or disables painting of the {@link MapRectangle} 645 * 675 * 646 676 * @param mapMarkersVisible 647 677 * @see #addMapRectangle(MapRectangle) … … 653 683 } 654 684 655 /* (non-Javadoc) 656 * @see org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener#getTileCache() 685 /* 686 * (non-Javadoc) 687 * 688 * @see 689 * org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener#getTileCache 690 * () 657 691 */ 658 692 public TileCache getTileCache() {
Note:
See TracChangeset
for help on using the changeset viewer.