|
@@ -74,7 +74,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
// The UpperNode
|
|
|
public CpsUpperNode upperNode;
|
|
|
|
|
|
- private boolean[] showedInformation = new boolean[3];
|
|
|
+ private boolean[] showedInformation = new boolean[5];
|
|
|
private boolean dragging = false; // for dragging
|
|
|
private boolean dragged = false; // if an object/objects was/were dragged
|
|
|
private boolean drawEdge = false; // for drawing edges
|
|
@@ -126,7 +126,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
* the Model
|
|
|
* @param control
|
|
|
* the Controller
|
|
|
- * @param unitGraph
|
|
|
+ * @param unitGraph
|
|
|
*/
|
|
|
public UpperNodeCanvas(Model mod, Control control, UnitGraph unitGraph, CpsUpperNode UpperNode, String parentPath) {
|
|
|
toolTip = false;
|
|
@@ -145,12 +145,13 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
borderPos = (int) (50 + scalediv20 + scalediv20 + 10);
|
|
|
for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
if (cps.getPosition().x < model.getScaleDiv2() + borderPos + 5) {
|
|
|
- cps.setPosition(new Position(borderPos + 5+model.getScaleDiv2(), cps.getPosition().y));
|
|
|
+ cps.setPosition(new Position(borderPos + 5 + model.getScaleDiv2(), cps.getPosition().y));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
showedInformation[0] = true;
|
|
|
showedInformation[1] = true;
|
|
|
+ showedInformation[4] = true;
|
|
|
|
|
|
popmenu.add(itemCut);
|
|
|
popmenu.add(itemCopy);
|
|
@@ -666,7 +667,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
cps = e.getA();
|
|
|
}
|
|
|
// Show and Highlight
|
|
|
- if (model.getSelectedCpsObjects().contains(cps)) {
|
|
|
+ if (model.getSelectedCpsObjects().contains(cps) || showedInformation[4] == true) {
|
|
|
for (CpsEdge ed : cps.getConnections()) {
|
|
|
AbstractCpsObject obj = null;
|
|
|
if (upperNode.getNodes().contains(ed.getA())) {
|
|
@@ -675,10 +676,23 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
obj = ed.getB();
|
|
|
}
|
|
|
if (obj != null) {
|
|
|
- g2.setColor(Color.BLUE);
|
|
|
+ if (ed.getFlow() == 0)
|
|
|
+ g2.setColor(Color.RED);
|
|
|
+ else
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
g2.drawLine(obj.getPosition().x, obj.getPosition().y, (borderPos >> 1),
|
|
|
- (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count)
|
|
|
- + 25);
|
|
|
+ (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + 25);
|
|
|
+ if (showedInformation[0]) {
|
|
|
+ if (ed.getConnected() == 0 || ed.getConnected() == 1) {
|
|
|
+ g2.drawString(ed.getFlow() + "/" + ed.getCapacity(),
|
|
|
+ (ed.getA().getPosition().x + ed.getB().getPosition().x) / 2,
|
|
|
+ (ed.getA().getPosition().y + ed.getB().getPosition().y) / 2);
|
|
|
+ } else {
|
|
|
+ g2.drawString("not connected",
|
|
|
+ (ed.getA().getPosition().x + ed.getB().getPosition().x) / 2,
|
|
|
+ (ed.getA().getPosition().y + ed.getB().getPosition().y) / 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -689,8 +703,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
if (g2.getColor() != Color.WHITE) {
|
|
|
g2.fillRect((int) ((borderPos >> 1) - 25 - scalediv20) - 3,
|
|
|
(int) (scalediv20 + 5 + (25 + scalediv20 + 10) * count - scalediv20) - 3,
|
|
|
- (int) (50 + ((scalediv20 + 3) * 2)),
|
|
|
- (int) (50 + ((scalediv20 + 3) * 2)));
|
|
|
+ (int) (50 + ((scalediv20 + 3) * 2)), (int) (50 + ((scalediv20 + 3) * 2)));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -712,15 +725,13 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
g2.setColor(Color.BLUE);
|
|
|
g2.fillRect((int) ((borderPos >> 1) - 25 - scalediv20),
|
|
|
(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count - scalediv20),
|
|
|
- (int) (50 + (scalediv20 * 2)),
|
|
|
- (int) (50 + (scalediv20 * 2)));
|
|
|
+ (int) (50 + (scalediv20 * 2)), (int) (50 + (scalediv20 * 2)));
|
|
|
} else if (cps instanceof HolonObject) {
|
|
|
g2.setColor(((HolonObject) cps).getColor());
|
|
|
|
|
|
g2.fillRect((int) ((borderPos >> 1) - 25 - scalediv20),
|
|
|
(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count - scalediv20),
|
|
|
- (int) (50 + (scalediv20 * 2)),
|
|
|
- (int) (50 + (scalediv20 * 2)));
|
|
|
+ (int) (50 + (scalediv20 * 2)), (int) (50 + (scalediv20 * 2)));
|
|
|
}
|
|
|
// draw image
|
|
|
File checkPath = new File(cps.getImage());
|
|
@@ -730,9 +741,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
|
|
|
}
|
|
|
}
|
|
|
- g2.drawImage(img, (borderPos >> 1) - 25,
|
|
|
- (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count), 50,
|
|
|
- 50, null);
|
|
|
+ g2.drawImage(img, (borderPos >> 1) - 25, (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count), 50, 50,
|
|
|
+ null);
|
|
|
count++;
|
|
|
}
|
|
|
|
|
@@ -1414,9 +1424,10 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
* @param object
|
|
|
* boolean for objects
|
|
|
*/
|
|
|
- public void setShowedInformation(boolean connection, boolean object) {
|
|
|
+ public void setShowedInformation(boolean connection, boolean object, boolean nodeOfnode) {
|
|
|
showedInformation[0] = connection;
|
|
|
showedInformation[1] = object;
|
|
|
+ showedInformation[4] = nodeOfnode;
|
|
|
}
|
|
|
|
|
|
/**
|