Changeset 313 in josm
- Timestamp:
- 2007-08-23T22:24:50+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
r306 r313 50 50 actions.add(new AddNodeAction(mf,tr("Add node"), Mode.node, tr("Add a new node to the map"))); 51 51 actions.add(new AddNodeAction(mf, tr("Add node into segment"), Mode.nodesegment,tr( "Add a node into an existing segment"))); 52 actions.add(new AddNodeAction(mf, tr("Add node and connect"), Mode.autonode,tr( "Add a node and connect it to the selected (previously added) node")));52 actions.add(new AddNodeAction(mf, tr("Add node and connect"), Mode.autonode,tr( "Add a node and connect it to the selected node (with CTRL: add node into segment; with ALT: re-use existing node)"))); 53 53 setCurrent(0); 54 54 } … … 93 93 Node n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY())); 94 94 if (n.coor.isOutSideWorld()) { 95 JOptionPane.showMessageDialog(Main.parent,tr("Can 95 JOptionPane.showMessageDialog(Main.parent,tr("Cannot add a node outside of the world.")); 96 96 return; 97 97 } … … 108 108 if (other == null && (e.getModifiersEx() & MouseEvent.ALT_DOWN_MASK) == 0) { 109 109 // moving the new point to the perpendicular point 110 // FIXME: when two segments are split, should move the new point to the 111 // intersection point! 110 112 EastNorth A = s.from.eastNorth; 111 113 EastNorth B = s.to.eastNorth; … … 131 133 } 132 134 135 // Add a node and connecting segment. 133 136 if (mode == Mode.autonode) { 137 138 Segment insertInto = null; 139 Node reuseNode = null; 140 141 // If CTRL is held, insert the node into a potentially existing segment 142 if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) { 143 insertInto = Main.map.mapView.getNearestSegment(e.getPoint()); 144 if (insertInto == null) 145 return; 146 } 147 // If ALT is held, instead of creating a new node, re-use an existing 148 // node (making this action identical to AddSegmentAction with the 149 // small difference that the node used will then be selected to allow 150 // continuation of the "add node and connect" stuff) 151 else if ((e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0) { 152 OsmPrimitive clicked = Main.map.mapView.getNearest(e.getPoint(), false); 153 if (clicked == null || !(clicked instanceof Node)) 154 return; 155 reuseNode = (Node) clicked; 156 } 157 134 158 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 135 159 if (selection.size() == 1 && selection.iterator().next() instanceof Node) { 136 160 Node n1 = (Node)selection.iterator().next(); 137 161 Collection<Command> cmds = new LinkedList<Command>(); 162 163 if (reuseNode != null) { 164 // in re-use node mode, n1 must not be identical to clicked node 165 if (n1 == reuseNode) return; 166 // replace newly created node with existing node 167 n = reuseNode; 168 } else { 169 // only add the node creation command if we're not re-using 170 cmds.add(c); 171 } 172 138 173 Segment s = new Segment(n1, n); 139 cmds.add(c); 174 175 if (insertInto != null) 176 splitSegmentAtNode(insertInto, n, cmds); 177 140 178 cmds.add(new AddCommand(s)); 141 179 … … 153 191 } 154 192 155 c = new SequenceCommand(tr( "Add nodeand connect"), cmds);193 c = new SequenceCommand(tr((insertInto == null) ? "Add node and connect" : "Add node into segment and connect"), cmds); 156 194 } 157 195 }
Note:
See TracChangeset
for help on using the changeset viewer.