diff --git a/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java b/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
index 252852c..1e84ad3 100644
|
a
|
b
|
import org.openstreetmap.josm.tools.Shortcut;
|
| 50 | 50 | */ |
| 51 | 51 | public class ExtrudeAction extends MapMode implements MapViewPaintable { |
| 52 | 52 | |
| 53 | | enum Mode { extrude, translate, select } |
| | 53 | enum Mode { extrude, translate, select, add_node } |
| 54 | 54 | |
| 55 | 55 | private Mode mode = Mode.select; |
| 56 | 56 | |
| … |
… |
public class ExtrudeAction extends MapMode implements MapViewPaintable {
|
| 116 | 116 | return tr("Move a segment along its normal, then release the mouse button."); |
| 117 | 117 | else if (mode == Mode.extrude) |
| 118 | 118 | return tr("Draw a rectangle of the desired size, then release the mouse button."); |
| | 119 | else if (mode == Mode.add_node) |
| | 120 | return tr("Release mouse button to add the node"); |
| 119 | 121 | else |
| 120 | | return tr("Drag a way segment to make a rectangle. Ctrl-drag to move a segment along its normal."); |
| | 122 | return tr("Drag a way segment to make a rectangle. Ctrl-drag to move a segment along its normal. Alt-click to add a node"); |
| 121 | 123 | } |
| 122 | 124 | |
| 123 | 125 | @Override public boolean layerIsSupported(Layer l) { |
| … |
… |
public class ExtrudeAction extends MapMode implements MapViewPaintable {
|
| 153 | 155 | |
| 154 | 156 | if (selectedSegment == null) { |
| 155 | 157 | // If nothing gets caught, stay in select mode |
| | 158 | } else if ((e.getModifiers() & ActionEvent.ALT_MASK) != 0) { |
| | 159 | mode = Mode.add_node; |
| | 160 | updateStatusLine(); |
| 156 | 161 | } else { |
| 157 | 162 | // Otherwise switch to another mode |
| 158 | 163 | |
| … |
… |
public class ExtrudeAction extends MapMode implements MapViewPaintable {
|
| 221 | 226 | if (System.currentTimeMillis() - mouseDownTime < initialMoveDelay) |
| 222 | 227 | return; |
| 223 | 228 | |
| 224 | | if (mode == Mode.select) { |
| | 229 | if (mode == Mode.select || mode == Mode.add_node) { |
| 225 | 230 | // Just sit tight and wait for mouse to be released. |
| 226 | 231 | } else { |
| 227 | 232 | //move and extrude mode - move the selected segment |
| … |
… |
public class ExtrudeAction extends MapMode implements MapViewPaintable {
|
| 291 | 296 | |
| 292 | 297 | if (mode == Mode.select) { |
| 293 | 298 | // Nothing to be done |
| | 299 | } else if (mode == Mode.add_node) { |
| | 300 | // Should maybe do the same as in DrawAction and fetch all nearby segments? |
| | 301 | WaySegment ws = Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive.isSelectablePredicate); |
| | 302 | if (ws == null) { |
| | 303 | mode = Mode.select; |
| | 304 | return; |
| | 305 | } |
| | 306 | |
| | 307 | Node n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY())); |
| | 308 | |
| | 309 | EastNorth A = ws.getFirstNode().getEastNorth(); |
| | 310 | EastNorth B = ws.getSecondNode().getEastNorth(); |
| | 311 | n.setEastNorth(Geometry.closestPointToSegment(A, B, n.getEastNorth())); |
| | 312 | |
| | 313 | Way wnew = new Way(ws.way); |
| | 314 | wnew.addNode(ws.lowerIndex+1, n); |
| | 315 | |
| | 316 | SequenceCommand cmds = new SequenceCommand(tr("Add a new node to an existing way"), |
| | 317 | new AddCommand(n), new ChangeCommand(ws.way, wnew)); |
| | 318 | |
| | 319 | Main.main.undoRedo.add(cmds); |
| | 320 | mode = Mode.select; |
| 294 | 321 | } else { |
| 295 | 322 | if (mode == Mode.extrude) { |
| 296 | 323 | if (e.getPoint().distance(initialMousePos) > 10 && newN1en != null) { |
| … |
… |
public class ExtrudeAction extends MapMode implements MapViewPaintable {
|
| 355 | 382 | moveCommand = null; |
| 356 | 383 | mode = Mode.select; |
| 357 | 384 | |
| 358 | | updateStatusLine(); |
| 359 | 385 | Main.map.mapView.repaint(); |
| 360 | 386 | } |
| | 387 | updateStatusLine(); |
| 361 | 388 | } |
| 362 | 389 | |
| 363 | 390 | /** |