|
@@ -305,10 +305,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
controller.addTrackingObj((HolonObject) o);
|
|
|
((HolonObject) o).updateTrackingInfo();
|
|
|
}
|
|
|
- controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
|
|
|
- controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
|
|
|
- controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
- controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
|
|
|
+ if (model.getShowConsoleLog()) {
|
|
|
+ controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
|
|
|
+ controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
|
|
|
+ controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
+ controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -555,136 +557,6 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if (model.getSelectedObjectID() > 0 || !model.getSelectedCpsObjects().isEmpty() || !tempSelected.isEmpty()) {
|
|
|
- g2.setColor(Color.BLUE);
|
|
|
- for (CpsEdge con : upperNode.getNodeEdges()) {
|
|
|
- if (con.getFlow() <= con.getCapacity()) {
|
|
|
- g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 3) + 1, 4)));
|
|
|
- } else {
|
|
|
- g2.setStroke(new BasicStroke(2));
|
|
|
- }
|
|
|
- if (con.getA().getId() == model.getSelectedObjectID()
|
|
|
- || model.getSelectedCpsObjects().contains(con.getA()) || tempSelected.contains(con.getA())
|
|
|
- || con.getB().getId() == model.getSelectedObjectID()
|
|
|
- || model.getSelectedCpsObjects().contains(con.getB())
|
|
|
- || tempSelected.contains(con.getB()) && con != edgeHighlight) {
|
|
|
- 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');
|
|
|
- } else if (con.getCapacity() == -2) {
|
|
|
- maxCap = "???";
|
|
|
- } else {
|
|
|
- maxCap = String.valueOf(con.getCapacity());
|
|
|
- }
|
|
|
- if (showedInformation[0]) {
|
|
|
- if (con.getConnected() == 0 || con.getConnected() == 1) {
|
|
|
- g2.drawString(con.getFlow() + "/" + maxCap,
|
|
|
- (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,
|
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (edgeHighlight != null) {
|
|
|
- g2.setColor(Color.BLUE);
|
|
|
- if (edgeHighlight.getFlow() <= edgeHighlight.getCapacity()) {
|
|
|
- g2.setStroke(
|
|
|
- new BasicStroke(Math.min((edgeHighlight.getFlow() / edgeHighlight.getCapacity() * 3) + 1, 4)));
|
|
|
- } else {
|
|
|
- g2.setStroke(new BasicStroke(2));
|
|
|
- }
|
|
|
- if (upperNode.getNodeEdges().contains(edgeHighlight)) {
|
|
|
- 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');
|
|
|
- } else if (edgeHighlight.getCapacity() == -2) {
|
|
|
- maxCap = "???";
|
|
|
- } else {
|
|
|
- maxCap = String.valueOf(edgeHighlight.getCapacity());
|
|
|
- }
|
|
|
- if (showedInformation[0]) {
|
|
|
- g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
|
|
|
- (edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2,
|
|
|
- (edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
-
|
|
|
- if (showedInformation[3]) {
|
|
|
- g2.setColor(cps.getBorderColor());
|
|
|
- if (g2.getColor() != Color.WHITE) {
|
|
|
- g2.fillRect((int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
|
|
|
- (int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20 - 3),
|
|
|
- (int) (controller.getScale() + ((scalediv20 + 3) * 2)),
|
|
|
- (int) (controller.getScale() + ((scalediv20 + 3) * 2)));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (cps instanceof CpsNode && (cps == tempCps || model.getSelectedCpsObject() == cps
|
|
|
- || model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps))) {
|
|
|
- img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
|
|
|
- } else {
|
|
|
- if (cps instanceof HolonSwitch) {
|
|
|
- if (((HolonSwitch) cps).getActiveAt()[model.getCurIteration()]) {
|
|
|
- ((HolonSwitch) cps).setAutoState(true);
|
|
|
- } else {
|
|
|
- ((HolonSwitch) cps).setAutoState(false);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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 - 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 - model.getScaleDiv2(),
|
|
|
- cps.getPosition().y - model.getScaleDiv2() - 10);
|
|
|
- }
|
|
|
- } else if (cps instanceof HolonObject) {
|
|
|
- g2.setColor(((HolonObject) cps).getColor());
|
|
|
-
|
|
|
- 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 - model.getScaleDiv2(),
|
|
|
- cps.getPosition().y - model.getScaleDiv2() - 10);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- File checkPath = new File(cps.getImage());
|
|
|
- if (checkPath.exists()) {
|
|
|
- img = new ImageIcon(cps.getImage()).getImage();
|
|
|
- } else {
|
|
|
- img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
|
|
|
- }
|
|
|
- }
|
|
|
- g2.drawImage(img, cps.getPosition().x - model.getScaleDiv2(), cps.getPosition().y - model.getScaleDiv2(),
|
|
|
- controller.getScale(), controller.getScale(), null);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
int count = 0;
|
|
|
for (CpsEdge e : upperNode.getConnections()) {
|
|
@@ -725,8 +597,15 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
g2.drawLine(obj.getPosition().x, obj.getPosition().y, (upperNode.getLeftBorder() >> 1),
|
|
|
(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + 25);
|
|
|
if (showedInformation[0]) {
|
|
|
+ if (ed.getCapacity() == -1) {
|
|
|
+ maxCap = Character.toString('\u221e');
|
|
|
+ } else if (ed.getCapacity() == -2) {
|
|
|
+ maxCap = "???";
|
|
|
+ } else {
|
|
|
+ maxCap = String.valueOf(ed.getCapacity());
|
|
|
+ }
|
|
|
if (ed.getConnected() == 0 || ed.getConnected() == 1) {
|
|
|
- g2.drawString(ed.getFlow() + "/" + ed.getCapacity(),
|
|
|
+ g2.drawString(ed.getFlow() + "/" + maxCap,
|
|
|
(obj.getPosition().x + (upperNode.getLeftBorder() >> 1)) / 2,
|
|
|
(obj.getPosition().y + (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count)
|
|
|
+ 25) / 2);
|
|
@@ -741,6 +620,140 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if (model.getSelectedObjectID() > 0 || !model.getSelectedCpsObjects().isEmpty()
|
|
|
+ || !tempSelected.isEmpty()) {
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
+ for (CpsEdge con : upperNode.getNodeEdges()) {
|
|
|
+ if (con.getFlow() <= con.getCapacity()) {
|
|
|
+ g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 3) + 1, 4)));
|
|
|
+ } else {
|
|
|
+ g2.setStroke(new BasicStroke(2));
|
|
|
+ }
|
|
|
+ if (con.getA().getId() == model.getSelectedObjectID()
|
|
|
+ || model.getSelectedCpsObjects().contains(con.getA()) || tempSelected.contains(con.getA())
|
|
|
+ || con.getB().getId() == model.getSelectedObjectID()
|
|
|
+ || model.getSelectedCpsObjects().contains(con.getB())
|
|
|
+ || tempSelected.contains(con.getB()) && con != edgeHighlight) {
|
|
|
+ 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');
|
|
|
+ } else if (con.getCapacity() == -2) {
|
|
|
+ maxCap = "???";
|
|
|
+ } else {
|
|
|
+ maxCap = String.valueOf(con.getCapacity());
|
|
|
+ }
|
|
|
+ if (showedInformation[0]) {
|
|
|
+ if (con.getConnected() == 0 || con.getConnected() == 1) {
|
|
|
+ g2.drawString(con.getFlow() + "/" + maxCap,
|
|
|
+ (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,
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (edgeHighlight != null) {
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
+ if (edgeHighlight.getFlow() <= edgeHighlight.getCapacity()) {
|
|
|
+ g2.setStroke(new BasicStroke(
|
|
|
+ Math.min((edgeHighlight.getFlow() / edgeHighlight.getCapacity() * 3) + 1, 4)));
|
|
|
+ } else {
|
|
|
+ g2.setStroke(new BasicStroke(2));
|
|
|
+ }
|
|
|
+ if (upperNode.getNodeEdges().contains(edgeHighlight)) {
|
|
|
+ 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');
|
|
|
+ } else if (edgeHighlight.getCapacity() == -2) {
|
|
|
+ maxCap = "???";
|
|
|
+ } else {
|
|
|
+ maxCap = String.valueOf(edgeHighlight.getCapacity());
|
|
|
+ }
|
|
|
+ if (showedInformation[0]) {
|
|
|
+ g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
|
|
|
+ (edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2,
|
|
|
+ (edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (AbstractCpsObject cps1 : upperNode.getNodes()) {
|
|
|
+
|
|
|
+ if (showedInformation[3]) {
|
|
|
+ g2.setColor(cps1.getBorderColor());
|
|
|
+ if (g2.getColor() != Color.WHITE) {
|
|
|
+ g2.fillRect((int) (cps1.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
|
|
|
+ (int) (cps1.getPosition().y - model.getScaleDiv2() - scalediv20 - 3),
|
|
|
+ (int) (controller.getScale() + ((scalediv20 + 3) * 2)),
|
|
|
+ (int) (controller.getScale() + ((scalediv20 + 3) * 2)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (cps1 instanceof CpsNode && (cps1 == tempCps || model.getSelectedCpsObject() == cps1
|
|
|
+ || model.getSelectedCpsObjects().contains(cps1) || tempSelected.contains(cps1))) {
|
|
|
+ img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
|
|
|
+ } else {
|
|
|
+ if (cps1 instanceof HolonSwitch) {
|
|
|
+ if (((HolonSwitch) cps1).getActiveAt()[model.getCurIteration()]) {
|
|
|
+ ((HolonSwitch) cps1).setAutoState(true);
|
|
|
+ } else {
|
|
|
+ ((HolonSwitch) cps1).setAutoState(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((cps1 == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
|
|
|
+ || model.getSelectedCpsObjects().contains(cps1) || tempSelected.contains(cps1)) {
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
+ g2.fillRect((int) (cps1.getPosition().x - model.getScaleDiv2() - scalediv20),
|
|
|
+ (int) (cps1.getPosition().y - model.getScaleDiv2() - scalediv20),
|
|
|
+ (int) (controller.getScale() + (scalediv20 * 2)),
|
|
|
+ (int) (controller.getScale() + (scalediv20 * 2)));
|
|
|
+ if (showedInformation[1] && cps1 instanceof HolonObject) {
|
|
|
+ g2.setColor(Color.BLACK);
|
|
|
+ float totalEnergy = ((HolonObject) cps1)
|
|
|
+ .getCurrentEnergyAtTimeStep(model.getCurIteration());
|
|
|
+ g2.drawString(Float.toString(totalEnergy), cps1.getPosition().x - model.getScaleDiv2(),
|
|
|
+ cps1.getPosition().y - model.getScaleDiv2() - 10);
|
|
|
+ }
|
|
|
+ } else if (cps1 instanceof HolonObject) {
|
|
|
+ g2.setColor(((HolonObject) cps1).getColor());
|
|
|
+
|
|
|
+ g2.fillRect((int) (cps1.getPosition().x - model.getScaleDiv2() - scalediv20),
|
|
|
+ (int) (cps1.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) cps1)
|
|
|
+ .getCurrentEnergyAtTimeStep(model.getCurIteration());
|
|
|
+ g2.drawString(Float.toString(totalEnergy), cps1.getPosition().x - model.getScaleDiv2(),
|
|
|
+ cps1.getPosition().y - model.getScaleDiv2() - 10);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ File checkPath = new File(cps1.getImage());
|
|
|
+ if (checkPath.exists()) {
|
|
|
+ img = new ImageIcon(cps1.getImage()).getImage();
|
|
|
+ } else {
|
|
|
+ img = new ImageIcon(this.getClass().getResource(cps1.getImage())).getImage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ g2.drawImage(img, cps1.getPosition().x - model.getScaleDiv2(),
|
|
|
+ cps1.getPosition().y - model.getScaleDiv2(), controller.getScale(), controller.getScale(),
|
|
|
+ null);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if (showedInformation[3]) {
|
|
|
g2.setColor(cps.getBorderColor());
|
|
@@ -874,10 +887,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
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);
|
|
|
- controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
|
|
|
- controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
- controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
|
|
|
+ if (model.getShowConsoleLog()) {
|
|
|
+ controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
|
|
|
+ controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
|
|
|
+ controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
+ controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
|
|
|
+ }
|
|
|
dragging = true;
|
|
|
if (e.isControlDown() && tempCps != null) {
|
|
|
if (model.getSelectedCpsObjects().contains(tempCps)) {
|
|
@@ -914,11 +929,13 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
|
&& x >= (upperNode.getLeftBorder() >> 1) - model.getScaleDiv2()
|
|
|
&& y >= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)) {
|
|
|
tempCps = cps;
|
|
|
- controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
|
|
|
- controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
|
|
|
- controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
- controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
|
|
|
- controller.setSelectedObjectID(tempCps.getId());
|
|
|
+ if (model.getShowConsoleLog()) {
|
|
|
+ controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
|
|
|
+ controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
|
|
|
+ controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
+ controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
|
|
|
+ controller.setSelectedObjectID(tempCps.getId());
|
|
|
+ }
|
|
|
|
|
|
if (tempCps.getClass() == HolonObject.class) {
|
|
|
HolonObject tempObj = ((HolonObject) tempCps);
|