Przeglądaj źródła

Main grid Properties werden mit NULL object übergeben

dominik.rieder 8 lat temu
rodzic
commit
9a98c3d8c5
1 zmienionych plików z 21 dodań i 12 usunięć
  1. 21 12
      src/ui/view/splitPane.java

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

@@ -68,6 +68,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 	public static final int PART_SUPPLIED_INT = 8;
 	public static final int GRID_PROD_INT = 9;
 	public static final int GRID_CONS_INT = 10;
+	public static final int NR_SUBNETS_INT = 11;
 	
 	// Property Strings
 	public static final String TOT_PROD_HOLON = "total Holon Production";
@@ -75,6 +76,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 	public static final String SUPPLIED_OBJ = "Percentage of supplied Objects";
 	public static final String NOT_SUPPLIED_OBJ = "Percentage of not supplied Objects";
 	public static final String PART_SUPPLIED_OBJ = "Percentage of partially supplied Objects";
+	public static final String NR_SUBNETS = "number of Subnets";
 	
 	public static final String TOT_PROD_OBJ = "total Production";
 	public static final String TOT_CONS_OBJ = "total Consumption";
@@ -95,7 +97,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 	private JTree objectTree;
 	private DefaultTreeModel treeModel;
 	private DefaultMutableTreeNode objectsNode;
-	private DefaultMutableTreeNode wholeHolon;
+	private DefaultMutableTreeNode mainGrid;
 	private DefaultMutableTreeNode switchesNode;
 	private DefaultMutableTreeNode gridsNode;
 	
@@ -125,6 +127,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 		holonHashtable.put(SUPPLIED_OBJ, new PropertyDataSet());
 		holonHashtable.put(NOT_SUPPLIED_OBJ, new PropertyDataSet());
 		holonHashtable.put(PART_SUPPLIED_OBJ, new PropertyDataSet());
+		holonHashtable.put(NR_SUBNETS, new PropertyDataSet());
 		
 		//propValTable associates the Strings to the numbers
 		propValTable = new Hashtable<String, Integer>();
@@ -139,6 +142,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 		propValTable.put(PART_SUPPLIED_OBJ, PART_SUPPLIED_INT);
 		propValTable.put(TOT_PROD_GRID, GRID_PROD_INT);
 		propValTable.put(TOT_CONS_GRID, GRID_CONS_INT);
+		propValTable.put(NR_SUBNETS, NR_SUBNETS_INT);
 
 		JScrollPane dataPane = new JScrollPane();
 		setLeftComponent(dataPane);
@@ -438,7 +442,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 				if (selectedNode == null) {
 					return;
 				} else {
-					if (selectedNode.getLevel() == 3) {
+					if (selectedNode.getLevel() == 3 || (selectedNode.getLevel() == 2 && selectedNode.getParent().toString().equals("Main Grid") )) {
 						StatisticGraphPanel tmp = null;
 						if (graphNrTxtField.getText().length() > 0) {
 							if (!graphHashtable.containsKey(graphNrTxtField.getText())
@@ -457,8 +461,12 @@ public class splitPane extends JSplitPane implements GraphListener {
 							}
 							String object = ((DefaultMutableTreeNode) selectedNode.getParent()).toString();
 							String property = selectedNode.toString();
+							AbstractCpsObject absCps = null;
+							if(!object.equals("Main Grid")){
 							GraphDataSet dataSet = objectHashtable.get(object);
-							TrackedDataSet tds = new TrackedDataSet(dataSet.getObject(), propValTable.get(property),
+							absCps = dataSet.getObject();
+							}
+							TrackedDataSet tds = new TrackedDataSet(absCps, propValTable.get(property),
 									currentProperty.getColor());
 							graphHashtable.get(graphNrTxtField.getText()).addObjec(tds);
 						}
@@ -556,12 +564,13 @@ public class splitPane extends JSplitPane implements GraphListener {
 		objectTree = new JTree();
 		treeModel = (DefaultTreeModel) objectTree.getModel();
 		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Statistics");
-		wholeHolon = new DefaultMutableTreeNode("whole Holon");
-		wholeHolon.add(new DefaultMutableTreeNode(TOT_PROD_HOLON));
-		wholeHolon.add(new DefaultMutableTreeNode(TOT_CONS_HOLON));
-		wholeHolon.add(new DefaultMutableTreeNode(SUPPLIED_OBJ));
-		wholeHolon.add(new DefaultMutableTreeNode(NOT_SUPPLIED_OBJ));
-		wholeHolon.add(new DefaultMutableTreeNode(PART_SUPPLIED_OBJ));
+		mainGrid = new DefaultMutableTreeNode("Main Grid");
+		mainGrid.add(new DefaultMutableTreeNode(TOT_PROD_HOLON));
+		mainGrid.add(new DefaultMutableTreeNode(TOT_CONS_HOLON));
+		mainGrid.add(new DefaultMutableTreeNode(SUPPLIED_OBJ));
+		mainGrid.add(new DefaultMutableTreeNode(NOT_SUPPLIED_OBJ));
+		mainGrid.add(new DefaultMutableTreeNode(PART_SUPPLIED_OBJ));
+		mainGrid.add(new DefaultMutableTreeNode(NR_SUBNETS));
 
 		objectsNode = new DefaultMutableTreeNode("Objects");
 		objectsNode.add(new DefaultMutableTreeNode("empty"));
@@ -569,11 +578,11 @@ public class splitPane extends JSplitPane implements GraphListener {
 		switchesNode = new DefaultMutableTreeNode("Switches");
 		switchesNode.add(new DefaultMutableTreeNode("empty"));
 		
-		gridsNode = new DefaultMutableTreeNode("Grids");
+		gridsNode = new DefaultMutableTreeNode("Groups");
 		gridsNode.add(new DefaultMutableTreeNode("empty"));
 		
 		treeModel.setRoot(root);
-		root.add(wholeHolon);
+		root.add(mainGrid);
 		root.add(objectsNode);
 		root.add(switchesNode);
 		root.add(gridsNode);
@@ -619,7 +628,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 						showObjectlbl.setText(selectedNode.toString());
 					}
 					if (selectedNode.getLevel() == 2) {
-						if (((DefaultMutableTreeNode) selectedNode.getParent()).toString().equals("whole Holon")) {
+						if (((DefaultMutableTreeNode) selectedNode.getParent()).toString().equals("Main Grid")) {
 							enableFields();
 							String object = selectedNode.getParent().toString();
 							String property = selectedNode.toString();