Quellcode durchsuchen

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git

Kevin Trometer vor 8 Jahren
Ursprung
Commit
8098204e9c
2 geänderte Dateien mit 23 neuen und 16 gelöschten Zeilen
  1. 7 2
      src/ui/view/StatisticGraphPanel.java
  2. 16 14
      src/ui/view/splitPane.java

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

@@ -16,6 +16,7 @@ import java.awt.BorderLayout;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.Hashtable;
 
 public class StatisticGraphPanel extends JPanel {
 
@@ -35,6 +36,8 @@ public class StatisticGraphPanel extends JPanel {
 	// Variables
 	String graphName;
 	private final JPanel Legendpanel = new JPanel();
+	private JPanel that;
+	private Hashtable<String, StatisticGraphPanel> graphHashtable;
 
 	/**
 	 * Constructor.
@@ -44,12 +47,13 @@ public class StatisticGraphPanel extends JPanel {
 	 * @param cont
 	 *            the Controller
 	 */
-	public StatisticGraphPanel(Model mod, Control cont, String name) {
+	public StatisticGraphPanel(Model mod, Control cont, String name, Hashtable<String, StatisticGraphPanel> gHt) {
 		super();
 		this.model = mod;
 		this.controller = cont;
 		this.sGraph = new StatisticGraph(mod, cont);
 		this.graphName = name;
+		this.graphHashtable = gHt;
 		setLayout(new BorderLayout(0, 0));
 
 		// ******************** Component Propertys ***************//
@@ -68,7 +72,7 @@ public class StatisticGraphPanel extends JPanel {
 		maximumLabel.setMinimumSize(new Dimension(30, 10));
 		// ******************** Component Listener ****************//
 
-		JPanel that = this;
+		that = this;
 		closeButton.addActionListener(new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
@@ -79,6 +83,7 @@ public class StatisticGraphPanel extends JPanel {
 						break;
 					}
 				}
+				graphHashtable.remove(graphName);
 				parent.remove(that);
 				parent.updateUI();
 			}

+ 16 - 14
src/ui/view/splitPane.java

@@ -61,6 +61,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 	private DefaultMutableTreeNode objectsNode;
 	private DefaultMutableTreeNode wholeHolon;
 	private Hashtable<String, GraphDataSet> objectHashtable;
+	private Hashtable<String, StatisticGraphPanel> graphHashtable;
 	private JPanel colorPanel;
 	private PropertyDataSet currentProperty = new PropertyDataSet();
 	private JComboBox colorComboBox;
@@ -70,10 +71,10 @@ public class splitPane extends JSplitPane implements GraphListener {
 	JLabel showObjectlbl;
 	JLabel showPropertylbl;
 	public splitPane(Control cont) {
-		//this.rightComponent
 		this.controller = cont;
 		objectHashtable = new Hashtable<String, GraphDataSet>();
-
+		graphHashtable = new Hashtable<String, StatisticGraphPanel>();
+		
 		JScrollPane dataPane = new JScrollPane(); 
 		setLeftComponent(dataPane);
 		JPanel panel = new JPanel();
@@ -342,25 +343,26 @@ public class splitPane extends JSplitPane implements GraphListener {
 		JButton btnAdd = new JButton("Add");
 		btnAdd.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
-				/*
 				 DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)objectTree.getLastSelectedPathComponent();
 				 if(selectedNode == null){
 					 return;
 				 }else{
 					 if(selectedNode.getLevel() == 3){
-
+						 if(!graphHashtable.containsKey(graphNrTxtField.getText()) && graphNrTxtField.getText().length() > 0){
+							StatisticGraphPanel tmp = new StatisticGraphPanel(controller.getModel(), controller, graphNrTxtField.getText(), 
+									graphHashtable);
+						 	tmp.setPreferredSize(new Dimension(280,150));
+						 	tmp.setMaximumSize(new Dimension(1000,150));
+						 	tmp.setMinimumSize(new Dimension(100,45));
+						 	tmp.setBorder(new LineBorder(new Color(0, 0, 0), 1));
+						 	graphPanel.add(tmp);
+						 	graphPanel.add(Box.createRigidArea(new Dimension(50,50)));
+						 	graphPanel.revalidate();
+						 	graphPanel.updateUI();
+						 	graphHashtable.put(graphNrTxtField.getText(), tmp);
+						 }
 					 }
 				 }
-				 */
-				 StatisticGraphPanel tmp = new StatisticGraphPanel(controller.getModel(), controller, graphNrTxtField.getText());
-				 tmp.setPreferredSize(new Dimension(280,120));
-				 tmp.setMaximumSize(new Dimension(1000,120));
-				 tmp.setMinimumSize(new Dimension(100,45));
-				 tmp.setBorder(new LineBorder(new Color(0, 0, 0), 1));
-				 graphPanel.add(tmp);
-				 graphPanel.add(Box.createRigidArea(new Dimension(50,50)));
-				 graphPanel.revalidate();
-				 graphPanel.updateUI();
 			}
 		});