|
@@ -139,7 +139,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
scalediv20 = model.getScale() / 20;
|
|
|
|
|
|
// Cps objecte aus dem border links schieben
|
|
|
- borderPos = (int) (model.getScale() + scalediv20 + scalediv20 + 10);
|
|
|
+ borderPos = (int) (model.getScale() + controller.getScaleDiv2() + scalediv20 + scalediv20 + 10);
|
|
|
for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
if (cps.getPosition().x < model.getScaleDiv2() + borderPos + 5) {
|
|
|
cps.setPosition(new Position(borderPos + 5, cps.getPosition().y));
|
|
@@ -162,7 +162,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
itemDelete.setEnabled(false);
|
|
|
itemCut.setEnabled(false);
|
|
|
itemCopy.setEnabled(false);
|
|
|
- itemPaste.setEnabled(false);
|
|
|
+ itemPaste.setEnabled(true);
|
|
|
itemGroup.setEnabled(false);
|
|
|
itemUngroup.setEnabled(false);
|
|
|
itemTrack.setEnabled(false);
|
|
@@ -228,7 +228,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
// save old Position
|
|
|
JTabbedPane tabbedPane = (JTabbedPane) getParent().getParent().getParent();
|
|
|
- for (int i = 3; i < tabbedPane.getTabCount(); i++) {
|
|
|
+ for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
|
if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
|
.getComponent(0)).upperNode.getId() == ((CpsUpperNode) tempCps).getId()) {
|
|
|
tabbedPane.remove(i);
|
|
@@ -422,26 +422,28 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
g2.setRenderingHints(rh);
|
|
|
|
|
|
+ // Left Border
|
|
|
+ borderPos = (int) (model.getScale() + scalediv20 + scalediv20 + 10);
|
|
|
+
|
|
|
// Paint the Background
|
|
|
if (!upperNode.getImagePath().isEmpty()) {
|
|
|
img = new ImageIcon(upperNode.getImagePath()).getImage();
|
|
|
switch (upperNode.getBackgroundMode()) {
|
|
|
case BackgroundPopUp.IMAGE_PIXELS:
|
|
|
- g2.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);
|
|
|
+ g2.drawImage(img, borderPos, 0, img.getWidth(null), img.getHeight(null), null);
|
|
|
break;
|
|
|
case BackgroundPopUp.STRETCHED:
|
|
|
- g2.drawImage(img, 0, 0, model.getCanvasX(), model.getCanvasY(), null);
|
|
|
+ g2.drawImage(img, borderPos, 0, model.getCanvasX(), model.getCanvasY(), null);
|
|
|
break;
|
|
|
case BackgroundPopUp.CUSTOM:
|
|
|
- g2.drawImage(img, 0, 0, upperNode.getImageWidht(), upperNode.getImageHeight(), null);
|
|
|
+ g2.drawImage(img, borderPos, 0, upperNode.getImageWidht(), upperNode.getImageHeight(), null);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Left Border
|
|
|
- borderPos = (int) (model.getScale() + scalediv20 + scalediv20 + 10);
|
|
|
+ // Draw Left Border
|
|
|
g2.setColor(new Color(230, 230, 230));
|
|
|
g2.fillRect(0, 0, borderPos, this.getHeight());
|
|
|
g2.setColor(Color.BLACK);
|
|
@@ -481,8 +483,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
count++;
|
|
|
}
|
|
|
} else {
|
|
|
- g2.drawLine(tempCps.getPosition().x + controller.getScaleDiv2(),
|
|
|
- tempCps.getPosition().y + controller.getScaleDiv2(), x, y);
|
|
|
+ g2.drawLine(tempCps.getPosition().x, tempCps.getPosition().y, x, y);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -503,10 +504,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
g2.setColor(Color.DARK_GRAY);
|
|
|
g2.setStroke(new BasicStroke(2));
|
|
|
}
|
|
|
- g2.drawLine(con.getA().getPosition().x + controller.getScaleDiv2(),
|
|
|
- con.getA().getPosition().y + controller.getScaleDiv2(),
|
|
|
- con.getB().getPosition().x + controller.getScaleDiv2(),
|
|
|
- con.getB().getPosition().y + controller.getScaleDiv2());
|
|
|
+ g2.drawLine(con.getA().getPosition().x, con.getA().getPosition().y, con.getB().getPosition().x,
|
|
|
+ con.getB().getPosition().y);
|
|
|
|
|
|
if (con.getCapacity() == -1) {
|
|
|
maxCap = Character.toString('\u221e');
|
|
@@ -518,16 +517,11 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
if (showedInformation[0]) {
|
|
|
if (con.getConnected() == 0 || con.getConnected() == 1) {
|
|
|
g2.drawString(con.getFlow() + "/" + maxCap,
|
|
|
- (con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
|
- + controller.getScaleDiv2(),
|
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
|
- + controller.getScaleDiv2());
|
|
|
+ (con.getA().getPosition().x + con.getB().getPosition().x) / 2,
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2);
|
|
|
} else {
|
|
|
- g2.drawString("not connected",
|
|
|
- (con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
|
- + controller.getScaleDiv2(),
|
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
|
- + controller.getScaleDiv2());
|
|
|
+ g2.drawString("not connected", (con.getA().getPosition().x + con.getB().getPosition().x) / 2,
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -547,10 +541,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
|| con.getB().getId() == model.getSelectedObjectID()
|
|
|
|| model.getSelectedCpsObjects().contains(con.getB())
|
|
|
|| tempSelected.contains(con.getB()) && con != edgeHighlight) {
|
|
|
- g2.drawLine(con.getA().getPosition().x + controller.getScaleDiv2(),
|
|
|
- con.getA().getPosition().y + controller.getScaleDiv2(),
|
|
|
- con.getB().getPosition().x + controller.getScaleDiv2(),
|
|
|
- con.getB().getPosition().y + controller.getScaleDiv2());
|
|
|
+ g2.drawLine(con.getA().getPosition().x, con.getA().getPosition().y, con.getB().getPosition().x,
|
|
|
+ con.getB().getPosition().y);
|
|
|
|
|
|
if (con.getCapacity() == -1) {
|
|
|
maxCap = Character.toString('\u221e');
|
|
@@ -562,16 +554,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
if (showedInformation[0]) {
|
|
|
if (con.getConnected() == 0 || con.getConnected() == 1) {
|
|
|
g2.drawString(con.getFlow() + "/" + maxCap,
|
|
|
- (con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
|
- + controller.getScaleDiv2(),
|
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
|
- + controller.getScaleDiv2());
|
|
|
+ (con.getA().getPosition().x + con.getB().getPosition().x) / 2,
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2);
|
|
|
} else {
|
|
|
g2.drawString("not connected",
|
|
|
- (con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
|
- + controller.getScaleDiv2(),
|
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
|
- + controller.getScaleDiv2());
|
|
|
+ (con.getA().getPosition().x + con.getB().getPosition().x) / 2,
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -584,10 +572,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
} else {
|
|
|
g2.setStroke(new BasicStroke(2));
|
|
|
}
|
|
|
- g2.drawLine(edgeHighlight.getA().getPosition().x + controller.getScaleDiv2(),
|
|
|
- edgeHighlight.getA().getPosition().y + controller.getScaleDiv2(),
|
|
|
- edgeHighlight.getB().getPosition().x + controller.getScaleDiv2(),
|
|
|
- edgeHighlight.getB().getPosition().y + controller.getScaleDiv2());
|
|
|
+ g2.drawLine(edgeHighlight.getA().getPosition().x, edgeHighlight.getA().getPosition().y,
|
|
|
+ edgeHighlight.getB().getPosition().x, edgeHighlight.getB().getPosition().y);
|
|
|
|
|
|
if (edgeHighlight.getCapacity() == -1) {
|
|
|
maxCap = Character.toString('\u221e');
|
|
@@ -598,10 +584,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
}
|
|
|
if (showedInformation[0]) {
|
|
|
g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
|
|
|
- (edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2
|
|
|
- + controller.getScaleDiv2(),
|
|
|
- (edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2
|
|
|
- + controller.getScaleDiv2());
|
|
|
+ (edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2,
|
|
|
+ (edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -634,25 +618,29 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
if ((cps == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
|
|
|
|| model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps)) {
|
|
|
g2.setColor(Color.BLUE);
|
|
|
- g2.fillRect((int) (cps.getPosition().x - scalediv20), (int) (cps.getPosition().y - scalediv20),
|
|
|
+ g2.fillRect((int) (cps.getPosition().x - model.getScaleDiv2() - scalediv20),
|
|
|
+ (int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20),
|
|
|
(int) (controller.getScale() + (scalediv20 * 2)),
|
|
|
(int) (controller.getScale() + (scalediv20 * 2)));
|
|
|
if (showedInformation[1] && cps instanceof HolonObject) {
|
|
|
g2.setColor(Color.BLACK);
|
|
|
float totalEnergy = ((HolonObject) cps).getCurrentEnergyAtTimeStep(model.getCurIteration());
|
|
|
- g2.drawString(Float.toString(totalEnergy), cps.getPosition().x, cps.getPosition().y - 10);
|
|
|
+ g2.drawString(Float.toString(totalEnergy), cps.getPosition().x - model.getScaleDiv2(),
|
|
|
+ cps.getPosition().y - model.getScaleDiv2() - 10);
|
|
|
}
|
|
|
} else if (cps instanceof HolonObject) {
|
|
|
g2.setColor(((HolonObject) cps).getColor());
|
|
|
|
|
|
- g2.fillRect((int) (cps.getPosition().x - scalediv20), (int) (cps.getPosition().y - scalediv20),
|
|
|
+ g2.fillRect((int) (cps.getPosition().x - model.getScaleDiv2() - scalediv20),
|
|
|
+ (int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20),
|
|
|
(int) (controller.getScale() + (scalediv20 * 2)),
|
|
|
(int) (controller.getScale() + (scalediv20 * 2)));
|
|
|
|
|
|
if (showedInformation[1]) {
|
|
|
g2.setColor(Color.BLACK);
|
|
|
float totalEnergy = ((HolonObject) cps).getCurrentEnergyAtTimeStep(model.getCurIteration());
|
|
|
- g2.drawString(Float.toString(totalEnergy), cps.getPosition().x, cps.getPosition().y - 10);
|
|
|
+ g2.drawString(Float.toString(totalEnergy), cps.getPosition().x - model.getScaleDiv2(),
|
|
|
+ cps.getPosition().y - model.getScaleDiv2() - 10);
|
|
|
}
|
|
|
}
|
|
|
// draw image
|
|
@@ -663,8 +651,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
|
|
|
}
|
|
|
}
|
|
|
- g2.drawImage(img, cps.getPosition().x, cps.getPosition().y, controller.getScale(), controller.getScale(),
|
|
|
- null);
|
|
|
+ g2.drawImage(img, cps.getPosition().x - model.getScaleDiv2(), cps.getPosition().y - model.getScaleDiv2(),
|
|
|
+ controller.getScale(), controller.getScale(), null);
|
|
|
}
|
|
|
|
|
|
// Objects connected to upperNode
|
|
@@ -687,8 +675,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
}
|
|
|
if (obj != null) {
|
|
|
g2.setColor(Color.BLUE);
|
|
|
- g2.drawLine(obj.getPosition().x + model.getScaleDiv2(),
|
|
|
- obj.getPosition().y + model.getScaleDiv2(), (borderPos >> 1),
|
|
|
+ g2.drawLine(obj.getPosition().x, obj.getPosition().y, (borderPos >> 1),
|
|
|
(int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)
|
|
|
+ model.getScaleDiv2());
|
|
|
}
|
|
@@ -827,8 +814,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
|
|
|
if (e.getX() > borderPos) {
|
|
|
for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
- cx = cps.getPosition().x;
|
|
|
- cy = cps.getPosition().y;
|
|
|
+ cx = cps.getPosition().x - model.getScaleDiv2();
|
|
|
+ cy = cps.getPosition().y - model.getScaleDiv2();
|
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
|
tempCps = cps;
|
|
|
controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
|
|
@@ -844,12 +831,6 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * else if (e.getButton() != MouseEvent.BUTTON3) {
|
|
|
- * controller.setSelectedObjectID(tempCps.getID());
|
|
|
- * model.getSelectedCpsObjects().clear();
|
|
|
- * controller.addSelectedObject(tempCps); }
|
|
|
- */
|
|
|
// If drawing an Edge (CTRL down)
|
|
|
if (tempCps.getClass() == HolonObject.class) {
|
|
|
HolonObject tempObj = ((HolonObject) tempCps);
|
|
@@ -963,19 +944,15 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
itemDelete.setEnabled(true);
|
|
|
itemCut.setEnabled(true);
|
|
|
itemCopy.setEnabled(true);
|
|
|
- if (tempCps != null)
|
|
|
+ if (tempCps != null) {
|
|
|
itemGroup.setEnabled(true);
|
|
|
+ itemTrack.setEnabled(true);
|
|
|
+ itemUntrack.setEnabled(true);
|
|
|
+ }
|
|
|
if (tempCps instanceof CpsUpperNode)
|
|
|
itemUngroup.setEnabled(true);
|
|
|
else
|
|
|
itemUngroup.setEnabled(false);
|
|
|
- if (!(tempCps instanceof HolonSwitch)) {
|
|
|
- itemTrack.setEnabled(true);
|
|
|
- itemUntrack.setEnabled(true);
|
|
|
- } else {
|
|
|
- itemTrack.setEnabled(false);
|
|
|
- itemUntrack.setEnabled(false);
|
|
|
- }
|
|
|
if (model.getSelectedCpsObjects().size() == 0) {
|
|
|
controller.addSelectedObject(tempCps);
|
|
|
}
|
|
@@ -1026,26 +1003,24 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
}
|
|
|
if (dragging) {
|
|
|
try {
|
|
|
+ // tempCps in the upperNode? else its a connected Object from
|
|
|
+ // outside
|
|
|
if (upperNode.getNodes().contains(tempCps)) {
|
|
|
dragged = true;
|
|
|
float xDist, yDist; // Distance
|
|
|
|
|
|
- x = e.getX() - controller.getScaleDiv2();
|
|
|
- y = e.getY() - controller.getScaleDiv2();
|
|
|
-
|
|
|
- // tempCps in the upperNode? if not its a connected Object
|
|
|
- // from
|
|
|
- // outside
|
|
|
+ x = e.getX();
|
|
|
+ y = e.getY();
|
|
|
|
|
|
// Make sure its in bounds
|
|
|
if (e.getX() < controller.getScaleDiv2() + borderPos + 5)
|
|
|
- x = borderPos + 5;
|
|
|
+ x = controller.getScaleDiv2() + borderPos + 5;
|
|
|
else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
|
|
|
- x = this.getWidth() - controller.getScale();
|
|
|
+ x = this.getWidth() - controller.getScaleDiv2();
|
|
|
if (e.getY() < controller.getScaleDiv2())
|
|
|
- y = 0;
|
|
|
+ y = controller.getScaleDiv2();
|
|
|
else if (e.getY() > this.getHeight() - controller.getScaleDiv2())
|
|
|
- y = this.getHeight() - controller.getScale();
|
|
|
+ y = this.getHeight() - controller.getScaleDiv2();
|
|
|
|
|
|
// Distance
|
|
|
xDist = x - tempCps.getPosition().x;
|
|
@@ -1056,8 +1031,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
// TipText Position and name
|
|
|
toolTip = true;
|
|
|
toolTipText = tempCps.getName() + ", " + tempCps.getId();
|
|
|
- toolTipPos.x = tempCps.getPosition().x;
|
|
|
- toolTipPos.y = tempCps.getPosition().y + model.getScale();
|
|
|
+ toolTipPos.x = tempCps.getPosition().x - model.getScaleDiv2();
|
|
|
+ toolTipPos.y = tempCps.getPosition().y + model.getScaleDiv2();
|
|
|
|
|
|
// All Selected Objects
|
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
@@ -1066,14 +1041,14 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
y = (int) (cps.getPosition().y + yDist);
|
|
|
|
|
|
// Make sure its in bounds
|
|
|
- if (x < borderPos + 5)
|
|
|
- x = borderPos + 5;
|
|
|
- else if (x > this.getWidth() - controller.getScale())
|
|
|
- x = this.getWidth() - controller.getScale();
|
|
|
- if (y <= 0)
|
|
|
- y = 0;
|
|
|
- else if (y > this.getHeight() - controller.getScale())
|
|
|
- y = this.getHeight() - controller.getScale();
|
|
|
+ if (x < borderPos + 5 + controller.getScaleDiv2())
|
|
|
+ x = controller.getScaleDiv2() + borderPos + 5;
|
|
|
+ else if (x > this.getWidth() - controller.getScaleDiv2())
|
|
|
+ x = this.getWidth() - controller.getScaleDiv2();
|
|
|
+ if (y <= controller.getScaleDiv2())
|
|
|
+ y = controller.getScaleDiv2();
|
|
|
+ else if (y > this.getHeight() - controller.getScaleDiv2())
|
|
|
+ y = this.getHeight() - controller.getScaleDiv2();
|
|
|
|
|
|
cps.setPosition(x, y);
|
|
|
}
|
|
@@ -1100,8 +1075,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
y2 = sy;
|
|
|
}
|
|
|
if (x1 <= cps.getPosition().x + model.getScaleDiv2() && y1 <= cps.getPosition().y + model.getScaleDiv2()
|
|
|
- && x2 >= cps.getPosition().x + model.getScaleDiv2()
|
|
|
- && y2 >= cps.getPosition().y + model.getScaleDiv2()) {
|
|
|
+ && x2 >= cps.getPosition().x && y2 >= cps.getPosition().y) {
|
|
|
tempSelected.add(cps);
|
|
|
|
|
|
}
|
|
@@ -1144,21 +1118,18 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
public void mouseMoved(MouseEvent e) {
|
|
|
x = e.getX();
|
|
|
y = e.getY();
|
|
|
- // Everytghing for the tooltip :)
|
|
|
|
|
|
+ // Everytghing for the tooltip :)
|
|
|
boolean on = false;
|
|
|
for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
|
|
|
- cx = cps.getPosition().x;
|
|
|
- cy = cps.getPosition().y;
|
|
|
+ cx = cps.getPosition().x - controller.getScaleDiv2();
|
|
|
+ cy = cps.getPosition().y - controller.getScaleDiv2();
|
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
|
-
|
|
|
on = true;
|
|
|
- toolTipPos.x = cps.getPosition().x;
|
|
|
- toolTipPos.y = cps.getPosition().y + model.getScale();
|
|
|
+ toolTipPos.x = cps.getPosition().x - model.getScaleDiv2();
|
|
|
+ toolTipPos.y = cps.getPosition().y + model.getScaleDiv2();
|
|
|
toolTipText = cps.getName() + ", " + cps.getId();
|
|
|
-
|
|
|
- on = true;
|
|
|
}
|
|
|
}
|
|
|
int count = 0;
|
|
@@ -1204,14 +1175,13 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
// to
|
|
|
// the
|
|
|
// outside
|
|
|
- boolean found = false;
|
|
|
+ boolean found = false; // dont search for outside connetion if inside
|
|
|
+ // connection is found
|
|
|
CpsEdge e = null;
|
|
|
- AbstractCpsObject tempCPS = null;
|
|
|
-
|
|
|
for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
|
|
|
- cx = cps.getPosition().x;
|
|
|
- cy = cps.getPosition().y;
|
|
|
+ cx = cps.getPosition().x - controller.getScaleDiv2();
|
|
|
+ cy = cps.getPosition().y - controller.getScaleDiv2();
|
|
|
|
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy
|
|
|
&& cps != tempCps) {
|
|
@@ -1236,7 +1206,6 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
deleteNode = true;
|
|
|
}
|
|
|
if (e.getB().getClass() == CpsNode.class && e.getB().getConnections().isEmpty()) {
|
|
|
- tempCPS = e.getB();
|
|
|
deleteNode = true;
|
|
|
}
|
|
|
}
|
|
@@ -1286,7 +1255,6 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
deleteNode = true;
|
|
|
}
|
|
|
if (e.getB().getClass() == CpsNode.class && e.getB().getConnections().isEmpty()) {
|
|
|
- tempCPS = e.getB();
|
|
|
deleteNode = true;
|
|
|
}
|
|
|
}
|
|
@@ -1314,7 +1282,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
|
|
|
CpsNode n = new CpsNode("Node");
|
|
|
|
|
|
- n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
|
|
|
+ n.setPosition(x, y);
|
|
|
controller.addObjUpperNode(n, upperNode);
|
|
|
|
|
|
AbstractCpsObject r, k;
|
|
@@ -1343,7 +1311,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
if (node && x > borderPos) {
|
|
|
CpsNode n = new CpsNode("Node");
|
|
|
|
|
|
- n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
|
|
|
+ n.setPosition(x, y);
|
|
|
controller.addObjUpperNode(n, upperNode);
|
|
|
|
|
|
e = new CpsEdge(n, tempCps, model.getMaxCapacity());
|
|
@@ -1373,6 +1341,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
* @return CpsEdge the Mouse is on, null if the mouse is not on an Edge
|
|
|
*/
|
|
|
public CpsEdge mousePositionOnEdge(int x, int y) {
|
|
|
+ x += controller.getScaleDiv2();
|
|
|
+ y += controller.getScaleDiv2();
|
|
|
int lx, ly, hx, hy;
|
|
|
for (CpsEdge p : upperNode.getNodeEdges()) {
|
|
|
Line2D l = new Line2D.Float(p.getA().getPosition().x, p.getA().getPosition().y, p.getB().getPosition().x,
|