- Timestamp:
- 2013-05-03T17:35:04+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r5909 r5922 66 66 import org.openstreetmap.josm.gui.MapFrame; 67 67 import org.openstreetmap.josm.gui.MapView; 68 import org.openstreetmap.josm.gui.NavigatableComponent; 68 69 import org.openstreetmap.josm.gui.layer.Layer; 69 70 import org.openstreetmap.josm.gui.layer.MapViewPaintable; … … 86 87 private Node lastUsedNode = null; 87 88 private double PHI=Math.toRadians(90); 89 private double toleranceMultiplier; 88 90 89 91 private Node mouseOnExistingNode; … … 215 217 wayIsFinished = currentBaseNode == null; 216 218 219 toleranceMultiplier = 0.01 * NavigatableComponent.PROP_SNAP_DISTANCE.get(); 220 217 221 snapHelper.init(); 218 222 snapCheckboxMenuItem.getAction().setEnabled(true); … … 276 280 * redraw to (possibly) get rid of helper line if selection changes. 277 281 */ 282 @Override 278 283 public void eventDispatched(AWTEvent event) { 279 284 if(Main.map == null || Main.map.mapView == null || !Main.map.mapView.isActiveLayerDrawable()) … … 335 340 * redraw to (possibly) get rid of helper line if selection changes. 336 341 */ 342 @Override 337 343 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 338 344 if(!Main.map.mapView.isActiveLayerDrawable()) … … 450 456 // project found node to snapping line 451 457 newEN = snapHelper.getSnapPoint(foundPoint); 452 if (foundPoint.distance(newEN) > 1e-4) { 458 // do not add new node if there is some node within snapping distance 459 double tolerance = Main.map.mapView.getDist100Pixel() * toleranceMultiplier; 460 if (foundPoint.distance(newEN) > tolerance) { 453 461 n = new Node(newEN); // point != projected, so we create new node 454 462 newNode = true; … … 631 639 if (n != null && Main.map.mapView.viewportFollowing) { 632 640 Main.map.mapView.smoothScrollTo(n.getEastNorth()); 633 } ;641 } 634 642 computeHelperLine(); 635 643 removeHighlighting(); … … 1082 1090 1083 1091 // This happens when nothing is selected, but we still want to highlight the "target node" 1084 if (mouseOnExistingNode == null && getCurrentDataSet().getSelected(). size() == 01092 if (mouseOnExistingNode == null && getCurrentDataSet().getSelected().isEmpty() 1085 1093 && mousePos != null) { 1086 1094 mouseOnExistingNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive.isSelectablePredicate); … … 1095 1103 1096 1104 // Insert the node into all the nearby way segments 1097 if (mouseOnExistingWays. size() == 0) {1105 if (mouseOnExistingWays.isEmpty()) { 1098 1106 Main.map.mapView.setNewCursor(cursor, this); 1099 1107 redrawIfRequired(); … … 1115 1123 } 1116 1124 1125 @Override 1117 1126 public void paint(Graphics2D g, MapView mv, Bounds box) { 1118 1127 // sanity checks … … 1685 1694 MouseListener anglePopupListener = new PopupMenuLauncher( new JPopupMenu() { 1686 1695 JCheckBoxMenuItem repeatedCb = new JCheckBoxMenuItem(new AbstractAction(tr("Toggle snapping by {0}", getShortcut().getKeyText())){ 1687 public void actionPerformed(ActionEvent e) {1696 @Override public void actionPerformed(ActionEvent e) { 1688 1697 boolean sel=((JCheckBoxMenuItem) e.getSource()).getState(); 1689 1698 Main.pref.put("draw.anglesnap.toggleOnRepeatedA", sel); … … 1692 1701 }); 1693 1702 JCheckBoxMenuItem helperCb = new JCheckBoxMenuItem(new AbstractAction(tr("Show helper geometry")){ 1694 public void actionPerformed(ActionEvent e) {1703 @Override public void actionPerformed(ActionEvent e) { 1695 1704 boolean sel=((JCheckBoxMenuItem) e.getSource()).getState(); 1696 1705 Main.pref.put("draw.anglesnap.drawConstructionGeometry", sel); … … 1702 1711 }); 1703 1712 JCheckBoxMenuItem projectionCb = new JCheckBoxMenuItem(new AbstractAction(tr("Snap to node projections")){ 1704 public void actionPerformed(ActionEvent e) {1713 @Override public void actionPerformed(ActionEvent e) { 1705 1714 boolean sel=((JCheckBoxMenuItem) e.getSource()).getState(); 1706 1715 Main.pref.put("draw.anglesnap.projectionsnap", sel); … … 1717 1726 add(projectionCb);; 1718 1727 add(new AbstractAction(tr("Disable")) { 1719 public void actionPerformed(ActionEvent e) {1728 @Override public void actionPerformed(ActionEvent e) { 1720 1729 saveAngles("180"); 1721 1730 init(); … … 1724 1733 }); 1725 1734 add(new AbstractAction(tr("0,90,...")) { 1726 public void actionPerformed(ActionEvent e) {1735 @Override public void actionPerformed(ActionEvent e) { 1727 1736 saveAngles("0","90","180"); 1728 1737 init(); … … 1731 1740 }); 1732 1741 add(new AbstractAction(tr("0,45,90,...")) { 1733 public void actionPerformed(ActionEvent e) {1742 @Override public void actionPerformed(ActionEvent e) { 1734 1743 saveAngles("0","45","90","135","180"); 1735 1744 init(); … … 1738 1747 }); 1739 1748 add(new AbstractAction(tr("0,30,45,60,90,...")) { 1740 public void actionPerformed(ActionEvent e) {1749 @Override public void actionPerformed(ActionEvent e) { 1741 1750 saveAngles("0","30","45","60","90","120","135","150","180"); 1742 1751 init();
Note:
See TracChangeset
for help on using the changeset viewer.