|
@@ -444,6 +444,48 @@ class NodeController {
|
|
|
object.setSav("" + upperNode.getId());
|
|
|
upperNode.getNodesIdx().put(object.getId(), upperNode.getNodes().size());
|
|
|
upperNode.getNodes().add(object);
|
|
|
+
|
|
|
+
|
|
|
+ * check if we should drag & drop replace
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+ int x = object.getPosition().x;
|
|
|
+
|
|
|
+
|
|
|
+ int y = object.getPosition().y;
|
|
|
+
|
|
|
+
|
|
|
+ int treshhold = model.getScale()/4;
|
|
|
+
|
|
|
+
|
|
|
+ int replaceCounter = 0;
|
|
|
+
|
|
|
+
|
|
|
+ AbstractCpsObject toBeReplaced = null;
|
|
|
+
|
|
|
+
|
|
|
+ for (AbstractCpsObject cps : upperNode.getNodes()){
|
|
|
+
|
|
|
+
|
|
|
+ if(cps == object)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){
|
|
|
+ replaceObjectInUpperNode(toBeReplaced, object, upperNode);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|