|
@@ -22,18 +22,13 @@ import javax.swing.JPanel;
|
|
import javax.swing.JPopupMenu;
|
|
import javax.swing.JPopupMenu;
|
|
import javax.swing.JToolTip;
|
|
import javax.swing.JToolTip;
|
|
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
-import com.sun.javafx.geom.Edge;
|
|
|
|
-
|
|
|
|
import classes.CpsEdge;
|
|
import classes.CpsEdge;
|
|
-=======
|
|
|
|
->>>>>>> branch 'Ohne_Drag_and_Drop' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git
|
|
|
|
import classes.CpsNode;
|
|
import classes.CpsNode;
|
|
import classes.CpsObject;
|
|
import classes.CpsObject;
|
|
import classes.HolonElement;
|
|
import classes.HolonElement;
|
|
import classes.HolonObject;
|
|
import classes.HolonObject;
|
|
import classes.HolonSwitch;
|
|
import classes.HolonSwitch;
|
|
-import classes.HolonTransformer;
|
|
|
|
|
|
+import javafx.util.Pair;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
import ui.model.*;
|
|
import ui.model.*;
|
|
|
|
|
|
@@ -114,7 +109,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
g2.drawLine(cps.getPosition().x + controller.getScaleDiv2(),
|
|
g2.drawLine(cps.getPosition().x + controller.getScaleDiv2(),
|
|
cps.getPosition().y + controller.getScaleDiv2(),
|
|
cps.getPosition().y + controller.getScaleDiv2(),
|
|
con.getKey().getPosition().x + controller.getScaleDiv2(),
|
|
con.getKey().getPosition().x + controller.getScaleDiv2(),
|
|
- con.getKey().getPosition().y + controller.getScaleDiv2());
|
|
|
|
|
|
+ con.getKey().getPosition().y + controller.getScaleDiv2());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -177,9 +172,9 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
tempCps = cps;
|
|
tempCps = cps;
|
|
// If drawing an Edge (CTRL down)
|
|
// If drawing an Edge (CTRL down)
|
|
- if (e.isControlDown()) {
|
|
|
|
- drawEdge = true;
|
|
|
|
- drawEdge = true;
|
|
|
|
|
|
+ if (e.isControlDown()) {
|
|
|
|
+ drawEdge = true;
|
|
|
|
+ drawEdge = true;
|
|
}
|
|
}
|
|
if (tempCps.getClass() == HolonObject.class) {
|
|
if (tempCps.getClass() == HolonObject.class) {
|
|
HolonObject tempObj = ((HolonObject) tempCps);
|
|
HolonObject tempObj = ((HolonObject) tempCps);
|
|
@@ -304,40 +299,41 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
CpsEdge e;
|
|
CpsEdge e;
|
|
CpsNode n = null;
|
|
CpsNode n = null;
|
|
Pair<CpsObject, CpsEdge> tempPair = null;
|
|
Pair<CpsObject, CpsEdge> tempPair = null;
|
|
- Pair<CpsObject, CpsEdge> cpsPair = null;
|
|
|
|
-
|
|
|
|
- for (Pair<CpsObject, CpsEdge> p: tempCps.getConnections()) {
|
|
|
|
- if(p.getKey() == tempCps){
|
|
|
|
|
|
+ Pair<CpsObject, CpsEdge> cpsPair = null;
|
|
|
|
+
|
|
|
|
+ for (Pair<CpsObject, CpsEdge> p : tempCps.getConnections()) {
|
|
|
|
+ if (p.getKey() == tempCps) {
|
|
cpsPair = p;
|
|
cpsPair = p;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
cx = cps.getPosition().x;
|
|
cx = cps.getPosition().x;
|
|
cy = cps.getPosition().y;
|
|
cy = cps.getPosition().y;
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy
|
|
&& cps != tempCps) {
|
|
&& cps != tempCps) {
|
|
node = false;
|
|
node = false;
|
|
- for (Pair<CpsObject, CpsEdge> p: tempCps.getConnections()) {
|
|
|
|
- if(p.getKey() == cps){
|
|
|
|
- System.out.println("remove");
|
|
|
|
- for (Pair<CpsObject, CpsEdge> pp: tempCps.getConnections()) {
|
|
|
|
- if(p.getKey() == tempCps){
|
|
|
|
- cpsPair = p;
|
|
|
|
- cps.getConnectedTo().remove(tempPair);
|
|
|
|
- tempCps.getConnectedTo().remove(cpsPair);
|
|
|
|
|
|
+ for (Pair<CpsObject, CpsEdge> p : tempCps.getConnections()) {
|
|
|
|
+ if (p.getKey() == cps) {
|
|
|
|
+ newEdge = false;
|
|
|
|
+ cpsPair = p;
|
|
|
|
+ for (Pair<CpsObject, CpsEdge> pp : cps.getConnections()) {
|
|
|
|
+ if (pp.getKey() == tempCps) {
|
|
|
|
+ tempPair = pp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ tempCps.getConnections().remove(cpsPair);
|
|
|
|
+ cps.getConnections().remove(tempPair);
|
|
if (newEdge) {
|
|
if (newEdge) {
|
|
e = new CpsEdge(cps, tempCps);
|
|
e = new CpsEdge(cps, tempCps);
|
|
tempPair = new Pair<CpsObject, CpsEdge>(tempCps, e);
|
|
tempPair = new Pair<CpsObject, CpsEdge>(tempCps, e);
|
|
cpsPair = new Pair<CpsObject, CpsEdge>(cps, e);
|
|
cpsPair = new Pair<CpsObject, CpsEdge>(cps, e);
|
|
-
|
|
|
|
|
|
+
|
|
cps.AddConnection(tempPair);
|
|
cps.AddConnection(tempPair);
|
|
tempCps.AddConnection(cpsPair);
|
|
tempCps.AddConnection(cpsPair);
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -345,11 +341,11 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
n = new CpsNode("Node");
|
|
n = new CpsNode("Node");
|
|
n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
|
|
n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
|
|
controller.addObjectCanvas(n);
|
|
controller.addObjectCanvas(n);
|
|
-
|
|
|
|
|
|
+
|
|
e = new CpsEdge(n, tempCps);
|
|
e = new CpsEdge(n, tempCps);
|
|
tempPair = new Pair<CpsObject, CpsEdge>(tempCps, e);
|
|
tempPair = new Pair<CpsObject, CpsEdge>(tempCps, e);
|
|
cpsPair = new Pair<CpsObject, CpsEdge>(n, e);
|
|
cpsPair = new Pair<CpsObject, CpsEdge>(n, e);
|
|
-
|
|
|
|
|
|
+
|
|
n.AddConnection(tempPair);
|
|
n.AddConnection(tempPair);
|
|
tempCps.AddConnection(cpsPair);
|
|
tempCps.AddConnection(cpsPair);
|
|
System.out.println("node ID: " + n.getID());
|
|
System.out.println("node ID: " + n.getID());
|