Permalink
Browse files

Every succeeding paste operation will place the newly pasted nodes of…

…fset from the previous paste.
  • Loading branch information...
1 parent 7f9d2a6 commit f87dbb78e3d3f0378330385e70681975286e7830 @stebanos stebanos committed Jan 10, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 src/java/nodebox/client/NodeBoxDocument.java
@@ -38,6 +38,7 @@
public static String lastExportPath;
private static NodeLibrary clipboardLibrary;
+ private static int pasteCount = 0;
private File documentFile;
private boolean documentChanged;
@@ -82,6 +83,7 @@ public static NodeLibrary getNodeClipboard() {
public static void setNodeClipboard(NodeLibrary clipboardLibrary) {
NodeBoxDocument.clipboardLibrary = clipboardLibrary;
+ NodeBoxDocument.pasteCount = 0;
}
public NodeBoxDocument(NodeLibrary library) {
@@ -1018,10 +1020,13 @@ public void copy() {
// The parent is used to preserve the connections, and also to save the state of the
// copied nodes.
// This parent is the root of a new library.
- NodeLibrary clipboardLibrary = new NodeLibrary("clipboard");
- Node clipboardRoot = clipboardLibrary.getRootNode();
- copyChildren(networkView.getSelectedNodes(), getActiveNetwork(), clipboardRoot);
- setNodeClipboard(clipboardLibrary);
+ Collection<Node> selectedNodes = networkView.getSelectedNodes();
+ if (! selectedNodes.isEmpty()) {
+ NodeLibrary clipboardLibrary = new NodeLibrary("clipboard");
+ Node clipboardRoot = clipboardLibrary.getRootNode();
+ copyChildren(selectedNodes, getActiveNetwork(), clipboardRoot);
+ setNodeClipboard(clipboardLibrary);
+ }
}
public void paste() {
@@ -1030,11 +1035,12 @@ public void paste() {
if (clipboardLibrary == null) return;
Node clipboardRoot = clipboardLibrary.getRootNode();
if (clipboardRoot.size() == 0) return;
+ NodeBoxDocument.pasteCount += 1;
Collection<Node> newNodes = copyChildren(clipboardRoot.getChildren(), clipboardRoot, getActiveNetwork());
for (Node newNode : newNodes) {
nodebox.graphics.Point pt = newNode.getPosition();
- pt.x += 20;
- pt.y += 80;
+ pt.x += NodeBoxDocument.pasteCount * 20;
+ pt.y += NodeBoxDocument.pasteCount * 80;
newNode.setPosition(pt);
}

0 comments on commit f87dbb7

Please sign in to comment.