Kaynağa Gözat

statistics are drawn even if you start in the middle

Kevin Trometer 7 yıl önce
ebeveyn
işleme
0ab2a73ee5
2 değiştirilmiş dosya ile 43 ekleme ve 48 silme
  1. 5 4
      src/ui/view/GUI.java
  2. 38 44
      src/ui/view/StatisticGraph.java

+ 5 - 4
src/ui/view/GUI.java

@@ -121,7 +121,7 @@ public class GUI<E> implements CategoryListener {
 	// private final JScrollPane holonSP = new JScrollPane();
 	private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
 	private final JTabbedPane tabbedPane2 = new JTabbedPane(JTabbedPane.TOP);
-	private final JButton splitButton = new JButton("Split View");
+	private final JButton splitButton = new JButton("Split View Test");
 	private JSplitPane tempSplit;
 	private boolean initSplit = true;
 
@@ -779,8 +779,9 @@ public class GUI<E> implements CategoryListener {
 					for (int i = 0; i < tabbedPane.getTabCount(); i++) {
 						tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
 						if (i >= 4) {
-							//tabbedPane2.setTabComponentAt(tabbedPane.getTabCount() - 1,
-								//	new ButtonTabComponent(tabbedPane, tabbedPane2));
+							// tabbedPane2.setTabComponentAt(tabbedPane.getTabCount()
+							// - 1,
+							// new ButtonTabComponent(tabbedPane, tabbedPane2));
 						}
 					}
 					if (tabbedPane.getSelectedComponent() == statScrollPane) {
@@ -2218,7 +2219,7 @@ public class GUI<E> implements CategoryListener {
 				tabbedPane2.setComponentAt(tabbedPane2.getSelectedIndex(), null);
 				tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
 				tabbedPane2.setSelectedComponent(sp);
-				
+
 				// tabbedPane2.setTabComponentAt(tabbedPane2.getTabCount() - 1,
 				// new ButtonTabComponent(tabbedPane, tabbedPane2));
 

+ 38 - 44
src/ui/view/StatisticGraph.java

@@ -488,13 +488,13 @@ public class StatisticGraph extends JPanel {
 				for (SubNet sub : controller.getSimManager().getSubNets()) {
 					val += sub.getSwitches().size();
 				}
-				val /=controller.getSimManager().getSubNets().size();
+				val /= controller.getSimManager().getSubNets().size();
 				set.setValAt(val, model.getCurIteration());
 				break;
 			case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
 				for (SubNet sub : controller.getSimManager().getSubNets()) {
 					for (HolonObject obj : sub.getObjects()) {
-						for (HolonElement ele: obj.getElements()) {
+						for (HolonElement ele : obj.getElements()) {
 							if (ele.getActive()) {
 								val++;
 							}
@@ -507,7 +507,7 @@ public class StatisticGraph extends JPanel {
 			case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
 				for (SubNet sub : controller.getSimManager().getSubNets()) {
 					for (HolonObject obj : sub.getObjects()) {
-						for (HolonElement ele: obj.getElements()) {
+						for (HolonElement ele : obj.getElements()) {
 							if (!ele.getActive()) {
 								val++;
 							}
@@ -537,22 +537,19 @@ public class StatisticGraph extends JPanel {
 	 * @param set
 	 */
 	private void createPathFloats(TrackedDataSet set) {
-		boolean init = true;
-		path.moveTo(0, 0);
+		if (set.getValues()[0] != -1) {
+			path.moveTo(0, convertToCanvasY(set.getValues()[0]));
+		} else {
+			path.moveTo(1 * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1]));
+		}
 		for (int i = 0; i < model.getCurIteration(); i++) {
-			if (init && set.getValues()[i] != -1) {
-				path.moveTo(i * this.getWidth() / model.getIterations() - 1, convertToCanvasY(set.getValues()[i]));
-				init = false;
+			if (set.getValues()[i + 1] != -1) {
+				path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
+						convertToCanvasY(set.getValues()[i + 1]));
+			} else {
+				path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
+						convertToCanvasY(set.getValues()[i + 2]));
 			}
-			if (!init) {
-				if (set.getValues()[i + 1] != -1) {
-					path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
-							convertToCanvasY(set.getValues()[i + 1]));
-				} else {
-					break;
-				}
-			}
-
 		}
 	}
 
@@ -562,20 +559,20 @@ public class StatisticGraph extends JPanel {
 	 * @param set
 	 */
 	private void createPathBooleans(TrackedDataSet set) {
-		boolean init = true;
+		if (set.getValues()[0] != -1) {
+			path.moveTo(0, convertToCanvasY((float) (set.getValues()[0] * (maximum / 3 * 2)) + (maximum / 6)));
+		} else {
+			path.moveTo(1 * this.getWidth() / model.getIterations(),
+					convertToCanvasY((float) (set.getValues()[1] * (maximum / 3 * 2)) + (maximum / 6)));
+		}
 		for (int i = 0; i < model.getCurIteration(); i++) {
-			if (init && set.getValues()[i] != -1) {
-				path.moveTo(i * this.getWidth() / model.getIterations() - 1,
-						convertToCanvasY((float) (set.getValues()[i] * maximum)));
-				init = false;
-			}
-			if (!init) {
-				if (set.getValues()[i + 1] != -1) {
-					path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
-							convertToCanvasY((float) (set.getValues()[i + 1] * maximum)));
-				} else {
-					break;
-				}
+			controller.addTextToConsole(set.getValues()[i] + "");
+			if (set.getValues()[i + 1] != -1) {
+				path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
+						convertToCanvasY((float) (set.getValues()[i + 1] * (maximum / 3 * 2)) + (maximum / 6)));
+			} else {
+				path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
+						convertToCanvasY((float) (set.getValues()[i + 2] * (maximum / 3 * 2)) + (maximum / 6)));
 			}
 		}
 	}
@@ -586,21 +583,18 @@ public class StatisticGraph extends JPanel {
 	 * @param set
 	 */
 	private void createPathPercent(TrackedDataSet set) {
-		boolean init = true;
-		path.moveTo(0, 0);
+		if (set.getValues()[0] != -1) {
+			path.moveTo(0, convertToCanvasY(set.getValues()[0] * maximum));
+		} else {
+			path.moveTo(1 * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1] * maximum));
+		}
 		for (int i = 0; i < model.getCurIteration(); i++) {
-			if (init && set.getValues()[i] != -1) {
-				path.moveTo(i * this.getWidth() / model.getIterations() - 1,
-						convertToCanvasY(set.getValues()[i] * maximum));
-				init = false;
-			}
-			if (!init) {
-				if (set.getValues()[i + 1] != -1) {
-					path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
-							convertToCanvasY(set.getValues()[i + 1] * maximum));
-				} else {
-					break;
-				}
+			if (set.getValues()[i + 1] != -1) {
+				path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
+						convertToCanvasY(set.getValues()[i + 1] * maximum));
+			} else {
+				path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
+						convertToCanvasY(set.getValues()[i + 2] * maximum));
 			}
 
 		}