Changeset 1023 in josm for trunk/src/org/openstreetmap/josm/actions/MoveAction.java
- Timestamp:
- 2008-10-05T17:06:27+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r627 r1023 17 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 18 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 19 import org.openstreetmap.josm.tools.ShortCut; 19 20 20 21 /** 21 22 * Moves the selection 22 * 23 * 23 24 * @author Frederik Ramm 24 25 */ … … 27 28 public enum Direction { UP, LEFT, RIGHT, DOWN } 28 29 private Direction myDirection; 29 30 31 // any better idea? 32 private static Object calltosupermustbefirststatementinconstructor(Direction dir, boolean text) { 33 ShortCut sc; 34 String directiontext; 35 if (dir == Direction.UP) { 36 directiontext = tr("up"); 37 sc = ShortCut.registerShortCut("core:moveup", tr("Move objects {0}", directiontext), KeyEvent.VK_UP, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT); 38 } else if (dir == Direction.DOWN) { 39 directiontext = tr("down"); 40 sc = ShortCut.registerShortCut("core:movedown", tr("Move objects {0}", directiontext), KeyEvent.VK_DOWN, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT); 41 } else if (dir == Direction.LEFT) { 42 directiontext = tr("left"); 43 sc = ShortCut.registerShortCut("core:moveleft", tr("Move objects {0}", directiontext), KeyEvent.VK_LEFT, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT); 44 } else { //dir == Direction.RIGHT) { 45 directiontext = tr("right"); 46 sc = ShortCut.registerShortCut("core:moveright", tr("Move objects {0}", directiontext), KeyEvent.VK_RIGHT, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT); 47 } 48 if (text) { 49 return directiontext; 50 } else { 51 return sc; 52 } 53 } 54 30 55 public MoveAction(Direction dir) { 31 super(tr("Move"), null, tr("Moves Objects"), 32 (dir == Direction.UP) ? KeyEvent.VK_UP : 33 (dir == Direction.DOWN) ? KeyEvent.VK_DOWN : 34 (dir == Direction.LEFT) ? KeyEvent.VK_LEFT : 35 KeyEvent.VK_RIGHT, 0, true); 56 super(tr("Move {0}", calltosupermustbefirststatementinconstructor(dir, true)), null, 57 tr("Moves Objects {0}", calltosupermustbefirststatementinconstructor(dir, true)), 58 (ShortCut)calltosupermustbefirststatementinconstructor(dir, false), true); 36 59 myDirection = dir; 37 60 } 38 61 39 62 public void actionPerformed(ActionEvent event) { 40 63 41 64 // find out how many "real" units the objects have to be moved in order to 42 65 // achive an 1-pixel movement 43 66 44 67 EastNorth en1 = Main.map.mapView.getEastNorth(100, 100); 45 68 EastNorth en2 = Main.map.mapView.getEastNorth(101, 101); 46 69 47 70 double distx = en2.east() - en1.east(); 48 71 double disty = en2.north() - en1.north(); 49 72 50 73 switch (myDirection) { 51 case UP: 74 case UP: 52 75 distx = 0; 53 76 disty = -disty; … … 62 85 disty = 0; 63 86 } 64 87 65 88 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 66 89 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 67 90 68 91 Command c = !Main.main.undoRedo.commands.isEmpty() 69 92 ? Main.main.undoRedo.commands.getLast() : null;
Note:
See TracChangeset
for help on using the changeset viewer.