|
@@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|
|
import Interfaces.CategoryListener;
|
|
|
import Interfaces.ObjectListener;
|
|
|
import classes.CpsEdge;
|
|
|
+import classes.CpsNode;
|
|
|
import classes.CpsObject;
|
|
|
import classes.HolonObject;
|
|
|
import classes.HolonSwitch;
|
|
@@ -115,6 +116,8 @@ public class CanvasController {
|
|
|
MODEL.getSelectedCpsObjects().clear();
|
|
|
CpsObject tCps = null;
|
|
|
int x = Integer.MAX_VALUE, y = Integer.MAX_VALUE;
|
|
|
+
|
|
|
+ // Location whre to copy the Elements
|
|
|
for (CpsObject cps : MODEL.getClipboradObjects()) {
|
|
|
if (cps.getPosition().x < x) {
|
|
|
x = cps.getPosition().x;
|
|
@@ -124,16 +127,45 @@ public class CanvasController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ ArrayList<CpsObject> tempList = new ArrayList<>();
|
|
|
+
|
|
|
+ // Objects
|
|
|
for (CpsObject cps : MODEL.getClipboradObjects()) {
|
|
|
if (cps instanceof HolonObject) {
|
|
|
tCps = new HolonObject((HolonObject) cps);
|
|
|
} else if (cps instanceof HolonSwitch) {
|
|
|
tCps = new HolonSwitch((HolonSwitch) cps);
|
|
|
+ } else {
|
|
|
+ tCps = new CpsNode("Node");
|
|
|
}
|
|
|
- tCps.setPosition(new Position(p.x + (cps.getPosition().x-x), p.y + (cps.getPosition().y-y)));
|
|
|
+ tCps.setPosition(new Position(p.x + (cps.getPosition().x - x), p.y + (cps.getPosition().y - y)));
|
|
|
+ tempList.add(tCps);
|
|
|
addObject(tCps);
|
|
|
- MODEL.getSelectedCpsObjects().add(tCps);
|
|
|
+ //MODEL.getSelectedCpsObjects().add(tCps);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Edges
|
|
|
+ boolean newEdge = true;
|
|
|
+ for (CpsObject cps : MODEL.getClipboradObjects()) {
|
|
|
+ for (CpsEdge e : cps.getConnectedTo()) {
|
|
|
+ // A and B of e in the copied Elements?
|
|
|
+ if (MODEL.getClipboradObjects().indexOf(e.getA()) != -1
|
|
|
+ && MODEL.getClipboradObjects().indexOf(e.getB()) != -1) {
|
|
|
+ for (CpsEdge e1 : tempList.get(MODEL.getClipboradObjects().indexOf(cps)).getConnectedTo()) {
|
|
|
+ if (e1.getA() == e.getA() && e1.getB() == e.getB()) {
|
|
|
+ newEdge = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (newEdge) {
|
|
|
+ CpsEdge tempE = new CpsEdge(tempList.get(MODEL.getClipboradObjects().indexOf(e.getA())), // A
|
|
|
+ tempList.get(MODEL.getClipboradObjects().indexOf(e.getB())), /* B */ e.getCapacity());
|
|
|
+ addEdgeOnCanvas(tempE);
|
|
|
+ }
|
|
|
+ newEdge = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|