Parcourir la source

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

Edgardo Palza il y a 8 ans
Parent
commit
0edf7ec68b

+ 43 - 0
src/DataSets/GraphDataSet.java

@@ -0,0 +1,43 @@
+package DataSets;
+
+import java.awt.Color;
+import java.util.Hashtable;
+
+import classes.AbstractCpsObject;
+
+/*
+ * a class which contains one AbstractCpsObject and a corresponding Hashtable
+ * for the properties "total Consumption", "total Produktion" and "number of activated Elements"
+ * so far...
+ */
+public class GraphDataSet {
+	Hashtable<String, PropertyDataSet> propertyTable;
+	AbstractCpsObject cpsObject;
+	
+	public GraphDataSet(AbstractCpsObject obj){
+		cpsObject = obj;
+		propertyTable = new Hashtable<String, PropertyDataSet>();
+	}
+	
+	public GraphDataSet(AbstractCpsObject obj, Hashtable<String, PropertyDataSet> ht){
+		cpsObject = obj;
+		propertyTable = ht;
+	}
+	
+	public void setObject(AbstractCpsObject aco){
+		cpsObject = aco;
+	}
+	
+	public void setPropertyTable(Hashtable<String, PropertyDataSet> ht){
+		propertyTable = ht;
+	}
+	
+	public AbstractCpsObject getObject(){
+		return cpsObject;
+	}
+	
+	public Hashtable<String, PropertyDataSet> getPropertytTable(){
+		return propertyTable;
+	}
+	
+}

+ 2 - 2
src/classes/PropertyDataSet.java → src/DataSets/PropertyDataSet.java

@@ -1,4 +1,4 @@
-package classes;
+package DataSets;
 
 import java.awt.Color;
 
@@ -10,7 +10,7 @@ public class PropertyDataSet {
 	
 	public PropertyDataSet(){
 		assignedGraph = "";
-		color = new Color(0,0,0);
+		color = new Color(255,255,255);
 	}
 	
 	public PropertyDataSet(String graph, Color color){

+ 0 - 1
src/classes/HolonObject.java

@@ -30,7 +30,6 @@ public class HolonObject extends AbstractCpsObject {
 	private float[] trackingProd;
 	/* Array for tracking Consumption */
 	private float[] trackingCons;
-
 	/*
 	 * 0 = no energy, 1 = not supplied, 2 = supplied, 3 producer
 	 */

+ 61 - 0
src/classes/TrackedDataSet.java

@@ -0,0 +1,61 @@
+package classes;
+
+import java.awt.Color;
+
+public class TrackedDataSet {
+
+	//Property Integers
+	public static  final int CONSUMPTION = 0;
+	public static final int PRODUCTION = 1;
+	public static final int ACTIVATED_ELEMENTS = 2;
+	public static final int ON_OFF = 3;
+	
+	//Variables of the Data Set
+	private AbstractCpsObject cps;
+	private int property;
+	private Color color;
+
+	//Value for each timeStep
+	
+	private float values[];
+	
+	/**
+	 * Data Set for the StatisticGraoh
+	 * 
+	 * @param cps
+	 *            the cps Object
+	 * @param property
+	 *            which value should be tracked
+	 * @param color
+	 *            color of the line in the graph
+	 */
+	public TrackedDataSet(AbstractCpsObject cps, int property, Color color) {
+		this.cps = cps;
+		this.property = property;
+		this.color = color;
+		this.values = new float[100];
+		for (int i = 0; i < values.length; i++) {
+			values[i] = -1;
+		}
+	}
+
+	public AbstractCpsObject getCpsObject() {
+		return this.cps;
+	}
+
+	public int getProperty() {
+		return this.property;
+	}
+
+	public Color getColor() {
+		return this.color;
+	}
+	
+	public float[] getValues() {
+		return this.values;
+	}
+	
+	public void setValAt(float val, int at){
+		this.values[at] = val;
+	}
+}

+ 0 - 9
src/classes/graphDataSet.java

@@ -1,9 +0,0 @@
-package classes;
-
-import java.awt.Color;
-import java.util.Hashtable;
-
-public class graphDataSet {
-	Hashtable<String, PropertyDataSet> propertyTable;
-	
-}

+ 7 - 4
src/ui/view/GUI.java

@@ -78,6 +78,7 @@ import classes.HolonSwitch;
 import classes.HolonTransformer;
 import classes.IdCounter;
 import classes.IdCounterElem;
+import classes.TrackedDataSet;
 import interfaces.CategoryListener;
 import ui.controller.Control;
 import ui.controller.UpdateController;
@@ -117,6 +118,7 @@ public class GUI<E> implements CategoryListener {
 
 	private final JScrollPane canvasSP = new JScrollPane();
 	private final JScrollPane scrollPane1 = new JScrollPane();
+	private final JScrollPane holonSP = new JScrollPane();
 	private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
 	private final JPanel panelTapped_SimMenu = new JPanel();
 	private JPopupMenu popmenuEdit = new JPopupMenu();
@@ -273,7 +275,7 @@ public class GUI<E> implements CategoryListener {
 	public GUI(Control control) {
 		this.controller = control;
 		this.model = control.getModel();
-		statSplitPane = new splitPane();
+		statSplitPane = new splitPane(controller);
 		model.addGraphListener(statSplitPane);
 		statScrollPane = new JScrollPane(statSplitPane);
 		this.canvas = new MyCanvas(model, control);
@@ -580,7 +582,7 @@ public class GUI<E> implements CategoryListener {
 				JOptionPane.showMessageDialog(null, myPanel);
 				controller.setCanvasX(Integer.parseInt(field1.getText()));
 				controller.setCanvasY(Integer.parseInt(field2.getText()));
-				for (int i = 2; i < tabbedPane.getTabCount(); i++) {
+				for (int i = 3; i < tabbedPane.getTabCount(); i++) {
 					tabbedPane.getComponentAt(i)
 							.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
 					tabbedPane.getComponentAt(i).repaint();
@@ -1531,6 +1533,7 @@ public class GUI<E> implements CategoryListener {
 		splitPaneCanvasConsole.setLeftComponent(panelTapped_SimMenu);
 		tabbedPane.addTab("View", canvasSP);
 		tabbedPane.addTab("Statistics", statScrollPane);
+		tabbedPane.addTab("Holon", holonSP);
 
 		splitPaneCanvasConsole.setRightComponent(console);
 		splitPane1.setLeftComponent(splitPaneCanvasConsole);
@@ -1797,7 +1800,7 @@ public class GUI<E> implements CategoryListener {
 
 		// check if tab already open for clicked NodeOfNode
 		boolean dupl = false;
-		for (int i = 2; i < tabbedPane.getTabCount() && dupl == false; i++) {
+		for (int i = 3; i < tabbedPane.getTabCount() && dupl == false; i++) {
 			if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport().getComponent(0)).upperNode
 					.getID() == temp.getID()) {
 				dupl = true;
@@ -1812,7 +1815,7 @@ public class GUI<E> implements CategoryListener {
 			unc.addMouseListener(new MouseAdapter() {
 				@Override
 				public void mousePressed(MouseEvent e) {
-					temp = unc.tempCps;
+					temp = ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getSelectedComponent()).getViewport().getComponent(0)).tempCps;
 					if (doubleClick() && temp instanceof CpsUpperNode) {
 						openNewUpperNodeTab();
 					}

+ 199 - 59
src/ui/view/StatisticGraph.java

@@ -4,14 +4,21 @@ import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
+import java.awt.Image;
 import java.awt.RenderingHints;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.geom.GeneralPath;
 import java.util.ArrayList;
 
+import javax.swing.ImageIcon;
 import javax.swing.JPanel;
+import javax.swing.Timer;
 
 import classes.HolonElement;
 import classes.HolonObject;
+import classes.HolonSwitch;
+import classes.TrackedDataSet;
 import ui.controller.Control;
 import ui.model.Model;
 
@@ -22,18 +29,12 @@ public class StatisticGraph extends JPanel {
 	 */
 	private static final long serialVersionUID = 1L;
 
-	// Max Objects
-	final int MAX_OBJECTS = 8;
-
 	// Maximum y Value
 	double maximum = 0;
 
 	// is the Simulation running?
 	private boolean isSimRunning;
 
-	// Colours
-	private ArrayList<Color> colors = new ArrayList<>();
-
 	// model and controller
 	private Model model;
 	private Control controller;
@@ -43,8 +44,7 @@ public class StatisticGraph extends JPanel {
 	GeneralPath path = new GeneralPath();
 
 	// Data
-	private ArrayList<HolonObject> objects = new ArrayList<>();
-	private ArrayList<GeneralPath> objPaths = new ArrayList<>();
+	private ArrayList<TrackedDataSet> objects = new ArrayList<>();
 
 	/**
 	 * Constructor.
@@ -57,18 +57,24 @@ public class StatisticGraph extends JPanel {
 	public StatisticGraph(final Model model, Control control) {
 		this.controller = control;
 		this.model = model;
-		colors.add(Color.BLUE);
-		colors.add(Color.RED);
-		colors.add(Color.GREEN);
-		colors.add(Color.CYAN);
-		colors.add(Color.ORANGE);
-		colors.add(Color.PINK);
-		colors.add(Color.MAGENTA);
-		colors.add(Color.YELLOW);
-		
-		
-		
+
+		// addObject(new TrackedDataSet(model.getObjectsOnCanvas().get(0),
+		// TrackedDataSet.CONSUMPTION, Color.RED));
+		// addObject(new TrackedDataSet(model.getObjectsOnCanvas().get(0),
+		// TrackedDataSet.PRODUCTION, Color.GREEN));
+		// addObject(new TrackedDataSet(model.getObjectsOnCanvas().get(0),
+		// TrackedDataSet.ACTIVATED_ELEMENTS, Color.CYAN));
+		addObject(new TrackedDataSet(model.getObjectsOnCanvas().get(0), TrackedDataSet.ON_OFF, Color.BLUE));
+
 		this.setBackground(Color.WHITE);
+
+		Timer timer = new Timer(200, new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent ae) {
+				repaint();
+			}
+		});
+		timer.start();
 	}
 
 	/**
@@ -96,41 +102,38 @@ public class StatisticGraph extends JPanel {
 			g2.drawLine(0, i, this.getWidth(), i);
 		}
 
-		// Reset?
-		if (!isSimRunning && model.getIsSimulation()) {
-			for (int i = 0; i < objects.size(); i++) {
-				objPaths.get(i).reset();
-				objPaths.get(i).moveTo(model.getCurIteration() * this.getWidth() / model.getIterations() - 1,
-						convertToCanvasY(Math.abs(objects.get(i).getCurrentEnergy())));
-			}
-		}
-
 		isSimRunning = model.getIsSimulation();
 
 		// if sim is on
 		if (isSimRunning) {
-			maximum = 0;
-			for (HolonObject obj : objects) {
-				if (maximum <= (Math.abs(obj.getCurrentEnergy()))) {
-					maximum = (Math.abs(obj.getCurrentEnergy()));
-				}
-			}
+			g2.setStroke(new BasicStroke(3));
+
+			// Calculate the Maximum
+			calcMaximum();
 
-			for (int i = 0; i < objects.size(); i++) {
-				g2.setColor(new Color((int) (Math.random() * 255), (int) (Math.random() * 255),
-						(int) (Math.random() * 255)));
-				objPaths.get(i).lineTo(model.getCurIteration() * this.getWidth() / model.getIterations() - 1,
-						convertToCanvasY(Math.abs(getEnergyAtCurrentTimeStep(objects.get(i)))));
-				objPaths.get(i).moveTo(model.getCurIteration() * this.getWidth() / model.getIterations() - 1,
-						convertToCanvasY(Math.abs(getEnergyAtCurrentTimeStep(objects.get(i)))));
+			// Calculate values for each set and add them
+			addValues();
+
+			// Create Paths and draw them
+			for (TrackedDataSet set : objects) {
+				path.reset();
+				switch (set.getProperty()) {
+				case TrackedDataSet.CONSUMPTION:
+				case TrackedDataSet.PRODUCTION:
+				case TrackedDataSet.ACTIVATED_ELEMENTS:
+					createPathFloats(set);
+					break;
+				case TrackedDataSet.ON_OFF:
+					createPathBooleans(set);
+					break;
+				default:
+					break;
+				}
+				g2.setColor(set.getColor());
+				g2.draw(path);
 
 			}
 		}
-		g2.setStroke(new BasicStroke(3));
-		for (int i = 0; i < objPaths.size(); i++) {
-			g2.setColor(colors.get(i));
-			g2.draw(objPaths.get(i));
-		}
 
 	}
 
@@ -140,14 +143,8 @@ public class StatisticGraph extends JPanel {
 	 * @param obj
 	 *            the Object to add
 	 */
-	public void addObject(HolonObject obj) {
-		if (objects.size() < MAX_OBJECTS && !objects.contains(obj)) {
-			objects.add((HolonObject) obj);
-			objPaths.add(new GeneralPath());
-			objPaths.get(objPaths.size() - 1)
-					.moveTo(model.getCurIteration() * this.getWidth() / model.getIterations() - 1, convertToCanvasY(Math
-							.abs(objects.get(objects.size() - 1).getCurrentEnergyAtTimeStep(model.getCurIteration()))));
-		}
+	public void addObject(TrackedDataSet set) {
+		objects.add(set);
 	}
 
 	/**
@@ -156,10 +153,9 @@ public class StatisticGraph extends JPanel {
 	 * @param obj
 	 *            the Object to remove
 	 */
-	public void removeObject(HolonObject obj) {
-		if (objects.contains(obj)) {
-			objPaths.remove(objects.indexOf(obj));
-			objects.remove(obj);
+	public void removeObject() {
+		for (TrackedDataSet set : objects) {
+			controller.addTextToConsole("Function not available");
 		}
 	}
 
@@ -173,7 +169,7 @@ public class StatisticGraph extends JPanel {
 	public double convertToCanvasY(float d) {
 		return Math.abs((this.getHeight() - (d * (this.getHeight() / maximum))));
 	}
-	
+
 	/**
 	 * Does take into account which timestep is watched, calculates the max
 	 * values.
@@ -190,4 +186,148 @@ public class StatisticGraph extends JPanel {
 		return temp;
 	}
 
+	/**
+	 * Calculate the Max Value of the Graph
+	 */
+	private void calcMaximum() {
+		maximum = 0;
+		for (TrackedDataSet set : objects) {
+			int val = 0;
+			switch (set.getProperty()) {
+			case TrackedDataSet.CONSUMPTION:
+				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
+					if (h.getEnergy() < 0) {
+						val += h.getEnergy();
+					}
+				}
+				val *= -1;
+				break;
+			case TrackedDataSet.PRODUCTION:
+				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
+					if (h.getEnergy() > 0) {
+						val += h.getEnergy();
+					}
+				}
+
+				break;
+			case TrackedDataSet.ACTIVATED_ELEMENTS:
+				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
+					val += h.getAmount();
+				}
+				break;
+			case TrackedDataSet.ON_OFF:
+				val = 1;
+				break;
+			default:
+				break;
+			}
+			if (val > maximum) {
+				maximum = val;
+			}
+		}
+	}
+
+	/**
+	 * Add the Current Values to each set
+	 */
+	private void addValues() {
+		for (TrackedDataSet set : objects) {
+			int val = 0;
+			switch (set.getProperty()) {
+			case TrackedDataSet.CONSUMPTION:
+				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
+					if (h.getEnergy() < 0) {
+						val += Math.abs(h.getEnergyAt()[model.getCurIteration()]);
+					}
+					set.setValAt(val, model.getCurIteration());
+				}
+				break;
+			case TrackedDataSet.PRODUCTION:
+				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
+					if (h.getEnergy() > 0) {
+						val += Math.abs(h.getEnergyAt()[model.getCurIteration()]);
+					}
+					set.setValAt(val, model.getCurIteration());
+				}
+
+				break;
+			case TrackedDataSet.ACTIVATED_ELEMENTS:
+				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
+					if (h.getActive()) {
+						val += h.getAmount();
+					}
+					set.setValAt(val, model.getCurIteration());
+				}
+				break;
+			case TrackedDataSet.ON_OFF:
+				if (((HolonSwitch) set.getCpsObject()).getManualMode()) {
+					if (((HolonSwitch) set.getCpsObject()).getActiveManual()) {
+						set.setValAt(1, model.getCurIteration());
+					} else {
+						set.setValAt(0, model.getCurIteration());
+					}
+				} else {
+					if (((HolonSwitch) set.getCpsObject()).getActiveAt()[model.getCurIteration()]) {
+						set.setValAt(1, model.getCurIteration());
+					} else {
+						set.setValAt(0, model.getCurIteration());
+					}
+				}
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+	/**
+	 * create Path with floats
+	 * 
+	 * @param set
+	 */
+	private void createPathFloats(TrackedDataSet set) {
+		boolean init = true;
+		path.moveTo(0, 0);
+		for (int i = 0; i < model.getCurIteration() - 1; i++) {
+			controller.addTextToConsole(path.getCurrentPoint().getX() + ", " + path.getCurrentPoint().getY());
+			if (init /* && set.getValues()[i] != -1 */) {
+				path.moveTo(i * this.getWidth() / model.getIterations() - 1, convertToCanvasY(set.getValues()[i]));
+				init = false;
+			}
+			if (!init) {
+				if (set.getValues()[i + 1] != -1) {
+					path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
+							convertToCanvasY(set.getValues()[i + 1]));
+				} else {
+					break;
+				}
+			}
+
+		}
+	}
+
+	/**
+	 * create Path with booleans(0 and 1)
+	 * 
+	 * @param set
+	 */
+	private void createPathBooleans(TrackedDataSet set) {
+		boolean init = true;
+		for (int i = 0; i < model.getCurIteration() - 1; i++) {
+			if (init && set.getValues()[i] != -1) {
+				path.moveTo(i * this.getWidth() / model.getIterations() - 1,
+						convertToCanvasY((float) (set.getValues()[i] * maximum)));
+				init = false;
+			}
+			if (!init) {
+				if (set.getValues()[i + 1] != -1) {
+					path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
+							convertToCanvasY((float) (set.getValues()[i + 1] * maximum)));
+				} else {
+					break;
+				}
+			}
+		}
+	}
+
 }

+ 30 - 2
src/ui/view/UpperNodeCanvas.java

@@ -888,6 +888,34 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 
 				}
 			}
+			int count = 0;
+			for (CpsEdge ed : upperNode.getConnections()) {
+				AbstractCpsObject cps = null;
+				if (ed.getA().equals(upperNode)) {
+					cps = ed.getB();
+				} else {
+					cps = ed.getA();
+				}
+
+				int x1 = sx, x2 = x, y1 = sy, y2 = y;
+
+				if (sx >= x) {
+					x1 = x;
+					x2 = sx;
+				}
+				if (sy >= y) {
+					y1 = y;
+					y2 = sy;
+				}
+
+				if (x1 <= borderPos >> 1
+						&& y1 <= (int) (5 + (model.getScale() + scalediv20 + 10) * count) + model.getScaleDiv2()
+						&& x2 >= borderPos >> 1 && y2 >= (int) (5 + (model.getScale() + scalediv20 + 10) * count)) {
+					tempSelected.add(cps);
+
+				}
+				count++;
+			}
 		}
 
 		repaint();
@@ -946,7 +974,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 	 * Draws or Deletes an Edge.
 	 */
 	private void drawDeleteEdge() {
-		boolean node = true;
+		boolean node = true; // new node?
 		boolean newEdge = true;
 		boolean onEdge = true;
 		boolean deleteNode = false;
@@ -1090,7 +1118,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 		}
 
 		// ins leere Gedragged
-		if (node) {
+		if (node && x > borderPos) {
 			CpsNode n = new CpsNode("Node");
 
 			n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());

+ 374 - 28
src/ui/view/splitPane.java

@@ -6,11 +6,14 @@ 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;
@@ -18,16 +21,31 @@ import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.MutableTreeNode;
 import javax.swing.tree.TreeNode;
 
+import DataSets.GraphDataSet;
+import DataSets.PropertyDataSet;
 import classes.HolonObject;
-import classes.PropertyDataSet;
 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.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.BoxLayout;
+import java.awt.FlowLayout;
 
 public class splitPane extends JSplitPane implements GraphListener {
 	private JTextField graphNrTxtField;
@@ -38,16 +56,24 @@ public class splitPane extends JSplitPane implements GraphListener {
 	private DefaultTreeModel treeModel;
 	private DefaultMutableTreeNode objectsNode;
 	private DefaultMutableTreeNode wholeHolon;
-	private Hashtable<String, Hashtable<String, PropertyDataSet>> objectHashtable;
+	private Hashtable<String, GraphDataSet> objectHashtable;
+	private JPanel colorPanel;
+	private PropertyDataSet currentProperty = new PropertyDataSet();
+	private JComboBox colorComboBox;
+	private Control controller;
+	private JPanel graphPanel;
 
 	JLabel showObjectlbl;
 	JLabel showPropertylbl;
-	public splitPane() {
-		
-		objectHashtable = new Hashtable<String, Hashtable<String, PropertyDataSet>>();
+	public splitPane(Control cont) {
+		//this.rightComponent
+		this.controller = cont;
+		objectHashtable = new Hashtable<String, GraphDataSet>();
 
+		JScrollPane dataPane = new JScrollPane(); 
+		setLeftComponent(dataPane);
 		JPanel panel = new JPanel();
-		setLeftComponent(panel);
+		dataPane.setViewportView(panel);
 		
 		JScrollPane treeScrollPane = new JScrollPane();
 		
@@ -61,21 +87,248 @@ public class splitPane extends JSplitPane implements GraphListener {
 		
 		JLabel lblGraph = new JLabel("Graph:");
 		
+		JLabel lblColor = new JLabel("Color:");
+		
+		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()));
+			}
+			
+		});
+				
+		//====================GRAPH NR TEXTFIELD======================//
 		graphNrTxtField = new JTextField();
 		graphNrTxtField.setColumns(10);
+		graphNrTxtField.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) {
+				if(currentProperty != null){
+					currentProperty.setGraph(graphNrTxtField.getText());
+				}
+			}
+
+			@Override
+			public void removeUpdate(DocumentEvent e) {
+				if(currentProperty != null){
+					currentProperty.setGraph(graphNrTxtField.getText());
+				}
+			}
+
+			@Override
+			public void changedUpdate(DocumentEvent e) {
+				
+			}
+		});
 		
-		JLabel lblColor = new JLabel("Color:");
-		
-		JComboBox colorComboBox = new JComboBox();
+		//====================GRAPH NR TEXTFIELD 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=========================//
 		
 		JLabel lblR = new JLabel("R:");
 		
@@ -84,8 +337,16 @@ public class splitPane extends JSplitPane implements GraphListener {
 		JLabel lblB = new JLabel("B:");
 		
 		JButton btnAdd = new JButton("Add");
+		btnAdd.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent e) {
+				StatisticGraph tmp = new StatisticGraph(controller.getModel(), controller);
+				graphPanel.add(tmp);
+				graphPanel.revalidate();
+				graphPanel.updateUI();
+			}
+		});
 		
-		JPanel colorPanel = new JPanel();
+		colorPanel = new JPanel();
 		colorPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
 		colorPanel.setBackground(Color.WHITE);
 		GroupLayout gl_panel = new GroupLayout(panel);
@@ -93,8 +354,10 @@ public class splitPane extends JSplitPane implements GraphListener {
 			gl_panel.createParallelGroup(Alignment.LEADING)
 				.addGroup(gl_panel.createSequentialGroup()
 					.addContainerGap()
-					.addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
-						.addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 165, GroupLayout.PREFERRED_SIZE)
+					.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
+						.addGroup(gl_panel.createSequentialGroup()
+							.addComponent(treeScrollPane, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
+							.addContainerGap())
 						.addGroup(gl_panel.createSequentialGroup()
 							.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
 								.addComponent(lblGraph)
@@ -112,6 +375,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 								.addComponent(showObjectlbl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 								.addComponent(showPropertylbl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 								.addComponent(colorComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+								.addComponent(graphNrTxtField)
 								.addGroup(gl_panel.createSequentialGroup()
 									.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
 										.addComponent(btnAdd)
@@ -122,16 +386,15 @@ public class splitPane extends JSplitPane implements GraphListener {
 									.addPreferredGap(ComponentPlacement.RELATED)
 									.addComponent(lblB)
 									.addPreferredGap(ComponentPlacement.RELATED)
-									.addComponent(blueField, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE))
-								.addComponent(graphNrTxtField))))
-					.addContainerGap())
+									.addComponent(blueField, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)))
+							.addGap(32))))
 		);
 		gl_panel.setVerticalGroup(
 			gl_panel.createParallelGroup(Alignment.LEADING)
 				.addGroup(gl_panel.createSequentialGroup()
 					.addContainerGap()
-					.addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 153, GroupLayout.PREFERRED_SIZE)
-					.addGap(27)
+					.addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE)
+					.addPreferredGap(ComponentPlacement.RELATED)
 					.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
 						.addComponent(lblObject, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
 						.addComponent(showObjectlbl))
@@ -157,9 +420,9 @@ public class splitPane extends JSplitPane implements GraphListener {
 						.addComponent(blueField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 					.addPreferredGap(ComponentPlacement.RELATED)
 					.addComponent(colorPanel, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
-					.addPreferredGap(ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
+					.addPreferredGap(ComponentPlacement.RELATED)
 					.addComponent(btnAdd)
-					.addContainerGap())
+					.addContainerGap(35, Short.MAX_VALUE))
 		);
 		
 		objectTree = new JTree();
@@ -183,40 +446,65 @@ public class splitPane extends JSplitPane implements GraphListener {
 		
 		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((HolonObject)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;
 						 showObjectlbl.setText(selectedNode.toString());
 					 }
 					 if(selectedNode.getLevel() == 2){
 						 if(((DefaultMutableTreeNode)selectedNode.getParent()).toString().equals("whole Holon")){
+							 enableFields();
 							 showPropertylbl.setText(selectedNode.toString());
 							 showObjectlbl.setText(selectedNode.getParent().toString());
 						 }else{
+							 disableFields();
+							 currentProperty = null;
 							 showObjectlbl.setText(selectedNode.toString());
 						 }
 					 }
 					 if(selectedNode.getLevel() == 3){
+						 enableFields();
 						 String object = ((DefaultMutableTreeNode)selectedNode.getParent()).toString();
 						 String property = selectedNode.toString();
-						 int r = objectHashtable.get(object).get(property).getColor().getRed();
-						 redField.setText(Integer.toString(r));
-						 int g = objectHashtable.get(object).get(property).getColor().getGreen();
-						 greenField.setText(Integer.toString(g));
-						 int b = objectHashtable.get(object).get(property).getColor().getBlue();
-						 blueField.setText(Integer.toString(b));
+						 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(objectHashtable.get(object).get(property).getAssignedGraph());
+						 graphNrTxtField.setText(currentProperty.getAssignedGraph());
+						 colorPanel.setBackground(color);
 					 }
 				 }
 			}
@@ -226,6 +514,13 @@ public class splitPane extends JSplitPane implements GraphListener {
 		
 		JScrollPane graphScrollPane = new JScrollPane();
 		setRightComponent(graphScrollPane);
+		
+		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
@@ -234,8 +529,9 @@ public class splitPane extends JSplitPane implements GraphListener {
 	}
 	@Override
 	public void addTrackedObject(ArrayList<HolonObject> hlList) {
+		objectsNode.removeAllChildren();
+		objectHashtable.clear();
 		if(hlList.size() > 0 && hlList != null){
-			objectsNode.removeAllChildren();
 			for(HolonObject hO : hlList){
 				Hashtable<String, PropertyDataSet> tmpHash = new Hashtable<String, PropertyDataSet>();
 				String name = hO.getName() + " " + hO.getID();
@@ -246,7 +542,8 @@ public class splitPane extends JSplitPane implements GraphListener {
 				tmpHash.put("total Production", new PropertyDataSet());
 				tmpHash.put("total Consumption", new PropertyDataSet());
 				tmpHash.put("number of activated Elements", new PropertyDataSet());
-				objectHashtable.put(name, tmpHash);
+				GraphDataSet gS = new GraphDataSet(hO, tmpHash);
+				objectHashtable.put(name, gS);
 				objectsNode.add(tmp);
 			}
 		}else{
@@ -254,4 +551,53 @@ public class splitPane extends JSplitPane implements GraphListener {
 		}
 		
 	}
+	
+	public void colorChanged(Color color){
+		colorPanel.setBackground(color);
+	}
+	
+	public void resetFields(){
+		colorPanel.setBackground(Color.WHITE);
+		redField.setText("");
+		greenField.setText("");
+		blueField.setText("");
+		//graphNrTxtField.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);
+	}
+	
+	private static void addPopup(Component component, final JPopupMenu popup) {
+		component.addMouseListener(new MouseAdapter() {
+			public void mousePressed(MouseEvent e) {
+				if (e.isPopupTrigger()) {
+					showMenu(e);
+				}
+			}
+			public void mouseReleased(MouseEvent e) {
+				if (e.isPopupTrigger()) {
+					showMenu(e);
+				}
+			}
+			private void showMenu(MouseEvent e) {
+				popup.show(e.getComponent(), e.getX(), e.getY());
+			}
+		});
+	}
 }