- Timestamp:
- 2015-10-18T23:16:54+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r8846 r8900 43 43 public class AutoScaleAction extends JosmAction { 44 44 45 /** 46 * A list of things we can zoom to. The zoom target is given depending on the mode. 47 */ 45 48 public static final Collection<String> MODES = Collections.unmodifiableList(Arrays.asList( 46 49 marktr(/* ICON(dialogs/autoscale/) */ "data"), … … 53 56 marktr(/* ICON(dialogs/autoscale/) */ "next"))); 54 57 58 /** 59 * One of {@link #MODES}. Defines what we are zooming to. 60 */ 55 61 private final String mode; 56 62 … … 83 89 } 84 90 91 /** 92 * Zooms the view to display the given set of primitives. 93 * @param sel The primitives to zoom to, e.g. the current selection. 94 */ 85 95 public static void zoomTo(Collection<OsmPrimitive> sel) { 86 96 BoundingXYVisitor bboxCalculator = new BoundingXYVisitor(); 87 97 bboxCalculator.computeBoundingBox(sel); 88 // increase bbox by 0.001 degrees on each side. this is required98 // increase bbox. This is required 89 99 // especially if the bbox contains one single node, but helpful 90 100 // in most other cases as well. … … 95 105 } 96 106 107 /** 108 * Performs the auto scale operation of the given mode without the need to create a new action. 109 * @param mode One of {@link #MODES}. 110 */ 97 111 public static void autoScale(String mode) { 98 112 new AutoScaleAction(mode, false).autoScale(); … … 172 186 } 173 187 188 /** 189 * Performs this auto scale operation for the mode this action is in. 190 */ 174 191 public void autoScale() { 175 192 if (Main.isDisplayingMapView()) { -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r8855 r8900 33 33 import java.util.List; 34 34 import java.util.TreeSet; 35 import java.util.concurrent.BlockingQueue; 36 import java.util.concurrent.LinkedBlockingQueue; 35 37 36 38 import javax.swing.AbstractAction; … … 348 350 private MapFrame parent; 349 351 352 private BlockingQueue<MouseState> incommingMouseState = new LinkedBlockingQueue<>(); 353 354 private Point lastMousePos; 355 350 356 Collector(MapFrame parent) { 351 357 this.parent = parent; … … 360 366 try { 361 367 for (;;) { 362 363 final MouseState ms = new MouseState(); 364 synchronized (this) { 365 // TODO Would be better if the timeout wasn't necessary 366 try { 367 wait(1000); 368 } catch (InterruptedException e) { 369 // Occurs frequently during JOSM shutdown, log set to trace only 370 Main.trace("InterruptedException in "+MapStatus.class.getSimpleName()); 368 try { 369 final MouseState ms = incommingMouseState.take(); 370 if (parent != Main.map) 371 return; // exit, if new parent. 372 373 // Do nothing, if required data is missing 374 if (ms.mousePos == null || mv.center == null) { 375 continue; 371 376 } 372 ms.modifiers = mouseState.modifiers; 373 ms.mousePos = mouseState.mousePos; 374 } 375 if (parent != Main.map) 376 return; // exit, if new parent. 377 378 // Do nothing, if required data is missing 379 if (ms.mousePos == null || mv.center == null) { 380 continue; 381 } 382 383 try { 377 384 378 EventQueue.invokeAndWait(new CollectorWorker(ms)); 385 379 } catch (InterruptedException e) { … … 650 644 return l; 651 645 } 646 647 /** 648 * Called whenever the mouse position or modifiers changed. 649 * @param mousePos The new mouse position. <code>null</code> if it did not change. 650 * @param modifiers The new modifiers. 651 */ 652 public synchronized void updateMousePosition(Point mousePos, int modifiers) { 653 MouseState ms = new MouseState(); 654 if (mousePos == null) { 655 ms.mousePos = lastMousePos; 656 } else { 657 lastMousePos = mousePos; 658 } 659 // remove mouse states that are in the queue. Our mouse state is newer. 660 incommingMouseState.clear(); 661 incommingMouseState.offer(ms); 662 } 652 663 } 653 664 … … 660 671 private int modifiers; 661 672 } 662 /**663 * The last sent mouse movement event.664 */665 private transient MouseState mouseState = new MouseState();666 673 667 674 private transient AWTEventListener awtListener = new AWTEventListener() { … … 671 678 ((InputEvent) event).getComponent() == mv) { 672 679 synchronized (collector) { 673 mouseState.modifiers = ((InputEvent) event).getModifiersEx(); 680 int modifiers = ((InputEvent) event).getModifiersEx(); 681 Point mousePos = null; 674 682 if (event instanceof MouseEvent) { 675 mouse State.mousePos = ((MouseEvent) event).getPoint();683 mousePos = ((MouseEvent) event).getPoint(); 676 684 } 677 collector. notifyAll();685 collector.updateMousePosition(mousePos, modifiers); 678 686 } 679 687 } … … 685 693 public void mouseMoved(MouseEvent e) { 686 694 synchronized (collector) { 687 mouseState.modifiers = e.getModifiersEx(); 688 mouseState.mousePos = e.getPoint(); 689 collector.notifyAll(); 695 collector.updateMousePosition(e.getPoint(), e.getModifiersEx()); 690 696 } 691 697 } … … 700 706 @Override public void keyPressed(KeyEvent e) { 701 707 synchronized (collector) { 702 mouseState.modifiers = e.getModifiersEx(); 703 collector.notifyAll(); 708 collector.updateMousePosition(null, e.getModifiersEx()); 704 709 } 705 710 }
Note:
See TracChangeset
for help on using the changeset viewer.