瀏覽代碼

verzerrte graphen hinzufügen

dominik.rieder 8 年之前
父節點
當前提交
a8427f94e6
共有 2 個文件被更改,包括 9 次插入1 次删除
  1. 2 0
      src/ui/view/StatisticGraph.java
  2. 7 1
      src/ui/view/splitPane.java

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

@@ -83,6 +83,7 @@ public class StatisticGraph extends JPanel {
 			g2.drawLine(0, i, this.getWidth(), i);
 		}
 
+		if(model != null){
 		isSimRunning = model.getIsSimulation();
 
 		// if sim is on
@@ -114,6 +115,7 @@ public class StatisticGraph extends JPanel {
 				g2.draw(path);
 			}
 		}
+		}
 	}
 
 	/**

+ 7 - 1
src/ui/view/splitPane.java

@@ -45,6 +45,7 @@ import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import javax.swing.JMenuItem;
 import javax.swing.BoxLayout;
+import java.awt.FlowLayout;
 
 public class splitPane extends JSplitPane implements GraphListener {
 	private JTextField graphNrTxtField;
@@ -338,7 +339,9 @@ public class splitPane extends JSplitPane implements GraphListener {
 		JButton btnAdd = new JButton("Add");
 		btnAdd.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
-				graphPanel.add(new JPanel());
+				StatisticGraph tmp = new StatisticGraph(controller.getModel(), controller);
+				graphPanel.add(tmp);
+				graphPanel.revalidate();
 				graphPanel.updateUI();
 			}
 		});
@@ -515,6 +518,9 @@ public class splitPane extends JSplitPane implements GraphListener {
 		graphPanel = new JPanel();
 		graphScrollPane.setViewportView(graphPanel);
 		graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));
+		
+		JPanel panel_1 = new JPanel();
+		graphPanel.add(panel_1);
 		repaintGraph();
 	}
 	@Override