Browse Source

small progress with graphs

dominik.rieder 7 years ago
parent
commit
b64e8d3b8d
1 changed files with 33 additions and 12 deletions
  1. 33 12
      src/ui/view/splitPane.java

+ 33 - 12
src/ui/view/splitPane.java

@@ -80,6 +80,8 @@ public class splitPane extends JSplitPane implements GraphListener {
 	private Hashtable<String, StatisticGraphPanel> graphHashtable;
 	private Hashtable<String, Integer> propValTable;
 	private JPanel colorPanel;
+	
+	//contains information about a selected property
 	private PropertyDataSet currentProperty = new PropertyDataSet();
 	private JComboBox colorComboBox;
 	private Control controller;
@@ -95,7 +97,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 		propValTable = new Hashtable<String, Integer>();
 		propValTable.put("total Production", PRODUCTION);
 		propValTable.put("total Consumption", CONSUMPTION);
-		propValTable.put("number of activated Elements", ACTIVATED_ELEMENTS);
+		propValTable.put("activated Elements", ACTIVATED_ELEMENTS);
 
 		JScrollPane dataPane = new JScrollPane();
 		setLeftComponent(dataPane);
@@ -103,6 +105,10 @@ public class splitPane extends JSplitPane implements GraphListener {
 		dataPane.setViewportView(panel);
 
 		JScrollPane treeScrollPane = new JScrollPane();
+		
+		
+		//================= LABLES ON THE LEFT SIDE =================//
+		
 		JLabel lblObject = new JLabel("Object(s):");
 
 		showObjectlbl = new JLabel("...");
@@ -114,7 +120,12 @@ public class splitPane extends JSplitPane implements GraphListener {
 		JLabel lblGraph = new JLabel("Graph:");
 
 		JLabel lblColor = new JLabel("Color:");
-
+		
+		//================= LABLES END ===============================//
+		
+		
+		//================= COLOR COMBOBOX ===========================//
+		
 		colorComboBox = new JComboBox();
 		colorComboBox.addItem("");
 		colorComboBox.addItem("Red");
@@ -183,6 +194,8 @@ public class splitPane extends JSplitPane implements GraphListener {
 			}
 
 		});
+		
+		// ==================== COLORBOX END ==========================//
 
 		// ====================GRAPH NR TEXTFIELD======================//
 		graphNrTxtField = new JTextField();
@@ -415,7 +428,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 		colorPanel.setBackground(Color.WHITE);
 		
 		
-		//======================================== LAYOUT FOR COMPONENTS ON THE LEFT SIDE ============================
+		//================== LAYOUT FOR COMPONENTS ON THE LEFT SIDE ==================//
 		
 		GroupLayout gl_panel = new GroupLayout(panel);
 		gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING)
@@ -489,10 +502,10 @@ public class splitPane extends JSplitPane implements GraphListener {
 								.addPreferredGap(ComponentPlacement.RELATED).addComponent(btnAdd)
 								.addContainerGap(35, Short.MAX_VALUE)));
 		
-		//======================================= LAYOUT END =======================================
+		//======================== LAYOUT END ================================//
 		
 		
-		//======================================= TREE STRUCTURE====================================
+		//======================== TREE STRUCTURE=============================//
 		
 		objectTree = new JTree();
 		treeModel = (DefaultTreeModel) objectTree.getModel();
@@ -589,7 +602,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 
 		});
 		
-		//=============================== TREE STRUCTURE END ====================================
+		//========================= TREE STRUCTURE END ============================//
 		
 		
 		panel.setLayout(gl_panel);
@@ -604,7 +617,11 @@ public class splitPane extends JSplitPane implements GraphListener {
 		graphScrollPane.setViewportView(graphPanel);
 		repaintTree();
 	}
+	
+	//=============================== END CONSTRUCTOR ==============================//
 
+	
+	//=============================== METHODS ======================================//
 	@Override
 	public void repaintTree() {
 		treeModel.reload();
@@ -620,24 +637,23 @@ public class splitPane extends JSplitPane implements GraphListener {
 			for (AbstractCpsObject abs : hlList) {
 				String name = abs.getName() + " " + abs.getID();
 				DefaultMutableTreeNode tmp = new DefaultMutableTreeNode(name);
+				Hashtable<String, PropertyDataSet> tmpHash = new Hashtable<String, PropertyDataSet>();
 
 				//HolonObjects
 				if(abs instanceof HolonObject){
-					Hashtable<String, PropertyDataSet> tmpHash = new Hashtable<String, PropertyDataSet>();
 					tmp.add(new DefaultMutableTreeNode("total Production"));
 					tmp.add(new DefaultMutableTreeNode("total Consumption"));
-					tmp.add(new DefaultMutableTreeNode("number of activated Elements"));
+					tmp.add(new DefaultMutableTreeNode("activated Elements"));
 					tmpHash.put("total Production", new PropertyDataSet());
 					tmpHash.put("total Consumption", new PropertyDataSet());
-					tmpHash.put("number of activated Elements", new PropertyDataSet());
-					GraphDataSet gS = new GraphDataSet(abs, tmpHash);
-					objectHashtable.put(name, gS);
+					tmpHash.put("activated Elements", new PropertyDataSet());
 					objectsNode.add(tmp);
 				}
 				
 				//HolonSwitches
 				if(abs instanceof HolonSwitch){
 					tmp.add(new DefaultMutableTreeNode("activated"));
+					tmpHash.put("activated", new PropertyDataSet());
 					switchesNode.add(tmp);
 				}
 				
@@ -645,15 +661,20 @@ public class splitPane extends JSplitPane implements GraphListener {
 				if(abs instanceof CpsUpperNode){
 					tmp.add(new DefaultMutableTreeNode("total Production"));
 					tmp.add(new DefaultMutableTreeNode("total Consumption"));
+					tmpHash.put("total Production", new PropertyDataSet());
+					tmpHash.put("total Consumption", new PropertyDataSet());
 					gridsNode.add(tmp);
 				}
+				
+				GraphDataSet gS = new GraphDataSet(abs, tmpHash);
+				objectHashtable.put(name, gS);
 			}
 		}
 		if(objectsNode.getChildCount() == 0){
 			objectsNode.add(new DefaultMutableTreeNode("empty"));
 		}
 		if(switchesNode.getChildCount() == 0){
-			objectsNode.add(new DefaultMutableTreeNode("empty"));
+			switchesNode.add(new DefaultMutableTreeNode("empty"));
 		}
 		if(gridsNode.getChildCount() == 0){
 			gridsNode.add(new DefaultMutableTreeNode("empty"));