|
@@ -1,5 +1,6 @@
|
|
package ui.controller;
|
|
package ui.controller;
|
|
|
|
|
|
|
|
+import java.awt.Point;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
|
|
|
|
@@ -14,6 +15,7 @@ public class NodeController {
|
|
private Model model;
|
|
private Model model;
|
|
private CanvasController cvs;
|
|
private CanvasController cvs;
|
|
private MultiPurposeController mpC;
|
|
private MultiPurposeController mpC;
|
|
|
|
+ private Point point;
|
|
|
|
|
|
public NodeController(Model model, CanvasController cvs, MultiPurposeController mpC) {
|
|
public NodeController(Model model, CanvasController cvs, MultiPurposeController mpC) {
|
|
// TODO Auto-generated constructor stub
|
|
// TODO Auto-generated constructor stub
|
|
@@ -49,6 +51,11 @@ public class NodeController {
|
|
* @param upperNode
|
|
* @param upperNode
|
|
*/
|
|
*/
|
|
public void undoUpperNode(CpsUpperNode node, CpsUpperNode upperNode) {
|
|
public void undoUpperNode(CpsUpperNode node, CpsUpperNode upperNode) {
|
|
|
|
+
|
|
|
|
+ Position old = calculatePos(node.getNodes());
|
|
|
|
+ Position p = node.getPosition();
|
|
|
|
+ point = new Point(old.x - p.x, old.y - p.y);
|
|
|
|
+
|
|
restoreOldEdges(node, upperNode);
|
|
restoreOldEdges(node, upperNode);
|
|
unmakeNodesOfNodes(node, upperNode);
|
|
unmakeNodesOfNodes(node, upperNode);
|
|
unmakeAdjacent(node, upperNode);
|
|
unmakeAdjacent(node, upperNode);
|
|
@@ -122,12 +129,13 @@ public class NodeController {
|
|
if (edge.getB().equals(node))
|
|
if (edge.getB().equals(node))
|
|
edge.getA().getConnections().remove(edge);
|
|
edge.getA().getConnections().remove(edge);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
for (AbstractCpsObject obj : node.getNodes()) {
|
|
for (AbstractCpsObject obj : node.getNodes()) {
|
|
- if(upperNode == null)
|
|
|
|
|
|
+ updatePosition(obj);
|
|
|
|
+ if (upperNode == null)
|
|
obj.setSav("CVS");
|
|
obj.setSav("CVS");
|
|
else
|
|
else
|
|
- obj.setSav(""+upperNode.getId());
|
|
|
|
|
|
+ obj.setSav("" + upperNode.getId());
|
|
}
|
|
}
|
|
|
|
|
|
(upperNode == null ? model.getObjectsOnCanvas() : upperNode.getNodes()).addAll(node.getNodes());
|
|
(upperNode == null ? model.getObjectsOnCanvas() : upperNode.getNodes()).addAll(node.getNodes());
|
|
@@ -505,7 +513,7 @@ public class NodeController {
|
|
}
|
|
}
|
|
upperNode.getNodeEdges().remove(e);
|
|
upperNode.getNodeEdges().remove(e);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
mpC.decIdx(object.getId(), upperNode.getNodesIdx());
|
|
mpC.decIdx(object.getId(), upperNode.getNodesIdx());
|
|
upperNode.getNodesIdx().remove(object.getId());
|
|
upperNode.getNodesIdx().remove(object.getId());
|
|
upperNode.getNodes().remove(object);
|
|
upperNode.getNodes().remove(object);
|
|
@@ -554,11 +562,21 @@ public class NodeController {
|
|
upperNode.getOldEdges().remove(edge);
|
|
upperNode.getOldEdges().remove(edge);
|
|
}
|
|
}
|
|
|
|
|
|
- private void refreshSave(ArrayList<AbstractCpsObject> list, CpsUpperNode upperNode) {
|
|
|
|
|
|
+ private void updatePosition(AbstractCpsObject temp) {
|
|
|
|
+ // TODO Auto-generated method stub
|
|
|
|
+ int x = temp.getPosition().x - point.x;
|
|
|
|
+ int y = temp.getPosition().y - point.y;
|
|
|
|
+ if (x > model.getCanvasX())
|
|
|
|
+ x = model.getCanvasX();
|
|
|
|
+ if (y > model.getCanvasX())
|
|
|
|
+ y = model.getCanvasY();
|
|
|
|
+ if (y < 0)
|
|
|
|
+ y = 0;
|
|
|
|
+ if (x < 0)
|
|
|
|
+ x = 0;
|
|
|
|
+
|
|
|
|
+ temp.setPosition(new Position(x, y));
|
|
|
|
|
|
- for (AbstractCpsObject abs : list) {
|
|
|
|
- abs.setSav("" + upperNode.getId());
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|