Changeset 1823 in josm for trunk/src/org
- Timestamp:
- 2009-07-22T20:33:41+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r1821 r1823 628 628 */ 629 629 private void computeHelperLine() { 630 MapView mv = Main.map.mapView; 630 631 if (mousePos == null) { 631 632 // Don't draw the line. … … 651 652 652 653 if (!ctrl && mousePos != null) { 653 currentMouseNode = Main.map.mapView.getNearestNode(mousePos);654 currentMouseNode = mv.getNearestNode(mousePos); 654 655 } 655 656 … … 657 658 // *and* there is no node nearby (because nodes beat ways when re-using) 658 659 if(!ctrl && currentMouseNode == null) { 659 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(mousePos);660 List<WaySegment> wss = mv.getNearestWaySegments(mousePos); 660 661 for(WaySegment ws : wss) { 661 662 mouseOnExistingWays.add(ws.way); … … 670 671 } else { 671 672 // no node found in clicked area 672 currentMouseEastNorth = Main.map.mapView.getEastNorth(mousePos.x, mousePos.y);673 currentMouseEastNorth = mv.getEastNorth(mousePos.x, mousePos.y); 673 674 } 674 675 … … 708 709 709 710 // find out the distance, in metres, between the base point and the mouse cursor 710 LatLon mouseLatLon = Main.proj.eastNorth2latlon(currentMouseEastNorth);711 LatLon mouseLatLon = mv.getProjection().eastNorth2latlon(currentMouseEastNorth); 711 712 distance = currentBaseNode.getCoor().greatCircleDistance(mouseLatLon); 712 713 double hdg = Math.toDegrees(currentBaseNode.getCoor().heading(mouseLatLon)); -
trunk/src/org/openstreetmap/josm/data/projection/Epsg4326.java
r1805 r1823 36 36 } 37 37 38 public ProjectionBounds getWorldBounds()39 {40 Bounds b = getWorldBoundsLatLon();41 return new ProjectionBounds(latlon2eastNorth(b.min), latlon2eastNorth(b.max));42 }43 44 38 public Bounds getWorldBoundsLatLon() 45 39 { -
trunk/src/org/openstreetmap/josm/data/projection/Lambert.java
r1724 r1823 277 277 } 278 278 279 public ProjectionBounds getWorldBounds()280 {281 Bounds b = getWorldBoundsLatLon();282 return new ProjectionBounds(latlon2eastNorth(b.min), latlon2eastNorth(b.max));283 }284 285 279 public Bounds getWorldBoundsLatLon() 286 280 { -
trunk/src/org/openstreetmap/josm/data/projection/LambertEST.java
r1724 r1823 107 107 } 108 108 109 public ProjectionBounds getWorldBounds()110 {111 Bounds b = getWorldBoundsLatLon();112 return new ProjectionBounds(latlon2eastNorth(b.min), latlon2eastNorth(b.max));113 }114 115 109 public Bounds getWorldBoundsLatLon() 116 110 { -
trunk/src/org/openstreetmap/josm/data/projection/Mercator.java
r1724 r1823 47 47 } 48 48 49 public ProjectionBounds getWorldBounds()50 {51 Bounds b = getWorldBoundsLatLon();52 return new ProjectionBounds(latlon2eastNorth(b.min), latlon2eastNorth(b.max));53 }54 55 49 public Bounds getWorldBoundsLatLon() 56 50 { -
trunk/src/org/openstreetmap/josm/data/projection/Projection.java
r1722 r1823 63 63 * Get the bounds of the world 64 64 */ 65 ProjectionBounds getWorldBounds();66 65 Bounds getWorldBoundsLatLon(); 67 66 } -
trunk/src/org/openstreetmap/josm/data/projection/SwissGrid.java
r1724 r1823 101 101 } 102 102 103 public ProjectionBounds getWorldBounds()104 {105 Bounds b = getWorldBoundsLatLon();106 return new ProjectionBounds(latlon2eastNorth(b.min), latlon2eastNorth(b.max));107 }108 109 103 public Bounds getWorldBoundsLatLon() 110 104 { -
trunk/src/org/openstreetmap/josm/data/projection/UTM.java
r1743 r1823 354 354 } 355 355 356 public ProjectionBounds getWorldBounds()357 {358 Bounds b = getWorldBoundsLatLon();359 return new ProjectionBounds(latlon2eastNorth(b.min), latlon2eastNorth(b.max));360 }361 362 356 public Bounds getWorldBoundsLatLon() 363 357 { -
trunk/src/org/openstreetmap/josm/gui/MapSlider.java
r1722 r1823 30 30 if (getModel().getValueIsAdjusting()) return; 31 31 32 ProjectionBounds world = Main.proj.getWorldBounds();32 ProjectionBounds world = this.mv.getMaxProjectionBounds(); 33 33 ProjectionBounds current = this.mv.getProjectionBounds(); 34 34 … … 54 54 if (preventChange) return; 55 55 56 ProjectionBounds world = Main.proj.getWorldBounds();56 ProjectionBounds world = this.mv.getMaxProjectionBounds(); 57 57 double fact = Math.pow(1.1, getValue()); 58 58 double es = world.max.east()-world.min.east(); -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r1820 r1823 13 13 import java.awt.event.MouseEvent; 14 14 import java.awt.event.MouseMotionListener; 15 import java.awt.geom.GeneralPath; 15 16 import java.awt.image.BufferedImage; 16 17 import java.util.ArrayList; … … 29 30 import org.openstreetmap.josm.actions.MoveAction; 30 31 import org.openstreetmap.josm.actions.mapmode.MapMode; 32 import org.openstreetmap.josm.data.Bounds; 31 33 import org.openstreetmap.josm.data.ProjectionBounds; 32 34 import org.openstreetmap.josm.data.SelectionChangedListener; … … 35 37 import org.openstreetmap.josm.data.osm.OsmPrimitive; 36 38 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 39 import org.openstreetmap.josm.data.coor.LatLon; 37 40 import org.openstreetmap.josm.gui.layer.Layer; 38 41 import org.openstreetmap.josm.gui.layer.MapViewPaintable; … … 295 298 // draw world borders 296 299 tempG.setColor(Color.WHITE); 297 ProjectionBounds b = getProjection().getWorldBounds(); 298 Point min = getPoint(b.min); 299 Point max = getPoint(b.max); 300 int x1 = Math.min(min.x, max.x); 301 int y1 = Math.min(min.y, max.y); 302 int x2 = Math.max(min.x, max.x); 303 int y2 = Math.max(min.y, max.y); 304 if (x1 > 0 || y1 > 0 || x2 < getWidth() || y2 < getHeight()) { 305 tempG.drawRect(x1, y1, x2-x1+1, y2-y1+1); 300 GeneralPath path = new GeneralPath(); 301 Bounds b = getProjection().getWorldBoundsLatLon(); 302 double lat = b.min.lat(); 303 double lon = b.min.lon(); 304 305 Point p = getPoint(b.min); 306 path.moveTo(p.x, p.y); 307 308 double max = b.max.lat(); 309 for(; lat <= max; lat += 1.0) 310 { 311 p = getPoint(new LatLon(lat >= max ? max : lat, lon)); 312 path.lineTo(p.x, p.y); 313 } 314 lat = max; max = b.max.lon(); 315 for(; lon <= max; lon += 1.0) 316 { 317 p = getPoint(new LatLon(lat, lon >= max ? max : lon)); 318 path.lineTo(p.x, p.y); 319 } 320 lon = max; max = b.min.lat(); 321 for(; lat >= max; lat -= 1.0) 322 { 323 p = getPoint(new LatLon(lat <= max ? max : lat, lon)); 324 path.lineTo(p.x, p.y); 325 } 326 lat = max; max = b.min.lon(); 327 for(; lon >= max; lon -= 1.0) 328 { 329 p = getPoint(new LatLon(lat, lon <= max ? max : lon)); 330 path.lineTo(p.x, p.y); 306 331 } 307 332 … … 309 334 playHeadMarker.paint(tempG, this); 310 335 } 336 tempG.draw(path); 311 337 312 338 g.drawImage(offscreenBuffer, 0, 0, null); … … 322 348 } 323 349 if (box.getBounds() == null) { 324 box.visit(getProjection().getWorldBounds()); 350 box.visit(getProjection().getWorldBoundsLatLon()); 325 351 } 326 352 if (!box.hasExtend()) { -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r1814 r1823 72 72 public double getDist100Pixel() 73 73 { 74 LatLon ll1 = getLatLon(0,0); 75 LatLon ll2 = getLatLon(100,0); 74 int w = getWidth()/2; 75 int h = getHeight()/2; 76 LatLon ll1 = getLatLon(w-50,h); 77 LatLon ll2 = getLatLon(w+50,h); 76 78 return ll1.greatCircleDistance(ll2); 77 79 } … … 103 105 center.east() - getWidth()/2.0*scale, 104 106 center.north() - getHeight()/2.0*scale), 105 106 107 107 new EastNorth( 108 center.east() + getWidth()/2.0*scale, 109 center.north() + getHeight()/2.0*scale)); 108 110 }; 109 111 112 /* FIXME: replace with better method - used by MapSlider */ 113 public ProjectionBounds getMaxProjectionBounds() { 114 Bounds b = getProjection().getWorldBoundsLatLon(); 115 return new ProjectionBounds(getProjection().latlon2eastNorth(b.min), 116 getProjection().latlon2eastNorth(b.max)); 117 }; 118 119 /* FIXME: replace with better method - used by Main to reset Bounds when projection changes, don't use otherwise */ 110 120 public Bounds getRealBounds() { 111 121 return new Bounds( … … 113 123 center.east() - getWidth()/2.0*scale, 114 124 center.north() - getHeight()/2.0*scale)), 115 116 117 125 getProjection().eastNorth2latlon(new EastNorth( 126 center.east() + getWidth()/2.0*scale, 127 center.north() + getHeight()/2.0*scale))); 118 128 }; 119 129 … … 161 171 */ 162 172 private void zoomTo(EastNorth newCenter, double newScale) { 163 /* TODO: check that newCenter is really inside visible world and that scale is correct, don't allow zooming out to much */164 173 boolean rep = false; 174 175 Bounds b = getProjection().getWorldBoundsLatLon(); 176 CachedLatLon cl = new CachedLatLon(newCenter); 177 boolean changed = false;; 178 double lat = cl.lat(); 179 double lon = cl.lon(); 180 if(lat < b.min.lat()) {changed = true; lat = b.min.lat(); } 181 else if(lat > b.max.lat()) {changed = true; lat = b.max.lat(); } 182 if(lon < b.min.lon()) {changed = true; lon = b.min.lon(); } 183 else if(lon > b.max.lon()) {changed = true; lon = b.max.lon(); } 184 if(changed) 185 newCenter = new CachedLatLon(lat, lon).getEastNorth(); 165 186 if (!newCenter.equals(center)) { 166 187 EastNorth oldCenter = center; … … 169 190 firePropertyChange("center", oldCenter, newCenter); 170 191 } 192 193 int width = getWidth()/2; 194 int height = getHeight()/2; 195 LatLon l1 = new LatLon(b.min.lat(), lon); 196 LatLon l2 = new LatLon(b.max.lat(), lon); 197 EastNorth e1 = getProjection().latlon2eastNorth(l1); 198 EastNorth e2 = getProjection().latlon2eastNorth(l2); 199 double d = e2.north() - e1.north(); 200 if(d < height*newScale) 201 { 202 double newScaleH = d/height; 203 e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.min.lon())); 204 e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.max.lon())); 205 d = e2.east() - e1.east(); 206 if(d < width*newScale) 207 newScale = Math.max(newScaleH, d/width); 208 } 209 else 210 { 211 d = d/(l1.greatCircleDistance(l2)*height*10); 212 if(newScale < d) 213 newScale = d; 214 } 171 215 if (scale != newScale) { 172 216 double oldScale = scale; … … 175 219 firePropertyChange("scale", oldScale, newScale); 176 220 } 221 177 222 if(rep) { 178 223 repaint(); … … 461 506 * @return The projection to be used in calculating stuff. 462 507 */ 463 p rotectedProjection getProjection() {508 public Projection getProjection() { 464 509 return Main.proj; 465 510 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r1808 r1823 196 196 */ 197 197 @Override public void paint(final Graphics g, final MapView mv) { 198 boolean active = Main.map.mapView.getActiveLayer() == this;198 boolean active = mv.getActiveLayer() == this; 199 199 boolean inactive = !active && Main.pref.getBoolean("draw.data.inactive_color", true); 200 boolean virtual = !inactive && Main.map.mapView.isVirtualNodesEnabled();200 boolean virtual = !inactive && mv.isVirtualNodesEnabled(); 201 201 202 202 // draw the hatched area for non-downloaded region. only draw if we're the active … … 204 204 if (active && Main.pref.getBoolean("draw.data.downloaded_area", true) && !data.dataSources.isEmpty()) { 205 205 // initialize area with current viewport 206 Rectangle b = Main.map.mapView.getBounds();206 Rectangle b = mv.getBounds(); 207 207 // on some platforms viewport bounds seem to be offset from the left, 208 208 // over-grow it just to be sure … … 213 213 for (DataSource src : data.dataSources) { 214 214 if (src.bounds != null && !src.bounds.min.equals(src.bounds.max)) { 215 EastNorth en1 = Main.proj.latlon2eastNorth(src.bounds.min);216 EastNorth en2 = Main.proj.latlon2eastNorth(src.bounds.max);215 EastNorth en1 = mv.getProjection().latlon2eastNorth(src.bounds.min); 216 EastNorth en2 = mv.getProjection().latlon2eastNorth(src.bounds.max); 217 217 Point p1 = mv.getPoint(en1); 218 218 Point p2 = mv.getPoint(en2); … … 536 536 /** 537 537 * replies the set of conflicts currently managed in this layer 538 * 538 * 539 539 * @return the set of conflicts currently managed in this layer 540 540 */
Note:
See TracChangeset
for help on using the changeset viewer.