|
@@ -657,17 +657,20 @@ public class MyCanvas extends AbstractCanvas implements MouseListener, MouseMoti
|
|
/**
|
|
/**
|
|
* Draws or Deletes an Edge.
|
|
* Draws or Deletes an Edge.
|
|
*/
|
|
*/
|
|
- private void drawDeleteEdge() {
|
|
|
|
|
|
+ void drawDeleteEdge() {
|
|
if (getMousePosition() != null) {
|
|
if (getMousePosition() != null) {
|
|
boolean node = true;
|
|
boolean node = true;
|
|
boolean newEdge = true;
|
|
boolean newEdge = true;
|
|
boolean onEdge = true;
|
|
boolean onEdge = true;
|
|
boolean deleteNode = false;
|
|
boolean deleteNode = false;
|
|
CpsEdge e = null;
|
|
CpsEdge e = null;
|
|
|
|
+
|
|
for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
|
|
cx = cps.getPosition().x - controller.getScaleDiv2();
|
|
cx = cps.getPosition().x - controller.getScaleDiv2();
|
|
cy = cps.getPosition().y - controller.getScaleDiv2();
|
|
cy = cps.getPosition().y - controller.getScaleDiv2();
|
|
- 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;
|
|
onEdge = false;
|
|
onEdge = false;
|
|
@@ -687,8 +690,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener, MouseMoti
|
|
if (e.getB().getClass() == CpsNode.class && e.getB().getConnections().isEmpty()) {
|
|
if (e.getB().getClass() == CpsNode.class && e.getB().getConnections().isEmpty()) {
|
|
deleteNode = true;
|
|
deleteNode = true;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (newEdge) {
|
|
|
|
|
|
+ } else {
|
|
e = new CpsEdge(cps, tempCps, model.getMaxCapacity());
|
|
e = new CpsEdge(cps, tempCps, model.getMaxCapacity());
|
|
controller.addEdgeOnCanvas(e);
|
|
controller.addEdgeOnCanvas(e);
|
|
}
|
|
}
|