Changeset 29757 in osm for applications/viewer/jmapviewer/src/org
- Timestamp:
- 2013-07-17T00:02:17+02:00 (12 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java
r29385 r29757 27 27 public static final Font ATTR_FONT = new Font("Arial", Font.PLAIN, 10); 28 28 public static final Font ATTR_LINK_FONT; 29 29 30 30 protected Rectangle attrTextBounds = null; 31 31 protected Rectangle attrToUBounds = null; … … 59 59 attrImageBounds = null; 60 60 attrTextBounds = null; 61 return; 61 return; 62 62 } 63 63 64 64 // Draw attribution 65 65 Font font = g.getFont(); … … 128 128 return false; 129 129 } 130 130 131 131 public boolean handleAttribution(Point p, boolean click) { 132 132 if (source == null || !source.requiresAttribution()) -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java
r29517 r29757 198 198 map().addMapPolygon( bermudas ); 199 199 map().addMapPolygon( new MapPolygonImpl(germanyEastLayer, "Riedstadt", ebersheim, darmstadt, eberstadt, empty)); 200 200 201 201 map().addMapMarker(new MapMarkerCircle(germanyWestLayer, "North of Suisse", new Coordinate(48, 7), .5)); 202 202 Layer spain = treeMap.addLayer("Spain"); 203 203 map().addMapMarker(new MapMarkerCircle(spain, "La Garena", new Coordinate(40.4838, -3.39), .002)); 204 204 spain.setVisible(false); 205 205 206 206 Layer wales = treeMap.addLayer("UK"); 207 207 map().addMapRectangle(new MapRectangleImpl(wales, "Wales", c(53.35,-4.57), c(51.64,-2.63))); … … 209 209 // map.setDisplayPositionByLatLon(49.807, 8.6, 11); 210 210 // map.setTileGridVisible(true); 211 211 212 212 map().addMouseListener(new MouseAdapter() { 213 213 @Override … … 218 218 } 219 219 }); 220 220 221 221 map().addMouseMotionListener(new MouseAdapter() { 222 222 @Override -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r29516 r29757 82 82 protected JButton zoomInButton; 83 83 protected JButton zoomOutButton; 84 84 85 85 public static enum ZOOM_BUTTON_STYLE { 86 86 HORIZONTAL, … … 425 425 return new Point(x, y); 426 426 } 427 427 428 428 /** 429 429 * Calculates the position on the map of a given coordinate … … 454 454 return getMapPosition(lat, lon, true); 455 455 } 456 456 457 457 /** 458 458 * Calculates the position on the map of a given coordinate … … 561 561 int x_max = getWidth(); 562 562 int y_max = getHeight(); 563 563 564 564 // calculate the length of the grid (number of squares per edge) 565 565 int gridLength = 1 << zoom; … … 617 617 center.x = center.x % mapSize; 618 618 } 619 619 620 620 if (mapPolygonsVisible && mapPolygonList != null) { 621 621 for (MapPolygon polygon : mapPolygonList) { … … 704 704 rectangle.paint(g, pTopLeft, pBottomRight); 705 705 } 706 706 707 707 } 708 708 } … … 1010 1010 repaint(); 1011 1011 } 1012 1012 1013 1013 public boolean isScrollWrapEnabled() { 1014 1014 return scrollWrapEnabled; 1015 1015 } 1016 1016 1017 1017 public void setScrollWrapEnabled(boolean scrollWrapEnabled) { 1018 1018 this.scrollWrapEnabled = scrollWrapEnabled; 1019 1019 repaint(); 1020 1020 } 1021 1021 1022 1022 public ZOOM_BUTTON_STYLE getZoomButtonStyle() { 1023 1023 return zoomButtonStyle; 1024 1024 } 1025 1025 1026 1026 public void setZoomButtonStyle(ZOOM_BUTTON_STYLE style) { 1027 1027 zoomButtonStyle = style; … … 1052 1052 return tileController; 1053 1053 } 1054 1054 1055 1055 /** 1056 1056 * Return tile information caching class -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapMarkerCircle.java
r29517 r29757 61 61 return coord.getLon(); 62 62 } 63 63 64 64 public double getRadius() { 65 65 return radius; 66 66 } 67 67 68 68 public STYLE getMarkerStyle() { 69 69 return markerStyle; … … 73 73 int size_h = radio; 74 74 int size = size_h * 2; 75 75 76 76 if (g instanceof Graphics2D && getBackColor()!=null) { 77 77 Graphics2D g2 = (Graphics2D) g; … … 84 84 g.setColor(getColor()); 85 85 g.drawOval(position.x - size_h, position.y - size_h, size, size); 86 86 87 87 if(getLayer()==null||getLayer().isVisibleTexts()) paintText(g, position); 88 88 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapMarkerDot.java
r29517 r29757 47 47 super(layer, name, coord, DOT_RADIUS, STYLE.FIXED, style); 48 48 } 49 49 50 50 public static Style getDefaultStyle(){ 51 51 return new Style(Color.BLACK, Color.YELLOW, null, getDefaultFont()); -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapPolygonImpl.java
r29516 r29757 80 80 Color oldColor = g.getColor(); 81 81 g.setColor(getColor()); 82 82 83 83 Stroke oldStroke = null; 84 84 if (g instanceof Graphics2D) { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
r29731 r29757 55 55 56 56 protected String cacheDirBase; 57 57 58 58 protected final Map<TileSource, File> sourceCacheDirMap; 59 59 … … 128 128 return dir; 129 129 } 130 130 131 131 protected class FileLoadJob implements TileJob { 132 132 InputStream input = null; … … 342 342 * </ul> 343 343 * 344 * @param fileAge time of the 344 * @param fileAge time of the 345 345 * @return <code>true</code> if the tile on the server is newer than the 346 346 * file … … 492 492 this.cacheDirBase = dir.getAbsolutePath(); 493 493 } 494 494 495 495 @Override 496 496 public void clearCache(TileSource source) { 497 497 clearCache(source, null); 498 498 } 499 499 500 500 @Override 501 501 public void clearCache(TileSource source, TileClearController controller) { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java
r28505 r29757 19 19 public static final double MAX_LAT = 85.05112877980659; 20 20 public static final double MIN_LAT = -85.05112877980659; 21 private static double EARTH_RADIUS = 6378137; // equatorial earth radius for EPSG:3857 (Mercator) 21 private static double EARTH_RADIUS = 6378137; // equatorial earth radius for EPSG:3857 (Mercator) 22 22 23 23 public static double radius(int aZoomlevel) { … … 51 51 * @param x2 the second x coordinate 52 52 * @param y2 the second y coordinate 53 * 53 * 54 54 * @param zoomLevel the zoom level 55 55 * @return the distance … … 85 85 * Math.cos(aEndLong - aStartLong)); 86 86 87 return (EARTH_RADIUS * distance); 87 return (EARTH_RADIUS * distance); 88 88 } 89 89 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
r29528 r29757 60 60 try { 61 61 tile.loadImage(input); 62 } finally { 62 } finally { 63 63 input.close(); 64 64 input = null; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java
r29362 r29757 284 284 /** 285 285 * Puts the given key/value pair to the metadata of the tile. 286 * If value is null, the (possibly existing) key/value pair is removed from 286 * If value is null, the (possibly existing) key/value pair is removed from 287 287 * the meta data. 288 * 288 * 289 289 * @param key 290 * @param value 290 * @param value 291 291 */ 292 292 public void putValue(String key, String value) { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/events/JMVCommandEvent.java
r26701 r29757 8 8 * Used for passing events between UI components and other 9 9 * objects that register as a JMapViewerEventListener 10 * 10 * 11 11 * @author Jason Huntley 12 12 * … … 20 20 private COMMAND command; 21 21 /** 22 * 22 * 23 23 */ 24 24 private static final long serialVersionUID = 8701544867914969620L; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/JMapViewerEventListener.java
r26701 r29757 10 10 * Must be implemented for processing commands while user 11 11 * interacts with map viewer. 12 * 12 * 13 13 * @author Jason Huntley 14 14 * 15 15 */ 16 16 public interface JMapViewerEventListener extends EventListener { 17 17 public void processCommand(JMVCommandEvent command); 18 18 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapMarker.java
r29513 r29757 33 33 */ 34 34 public double getLon(); 35 35 36 36 /** 37 37 * @return Radius of the map marker position 38 38 */ 39 39 public double getRadius(); 40 40 41 41 /** 42 42 * @return Style of the map marker -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapPolygon.java
r29516 r29757 20 20 21 21 /** 22 * Paints the map rectangle on the map. The <code>points</code> 22 * Paints the map rectangle on the map. The <code>points</code> 23 23 * are specifying the coordinates within <code>g</code> 24 24 * … … 29 29 30 30 /** 31 * Paints the map rectangle on the map. The <code>polygon</code> 31 * Paints the map rectangle on the map. The <code>polygon</code> 32 32 * is specifying the coordinates within <code>g</code> 33 33 * -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
r26976 r29757 65 65 } 66 66 67 private static double RADIUS_E = 6378137; 67 private static double RADIUS_E = 6378137; /* radius of Earth at equator, m */ 68 68 private static double EQUATOR = 40075016.68557849; /* equator length, m */ 69 private static double E = 0.0818191908426; 69 private static double E = 0.0818191908426; /* eccentricity of Earth's ellipsoid */ 70 70 71 71 @Override … … 93 93 @Override 94 94 public double tileYToLat(int y, int zoom) { 95 95 Random r= new Random(); 96 96 double lat0, lat; 97 97 98 99 100 98 lat = cached_lat; 99 do { 100 lat0 = lat; 101 101 lat = lat - Math.toDegrees(NextTerm(Math.toRadians(lat), y, zoom)); 102 102 if (lat > OsmMercator.MAX_LAT || lat < OsmMercator.MIN_LAT) { … … 105 105 OsmMercator.MIN_LAT)); 106 106 } 107 107 } while ((Math.abs(lat0 - lat) > 0.000001)); 108 108 109 109 cached_lat = lat; 110 110 111 111 return (lat); … … 116 116 double sinl=Math.sin(lat); 117 117 double cosl=Math.cos(lat); 118 118 double ec, f, df; 119 119 120 120 zoom = (int )Math.pow(2.0, zoom - 1); 121 121 ec = Math.exp((1 - y/zoom)*Math.PI); 122 122 123 124 123 f = (Math.tan(Math.PI/4+lat/2) - 124 ec * Math.pow(Math.tan(Math.PI/4 + Math.asin(E * sinl)/2), E)); 125 125 df = 1/(1 - sinl) - ec * E * cosl/((1 - E * sinl) * 126 126 (Math.sqrt (1 - E * E * sinl * sinl)));
Note:
See TracChangeset
for help on using the changeset viewer.