Changeset 18772 in osm for applications/viewer/jmapviewer/src/org/openstreetmap
- Timestamp:
- 2009-11-24T10:16:52+01:00 (15 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Coordinate.java
r16032 r18772 12 12 * This class encapsulates a Point2D.Double and provide access 13 13 * via <tt>lat</tt> and <tt>lon</tt>. 14 * 14 * 15 15 * @author Jan Peter Stotz 16 * 16 * 17 17 */ 18 18 public class Coordinate implements Serializable { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java
r16969 r18772 13 13 * Default map controller which implements map moving by pressing the right 14 14 * mouse button and zooming by double click or by mouse wheel. 15 * 15 * 16 16 * @author Jan Peter Stotz 17 * 17 * 18 18 */ 19 19 public class DefaultMapController extends JMapController implements MouseListener, MouseMotionListener, … … 87 87 /** 88 88 * Enables or disables that the map pane can be moved using the mouse. 89 * 89 * 90 90 * @param movementEnabled 91 91 */ … … 106 106 * <li>{@link MouseEvent#BUTTON3} (right mouse button)</li> 107 107 * </ul> 108 * 108 * 109 109 * @param movementMouseButton 110 110 */ -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java
r14053 r18772 20 20 21 21 /** 22 * 22 * 23 23 * Demonstrates the usage of {@link JMapViewer} 24 * 24 * 25 25 * @author Jan Peter Stotz 26 * 26 * 27 27 */ 28 28 public class Demo extends JFrame { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapController.java
r14053 r18772 16 16 * <li>{@link MouseWheelListener}</li> 17 17 * </ul> 18 * 18 * 19 19 * @author Jan Peter Stotz 20 20 */ -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r16391 r18772 28 28 29 29 /** 30 * 30 * 31 31 * Provides a simple panel that displays pre-rendered map tiles loaded from the 32 32 * OpenStreetMap project. 33 * 33 * 34 34 * @author Jan Peter Stotz 35 * 35 * 36 36 */ 37 37 public class JMapViewer extends JPanel implements TileLoaderListener { … … 54 54 55 55 protected boolean tileGridVisible; 56 57 protected TileController tileController; 56 57 protected TileController tileController; 58 58 59 59 /** … … 71 71 protected JButton zoomInButton; 72 72 protected JButton zoomOutButton; 73 74 75 73 76 74 /** … … 150 148 * Changes the map pane so that it is centered on the specified coordinate 151 149 * at the given zoom level. 152 * 150 * 153 151 * @param lat 154 152 * latitude of the specified coordinate … … 166 164 * level is displayed on the map at the screen coordinate 167 165 * <code>mapPoint</code>. 168 * 166 * 169 167 * @param mapPoint 170 168 * point on the map denoted in pixels where the coordinate should … … 252 250 setDisplayPosition(x, y, newZoom); 253 251 } 254 252 255 253 /** 256 254 * Sets the displayed map pane and zoom level so that all map markers are … … 318 316 /** 319 317 * Calculates the position on the map of a given coordinate 320 * 318 * 321 319 * @param lat 322 320 * @param lon 323 321 * @param checkOutside 324 * @return point on the map or <code>null</code> if the point is not visible and checkOutside set to <code>true</code> 322 * @return point on the map or <code>null</code> if the point is not visible and checkOutside set to <code>true</code> 325 323 */ 326 324 public Point getMapPosition(double lat, double lon, boolean checkOutside) { … … 336 334 return new Point(x, y); 337 335 } 338 336 339 337 /** 340 338 * Calculates the position on the map of a given coordinate 341 * 339 * 342 340 * @param lat 343 341 * @param lon … … 347 345 return getMapPosition(lat, lon, true); 348 346 } 349 347 350 348 /** 351 349 * Calculates the position on the map of a given coordinate 352 * 350 * 353 351 * @param coord 354 352 * @return point on the map or <code>null</code> if the point is not visible … … 361 359 } 362 360 } 363 361 364 362 /** 365 363 * Calculates the position on the map of a given coordinate 366 * 364 * 367 365 * @param coord 368 366 * @return point on the map or <code>null</code> if the point is not visible and checkOutside set to <code>true</code> … … 476 474 /** 477 475 * Moves the visible map pane. 478 * 476 * 479 477 * @param x 480 478 * horizontal movement in pixel. … … 540 538 * derived implementations for adapting zoom dependent values. The new zoom 541 539 * level can be obtained via {@link #getZoom()}. 542 * 540 * 543 541 * @param oldZoom 544 542 * the previous zoom level … … 567 565 /** 568 566 * Enables or disables painting of the {@link MapMarker} 569 * 567 * 570 568 * @param mapMarkersVisible 571 569 * @see #addMapMarker(MapMarker) … … 644 642 /** 645 643 * Enables or disables painting of the {@link MapSquare} 646 * 644 * 647 645 * @param mapMarkersVisible 648 646 * @see #addMapSquare(MapSquare) -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java
r16391 r18772 13 13 * more than {@link #WORKER_THREAD_TIMEOUT} seconds (default: 30), the instance 14 14 * ends itself. 15 * 15 * 16 16 * @author Jan Peter Stotz 17 17 */ -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapMarkerDot.java
r18286 r18772 13 13 * is painted as a circle with a black border line and filled with a specified 14 14 * color. 15 * 15 * 16 16 * @author Jan Peter Stotz 17 * 17 * 18 18 */ 19 19 public class MapMarkerDot implements MapMarker { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java
r14053 r18772 13 13 * memory up to a certain limit ({@link #getCacheSize()}). If the limit is 14 14 * exceeded the least recently used {@link Tile} objects will be deleted. 15 * 15 * 16 16 * @author Jan Peter Stotz 17 17 */ … … 81 81 82 82 /** 83 * Clears the cache deleting all tiles from memory 83 * Clears the cache deleting all tiles from memory 84 84 */ 85 85 public void clear() { … … 100 100 /** 101 101 * Changes the maximum number of {@link Tile} objects that this cache holds. 102 * 102 * 103 103 * @param cacheSize 104 104 * new maximum number of tiles … … 142 142 * elements. It supports element removal in constant time - in difference to 143 143 * the Java implementation which needs O(n). 144 * 144 * 145 145 * @author Jan Peter Stotz 146 146 */ … … 162 162 /** 163 163 * Add the element to the head of the list. 164 * 164 * 165 165 * @param new element to be added 166 166 */ … … 182 182 /** 183 183 * Removes the specified elemntent form the list. 184 * 184 * 185 185 * @param element 186 186 * to be removed -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
r16850 r18772 27 27 * saves all loaded files in a directory located in the the temporary directory. 28 28 * If a tile is present in this file cache it will not be loaded from OSM again. 29 * 29 * 30 30 * @author Jan Peter Stotz 31 31 * @author Stefan Zeller … … 71 71 throw new IOException("No temp directory set"); 72 72 String subDirName = "JMapViewerTiles"; 73 // On Linux/Unix systems we do not have a per user tmp directory. 74 // Therefore we add the user name for getting a unique dir name. 73 // On Linux/Unix systems we do not have a per user tmp directory. 74 // Therefore we add the user name for getting a unique dir name. 75 75 if (userName != null && userName.length() > 0) 76 76 subDirName += "_" + userName; … … 273 273 * Performs a <code>HEAD</code> request for retrieving the 274 274 * <code>LastModified</code> header value. 275 * 275 * 276 276 * Note: This does only work with servers providing the 277 277 * <code>LastModified</code> header: … … 280 280 * <li>{@link OsmTileLoader#MAP_MAPNIK} - not supported</li> 281 281 * </ul> 282 * 282 * 283 283 * @param fileAge 284 284 * @return <code>true</code> if the tile on the server is newer than the … … 371 371 * if a newer tile is available using the mechanism specified for the 372 372 * selected tile source/server. 373 * 373 * 374 374 * @param maxFileAge 375 375 * maximum age in milliseconds -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java
r16978 r18772 9 9 * space is measured in pixels. The origin of the map space is the top left 10 10 * corner. The map space origin (0,0) has latitude ~85 and longitude -180 11 * 11 * 12 12 * @author Tim Haussmann 13 * 13 * 14 14 */ 15 15 … … 27 27 * Returns the absolut number of pixels in y or x, defined as: 2^Zoomlevel * 28 28 * TILE_WIDTH where TILE_WIDTH is the width of a tile in pixels 29 * 29 * 30 30 * @param aZoomlevel 31 31 * @return … … 45 45 /** 46 46 * Transform longitude to pixelspace 47 * 47 * 48 48 * <p> 49 49 * Mathematical optimization<br> … … 55 55 * </code> 56 56 * </p> 57 * 57 * 58 58 * @param aLongitude 59 59 * [-180..180] … … 74 74 * <code> 75 75 * log(u) := log((1.0 + sin(toRadians(aLat))) / (1.0 - sin(toRadians(aLat))<br> 76 * 76 * 77 77 * y = -1 * (radius(aZoomlevel) / 2 * log(u)))) - falseNorthing(aZoomlevel))<br> 78 78 * y = -1 * (getMaxPixel(aZoomlevel) / 2 * PI / 2 * log(u)) - -1 * getMaxPixel(aZoomLevel) / 2<br> … … 101 101 /** 102 102 * Transforms pixel coordinate X to longitude 103 * 103 * 104 104 * <p> 105 105 * Mathematical optimization<br> … … 123 123 /** 124 124 * Transforms pixel coordinate Y to latitude 125 * 125 * 126 126 * @param aY 127 127 * [0..2^Zoomlevel*TILE_WIDTH[ -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
r18211 r18772 15 15 /** 16 16 * A {@link TileLoader} implementation that loads tiles from OSM via HTTP. 17 * 17 * 18 18 * @author Jan Peter Stotz 19 19 */ … … 21 21 22 22 /** 23 * Holds the used user agent used for HTTP requests. If this field is 23 * Holds the used user agent used for HTTP requests. If this field is 24 24 * <code>null</code>, the default Java user agent is used. 25 25 */ -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java
r18211 r18772 18 18 * Holds one map tile. Additionally the code for loading the tile image and 19 19 * painting it is also included in this class. 20 * 20 * 21 21 * @author Jan Peter Stotz 22 22 */ … … 52 52 /** 53 53 * Creates a tile with empty image. 54 * 54 * 55 55 * @param source 56 56 * @param xtile … … 191 191 * Paints the tile-image on the {@link Graphics} <code>g</code> at the 192 192 * position <code>x</code>/<code>y</code>. 193 * 193 * 194 194 * @param g 195 195 * @param x -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileController.java
r16399 r18772 11 11 protected TileCache tileCache; 12 12 protected TileSource tileSource; 13 13 14 14 JobDispatcher jobDispatcher; 15 15 16 16 public TileController(TileSource source, TileCache tileCache, TileLoaderListener listener) { 17 17 tileSource = new OsmTileSource.Mapnik(); … … 20 20 jobDispatcher = JobDispatcher.getInstance(); 21 21 } 22 22 23 23 /** 24 24 * retrieves a tile from the cache. If the tile is not present in the cache 25 25 * a load job is added to the working queue of {@link JobThread}. 26 * 26 * 27 27 * @param tilex 28 28 * @param tiley … … 76 76 77 77 /** 78 * 78 * 79 79 */ 80 80 public void cancelOutstandingJobs() { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapMarker.java
r16032 r18772 10 10 /** 11 11 * Interface to be implemented by all one dimensional elements that can be displayed on the map. 12 * 12 * 13 13 * @author Jan Peter Stotz 14 14 * @see JMapViewer#addMapMarker(MapMarker) … … 30 30 * Paints the map marker on the map. The <code>position</code> specifies the 31 31 * coordinates within <code>g</code> 32 * 32 * 33 33 * @param g 34 34 * @param position -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapSquare.java
r16032 r18772 11 11 /** 12 12 * Interface to be implemented by squares that can be displayed on the map. 13 * 13 * 14 14 * @author Stefan Zeller 15 15 * @see JMapViewer#addMapSquare(MapSquare) … … 32 32 * Paints the map square on the map. The <code>topLeft</code> and 33 33 * <code>bottomRight</code> specifies the coordinates within <code>g</code> 34 * 34 * 35 35 * @param g 36 36 * @param position -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileCache.java
r14053 r18772 9 9 * Implement this interface for creating your custom tile cache for 10 10 * {@link JMapViewer}. 11 * 11 * 12 12 * @author Jan Peter Stotz 13 13 */ … … 17 17 * Retrieves a tile from the cache if present, otherwise <code>null</code> 18 18 * will be returned. 19 * 19 * 20 20 * @param source 21 21 * @param x … … 34 34 * via {@link #getTile(int, int, int)} is unspecified and depends on the 35 35 * implementation. 36 * 36 * 37 37 * @param tile 38 38 */ -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java
r14053 r18772 6 6 * Interface for implementing a tile loader. Tiles are usually loaded via HTTP 7 7 * or from a file. 8 * 8 * 9 9 * @author Jan Peter Stotz 10 10 */ … … 15 15 * should create and return a new {@link Job} instance that performs the 16 16 * load action. 17 * 17 * 18 18 * @param tileLayerSource 19 19 * @param tilex -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoaderListener.java
r14053 r18772 8 8 9 9 /** 10 * Will be called if a new {@link Tile} has been loaded successfully. 11 * Loaded can mean downloaded or loaded from file cache. 12 * 10 * Will be called if a new {@link Tile} has been loaded successfully. 11 * Loaded can mean downloaded or loaded from file cache. 12 * 13 13 * @param tile 14 14 */ -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java
r13758 r18772 6 6 7 7 /** 8 * 8 * 9 9 * @author Jan Peter Stotz 10 10 */ … … 40 40 * Specifies the maximum zoom value. The number of zoom levels is [0.. 41 41 * {@link #getMaxZoom()}]. 42 * 42 * 43 43 * @return maximum zoom value that has to be smaller or equal to 44 44 * {@link JMapViewer#MAX_ZOOM} … … 47 47 48 48 /** 49 * Specifies the minimum zoom value. This value is usually 0. 50 * Only for maps that cover a certain region up to a limited zoom level 51 * this method should return a value different than 0. 52 * 49 * Specifies the minimum zoom value. This value is usually 0. 50 * Only for maps that cover a certain region up to a limited zoom level 51 * this method should return a value different than 0. 52 * 53 53 * @return minimum zoom value - usually 0 54 54 */ … … 64 64 * A tile layer name has to be unique and has to consist only of characters 65 65 * valid for filenames. 66 * 66 * 67 67 * @return Name of the tile layer 68 68 */ … … 71 71 /** 72 72 * Constructs the tile url. 73 * 73 * 74 74 * @param zoom 75 75 * @param tilex … … 82 82 * Specifies the tile image type. For tiles rendered by Mapnik or 83 83 * Osmarenderer this is usually <code>"png"</code>. 84 * 84 * 85 85 * @return file extension of the tile image type 86 86 */
Note:
See TracChangeset
for help on using the changeset viewer.