Changeset 19697 in osm for applications/viewer


Ignore:
Timestamp:
2010-01-31T13:22:03+01:00 (14 years ago)
Author:
stotz
Message:

JavaDoc added for getPosition() methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r18890 r19697  
    1010import java.awt.event.ActionEvent;
    1111import java.awt.event.ActionListener;
     12import java.awt.event.MouseEvent;
    1213import java.util.LinkedList;
    1314import java.util.List;
     
    2829
    2930/**
    30  *
     31 * 
    3132 * Provides a simple panel that displays pre-rendered map tiles loaded from the
    3233 * OpenStreetMap project.
    33  *
     34 * 
    3435 * @author Jan Peter Stotz
    35  *
     36 * 
    3637 */
    3738public class JMapViewer extends JPanel implements TileLoaderListener {
     
    9798        setPreferredSize(new Dimension(400, 400));
    9899        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);
    99108    }
    100109
     
    148157     * Changes the map pane so that it is centered on the specified coordinate
    149158     * at the given zoom level.
    150      *
     159     * 
    151160     * @param lat
    152161     *            latitude of the specified coordinate
     
    164173     * level is displayed on the map at the screen coordinate
    165174     * <code>mapPoint</code>.
    166      *
     175     * 
    167176     * @param mapPoint
    168177     *            point on the map denoted in pixels where the coordinate should
     
    292301    }
    293302
     303    /**
     304     * Calculates the latitude/longitude coordinate of the center of the
     305     * currently displayed map area.
     306     *
     307     * @return latitude / longitude
     308     */
    294309    public Coordinate getPosition() {
    295310        double lon = OsmMercator.XToLon(center.x, zoom);
     
    298313    }
    299314
     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     */
    300324    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     */
    308336    public Coordinate getPosition(int mapPointX, int mapPointY) {
    309337        int x = center.x + mapPointX - getWidth() / 2;
     
    316344    /**
    317345     * Calculates the position on the map of a given coordinate
    318      *
     346     * 
    319347     * @param lat
    320348     * @param lon
    321349     * @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>
    323352     */
    324353    public Point getMapPosition(double lat, double lon, boolean checkOutside) {
     
    337366    /**
    338367     * Calculates the position on the map of a given coordinate
    339      *
     368     * 
    340369     * @param lat
    341370     * @param lon
     
    348377    /**
    349378     * Calculates the position on the map of a given coordinate
    350      *
     379     * 
    351380     * @param coord
    352381     * @return point on the map or <code>null</code> if the point is not visible
     
    362391    /**
    363392     * Calculates the position on the map of a given coordinate
    364      *
     393     * 
    365394     * @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>
    367397     */
    368398    public Point getMapPosition(Coordinate coord, boolean checkOutside) {
     
    474504    /**
    475505     * Moves the visible map pane.
    476      *
     506     * 
    477507     * @param x
    478508     *            horizontal movement in pixel.
     
    539569     * derived implementations for adapting zoom dependent values. The new zoom
    540570     * level can be obtained via {@link #getZoom()}.
    541      *
     571     * 
    542572     * @param oldZoom
    543573     *            the previous zoom level
     
    566596    /**
    567597     * Enables or disables painting of the {@link MapMarker}
    568      *
     598     * 
    569599     * @param mapMarkersVisible
    570600     * @see #addMapMarker(MapMarker)
     
    643673    /**
    644674     * Enables or disables painting of the {@link MapRectangle}
    645      *
     675     * 
    646676     * @param mapMarkersVisible
    647677     * @see #addMapRectangle(MapRectangle)
     
    653683    }
    654684
    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     * ()
    657691     */
    658692    public TileCache getTileCache() {
Note: See TracChangeset for help on using the changeset viewer.