|
@@ -719,7 +719,46 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
}
|
|
|
|
|
|
if (dragged) {
|
|
|
- try {
|
|
|
+ try {
|
|
|
+
|
|
|
+ int x = tempCps.getPosition().x;
|
|
|
+
|
|
|
+
|
|
|
+ int y = tempCps.getPosition().y;
|
|
|
+
|
|
|
+
|
|
|
+ int treshhold = controller.getScale()/4;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ int replaceCounter = 0;
|
|
|
+
|
|
|
+
|
|
|
+ AbstractCpsObject toBeReplaced = null;
|
|
|
+
|
|
|
+
|
|
|
+ for (AbstractCpsObject cps : upperNode.getNodes()){
|
|
|
+
|
|
|
+
|
|
|
+ if(cps == tempCps)continue;
|
|
|
+
|
|
|
+
|
|
|
+ int c_x = cps.getPosition().x;
|
|
|
+
|
|
|
+
|
|
|
+ int c_y = cps.getPosition().y;
|
|
|
+
|
|
|
+
|
|
|
+ if(Math.abs(x-c_x)<treshhold && Math.abs(y-c_y)<treshhold){
|
|
|
+ replaceCounter++;
|
|
|
+ toBeReplaced = cps;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(replaceCounter == 1 && toBeReplaced != null){
|
|
|
+ controller.replaceCanvasObject(toBeReplaced, tempCps);
|
|
|
+ }
|
|
|
controller.autoSave();
|
|
|
} catch (IOException ex) {
|
|
|
ex.printStackTrace();
|