Browse Source

#20 Plotting does not work if the plotting view is not selected - fixed

Kevin Trometer 7 năm trước cách đây
mục cha
commit
e2a96a0d26

+ 2 - 1
src/ui/view/GUI.java

@@ -1842,9 +1842,10 @@ public class GUI<E> implements CategoryListener {
 				int i = model.getCurIteration();
 				controller.runAlgorithm(model, controller);
 				controller.calculateStateForTimeStep(i);
-				contentPane.updateUI();
 				unitGraph.repaint();
 				statSplitPane.repaintGraphs();
+				controller.addTextToConsole("test");
+				contentPane.updateUI();
 			}
 		});
 		splitPane1.setMinimumSize(new Dimension(0, 25));

+ 2 - 0
src/ui/view/SplitPane.java

@@ -812,6 +812,8 @@ public class SplitPane extends JSplitPane implements GraphListener {
 
 	public void repaintGraphs() {
 		for (StatisticGraphPanel sg : graphHashtable.values()) {
+			sg.calcMaximum();
+			sg.addValues();
 			sg.repaint();
 		}
 	}

+ 2 - 0
src/ui/view/StatPanel2.java

@@ -771,6 +771,8 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 
 	public void repaintGraphs() {
 		for (StatisticGraphPanel sg : graphHashtable.values()) {
+			sg.calcMaximum();
+			sg.addValues();
 			sg.repaint();
 		}
 	}

+ 15 - 9
src/ui/view/StatisticGraph.java

@@ -90,10 +90,10 @@ public class StatisticGraph extends JPanel {
 			g2.setStroke(new BasicStroke(3));
 
 			// Calculate the Maximum
-			calcMaximum();
+			// calcMaximum();
 
 			// Calculate values for each set and add them
-			addValues();
+			// addValues();
 
 			// Create Paths and draw them
 			for (TrackedDataSet set : dataSets) {
@@ -329,7 +329,7 @@ public class StatisticGraph extends JPanel {
 	/**
 	 * Add the Current Values to each set
 	 */
-	private void addValues() {
+	public void addValues() {
 		for (TrackedDataSet set : dataSets) {
 			float val = 0;
 			switch (set.getProperty()) {
@@ -547,8 +547,10 @@ public class StatisticGraph extends JPanel {
 				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 (i + 2 < model.getCurIteration()) {
+					path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
+							convertToCanvasY(set.getValues()[i + 2]));
+				}
 			}
 		}
 	}
@@ -571,8 +573,10 @@ public class StatisticGraph extends JPanel {
 				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)));
+				if (i + 2 < model.getCurIteration()) {
+					path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
+							convertToCanvasY((float) (set.getValues()[i + 2] * (maximum / 3 * 2)) + (maximum / 6)));
+				}
 			}
 		}
 	}
@@ -593,8 +597,10 @@ public class StatisticGraph extends JPanel {
 				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));
+				if (i + 2 < model.getCurIteration()) {
+					path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
+							convertToCanvasY(set.getValues()[i + 2] * maximum));
+				}
 			}
 
 		}

+ 14 - 0
src/ui/view/StatisticGraphPanel.java

@@ -274,5 +274,19 @@ public class StatisticGraphPanel extends JPanel {
 	public String getGraphName() {
 		return this.graphName;
 	}
+	
+	/**
+	 * Calls the addValue function of the sGraph
+	 */
+	public void addValues(){
+		sGraph.addValues();
+	}
 
+	/**
+	 * Calls the calcMaximum function of the sGraph
+	 */
+	public void calcMaximum(){
+		sGraph.calcMaximum();
+	}
+	
 }