From 7ba565933582d2a9ff592f1baa7d4456eae481de Mon Sep 17 00:00:00 2001
From: Michel Marti <mcdmx@users.sf.net>
Date: Thu, 14 May 2009 16:13:06 +0200
Subject: [PATCH] Don't adjust coordinates when copying from another layer
When copying objects from one layer to another, the user usually does
not want JOSM to tinker with the coordinates of the copied objects.
---
src/org/openstreetmap/josm/Main.java | 1 +
src/org/openstreetmap/josm/actions/CopyAction.java | 1 +
.../openstreetmap/josm/actions/PasteAction.java | 13 ++++++++-----
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
index 1b5c14d..6381f2d 100644
|
a
|
b
|
abstract public class Main {
|
| 86 | 86 | * The global paste buffer. |
| 87 | 87 | */ |
| 88 | 88 | public static DataSet pasteBuffer = new DataSet(); |
| | 89 | public static Layer pasteSource; |
| 89 | 90 | /** |
| 90 | 91 | * The projection method used. |
| 91 | 92 | */ |
diff --git a/src/org/openstreetmap/josm/actions/CopyAction.java b/src/org/openstreetmap/josm/actions/CopyAction.java
index d427168..1423037 100644
|
a
|
b
|
public final class CopyAction extends JosmAction implements SelectionChangedList
|
| 47 | 47 | if(noSelection()) return; |
| 48 | 48 | |
| 49 | 49 | Main.pasteBuffer = copyData(); |
| | 50 | Main.pasteSource = Main.main.editLayer(); |
| 50 | 51 | Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */ |
| 51 | 52 | |
| 52 | 53 | for(JosmAction a : listeners) { |
diff --git a/src/org/openstreetmap/josm/actions/PasteAction.java b/src/org/openstreetmap/josm/actions/PasteAction.java
index f6c4b0b..a2bfa7b 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
| 23 | 23 | import org.openstreetmap.josm.data.osm.RelationMember; |
| 24 | 24 | import org.openstreetmap.josm.data.osm.Way; |
| 25 | 25 | import org.openstreetmap.josm.data.coor.EastNorth; |
| | 26 | import org.openstreetmap.josm.gui.layer.Layer; |
| 26 | 27 | import org.openstreetmap.josm.tools.Shortcut; |
| 27 | 28 | |
| 28 | 29 | public final class PasteAction extends JosmAction { |
| … |
… |
public final class PasteAction extends JosmAction {
|
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | public void actionPerformed(ActionEvent e) { |
| 37 | | pasteData(Main.pasteBuffer, e); |
| | 38 | pasteData(Main.pasteBuffer, Main.pasteSource, e); |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | | public static void pasteData(DataSet pasteBuffer, ActionEvent e) { |
| | 41 | public static void pasteData(DataSet pasteBuffer, Layer source, ActionEvent e) { |
| 41 | 42 | /* Find the middle of the pasteBuffer area */ |
| 42 | 43 | double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100; |
| 43 | 44 | for (Node n : pasteBuffer.nodes) { |
| … |
… |
public final class PasteAction extends JosmAction {
|
| 51 | 52 | |
| 52 | 53 | EastNorth mPosition; |
| 53 | 54 | if((e.getModifiers() & ActionEvent.CTRL_MASK) ==0){ |
| | 55 | /* adjust the coordinates to the middle of the visible map area */ |
| 54 | 56 | mPosition = Main.map.mapView.getCenter(); |
| 55 | 57 | } else { |
| 56 | 58 | mPosition = Main.map.mapView.getEastNorth(Main.map.mapView.lastMEvent.getX(), Main.map.mapView.lastMEvent.getY()); |
| … |
… |
public final class PasteAction extends JosmAction {
|
| 66 | 68 | for (Node n : pasteBuffer.nodes) { |
| 67 | 69 | Node nnew = new Node(n); |
| 68 | 70 | nnew.id = 0; |
| 69 | | /* adjust the coordinates to the middle of the visible map area */ |
| 70 | | nnew.eastNorth = new EastNorth(nnew.eastNorth.east() + offsetEast, nnew.eastNorth.north() + offsetNorth); |
| 71 | | nnew.coor = Main.proj.eastNorth2latlon(nnew.eastNorth); |
| | 71 | if (Main.main.editLayer() == source) { |
| | 72 | nnew.eastNorth = new EastNorth(nnew.eastNorth.east() + offsetEast, nnew.eastNorth.north() + offsetNorth); |
| | 73 | nnew.coor = Main.proj.eastNorth2latlon(nnew.eastNorth); |
| | 74 | } |
| 72 | 75 | map.put(n, nnew); |
| 73 | 76 | } |
| 74 | 77 | for (Way w : pasteBuffer.ways) { |