Changeset 3837 in josm
- Timestamp:
- 2011-02-01T01:49:32+01:00 (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r3416 r3837 559 559 getCurrentDataSet().setSelected(newSelection); 560 560 561 // "viewport following" mode for tracing long features 562 // from aerial imagery or GPS tracks. 563 if (n != null && Main.map.mapView.viewportFollowing) { 564 Main.map.mapView.smoothScrollTo(n.getEastNorth()); 565 }; 561 566 computeHelperLine(); 562 567 removeHighlighting(); -
trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java
r1724 r3837 34 34 public EastNorth getCenter(EastNorth en2) { 35 35 return new EastNorth((this.x + en2.x)/2.0, (this.y + en2.y)/2.0); 36 } 37 38 public double distance(EastNorth en2) { 39 return Math.sqrt((this.x-en2.x)*(this.x-en2.x) + (this.y-en2.y)*(this.y-en2.y)); 36 40 } 37 41 -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r3737 r3837 74 74 import org.openstreetmap.josm.actions.UploadAction; 75 75 import org.openstreetmap.josm.actions.UploadSelectionAction; 76 import org.openstreetmap.josm.actions.ViewportFollowToggleAction; 76 77 import org.openstreetmap.josm.actions.WireframeToggleAction; 77 78 import org.openstreetmap.josm.actions.ZoomInAction; … … 286 287 } 287 288 289 // -- viewport follow toggle action 290 ViewportFollowToggleAction viewportFollowToggleAction = new ViewportFollowToggleAction(); 291 final JCheckBoxMenuItem vft = new JCheckBoxMenuItem(viewportFollowToggleAction); 292 viewMenu.add(vft); 293 vft.setAccelerator(viewportFollowToggleAction.getShortcut().getKeyStroke()); 294 viewportFollowToggleAction.addButtonModel(vft.getModel()); 295 288 296 // -- changeset manager toggle action 289 297 ChangesetManagerToggleAction changesetManagerToggleAction = new ChangesetManagerToggleAction(); -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r3705 r3837 82 82 } 83 83 84 public boolean viewportFollowing = false; 85 84 86 /** 85 87 * the layer listeners -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r3652 r3837 23 23 24 24 import javax.swing.JComponent; 25 import javax.swing.SwingUtilities; 25 26 26 27 import org.openstreetmap.josm.Main; … … 356 357 } 357 358 359 public void smoothScrollTo(LatLon newCenter) { 360 if (newCenter instanceof CachedLatLon) { 361 smoothScrollTo(((CachedLatLon)newCenter).getEastNorth()); 362 } else { 363 smoothScrollTo(getProjection().latlon2eastNorth(newCenter)); 364 } 365 } 366 367 /** 368 * Create a thread that moves the viewport to the given center in an 369 * animated fashion. 370 */ 371 public void smoothScrollTo(EastNorth newCenter) { 372 // fixme make these configurable. 373 final int fps = 20; // animation frames per second 374 final int speed = 1500; // milliseconds for full-screen-width pan 375 if (!newCenter.equals(center)) { 376 final EastNorth oldCenter = center; 377 final double distance = newCenter.distance(oldCenter) / scale; 378 final double milliseconds = distance / getWidth() * speed; 379 final double frames = milliseconds * fps / 1000; 380 final EastNorth finalNewCenter = newCenter; 381 382 // we attempt to smooth-scroll at 10 fps, and use 2 seconds to scroll one 383 // screen width. 384 385 new Thread( 386 new Runnable() { 387 public void run() { 388 for (int i=0; i<frames; i++) 389 { 390 // fixme - not use zoom history here 391 zoomTo(oldCenter.interpolate(finalNewCenter, (double) (i+1) / (double) frames)); 392 try { Thread.sleep(1000 / fps); } catch (InterruptedException ex) { }; 393 } 394 } 395 } 396 ).start(); 397 } 398 } 399 358 400 public void zoomToFactor(double x, double y, double factor) { 359 401 double newScale = scale*factor;
Note:
See TracChangeset
for help on using the changeset viewer.