Kevin Trometer vor 8 Jahren
Ursprung
Commit
1404804f84
2 geänderte Dateien mit 24 neuen und 8 gelöschten Zeilen
  1. 3 6
      src/ui/view/StatisticGraph.java
  2. 21 2
      src/ui/view/StatisticGraphPanel.java

+ 3 - 6
src/ui/view/StatisticGraph.java

@@ -57,8 +57,6 @@ public class StatisticGraph extends JPanel {
 	public StatisticGraph(final Model model, Control control) {
 		this.controller = control;
 		this.model = model;
-
-		
 	
 		this.setBackground(Color.WHITE);
 	}
@@ -274,9 +272,8 @@ public class StatisticGraph extends JPanel {
 	private void createPathFloats(TrackedDataSet set) {
 		boolean init = true;
 		path.moveTo(0, 0);
-		for (int i = 0; i < model.getCurIteration() - 1; i++) {
-			controller.addTextToConsole(path.getCurrentPoint().getX() + ", " + path.getCurrentPoint().getY());
-			if (init /* && set.getValues()[i] != -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;
 			}
@@ -299,7 +296,7 @@ public class StatisticGraph extends JPanel {
 	 */
 	private void createPathBooleans(TrackedDataSet set) {
 		boolean init = true;
-		for (int i = 0; i < model.getCurIteration() - 1; i++) {
+		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)));

+ 21 - 2
src/ui/view/StatisticGraphPanel.java

@@ -9,6 +9,8 @@ import ui.model.Model;
 import javax.swing.JLabel;
 import javax.swing.JButton;
 import javax.swing.SwingConstants;
+import javax.swing.Timer;
+
 import java.awt.BorderLayout;
 import javax.swing.border.LineBorder;
 
@@ -75,7 +77,7 @@ public class StatisticGraphPanel extends JPanel {
 				JPanel parent = (JPanel) that.getParent();
 				for (int i = 0; i < parent.getComponentCount(); i++) {
 					if (parent.getComponent(i).equals(that)) {
-						parent.remove(parent.getComponent(i+1));
+						parent.remove(parent.getComponent(i + 1));
 						break;
 					}
 				}
@@ -89,7 +91,15 @@ public class StatisticGraphPanel extends JPanel {
 		this.add(topPanel, BorderLayout.NORTH);
 		this.add(maximumLabel, BorderLayout.WEST);
 		this.add(Legendpanel, BorderLayout.SOUTH);
-		
+
+		Timer t = new Timer(200, new ActionListener() {
+
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				that.repaint();
+			}
+		});
+		t.start();
 
 	}
 
@@ -117,4 +127,13 @@ public class StatisticGraphPanel extends JPanel {
 	public void setMaximumLabel(int max) {
 		maximumLabel.setText(Integer.toString(max));
 	}
+
+	/**
+	 * Get the name of the Graph.
+	 * 
+	 * @return the name of the Graph
+	 */
+	public String getGraphName() {
+		return this.graphName;
+	}
 }