Changeset 311 in josm for src/org/openstreetmap/josm
- Timestamp:
- 2007-08-22T22:55:36+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/mapmode/MoveAction.java
r301 r311 14 14 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.actions.GroupAction; 17 import org.openstreetmap.josm.actions.mapmode.AddNodeAction.Mode; 16 18 import org.openstreetmap.josm.command.Command; 17 19 import org.openstreetmap.josm.command.MoveCommand; 20 import org.openstreetmap.josm.command.RotateCommand; 18 21 import org.openstreetmap.josm.data.coor.EastNorth; 19 22 import org.openstreetmap.josm.data.osm.Node; … … 35 38 */ 36 39 public class MoveAction extends MapMode implements SelectionEnded { 40 41 enum Mode {move, rotate} 42 private final Mode mode; 43 44 public static class MoveGroup extends GroupAction { 45 public MoveGroup(MapFrame mf) { 46 super(KeyEvent.VK_M,0); 47 putValue("help", "Action/Move"); 48 actions.add(new MoveAction(mf, tr("Move"), Mode.move, tr("Move around objects that are under the mouse or selected."))); 49 actions.add(new MoveAction(mf, tr("Rotate"), Mode.rotate, tr("Rotate selected nodes around centre"))); 50 setCurrent(0); 51 } 52 } 53 37 54 /** 38 55 * The old cursor before the user pressed the mouse button. … … 50 67 * @param mapFrame The MapFrame, this action belongs to. 51 68 */ 52 public MoveAction(MapFrame mapFrame) { 53 super(tr("Move"), 54 "move", 55 tr("Move around objects that are under the mouse or selected."), 56 KeyEvent.VK_M, 57 mapFrame, 58 ImageProvider.getCursor("normal", "move")); 69 public MoveAction(MapFrame mapFrame, String name, Mode mode, String desc) { 70 super(name, "move/"+mode, desc, mapFrame, getCursor()); 71 this.mode = mode; 72 putValue("help", "Action/Move/"+Character.toUpperCase(mode.toString().charAt(0))+mode.toString().substring(1)); 59 73 selectionManager = new SelectionManager(this, false, mapFrame.mapView); 60 74 } 61 75 76 private static Cursor getCursor() { 77 try { 78 return ImageProvider.getCursor("crosshair", null); 79 } catch (Exception e) { 80 } 81 return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); 82 } 83 62 84 @Override public void enterMode() { 63 85 super.enterMode(); … … 72 94 } 73 95 74 75 96 /** 76 97 * If the left mouse button is pressed, move all currently selected … … 87 108 if (mousePos == null) 88 109 mousePos = e.getPoint(); 89 110 90 111 EastNorth mouseEN = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 91 112 EastNorth mouseStartEN = Main.map.mapView.getEastNorth(mousePos.x, mousePos.y); … … 97 118 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 98 119 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 120 121 // when rotating, having only one node makes no sense - quit silently 122 if (affectedNodes.size() < 2 && mode == Mode.move) 123 return; 124 99 125 100 126 // check if any coordinate would be outside the world … … 105 131 } 106 132 } 107 108 133 Command c = !Main.main.undoRedo.commands.isEmpty() ? Main.main.undoRedo.commands.getLast() : null; 109 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand)c).objects)) 110 ((MoveCommand)c).moveAgain(dx,dy); 111 else 112 Main.main.undoRedo.add(new MoveCommand(selection, dx, dy)); 134 135 if (mode == Mode.move) { 136 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand)c).objects)) 137 ((MoveCommand)c).moveAgain(dx,dy); 138 else 139 Main.main.undoRedo.add(new MoveCommand(selection, dx, dy)); 140 } else if (mode == Mode.rotate) { 141 if (c instanceof RotateCommand && affectedNodes.equals(((RotateCommand)c).objects)) 142 ((RotateCommand)c).rotateAgain(mouseStartEN, mouseEN); 143 else 144 Main.main.undoRedo.add(new RotateCommand(selection, mouseStartEN, mouseEN)); 145 } 113 146 114 147 Main.map.mapView.repaint(); … … 135 168 Main.ds.setSelected(osm); 136 169 oldCursor = Main.map.mapView.getCursor(); 137 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 170 171 if (mode == Mode.move) { 172 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 173 } else { 174 Main.map.mapView.setCursor(ImageProvider.getCursor("rotate", null)); 175 } 138 176 } else { 139 177 selectionMode = true; -
src/org/openstreetmap/josm/gui/MapFrame.java
r298 r311 22 22 import org.openstreetmap.josm.actions.mapmode.ZoomAction; 23 23 import org.openstreetmap.josm.actions.mapmode.AddNodeAction.AddNodeGroup; 24 import org.openstreetmap.josm.actions.mapmode.MoveAction.MoveGroup; 24 25 import org.openstreetmap.josm.gui.dialogs.CommandStackDialog; 25 26 import org.openstreetmap.josm.gui.dialogs.ConflictDialog; … … 82 83 final Action selectionAction = new SelectionAction.Group(this); 83 84 toolBarActions.add(new IconToggleButton(selectionAction)); 84 toolBarActions.add(new IconToggleButton(new Move Action(this)));85 toolBarActions.add(new IconToggleButton(new MoveGroup(this))); 85 86 toolBarActions.add(new IconToggleButton(new AddNodeGroup(this))); 86 87 toolBarActions.add(new IconToggleButton(new AddSegmentAction(this)));
Note:
See TracChangeset
for help on using the changeset viewer.