|
@@ -234,15 +234,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
g2.drawRect(sx, y, x - sx, sy - y);
|
|
g2.drawRect(sx, y, x - sx, sy - y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
- * // Testing for (CpsObject cps : markSelect) {
|
|
|
|
- * g2.setColor(Color.BLUE); g2.fillRect(cps.getPosition().x -
|
|
|
|
- * (controller.getScale() / 20), cps.getPosition().y -
|
|
|
|
- * (controller.getScale() / 20), controller.getScale() +
|
|
|
|
- * ((controller.getScale() / 20) * 2), controller.getScale() +
|
|
|
|
- * ((controller.getScale() / 20) * 2)); }
|
|
|
|
- */
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -250,6 +241,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
// clear SelectedObjects
|
|
// clear SelectedObjects
|
|
if (!e.isControlDown() && dragging == false) {
|
|
if (!e.isControlDown() && dragging == false) {
|
|
model.getSelectedCpsObjects().clear();
|
|
model.getSelectedCpsObjects().clear();
|
|
|
|
+ TempSelected.clear();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -348,58 +340,33 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
y = e.getY();
|
|
y = e.getY();
|
|
if (!model.getSelectedCpsObjects().contains(tempCps)) {
|
|
if (!model.getSelectedCpsObjects().contains(tempCps)) {
|
|
model.getSelectedCpsObjects().clear();
|
|
model.getSelectedCpsObjects().clear();
|
|
|
|
+ TempSelected.clear();
|
|
}
|
|
}
|
|
|
|
|
|
if (dragging) {
|
|
if (dragging) {
|
|
try {
|
|
try {
|
|
- if (model.getSelectedCpsObjects().size() > 0) {
|
|
|
|
- for (CpsObject cps : model.getSelectedCpsObjects()) {
|
|
|
|
- // Au�erhalb des Randes gedragged?
|
|
|
|
- if (cps == tempCps) {
|
|
|
|
- x = e.getX() - controller.getScaleDiv2();
|
|
|
|
- y = e.getY() - controller.getScaleDiv2();
|
|
|
|
- } else {
|
|
|
|
- x = e.getX() + (cps.getPosition().x - e.getX());
|
|
|
|
- y = e.getY() + (cps.getPosition().y - e.getY());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (x < controller.getScaleDiv2())
|
|
|
|
- x = 0;
|
|
|
|
- else if (x > this.getWidth() - controller.getScaleDiv2())
|
|
|
|
- x = this.getWidth() - controller.getScale();
|
|
|
|
- if (y < controller.getScaleDiv2())
|
|
|
|
- y = 0;
|
|
|
|
- else if (y > this.getHeight() - controller.getScaleDiv2())
|
|
|
|
- y = this.getHeight() - controller.getScale();
|
|
|
|
-
|
|
|
|
- System.out.println(x + ", " + y);
|
|
|
|
- // Drag Position
|
|
|
|
- cps.setPosition(x, y);
|
|
|
|
- // TipText Position and name
|
|
|
|
- objectTT.setTipText(tempCps.getName());
|
|
|
|
- objectTT.setLocation(e.getX() - controller.getScaleDiv2(),
|
|
|
|
- e.getY() - controller.getScaleDiv2() + controller.getScale());
|
|
|
|
|
|
+ x = e.getX() - controller.getScaleDiv2();
|
|
|
|
+ y = e.getY() - controller.getScaleDiv2();
|
|
|
|
+
|
|
|
|
+ if (e.getX() < controller.getScaleDiv2())
|
|
|
|
+ x = 0;
|
|
|
|
+ else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
|
|
|
|
+ x = this.getWidth() - controller.getScale();
|
|
|
|
+ if (e.getY() < controller.getScaleDiv2())
|
|
|
|
+ y = 0;
|
|
|
|
+ else if (e.getY() > this.getHeight() - controller.getScaleDiv2())
|
|
|
|
+ y = this.getHeight() - controller.getScale();
|
|
|
|
+ // Drag Position
|
|
|
|
+ tempCps.setPosition(x, y);
|
|
|
|
+ // Highlighting Position
|
|
|
|
+ selectRect.setLocation(x - (controller.getScale() / 20), y - (controller.getScale() / 20));
|
|
|
|
+ // TipText Position and name
|
|
|
|
+ objectTT.setTipText(tempCps.getName());
|
|
|
|
+ objectTT.setLocation(x, y + controller.getScale());
|
|
|
|
+ for (CpsObject cps : model.getSelectedCpsObjects()) {
|
|
|
|
+ if (cps != tempCps) {
|
|
|
|
+
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- // Au�erhalb des Randes gedragged?
|
|
|
|
- x = e.getX() - controller.getScaleDiv2();
|
|
|
|
- y = e.getY() - controller.getScaleDiv2();
|
|
|
|
-
|
|
|
|
- if (e.getX() < controller.getScaleDiv2())
|
|
|
|
- x = 0;
|
|
|
|
- else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
|
|
|
|
- x = this.getWidth() - controller.getScale();
|
|
|
|
- if (e.getY() < controller.getScaleDiv2())
|
|
|
|
- y = 0;
|
|
|
|
- else if (e.getY() > this.getHeight() - controller.getScaleDiv2())
|
|
|
|
- y = this.getHeight() - controller.getScale();
|
|
|
|
- // Drag Position
|
|
|
|
- tempCps.setPosition(x, y);
|
|
|
|
- // Highlighting Position
|
|
|
|
- selectRect.setLocation(x - (controller.getScale() / 20), y - (controller.getScale() / 20));
|
|
|
|
- // TipText Position and name
|
|
|
|
- objectTT.setTipText(tempCps.getName());
|
|
|
|
- objectTT.setLocation(x, y + controller.getScale());
|
|
|
|
}
|
|
}
|
|
repaint();
|
|
repaint();
|
|
} catch (Exception e2) {
|
|
} catch (Exception e2) {
|
|
@@ -409,7 +376,9 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
|
|
|
// Mark Objects
|
|
// Mark Objects
|
|
TempSelected.clear();
|
|
TempSelected.clear();
|
|
- if (doMark) {
|
|
|
|
|
|
+ if (doMark)
|
|
|
|
+
|
|
|
|
+ {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
int x1 = sx, x2 = x, y1 = sy, y2 = y;
|
|
int x1 = sx, x2 = x, y1 = sy, y2 = y;
|
|
|
|
|
|
@@ -499,8 +468,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
}
|
|
}
|
|
if (!newEdge) {
|
|
if (!newEdge) {
|
|
controller.removeEdgesOnCanvas(e);
|
|
controller.removeEdgesOnCanvas(e);
|
|
- tempCps.getConnections().remove(e);
|
|
|
|
- cps.getConnections().remove(e);
|
|
|
|
// Node ohne Edge?
|
|
// Node ohne Edge?
|
|
if (e.getA().getClass() == CpsNode.class && e.getA().getConnections().isEmpty()) {
|
|
if (e.getA().getClass() == CpsNode.class && e.getA().getConnections().isEmpty()) {
|
|
tempCps = e.getA();
|
|
tempCps = e.getA();
|
|
@@ -521,7 +488,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
if (onEdge) {
|
|
if (onEdge) {
|
|
CpsEdge p = mousePositionOnEdge(x, y);
|
|
CpsEdge p = mousePositionOnEdge(x, y);
|
|
if (p != null) {
|
|
if (p != null) {
|
|
- CpsEdge temp = null;
|
|
|
|
CpsEdge e1 = null;
|
|
CpsEdge e1 = null;
|
|
CpsEdge e2 = null;
|
|
CpsEdge e2 = null;
|
|
|
|
|
|
@@ -542,11 +508,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
|
|
|
e2 = new CpsEdge(n, k, edgeCapacity);
|
|
e2 = new CpsEdge(n, k, edgeCapacity);
|
|
|
|
|
|
- p.getA().getConnections().remove(p);
|
|
|
|
- p.getB().getConnections().remove(p);
|
|
|
|
-
|
|
|
|
- temp = p;
|
|
|
|
- controller.removeEdgesOnCanvas(temp);
|
|
|
|
|
|
+ controller.removeEdgesOnCanvas(p);
|
|
controller.AddEdgeOnCanvas(e);
|
|
controller.AddEdgeOnCanvas(e);
|
|
controller.AddEdgeOnCanvas(e1);
|
|
controller.AddEdgeOnCanvas(e1);
|
|
controller.AddEdgeOnCanvas(e2);
|
|
controller.AddEdgeOnCanvas(e2);
|