|
@@ -83,60 +83,54 @@ public class StatisticGraph extends JPanel {
|
|
g2.drawLine(0, i, this.getWidth(), i);
|
|
g2.drawLine(0, i, this.getWidth(), i);
|
|
}
|
|
}
|
|
|
|
|
|
- isSimRunning = true;
|
|
|
|
-
|
|
|
|
- // if sim is on
|
|
|
|
- if (isSimRunning) {
|
|
|
|
- g2.setStroke(new BasicStroke(3));
|
|
|
|
-
|
|
|
|
- // Calculate the Maximum
|
|
|
|
- // calcMaximum();
|
|
|
|
-
|
|
|
|
- // Calculate values for each set and add them
|
|
|
|
- // addValues();
|
|
|
|
-
|
|
|
|
- // Create Paths and draw them
|
|
|
|
- for (TrackedDataSet set : dataSets) {
|
|
|
|
- path.reset();
|
|
|
|
- switch (set.getProperty()) {
|
|
|
|
- case TrackedDataSet.CONSUMPTION:
|
|
|
|
- case TrackedDataSet.PRODUCTION:
|
|
|
|
- case TrackedDataSet.ACTIVATED_ELEMENTS:
|
|
|
|
- case TrackedDataSet.TOTAL_PRODUCTION:
|
|
|
|
- case TrackedDataSet.TOTAL_CONSUMPTION:
|
|
|
|
- case TrackedDataSet.AMOUNT_HOLONS:
|
|
|
|
- case TrackedDataSet.GROUP_CONSUMPTION:
|
|
|
|
- case TrackedDataSet.GROUP_PRODUCTION:
|
|
|
|
- case TrackedDataSet.AMOUNT_CLOSED_SWITCHES:
|
|
|
|
- case TrackedDataSet.AVG_AMOUNT_OBJECTS_IN_HOLONS:
|
|
|
|
- case TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS:
|
|
|
|
- case TrackedDataSet.AVG_AMOUNT_PRODUCERS_IN_HOLONS:
|
|
|
|
- case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
|
|
|
|
- case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
|
|
|
|
- case TrackedDataSet.AMOUNT_BROKEN_EDGES:
|
|
|
|
- case TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS:
|
|
|
|
- case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
|
|
|
|
- case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
|
|
|
|
- case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
|
|
|
|
- createPathFloats(set);
|
|
|
|
- break;
|
|
|
|
- case TrackedDataSet.ON_OFF:
|
|
|
|
- createPathBooleans(set);
|
|
|
|
- break;
|
|
|
|
- case TrackedDataSet.PERCENT_SUPPLIED:
|
|
|
|
- case TrackedDataSet.PERCENT_NOT_SUPPLIED:
|
|
|
|
- case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
|
|
|
|
- case TrackedDataSet.RATIO_PRODUCERS_CONSUMERS:
|
|
|
|
- createPathPercent(set);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- g2.setColor(set.getColor());
|
|
|
|
- g2.draw(path);
|
|
|
|
|
|
+ g2.setStroke(new BasicStroke(3));
|
|
|
|
+
|
|
|
|
+ // Calculate the Maximum
|
|
|
|
+ // calcMaximum();
|
|
|
|
+
|
|
|
|
+ // Calculate values for each set and add them
|
|
|
|
+ // addValues();
|
|
|
|
+
|
|
|
|
+ // Create Paths and draw them
|
|
|
|
+ for (TrackedDataSet set : dataSets) {
|
|
|
|
+ path.reset();
|
|
|
|
+ switch (set.getProperty()) {
|
|
|
|
+ case TrackedDataSet.CONSUMPTION:
|
|
|
|
+ case TrackedDataSet.PRODUCTION:
|
|
|
|
+ case TrackedDataSet.ACTIVATED_ELEMENTS:
|
|
|
|
+ case TrackedDataSet.TOTAL_PRODUCTION:
|
|
|
|
+ case TrackedDataSet.TOTAL_CONSUMPTION:
|
|
|
|
+ case TrackedDataSet.AMOUNT_HOLONS:
|
|
|
|
+ case TrackedDataSet.GROUP_CONSUMPTION:
|
|
|
|
+ case TrackedDataSet.GROUP_PRODUCTION:
|
|
|
|
+ case TrackedDataSet.AMOUNT_CLOSED_SWITCHES:
|
|
|
|
+ case TrackedDataSet.AVG_AMOUNT_OBJECTS_IN_HOLONS:
|
|
|
|
+ case TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS:
|
|
|
|
+ case TrackedDataSet.AVG_AMOUNT_PRODUCERS_IN_HOLONS:
|
|
|
|
+ case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
|
|
|
|
+ case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
|
|
|
|
+ case TrackedDataSet.AMOUNT_BROKEN_EDGES:
|
|
|
|
+ case TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS:
|
|
|
|
+ case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
|
|
|
|
+ case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
|
|
|
|
+ case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
|
|
|
|
+ createPathFloats(set);
|
|
|
|
+ break;
|
|
|
|
+ case TrackedDataSet.ON_OFF:
|
|
|
|
+ createPathBooleans(set);
|
|
|
|
+ break;
|
|
|
|
+ case TrackedDataSet.PERCENT_SUPPLIED:
|
|
|
|
+ case TrackedDataSet.PERCENT_NOT_SUPPLIED:
|
|
|
|
+ case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
|
|
|
|
+ case TrackedDataSet.RATIO_PRODUCERS_CONSUMERS:
|
|
|
|
+ createPathPercent(set);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
+ g2.setColor(set.getColor());
|
|
|
|
+ g2.draw(path);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -537,17 +531,21 @@ public class StatisticGraph extends JPanel {
|
|
* @param set
|
|
* @param set
|
|
*/
|
|
*/
|
|
private void createPathFloats(TrackedDataSet set) {
|
|
private void createPathFloats(TrackedDataSet set) {
|
|
|
|
+ int range = model.getCurIteration(); //to which iteration
|
|
|
|
+ if (!model.getIsSimRunning()) {
|
|
|
|
+ range = model.getIterations()-1;
|
|
|
|
+ }
|
|
if (set.getValues()[0] != -1) {
|
|
if (set.getValues()[0] != -1) {
|
|
path.moveTo(0, convertToCanvasY(set.getValues()[0]));
|
|
path.moveTo(0, convertToCanvasY(set.getValues()[0]));
|
|
} else {
|
|
} else {
|
|
path.moveTo(1 * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1]));
|
|
path.moveTo(1 * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1]));
|
|
}
|
|
}
|
|
- for (int i = 0; i < model.getCurIteration(); i++) {
|
|
|
|
|
|
+ for (int i = 0; i < range; i++) {
|
|
if (set.getValues()[i + 1] != -1) {
|
|
if (set.getValues()[i + 1] != -1) {
|
|
path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
|
|
path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
|
|
convertToCanvasY(set.getValues()[i + 1]));
|
|
convertToCanvasY(set.getValues()[i + 1]));
|
|
} else {
|
|
} else {
|
|
- if (i + 2 < model.getCurIteration()) {
|
|
|
|
|
|
+ if (i + 2 < range) {
|
|
path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
|
|
path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
|
|
convertToCanvasY(set.getValues()[i + 2]));
|
|
convertToCanvasY(set.getValues()[i + 2]));
|
|
}
|
|
}
|
|
@@ -714,8 +712,22 @@ public class StatisticGraph extends JPanel {
|
|
return stateObjectss / count;
|
|
return stateObjectss / count;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Return all TrackedDataSets
|
|
|
|
+ *
|
|
|
|
+ * @return ArrayList of TrackedDataSet
|
|
|
|
+ */
|
|
public ArrayList<TrackedDataSet> getDataSets() {
|
|
public ArrayList<TrackedDataSet> getDataSets() {
|
|
return dataSets;
|
|
return dataSets;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Reset the Graph. Delete all calculated values.
|
|
|
|
+ */
|
|
|
|
+ public void resetGraph() {
|
|
|
|
+ for (TrackedDataSet s : dataSets) {
|
|
|
|
+ s.resetValues();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|