Browse Source

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons

Teh-Hai Julian Zheng 7 years ago
parent
commit
c39d079f06
2 changed files with 18 additions and 8 deletions
  1. 4 4
      src/ui/view/StatisticGraph.java
  2. 14 4
      src/ui/view/UpperNodeCanvas.java

+ 4 - 4
src/ui/view/StatisticGraph.java

@@ -335,16 +335,16 @@ public class StatisticGraph extends JPanel {
 			switch (set.getProperty()) {
 			case TrackedDataSet.CONSUMPTION:
 				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
-					if (h.getEnergy() < 0 && h.getActive()) {
-						val += Math.abs(h.getEnergyAt()[model.getCurIteration()]) * h.getAmount();
+					if (h.getTotalEnergyAtTimeStep(model.getCurIteration()) < 0 && h.getActive()) {
+						val += Math.abs(h.getTotalEnergyAtTimeStep(model.getCurIteration()));
 					}
 					set.setValAt(val, model.getCurIteration());
 				}
 				break;
 			case TrackedDataSet.PRODUCTION:
 				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
-					if (h.getEnergy() > 0 && h.getActive()) {
-						val += Math.abs(h.getEnergyAt()[model.getCurIteration()]) * h.getAmount();
+					if (h.getTotalEnergyAtTimeStep(model.getCurIteration()) > 0 && h.getActive()) {
+						val += Math.abs(h.getTotalEnergyAtTimeStep(model.getCurIteration()));
 					}
 					set.setValAt(val, model.getCurIteration());
 				}

+ 14 - 4
src/ui/view/UpperNodeCanvas.java

@@ -676,10 +676,20 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 						obj = ed.getB();
 					}
 					if (obj != null) {
-						if (ed.getFlow() == 0)
-							g2.setColor(Color.RED);
-						else
-							g2.setColor(Color.BLUE);
+						if (ed.getConnected() == 0) {
+							if (ed.getState()) {
+								g2.setColor(Color.GREEN);
+								if (ed.getCapacity() != -1) {
+									g2.setStroke(new BasicStroke(Math.min(((ed.getFlow() / ed.getCapacity() * 3) + 1), 4)));
+								}
+							} else {
+								g2.setColor(Color.RED);
+								g2.setStroke(new BasicStroke(2));
+							}
+						} else {
+							g2.setColor(Color.DARK_GRAY);
+							g2.setStroke(new BasicStroke(2));
+						}
 						g2.drawLine(obj.getPosition().x, obj.getPosition().y, (borderPos >> 1),
 								(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + 25);
 						if (showedInformation[0]) {