فهرست منبع

Resize geschichten funktionieren endlich

dominik.rieder 7 سال پیش
والد
کامیت
10fffed1f4

+ 2 - 2
src/classes/HolonElement.java

@@ -67,7 +67,7 @@ public class HolonElement {
 		setActive(true);
 		setSign(energy);
 		setEnergyAt(energy);
-		setGraphPoints(new LinkedList<>());
+		setGraphPoints(new LinkedList<Point>());
 		setId(IdCounterElem.nextId());
 	}
 
@@ -87,7 +87,7 @@ public class HolonElement {
 		for (int i = 0; i < energyAt.length; i++) {
 			energyAt[i] = element.getEnergyAt()[i];
 		}
-		setGraphPoints(new LinkedList<>());
+		setGraphPoints(new LinkedList<Point>());
 		for (Point p : element.getGraphPoints()) {
 			this.graphPoints.add(new Point((int) p.getX(), (int) p.getY()));
 		}

+ 2 - 2
src/classes/HolonSwitch.java

@@ -62,7 +62,7 @@ public class HolonSwitch extends AbstractCpsObject {
 		setAutoState(true);
 		setActiveAt(true);
 		setManualMode(false);
-		setGraphPoints(new LinkedList<>());
+		setGraphPoints(new LinkedList<Point>());
 	}
 
 	/**
@@ -80,7 +80,7 @@ public class HolonSwitch extends AbstractCpsObject {
 		for (int i = 0; i < activeAt.length; i++) {
 			activeAt[i] = ((HolonSwitch)obj).getActiveAt()[i];
 		}
-		setGraphPoints(new LinkedList<>());
+		setGraphPoints(new LinkedList<Point>());
 		for (Point p :((HolonSwitch)obj).getGraphPoints()) {
 			this.graphPoints.add(new Point((int)p.getX(), (int)p.getY()));
 		}

+ 7 - 7
src/ui/controller/LoadController.java

@@ -388,9 +388,9 @@ public class LoadController {
 	 */
 	private void initObjects(AbstractCpsObject obj) {
 
-		obj.setConnections(new ArrayList<>());
-		obj.setTags(new ArrayList<>());
-		obj.setPseudoTags(new ArrayList<>());
+		obj.setConnections(new ArrayList<CpsEdge>());
+		obj.setTags(new ArrayList<Integer>());
+		obj.setPseudoTags(new ArrayList<Integer>());
 
 		if (obj instanceof HolonObject) {
 			((HolonObject) obj).setElements(new ArrayList<HolonElement>());
@@ -402,7 +402,7 @@ public class LoadController {
 
 		if (obj instanceof HolonSwitch) {
 			((HolonSwitch) obj).setActiveAt(true);
-			((HolonSwitch) obj).setGraphPoints(new LinkedList<>());
+			((HolonSwitch) obj).setGraphPoints(new LinkedList<Point>());
 		}
 
 		if (obj instanceof CpsUpperNode) {
@@ -421,7 +421,7 @@ public class LoadController {
 	private void initElements(HolonElement ele) {
 
 		ele.setEnergyAt(ele.getEnergy());
-		ele.setGraphPoints(new LinkedList<>());
+		ele.setGraphPoints(new LinkedList<Point>());
 	}
 
 	/**
@@ -430,8 +430,8 @@ public class LoadController {
 	 * @param edge
 	 */
 	private void initCpsEdge(CpsEdge edge) {
-		edge.setTags(new ArrayList<>());
-		edge.setPseudoTag(new ArrayList<>());
+		edge.setTags(new ArrayList<Integer>());
+		edge.setPseudoTag(new ArrayList<Integer>());
 		edge.setA(null);
 		edge.setB(null);
 	}

+ 3 - 0
src/ui/view/SplitPane.java

@@ -115,6 +115,9 @@ public class SplitPane extends JSplitPane implements GraphListener {
 	JLabel showPropertylbl;
 
 	public SplitPane(Control cont) {
+		setPreferredSize(new Dimension(0, 0));
+		setMinimumSize(new Dimension(0, 0));
+		setMaximumSize(new Dimension(0, 0));
 		setContinuousLayout(true);
 		this.controller = cont;
 		objectHashtable = new Hashtable<String, GraphDataSet>();

+ 762 - 0
src/ui/view/StatPanel2.java

@@ -0,0 +1,762 @@
+package ui.view;
+
+import javax.swing.JSplitPane;
+import javax.swing.JScrollPane;
+import javax.swing.JPanel;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Random;
+
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+import javax.swing.JLabel;
+import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.MutableTreeNode;
+import javax.swing.tree.TreeNode;
+
+import DataSets.GraphDataSet;
+import DataSets.PropertyDataSet;
+import classes.AbstractCpsObject;
+import classes.CpsUpperNode;
+import classes.HolonObject;
+import classes.HolonSwitch;
+import classes.TrackedDataSet;
+import interfaces.GraphListener;
+import ui.controller.Control;
+
+import javax.swing.JTextField;
+import javax.swing.JComboBox;
+import javax.swing.JButton;
+import javax.swing.JTree;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.LineBorder;
+import javax.swing.JPopupMenu;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JMenuItem;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import java.awt.FlowLayout;
+import java.awt.BorderLayout;
+
+public class StatPanel2 extends JSplitPane implements GraphListener {
+	public static final String MAIN_GRID = "Main Grid";
+	public static final String HOLON = "Holons";
+	
+	// Property Strings
+	public static final String TOT_PROD_HOLON = "total Holon Production";
+	public static final String TOT_CONS_HOLON = "total Holon Consumption";
+	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 = "Nr. of Subnets";
+	public static final String NR_CLOSED_SWITCHES = "Nr. of closed Switches";
+	public static final String AVG_OBJ_IN_HOLONS = "Average amount of Objects in Holons";
+	public static final String AVG_ELEM_IN_HOLONS = "Average amount of Elements in Holons";
+	public static final String AVG_PRODS_IN_HOLONS ="Average amount of Producers in Holons";
+	public static final String AVG_CONS_ENERGY_IN_HOLONS = "Average consumed Energy";
+	public static final String AVG_WASTED_ENERGY_HOLONS = "Average wasted Energy";
+	public static final String NR_BROKEN_EDGES = "Amount of broken Edges";
+	public static final String PROD_CONS_RATIO = "Producer/Consumer Ratio";
+	
+	public static final String TOT_PROD_OBJ = "total Production";
+	public static final String TOT_CONS_OBJ = "total Consumption";
+	public static final String NR_ACTIVE_ELEMENTS = "active Elements";
+	
+	public static final String SW_ACTIVE = "active";
+	
+	public static final String TOT_PROD_GRID = "total Grid Production";
+	public static final String TOT_CONS_GRID = "total Grid Consumption";
+	private DefaultTreeModel treeModel;
+	private DefaultMutableTreeNode objectsNode;
+	private DefaultMutableTreeNode mainGrid;
+	private DefaultMutableTreeNode holonNode;
+	private DefaultMutableTreeNode switchesNode;
+	private DefaultMutableTreeNode groupNode;
+	
+	private Hashtable<String, GraphDataSet> objectHashtable;
+	private Hashtable<String, StatisticGraphPanel> graphHashtable;
+	private Hashtable<String, PropertyDataSet> holonHashtable;
+	private Hashtable<String, Integer> propValTable;
+	
+	//contains information about a selected property
+	private PropertyDataSet currentProperty = new PropertyDataSet();
+	private Control controller;
+	private JPanel graphPanel;
+	
+	//WindowBuilder Components
+	private JTree objectTree;
+	private JTextField graphNrTxtField;
+	private JTextField redField;
+	private JTextField greenField;
+	private JTextField blueField;
+	private JPanel colorPanel;
+	private JComboBox colorComboBox;
+	private JLabel showObjectlbl;
+	private JLabel showPropertylbl;
+	private JButton btnAdd;
+	
+
+	public StatPanel2(Control cont) {
+		setMaximumSize(new Dimension(0, 0));
+		setPreferredSize(new Dimension(0, 0));
+		setMinimumSize(new Dimension(0, 0));
+		this.setDividerLocation(180);
+		setContinuousLayout(true);
+		this.controller = cont;
+		objectHashtable = new Hashtable<String, GraphDataSet>();
+		graphHashtable = new Hashtable<String, StatisticGraphPanel>();
+		
+		holonHashtable = new Hashtable<String, PropertyDataSet>();
+		holonHashtable.put(TOT_PROD_HOLON, new PropertyDataSet());
+		holonHashtable.put(TOT_CONS_HOLON, new PropertyDataSet());
+		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());
+		holonHashtable.put(NR_CLOSED_SWITCHES, new PropertyDataSet());
+		holonHashtable.put(AVG_OBJ_IN_HOLONS, new PropertyDataSet());
+		holonHashtable.put(AVG_ELEM_IN_HOLONS, new PropertyDataSet());
+		holonHashtable.put(AVG_PRODS_IN_HOLONS, new PropertyDataSet());
+		holonHashtable.put(AVG_CONS_ENERGY_IN_HOLONS, new PropertyDataSet());
+		holonHashtable.put(AVG_WASTED_ENERGY_HOLONS, new PropertyDataSet());
+		holonHashtable.put(NR_BROKEN_EDGES, new PropertyDataSet());
+		holonHashtable.put(PROD_CONS_RATIO, new PropertyDataSet());
+		
+		//propValTable associates the Strings to the numbers
+		propValTable = new Hashtable<String, Integer>();
+		propValTable.put(TOT_PROD_OBJ, TrackedDataSet.PRODUCTION);
+		propValTable.put(TOT_CONS_OBJ, TrackedDataSet.CONSUMPTION);
+		propValTable.put(NR_ACTIVE_ELEMENTS, TrackedDataSet.ACTIVATED_ELEMENTS);
+		propValTable.put(SW_ACTIVE, TrackedDataSet.ON_OFF);
+		propValTable.put(TOT_PROD_HOLON, TrackedDataSet.TOTAL_PRODUCTION);
+		propValTable.put(TOT_CONS_HOLON, TrackedDataSet.TOTAL_CONSUMPTION);
+		propValTable.put(SUPPLIED_OBJ, TrackedDataSet.PERCENT_SUPPLIED);
+		propValTable.put(NOT_SUPPLIED_OBJ, TrackedDataSet.PERCENT_NOT_SUPPLIED);
+		propValTable.put(PART_SUPPLIED_OBJ, TrackedDataSet.PERCENT_PARTIAL_SUPPLIED);
+		propValTable.put(TOT_PROD_GRID, TrackedDataSet.GROUP_PRODUCTION);
+		propValTable.put(TOT_CONS_GRID, TrackedDataSet.GROUP_CONSUMPTION);
+		propValTable.put(NR_SUBNETS, TrackedDataSet.AMOUNT_HOLONS);
+		propValTable.put(NR_CLOSED_SWITCHES, TrackedDataSet.AMOUNT_CLOSED_SWITCHES);
+		propValTable.put(AVG_OBJ_IN_HOLONS, TrackedDataSet.AVG_AMOUNT_OBJECTS_IN_HOLONS);
+		propValTable.put(AVG_ELEM_IN_HOLONS, TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS);
+		propValTable.put(AVG_PRODS_IN_HOLONS, TrackedDataSet.AVG_AMOUNT_PRODUCERS_IN_HOLONS);
+		propValTable.put(AVG_CONS_ENERGY_IN_HOLONS, TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS);
+		propValTable.put(AVG_WASTED_ENERGY_HOLONS, TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS);
+		propValTable.put(NR_BROKEN_EDGES, TrackedDataSet.AMOUNT_BROKEN_EDGES);
+		propValTable.put(PROD_CONS_RATIO, TrackedDataSet.RATIO_PRODUCERS_CONSUMERS);
+
+		JScrollPane graphScrollPane = new JScrollPane();
+		setRightComponent(graphScrollPane);
+
+		graphPanel = new JPanel();
+		graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));
+		graphPanel.revalidate();
+		graphPanel.updateUI();
+		graphScrollPane.setViewportView(graphPanel);
+		
+		JSplitPane splitPane = new JSplitPane();
+		splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
+		setLeftComponent(splitPane);
+		
+		//========================== TREE STRUCTURE ===============================//
+		JScrollPane treeScrollPane = new JScrollPane();
+		objectTree = new JTree();
+		treeModel = (DefaultTreeModel) objectTree.getModel();
+		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Statistics");
+		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));
+		mainGrid.add(new DefaultMutableTreeNode(PROD_CONS_RATIO));
+		mainGrid.add(new DefaultMutableTreeNode(NR_BROKEN_EDGES));
+		mainGrid.add(new DefaultMutableTreeNode(NR_CLOSED_SWITCHES));
+		
+		holonNode = new DefaultMutableTreeNode(HOLON);
+		holonNode.add(new DefaultMutableTreeNode(AVG_OBJ_IN_HOLONS));
+		holonNode.add(new DefaultMutableTreeNode(AVG_ELEM_IN_HOLONS));
+		holonNode.add(new DefaultMutableTreeNode(AVG_WASTED_ENERGY_HOLONS));
+		holonNode.add(new DefaultMutableTreeNode(AVG_CONS_ENERGY_IN_HOLONS));
+		holonNode.add(new DefaultMutableTreeNode(AVG_PRODS_IN_HOLONS));
+
+		objectsNode = new DefaultMutableTreeNode("Objects");
+		objectsNode.add(new DefaultMutableTreeNode("empty"));
+		
+		switchesNode = new DefaultMutableTreeNode("Switches");
+		switchesNode.add(new DefaultMutableTreeNode("empty"));
+		
+		groupNode = new DefaultMutableTreeNode("Groups");
+		groupNode.add(new DefaultMutableTreeNode("empty"));
+		
+		treeModel.setRoot(root);
+		root.add(mainGrid);
+		root.add(holonNode);
+		root.add(objectsNode);
+		root.add(switchesNode);
+		root.add(groupNode);
+		objectTree.setModel(treeModel);
+
+		treeScrollPane.setViewportView(objectTree);
+
+		JPopupMenu popupMenu = new JPopupMenu();
+		addPopup(objectTree, popupMenu);
+
+		JMenuItem mntmUntrack = new JMenuItem("Untrack");
+		mntmUntrack.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent e) {
+				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) objectTree
+						.getLastSelectedPathComponent();
+				if (selectedNode.getLevel() == 2 && !selectedNode.getParent().toString().equals("whole Holon")) {
+					String object = selectedNode.toString();
+					controller.removeTrackingObj(objectHashtable.get(object).getObject());
+				}
+			}
+		});
+		popupMenu.add(mntmUntrack);
+
+		objectTree.addTreeSelectionListener(new TreeSelectionListener() {
+
+			@Override
+			public void valueChanged(TreeSelectionEvent e) {
+				resetFields();
+				showObjectlbl.setText("...");
+				//showPropertylbl.setText("...");
+				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) objectTree
+						.getLastSelectedPathComponent();
+				if (selectedNode == null) {
+					return;
+				} else {
+					if (selectedNode.getLevel() == 0) {
+						disableFields();
+					}
+					if (selectedNode.getLevel() == 1) {
+						disableFields();
+						currentProperty = null;
+						graphNrTxtField.setText("");
+						showObjectlbl.setText(selectedNode.toString());
+					}
+					if (selectedNode.getLevel() == 2) {
+						if (((DefaultMutableTreeNode) selectedNode.getParent()).toString().equals(MAIN_GRID)
+								|| ((DefaultMutableTreeNode) selectedNode.getParent()).toString().equals(HOLON)) {
+							enableFields();
+							String object = selectedNode.getParent().toString();
+							String property = selectedNode.toString();
+							currentProperty = holonHashtable.get(property);
+							Color color = currentProperty.getColor();
+							
+							redField.setText(Integer.toString(color.getRed()));
+							greenField.setText(Integer.toString(color.getGreen()));
+							blueField.setText(Integer.toString(color.getBlue()));
+							
+							showPropertylbl.setText(property);
+							showObjectlbl.setText(object);
+							graphNrTxtField.setText(currentProperty.getAssignedGraph());
+							colorPanel.setBackground(color);
+						} else {
+							disableFields();
+							currentProperty = null;
+							graphNrTxtField.setText("");
+							showObjectlbl.setText(selectedNode.toString());
+						}
+					}
+					if (selectedNode.getLevel() == 3) {
+						enableFields();
+						String object = ((DefaultMutableTreeNode) selectedNode.getParent()).toString();
+						String property = selectedNode.toString();
+						currentProperty = objectHashtable.get(object).getPropertytTable().get(property);
+						Color color = currentProperty.getColor();
+						redField.setText(Integer.toString(color.getRed()));
+						greenField.setText(Integer.toString(color.getGreen()));
+						blueField.setText(Integer.toString(color.getBlue()));
+
+						showObjectlbl.setText(object);
+						showPropertylbl.setText(property);
+						graphNrTxtField.setText(currentProperty.getAssignedGraph());
+						colorPanel.setBackground(color);
+					}
+				}
+			}
+
+		});
+		
+		splitPane.setLeftComponent(treeScrollPane);
+		repaintTree();
+		//=========================== TREE STRUCTURE END ==========================//
+		
+		//================= COLOR COMBOBOX ===========================//
+		
+		colorComboBox = new JComboBox();
+		colorComboBox.addItem("");
+		colorComboBox.addItem("Red");
+		colorComboBox.addItem("Blue");
+		colorComboBox.addItem("Green");
+		colorComboBox.addItem("Yellow");
+		colorComboBox.addItem("Orange");
+		colorComboBox.addItem("Cyan");
+		colorComboBox.addItem("Magenta");
+		colorComboBox.addItem("Pink");
+		colorComboBox.addItem("Gray");
+		colorComboBox.addItem("Random");
+		colorComboBox.addItemListener(new ItemListener() {
+
+			@Override
+			public void itemStateChanged(ItemEvent e) {
+				String colorName = (String) colorComboBox.getSelectedItem();
+				Color tmpColor = Color.WHITE;
+				switch (colorName) {
+				case "":
+					tmpColor = currentProperty.getColor();
+					break;
+				case "Red":
+					tmpColor = Color.RED;
+					colorChanged(tmpColor);
+					break;
+				case "Blue":
+					tmpColor = Color.BLUE;
+					colorChanged(tmpColor);
+					break;
+				case "Green":
+					tmpColor = Color.GREEN;
+					colorChanged(tmpColor);
+					break;
+				case "Yellow":
+					tmpColor = Color.YELLOW;
+					colorChanged(tmpColor);
+					break;
+				case "Orange":
+					tmpColor = Color.ORANGE;
+					colorChanged(tmpColor);
+					break;
+				case "Cyan":
+					tmpColor = Color.CYAN;
+					colorChanged(tmpColor);
+					break;
+				case "Magenta":
+					tmpColor = Color.MAGENTA;
+					colorChanged(tmpColor);
+					break;
+				case "Pink":
+					tmpColor = Color.PINK;
+					colorChanged(tmpColor);
+					break;
+				case "Gray":
+					tmpColor = Color.GRAY;
+					colorChanged(tmpColor);
+					break;
+				case "Random":
+					Random rdm = new Random();
+					tmpColor = new Color(rdm.nextInt(255), rdm.nextInt(255), rdm.nextInt(255));
+				}
+				redField.setText(Integer.toString(tmpColor.getRed()));
+				greenField.setText(Integer.toString(tmpColor.getGreen()));
+				blueField.setText(Integer.toString(tmpColor.getBlue()));
+			}
+		});
+		
+		// ==================== COLORBOX END ==========================//
+		
+		// ====================RED TEXTFIELD===========================//
+		redField = new JTextField();
+		redField.setColumns(10);
+		redField.getDocument().addDocumentListener(new DocumentListener() {
+			/*
+			 * if textField for Red changes, changes will applied in the
+			 * DataStructure "currentProperty" if Value is legit
+			 */
+			@Override
+			public void insertUpdate(DocumentEvent e) {
+				int tmp = -1;
+				try {
+					tmp = Integer.parseInt(redField.getText());
+				} catch (NumberFormatException e1) {
+
+				}
+				if (tmp > -1 && tmp <= 255) {
+					if (currentProperty != null) {
+						Color oldColor = currentProperty.getColor();
+						Color color = new Color(tmp, oldColor.getGreen(), oldColor.getBlue());
+						currentProperty.setColor(color);
+						colorChanged(color);
+					}
+				}
+			}
+
+			@Override
+			public void removeUpdate(DocumentEvent e) {
+				int tmp = -1;
+				try {
+					tmp = Integer.parseInt(redField.getText());
+				} catch (NumberFormatException e1) {
+
+				}
+				if (tmp > -1 && tmp <= 255) {
+					if (currentProperty != null) {
+						Color oldColor = currentProperty.getColor();
+						Color color = new Color(tmp, oldColor.getGreen(), oldColor.getBlue());
+						currentProperty.setColor(color);
+						colorChanged(color);
+					}
+				}
+			}
+
+			@Override
+			public void changedUpdate(DocumentEvent e) {
+
+			}
+		});
+		// ======================RED TEXTFIELD END==========================//
+		
+		// ======================GREEN TEXTFIELD============================//
+		greenField = new JTextField();
+		greenField.setColumns(10);
+		greenField.getDocument().addDocumentListener(new DocumentListener() {
+			/*
+			 * if textField for Red changes, changes will applied in the
+			 * DataStructure "currentProperty" if Value is legit
+			 */
+			@Override
+			public void insertUpdate(DocumentEvent e) {
+				int tmp = -1;
+				try {
+					tmp = Integer.parseInt(greenField.getText());
+				} catch (NumberFormatException e1) {
+
+				}
+				if (tmp > -1 && tmp <= 255) {
+					if (currentProperty != null) {
+						Color oldColor = currentProperty.getColor();
+						Color color = new Color(oldColor.getRed(), tmp, oldColor.getBlue());
+						currentProperty.setColor(color);
+						colorChanged(color);
+					}
+				}
+			}
+
+			@Override
+			public void removeUpdate(DocumentEvent e) {
+				int tmp = -1;
+				try {
+					tmp = Integer.parseInt(greenField.getText());
+				} catch (NumberFormatException e1) {
+
+				}
+				if (tmp > -1 && tmp <= 255) {
+					if (currentProperty != null) {
+						Color oldColor = currentProperty.getColor();
+						Color color = new Color(oldColor.getRed(), tmp, oldColor.getBlue());
+						currentProperty.setColor(color);
+						colorChanged(color);
+					}
+				}
+			}
+
+			@Override
+			public void changedUpdate(DocumentEvent e) {
+
+			}
+		});
+		// ======================GREEN TEXTFIELD END========================//
+		
+		// ======================BLUE TEXTFIELD=============================//
+		blueField = new JTextField();
+		blueField.setColumns(10);
+		blueField.getDocument().addDocumentListener(new DocumentListener() {
+			/*
+			 * if textField for Red changes, changes will applied in the
+			 * DataStructure "currentProperty" if Value is legit
+			 */
+			@Override
+			public void insertUpdate(DocumentEvent e) {
+				int tmp = -1;
+				try {
+					tmp = Integer.parseInt(blueField.getText());
+				} catch (NumberFormatException e1) {
+
+				}
+				if (tmp > -1 && tmp <= 255) {
+					if (currentProperty != null) {
+						Color oldColor = currentProperty.getColor();
+						Color color = new Color(oldColor.getRed(), oldColor.getGreen(), tmp);
+						currentProperty.setColor(color);
+						colorChanged(color);
+					}
+				}
+			}
+
+			@Override
+			public void removeUpdate(DocumentEvent e) {
+				int tmp = -1;
+				try {
+					tmp = Integer.parseInt(blueField.getText());
+				} catch (NumberFormatException e1) {
+
+				}
+				if (tmp > -1 && tmp <= 255) {
+					if (currentProperty != null) {
+						Color oldColor = currentProperty.getColor();
+						Color color = new Color(oldColor.getRed(), oldColor.getGreen(), tmp);
+						currentProperty.setColor(color);
+						colorChanged(color);
+					}
+				}
+			}
+
+			@Override
+			public void changedUpdate(DocumentEvent e) {
+
+			}
+		});
+		// ======================BLUE TEXTFIELD END=========================//
+		
+		//======================== ADD BUTTON =============================//
+
+		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 || (selectedNode.getLevel() == 2 && 
+							(selectedNode.getParent().toString().equals(HOLON) || selectedNode.getParent().toString().equals(MAIN_GRID) ))) {
+						StatisticGraphPanel tmp = null;
+						if (graphNrTxtField.getText().length() > 0) {
+							if (!graphHashtable.containsKey(graphNrTxtField.getText())
+									&& graphNrTxtField.getText().length() > 0) {
+								tmp = new StatisticGraphPanel(controller.getModel(), controller,
+										graphNrTxtField.getText(), graphHashtable);
+								//tmp.setPreferredSize(new Dimension(280, 150));
+								//tmp.setMaximumSize(new Dimension(1000, 1000));
+								// 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);
+							}
+							String object = ((DefaultMutableTreeNode) selectedNode.getParent()).toString();
+							String property = selectedNode.toString();
+							AbstractCpsObject absCps = null;
+							if(!object.equals(MAIN_GRID) && !object.equals(HOLON)){
+							GraphDataSet dataSet = objectHashtable.get(object);
+							absCps = dataSet.getObject();
+							}
+							TrackedDataSet tds = new TrackedDataSet(absCps, propValTable.get(property),
+									currentProperty.getColor());
+							graphHashtable.get(graphNrTxtField.getText()).addObjec(tds);
+						}
+					}
+				}
+			}
+		});
+		
+		//============================== ADD BUTTON END ==============================//
+		
+		//=========================== WINDOWBUILDER COMPONENTS ====================//
+		JScrollPane scrollPane = new JScrollPane();
+		splitPane.setRightComponent(scrollPane);
+		
+		JPanel editPanel = new JPanel();
+		editPanel.setBounds(0,0,600,600);
+		editPanel.setPreferredSize(new Dimension(420,280));
+		scrollPane.setBounds(0,0,600,600);
+		scrollPane.setViewportView(editPanel);
+		editPanel.setLayout(null);
+		
+		JLabel lblObject = new JLabel("Object(s):");
+		lblObject.setBounds(10, 11, 49, 14);
+		editPanel.add(lblObject);
+		
+		showObjectlbl = new JLabel("...");
+		showObjectlbl.setBounds(69, 11, 86, 14);
+		editPanel.add(showObjectlbl);
+		
+		JLabel lblProperty = new JLabel("Property:");
+		lblProperty.setBounds(10, 36, 46, 14);
+		editPanel.add(lblProperty);
+		
+		showPropertylbl = new JLabel("...");
+		showPropertylbl.setBounds(69, 36, 86, 14);
+		editPanel.add(showPropertylbl);
+		
+		JLabel lblGraph = new JLabel("Graph:");
+		lblGraph.setBounds(10, 61, 33, 14);
+		editPanel.add(lblGraph);
+		
+		graphNrTxtField = new JTextField();
+		graphNrTxtField.setColumns(10);
+		graphNrTxtField.setBounds(69, 61, 86, 20);
+		editPanel.add(graphNrTxtField);
+		
+		JLabel lblColor = new JLabel("Color:");
+		lblColor.setBounds(10, 86, 29, 14);
+		editPanel.add(lblColor);
+		
+		colorComboBox.setBounds(69, 83, 86, 20);
+		editPanel.add(colorComboBox);
+		
+		JLabel lblR = new JLabel("R");
+		lblR.setBounds(10, 111, 11, 14);
+		editPanel.add(lblR);
+		
+		redField = new JTextField();
+		redField.setColumns(10);
+		redField.setBounds(20, 108, 37, 20);
+		editPanel.add(redField);
+		
+		JLabel lblG = new JLabel("G");
+		lblG.setBounds(58, 111, 11, 14);
+		editPanel.add(lblG);
+		
+		greenField = new JTextField();
+		greenField.setColumns(10);
+		greenField.setBounds(69, 108, 37, 20);
+		editPanel.add(greenField);
+		
+		JLabel lblB = new JLabel("B");
+		lblB.setBounds(108, 111, 10, 14);
+		editPanel.add(lblB);
+		
+		blueField = new JTextField();
+		blueField.setColumns(10);
+		blueField.setBounds(116, 108, 39, 20);
+		editPanel.add(blueField);
+		
+		colorPanel = new JPanel();
+		colorPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
+		colorPanel.setBackground(Color.WHITE);
+		colorPanel.setBounds(10, 136, 49, 36);
+		editPanel.add(colorPanel);
+
+		btnAdd.setBounds(10, 175, 51, 23);
+		editPanel.add(btnAdd);
+		splitPane.setDividerLocation(170);
+		
+		//============================= WINDOWBUILDER COMPONENTS END =================//
+		
+	}
+	
+	//=============================== END CONSTRUCTOR ==============================//
+
+	
+	//=============================== METHODS ======================================//
+	@Override
+	public void repaintTree() {
+		treeModel.reload();
+	}
+
+	@Override
+	public void addTrackedObject(ArrayList<AbstractCpsObject> hlList) {
+		objectsNode.removeAllChildren();
+		switchesNode.removeAllChildren();
+		groupNode.removeAllChildren();
+		objectHashtable.clear();
+		if (hlList.size() > 0 && hlList != null) {
+			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){
+					tmp.add(new DefaultMutableTreeNode(TOT_PROD_OBJ));
+					tmp.add(new DefaultMutableTreeNode(TOT_CONS_OBJ));
+					tmp.add(new DefaultMutableTreeNode(NR_ACTIVE_ELEMENTS));
+					tmpHash.put(TOT_PROD_OBJ, new PropertyDataSet());
+					tmpHash.put(TOT_CONS_OBJ, new PropertyDataSet());
+					tmpHash.put(NR_ACTIVE_ELEMENTS, new PropertyDataSet());
+					objectsNode.add(tmp);
+				}
+				
+				//HolonSwitches
+				if(abs instanceof HolonSwitch){
+					tmp.add(new DefaultMutableTreeNode(SW_ACTIVE));
+					tmpHash.put(SW_ACTIVE, new PropertyDataSet());
+					switchesNode.add(tmp);
+				}
+				
+				//NodesOfNodes
+				if(abs instanceof CpsUpperNode){
+					tmp.add(new DefaultMutableTreeNode(TOT_PROD_GRID));
+					tmp.add(new DefaultMutableTreeNode(TOT_CONS_GRID));
+					tmpHash.put(TOT_PROD_GRID, new PropertyDataSet());
+					tmpHash.put(TOT_CONS_GRID, new PropertyDataSet());
+					groupNode.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){
+			switchesNode.add(new DefaultMutableTreeNode("empty"));
+		}
+		if(groupNode.getChildCount() == 0){
+			groupNode.add(new DefaultMutableTreeNode("empty"));
+		}
+
+	}
+
+	public void colorChanged(Color color) {
+		colorPanel.setBackground(color);
+	}
+
+	public void resetFields() {
+		colorPanel.setBackground(Color.WHITE);
+		redField.setText("");
+		greenField.setText("");
+		blueField.setText("");
+		colorComboBox.setSelectedIndex(0);
+	}
+
+	public void disableFields() {
+		redField.setEnabled(false);
+		greenField.setEnabled(false);
+		blueField.setEnabled(false);
+		graphNrTxtField.setEnabled(false);
+		colorComboBox.setEnabled(false);
+		colorPanel.setBackground(Color.LIGHT_GRAY);
+	}
+
+	public void enableFields() {
+		redField.setEnabled(true);
+		greenField.setEnabled(true);
+		blueField.setEnabled(true);
+		graphNrTxtField.setEnabled(true);
+		colorComboBox.setEnabled(true);
+		colorPanel.setBackground(Color.WHITE);
+	}
+
+	public void repaintGraphs() {
+		for (StatisticGraphPanel sg : graphHashtable.values()) {
+			sg.repaint();
+		}
+	}
+
+	private static void addPopup(Component component, final JPopupMenu popup) {
+	}
+}

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

@@ -271,7 +271,7 @@ public class StatisticGraph extends JPanel {
 				break;
 			case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
 				for (SubNet sub : controller.getSimManager().getSubNets()) {
-					float tempVal = -getMaxTotalConsumption(new ArrayList<>(sub.getObjects()));
+					float tempVal = -getMaxTotalConsumption(new ArrayList<AbstractCpsObject>(sub.getObjects()));
 					if (val < tempVal) {
 						val = tempVal;
 					}
@@ -279,7 +279,7 @@ public class StatisticGraph extends JPanel {
 				break;
 			case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
 				for (SubNet sub : controller.getSimManager().getSubNets()) {
-					float tempVal = getMaxTotalProduction(new ArrayList<>(sub.getObjects()));
+					float tempVal = getMaxTotalProduction(new ArrayList<AbstractCpsObject>(sub.getObjects()));
 					if (val < tempVal) {
 						val = tempVal;
 					}