Browse Source

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

Kevin Trometer 8 years ago
parent
commit
8b8399429a

+ 31 - 19
src/classes/CpsEdge.java

@@ -5,11 +5,15 @@ public class CpsEdge {
 	float maxCapacity;
 	float flow;
 	boolean isWorking;
-	
+	//State represents the real status of the edge
+	//If it breaks --> stay ruin no matter the actual scenario
+	//The only way to repair it is through manual change (setStateEdge) 
+	boolean state = true;
+
 	CpsObject A;
 	CpsObject B;
 
-	public CpsEdge(CpsObject A, CpsObject B){
+	public CpsEdge(CpsObject A, CpsObject B) {
 		setA(A);
 		setB(B);
 		this.A.AddConnection(this);
@@ -18,8 +22,8 @@ public class CpsEdge {
 		flow = 0;
 		isWorking = true;
 	}
-	
-	public CpsEdge(CpsObject A, CpsObject B, float maxCap){
+
+	public CpsEdge(CpsObject A, CpsObject B, float maxCap) {
 		setA(A);
 		setB(B);
 		this.A.AddConnection(this);
@@ -28,8 +32,7 @@ public class CpsEdge {
 		flow = 0;
 		isWorking = true;
 	}
-	
-	
+
 	/**
 	 * @return the capacity
 	 */
@@ -38,7 +41,8 @@ public class CpsEdge {
 	}
 
 	/**
-	 * @param cap the Capacity to set
+	 * @param cap
+	 *            the Capacity to set
 	 */
 	public void setCapacity(float cap) {
 		this.maxCapacity = cap;
@@ -51,18 +55,28 @@ public class CpsEdge {
 		return flow;
 	}
 
+	public boolean getStateEdge() {
+		return state;
+	}
+
 	/**
-	 * @param flow the flow to set
+	 * @param flow
+	 *            the flow to set
 	 */
 	public void setFlow(float flow) {
 		this.flow = flow;
-		if(flow <= maxCapacity || flow == -1){
+		if (flow <= maxCapacity || flow == -1) {
 			isWorking = true;
-		}else{
+		} else {
 			isWorking = false;
+			state = false;
 		}
 	}
-	
+
+	public void setState(boolean isActive) {
+		state = isActive;
+	}
+
 	/**
 	 * @return the a
 	 */
@@ -70,15 +84,14 @@ public class CpsEdge {
 		return A;
 	}
 
-
 	/**
-	 * @param a the a to set
+	 * @param a
+	 *            the a to set
 	 */
 	public void setA(CpsObject a) {
 		A = a;
 	}
 
-
 	/**
 	 * @return the b
 	 */
@@ -86,17 +99,16 @@ public class CpsEdge {
 		return B;
 	}
 
-
 	/**
-	 * @param b the b to set
+	 * @param b
+	 *            the b to set
 	 */
 	public void setB(CpsObject b) {
 		B = b;
 	}
-	
-	public boolean getState(){
+
+	public boolean getState() {
 		return isWorking;
 	}
-	
 
 }

+ 25 - 10
src/classes/HolonElement.java

@@ -2,6 +2,7 @@ package classes;
 
 import java.awt.Point;
 import java.util.LinkedList;
+import ui.model.idCounterElem;
 
 public class HolonElement {
 
@@ -19,16 +20,17 @@ public class HolonElement {
 	String image;
 	/* +: for Consumers and -: Producers */
 	char sign;
-	/* Place where the Object is Stored*/
+	/* Place where the Object is Stored */
 	String sav;
-	/* Object where the Element is Stored*/
+	/* Object where the Element is Stored */
 	String obj;
+	int id;
 	/*
 	 * Energy at each point of the graph with 100 predefined points. At the
 	 * beginning, it starts with all values at energy
 	 */
 	float[] energyAt = new float[100];
-	//Points on the UnitGraph
+	// Points on the UnitGraph
 	LinkedList<Point> graphPoints = new LinkedList<>();
 
 	public HolonElement(String eleName, int amount, float energy) {
@@ -38,6 +40,7 @@ public class HolonElement {
 		setActive(true);
 		setSign(energy);
 		setEnergyAt(energy);
+		setId(idCounterElem.nextId());
 	}
 
 	public HolonElement(HolonElement element) {
@@ -49,6 +52,7 @@ public class HolonElement {
 		setEnergyAt(element.getEnergy());
 		setSav("CVS");
 		setObj(element.getObj());
+		setId(idCounterElem.nextId());
 	}
 
 	/**
@@ -59,7 +63,8 @@ public class HolonElement {
 	}
 
 	/**
-	 * @param energy, the value
+	 * @param energy,
+	 *            the value
 	 */
 	public void setEnergyAt(float energy) {
 		for (int i = 0; i < energyAt.length; i++) {
@@ -157,8 +162,8 @@ public class HolonElement {
 		totalEnergy = ((float) amount) * energy;
 		return totalEnergy;
 	}
-	
-	public float getTotalEnergyAtTimeStep(int x){
+
+	public float getTotalEnergyAtTimeStep(int x) {
 		float result = ((float) amount) * energyAt[x];
 		return result;
 	}
@@ -189,7 +194,8 @@ public class HolonElement {
 	}
 
 	/**
-	 * @param stored the stored to set
+	 * @param stored
+	 *            the stored to set
 	 */
 	public void setSav(String sav) {
 		this.sav = sav;
@@ -203,12 +209,13 @@ public class HolonElement {
 	}
 
 	/**
-	 * @param obj the obj to set
+	 * @param obj
+	 *            the obj to set
 	 */
 	public void setObj(String obj) {
 		this.obj = obj;
 	}
-	
+
 	/**
 	 * @return the Graph Points
 	 */
@@ -217,10 +224,18 @@ public class HolonElement {
 	}
 
 	/**
-	 * @param points, the Graph points
+	 * @param points,
+	 *            the Graph points
 	 */
 	public void setGraphPoints(LinkedList<Point> points) {
 		this.graphPoints = points;
 	}
 
+	private void setId(int id) {
+		this.id = id;
+	}
+
+	public int getId() {
+		return id;
+	}
 }

+ 64 - 1
src/classes/HolonObject.java

@@ -1,5 +1,6 @@
 package classes;
 
+import java.awt.Color;
 import java.util.ArrayList;
 import java.util.HashMap;
 
@@ -7,7 +8,8 @@ import ui.controller.MultiPurposeController;
 import ui.model.idCounter;
 
 public class HolonObject extends CpsObject {
-
+	
+	private Color stateColor;
 	/* Array of all consumers */
 	private ArrayList<HolonElement> elements;
 	/* Array of all Indices of Elements */
@@ -53,9 +55,11 @@ public class HolonObject extends CpsObject {
 	public void setState() {
 		if (getCurrentEnergy() > 0) {
 			setState(3);
+			stateColor = Color.lightGray;
 		} else {
 			if (getCurrentEnergy() == 0) {
 				setState(0);
+				stateColor = Color.WHITE;
 			}
 		}
 	}
@@ -180,6 +184,21 @@ public class HolonObject extends CpsObject {
 	 */
 	public void setState(int st) {
 		this.state = st;
+		switch(st){
+			case 0: stateColor = Color.WHITE;
+					break;
+			
+			case 1: stateColor = new Color(230,120,100);
+					break;
+					
+			case 2: stateColor = Color.GREEN;
+					break;
+			
+			case 3: stateColor = Color.lightGray;
+					break;
+			
+			case 4: stateColor = Color.YELLOW;
+		}
 	}
 
 	public HolonElement searchElement(String name) {
@@ -191,4 +210,48 @@ public class HolonObject extends CpsObject {
 		}
 		return ele;
 	}
+
+	public HolonElement searchElementById(int id) {
+		HolonElement ele = null;
+		for (HolonElement e : getElements()) {
+			if (e.getId() == id) {
+				ele = e;
+			}
+		}
+		return ele;
+	}
+
+	public boolean checkIfPartiallySupplied(int x) {
+		if (getElements().size() == 0) {
+			return false;
+		}
+		float minConsum = getElements().get(0).getTotalEnergyAtTimeStep(x);
+		float prod = 0;
+		for (HolonElement e : getElements()) {
+			if (e.getActive()) {
+				if (e.getTotalEnergyAtTimeStep(x) > 0) {
+					prod = prod + e.getTotalEnergyAtTimeStep(x);
+				}
+				if (minConsum < 0 && (e.getTotalEnergyAtTimeStep(x) > minConsum && e.getTotalEnergyAtTimeStep(x) < 0)) {
+					minConsum = e.getTotalEnergyAtTimeStep(x);
+				} else if (minConsum >= 0 && e.getTotalEnergyAtTimeStep(x) < minConsum) {
+					minConsum = e.getTotalEnergyAtTimeStep(x);
+				}
+			}
+		}
+//		System.out.println("minCons: " + minConsum + " prod: " + prod);
+		if (minConsum < 0 && prod >= -minConsum) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	
+	public void setColor(Color color){
+		stateColor = color;
+	}
+	
+	public Color getColor(){
+		return stateColor;
+	}
 }

+ 13 - 0
src/classes/HolonSwitch.java

@@ -9,6 +9,11 @@ public class HolonSwitch extends CpsObject {
 	 * false
 	 */
 	boolean active;
+	
+	/*
+	 * true if switch has to be used manually
+	 */
+	boolean manualMode;
 
 	/*
 	 * Energy at each point of the graph with 50 predefined points. At the
@@ -91,4 +96,12 @@ public class HolonSwitch extends CpsObject {
 			this.activeAt[i] = active;
 		}
 	}
+	
+	public void setManualMode(boolean mode){
+		manualMode = mode;
+	}
+	
+	public boolean getManualMode(){
+		return manualMode;
+	}
 }

+ 11 - 2
src/ui/controller/Control.java

@@ -171,8 +171,8 @@ public class Control {
 		objectController.addNewElementIntoCategoryObject(catName, objName, eleName, amount, energy);
 	}
 
-	public void deleteElementCanvas(int id, String element) {
-		objectController.deleteElementInCanvas(id, element);
+	public void deleteElementCanvas(int id, int elementId) {
+		objectController.deleteElementInCanvas(id, elementId);
 	}
 
 	public void deleteElementCanvas(HolonObject obj, HolonElement ele) {
@@ -214,6 +214,11 @@ public class Control {
 		categoryController.addCategoryListener(catLis);
 	}
 
+	public void calculateStateForCurrentTimeStep() {
+		simulationManager.reset();
+		simulationManager.calculateStateForTimeStep(MODEL.getCurIteration());
+	}
+
 	public void calculateStateForTimeStep(int x) {
 		simulationManager.reset();
 		simulationManager.calculateStateForTimeStep(x);
@@ -280,4 +285,8 @@ public class Control {
 		return MODEL;
 	}
 
+	public SimulationManager getSimManager() {
+		return simulationManager;
+	}
+
 }

+ 9 - 4
src/ui/controller/MultiPurposeController.java

@@ -86,16 +86,21 @@ public class MultiPurposeController {
 			return object.getElements().get(idx);
 	}
 
+	public HolonElement searchEleById(HolonObject object, int idEle) {
+		return object.searchElementById(idEle);
+	}
+
 	public CpsEdge searchEdge(int a, int b) {
 
 		CpsObject A = searchByID(a);
 		CpsObject B = searchByID(b);
 
 		for (CpsEdge edge : MODEL.getEdgesOnCanvas()) {
-//			if (edge.getA().getObjName().equals(A.getObjName()) && (edge.getB().getObjName().equals(B.getObjName()))
-//					|| edge.getB().getObjName().equals(A.getObjName())
-//							&& (edge.getA().getObjName().equals(B.getObjName())))
-			if( (edge.getA().equals(A) && edge.getB().equals(B)) || (edge.getB().equals(A)) && edge.getA().equals(B))
+			// if (edge.getA().getObjName().equals(A.getObjName()) &&
+			// (edge.getB().getObjName().equals(B.getObjName()))
+			// || edge.getB().getObjName().equals(A.getObjName())
+			// && (edge.getA().getObjName().equals(B.getObjName())))
+			if ((edge.getA().equals(A) && edge.getB().equals(B)) || (edge.getB().equals(A)) && edge.getA().equals(B))
 				return edge;
 		}
 		return null;

+ 8 - 6
src/ui/controller/ObjectController.java

@@ -102,7 +102,7 @@ public class ObjectController {
 	 * @param ele
 	 */
 	public void deleteElement(HolonObject obj, HolonElement ele) {
-
+		System.out.println(ele.getEleName() + " and " + obj.getEleIdx());
 		mpC.decIdx(ele.getEleName(), obj.getEleIdx());
 		obj.getEleIdx().remove(ele.getEleName());
 		obj.getElements().remove(ele);
@@ -133,10 +133,11 @@ public class ObjectController {
 	 * @param ele
 	 * @param amount
 	 */
-	public void deleteElementInCanvas(int ID, String ele) {
+	public void deleteElementInCanvas(int ID, int eleId) {
 		HolonObject object = (HolonObject) mpC.searchByID(ID);
-		HolonElement element = mpC.searchEle(object, ele);
-
+		HolonElement element = mpC.searchEleById(object, eleId);
+		// mpC.searchEle(object, ele);
+		System.out.println(object.getName() + " and " + element.getEleName());
 		deleteElement(object, element);
 	}
 
@@ -164,11 +165,12 @@ public class ObjectController {
 	public void setSelectedObjectID(int id) {
 		MODEL.setSelectedObjectID(id);
 	}
-	
+
 	/**
 	 * sets clipBoardObjects
 	 * 
-	 * @param ArrayList of CpsObjects
+	 * @param ArrayList
+	 *            of CpsObjects
 	 */
 	public void setClipboardObjects(ArrayList<CpsObject> list) {
 		MODEL.setClipboradObjects(list);

+ 31 - 25
src/ui/controller/SimulationManager.java

@@ -15,6 +15,7 @@ import ui.view.MyCanvas;
 public class SimulationManager {
 	private Model model;
 	private ArrayList<CpsObject> objectsToHandle;
+	private ArrayList<CpsEdge> allConnections;
 	private ArrayList<subNet> subNets;
 	private MyCanvas canvas;
 	private int timeStep;
@@ -34,62 +35,67 @@ public class SimulationManager {
 		timeStep = x;
 		searchForSubNets();
 		for(subNet singleSubNet: subNets){
-			float production = calculateEnergy("prod", singleSubNet, x);
-			float consumption = calculateEnergy("cons", singleSubNet, x);
-			float minConsumption = calculateMinimumEnergy( singleSubNet, x);
-			for(CpsEdge e: singleSubNet.getEdges()){
-				e.setFlow(0);
-			}
+			ResetConnections(singleSubNet.getObjects().get(0), new ArrayList<Integer>(), new ArrayList<CpsEdge>());
+		}
+		for(subNet singleSubNet: subNets){
+			float production = calculateEnergy("prod", singleSubNet, timeStep);
+			float consumption = calculateEnergy("cons", singleSubNet, timeStep);
+			float minConsumption = calculateMinimumEnergy( singleSubNet, timeStep);
 			setFlow(singleSubNet);
 			for(HolonObject hl: singleSubNet.getObjects()){
 				if(!(hl.getState() == 0) && !(hl.getState() == 3)){
 					for(int i = 0; i < hl.getConnections().size(); i++){
 						CpsEdge edge = hl.getConnectedTo().get(i);
-						if(edge.getState() && edge.getFlow() > 0){
-							// 0 = no energy, 1 = not supplied, 2 = supplied
+						if(edge.getState() && edge.getFlow() > 0 || edge.getCapacity() == -1){
+							// 0 = no energy, 1 = not supplied, 2 = supplied, 3 = producer, 4 = partially supplied
 							if((production + consumption) >= 0){
 								hl.setState(2);
 							}
-							if((production + consumption) < 0){
+							if((production + consumption) < 0 ){
 								if((production + minConsumption) >= 0){
 									hl.setState(4);
-								}else{
+								}else if(hl.checkIfPartiallySupplied(timeStep)){
+									hl.setState(4);
+								}else {
 									hl.setState(1);
 								}
 							}
 							break;
 						}
-						hl.setState(1);
+							hl.setState(1);
+					}
+					if(hl.checkIfPartiallySupplied(timeStep) && !(hl.getState() == 2)){
+						hl.setState(4);
 					}
 				}
 			}
 		}
-		//printNet();
 		canvas.repaint();
 	}
 	
 	public void setFlow(subNet sN){
 		for(HolonObject hl: sN.getObjects()){
-			if(hl.getCurrentEnergyAtTimeStep(timeStep) > 0){
-				fillConnectionsFor(hl, new ArrayList<Integer>(), new ArrayList<CpsEdge>(), hl.getCurrentEnergyAtTimeStep(timeStep));
+			float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
+			if(energy > 0){
+				for(CpsEdge e : sN.getEdges()){
+					e.setFlow(e.getFlow() + energy);
+				}
 			}
 		}
 	}
 	
-	public void fillConnectionsFor(CpsObject cps, ArrayList<Integer> visitedObj, ArrayList<CpsEdge> visitedEdges ,float energy ){
+	public void ResetConnections(CpsObject cps, ArrayList<Integer> visitedObj, ArrayList<CpsEdge> visitedEdges){
 		visitedObj.add(cps.getID());
 		for(CpsEdge e: cps.getConnections()){
 			if(!(visitedEdges.contains(e))){
-				e.setFlow(e.getFlow() + energy);
-				if(e.getState()){
-					visitedEdges.add(e);
-					if(!(visitedObj.contains(e.getA().getID()))){
-					fillConnectionsFor(e.getA(), visitedObj, visitedEdges, energy);
-					}
-					if(!(visitedObj.contains(e.getB().getID()))){
-						fillConnectionsFor(e.getB(), visitedObj, visitedEdges, energy);
-					}
-			}
+				e.setFlow(0);
+				visitedEdges.add(e);
+				if(!(visitedObj.contains(e.getA().getID()))){
+					ResetConnections(e.getA(), visitedObj, visitedEdges);
+				}
+				if(!(visitedObj.contains(e.getB().getID()))){
+					ResetConnections(e.getB(), visitedObj, visitedEdges);
+				}
 			}
 		}
 	}

+ 26 - 0
src/ui/model/idCounterElem.java

@@ -0,0 +1,26 @@
+package ui.model;
+
+public class idCounterElem {
+	private static int counter = 1;
+
+
+	public static synchronized int nextId() {
+		return counter++;
+
+	}
+	
+	/**
+	 * @return the counter
+	 */
+	public static int getCounter() {
+		return counter;
+	}
+
+	/**
+	 * @param counter the counter to set
+	 */
+	public static void setCounter(int counter) {
+		idCounterElem.counter = counter;
+	}
+
+}

+ 3 - 2
src/ui/view/EditEdgesPopUp.java

@@ -131,8 +131,7 @@ public class EditEdgesPopUp extends JDialog{
 						JOptionPane.showMessageDialog(new JFrame(),
 							"Please enter a number greater or equal 0 in the Field for Maximum Capacity");
 					}
-				}
-			}
+				}			}
 		});
 		btnOk_1.setBounds(186, 147, 89, 23);
 		contentPanel.add(btnOk_1);
@@ -162,10 +161,12 @@ public class EditEdgesPopUp extends JDialog{
 		for(CpsEdge edge : controller.getModel().getEdgesOnCanvas()){
 			edge.setCapacity(cap);
 		}
+		controller.calculateStateForCurrentTimeStep();
 		canvas.repaint();
 	}
 	public void changeForExAndNew(float cap){
 		changeForNew(cap);
 		changeForExisting(cap);
 	}
+
 }

+ 223 - 137
src/ui/view/GUI.java

@@ -6,6 +6,7 @@ import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Dimension;
 import java.awt.Image;
+import java.awt.MouseInfo;
 import java.awt.Point;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
@@ -13,6 +14,7 @@ import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.io.File;
@@ -55,11 +57,14 @@ import javax.swing.border.LineBorder;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.filechooser.FileNameExtensionFilter;
+import javax.swing.plaf.FileChooserUI;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeCellRenderer;
 
+import com.sun.corba.se.spi.orbutil.fsm.Action;
+
 import Interfaces.CategoryListener;
 import classes.Category;
 import classes.CpsEdge;
@@ -68,8 +73,11 @@ import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonTransformer;
+import classes.Position;
 import ui.controller.Control;
-import ui.model.Model;;
+import ui.model.Model;
+import javax.swing.JList;
+import javax.swing.Box;;
 
 public class GUI<E> implements CategoryListener {
 
@@ -90,7 +98,7 @@ public class GUI<E> implements CategoryListener {
 	private final JSplitPane splitPane_1 = new JSplitPane();
 	private final JScrollPane scrollPane_1 = new JScrollPane();
 	private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
-	private final JScrollPane scrollPane_2 = new JScrollPane();
+	private final JScrollPane SimulationPane = new JScrollPane();
 	private JPopupMenu popmenuEdit = new JPopupMenu();
 	private JMenuItem editItem = new JMenuItem("Edit Object");
 	private String catOfObjToBeEdited;
@@ -102,7 +110,6 @@ public class GUI<E> implements CategoryListener {
 	private final ArrayList<HolonElement> selectedElements = new ArrayList<HolonElement>();
 	private String holonEleNamesDisplayed = "None ";
 	HashMap<Integer, ArrayList<HolonElement>> eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
-
 	private final JTree tree = new JTree();
 	private final JEditorPane dtrpnHereWillBe = new JEditorPane();
 	/******************************************
@@ -117,7 +124,9 @@ public class GUI<E> implements CategoryListener {
 	// In this section are all the Holonelements that correspond to the clicked
 	// HolonObject with consumption/production, name and amount.
 
+	// Table for HolonElements --> all cells are editable
 	private JTable tableHolonElement = new JTable();
+	// Model for single or multi selection
 	private PropertyTable tableModelHolonElementMulti = new PropertyTable();
 	private PropertyTable tableModelHolonElementSingle = new PropertyTable();
 	private final JPanel scrollElements = new JPanel();
@@ -125,7 +134,8 @@ public class GUI<E> implements CategoryListener {
 
 	// In this section are all the properties that correspond to the clicked
 	// HolonObject, such as connections, name, Type, etc.
-
+	// Table for Properties --> Cell with (0,1) is editable by CpsObjt and
+	// Cell(3,1) is editable by Edges
 	private JTable tableProperties = new JTable();
 	private JPanel graphLabel = new JPanel();
 	private DefaulTable tableModelProperties;
@@ -133,7 +143,6 @@ public class GUI<E> implements CategoryListener {
 
 	// In this section is the graph for the selected HolonElement of the clicked
 	// HolonObject
-
 	private JTable tableGraph = new JTable();
 	private DefaultTableModel tableModelGraph = new DefaultTableModel();
 	private final JScrollPane scrollGraph = new JScrollPane();
@@ -167,7 +176,6 @@ public class GUI<E> implements CategoryListener {
 	private String actualObjectClicked;
 	private Image img = null;
 	private CpsObject tempCps = null;
-	private HolonElement tempElement = null;
 	private int yValueElements = 0;
 
 	private MyCanvas canvas;
@@ -179,11 +187,11 @@ public class GUI<E> implements CategoryListener {
 	private TimePanel timePanel;
 	private final JMenu mnAlgorithm = new JMenu("Algorithm");
 	private final JCheckBoxMenuItem chckbxmntmUseAlgorithm = new JCheckBoxMenuItem("Use Algorithm");
-	private final JSplitPane splitPane_2 = new JSplitPane();
-	private final JLabel lblSelect = new JLabel("Select");
 	private final JComboBox comboBoxAlgo = new JComboBox();
+	// Coord for all Cells with text
 	private int yTHIS;
 	private int xTHIS;
+	// Coord for all Cells with boolean values (checkbox)
 	private int yBTHIS;
 	private int xBTHIS;
 	private CpsObject temp = null;
@@ -194,6 +202,10 @@ public class GUI<E> implements CategoryListener {
 	private final JMenuItem mntmFindReplace = new JMenuItem("Find/ Replace");
 	private final JMenuItem mntmEditShowedInformation = new JMenuItem("Edit showed Information");
 	private final JMenuItem mntmResetCategory = new JMenuItem("Reset Categories");
+	private final JMenuItem mntmSetFolder = new JMenuItem("Set Folder");
+	private final JMenu mnSimulationSpeed = new JMenu("Simulation Speed");
+	private final JTextField simulationSpeedField = new JTextField();
+	private final JButton btnApply = new JButton("Apply");
 
 	/**
 	 * Create the application.
@@ -214,6 +226,7 @@ public class GUI<E> implements CategoryListener {
 	 */
 	@SuppressWarnings({ "serial", "unchecked" })
 	private void initialize() {
+		simulationSpeedField.setColumns(10);
 		frmCyberPhysical = new JFrame();
 		frmCyberPhysical.setTitle("Cyber Physical Systems Model");
 		frmCyberPhysical.setBounds(100, 100, 1000, 800);
@@ -321,17 +334,15 @@ public class GUI<E> implements CategoryListener {
 					controller.delCanvasObject(cps);
 				}
 				model.getSelectedCpsObjects().clear();
-				/* controller.setSelectedObjectID(0);
-				for (int i = tableModelHolonElementMulti.getRowCount() - 1; i > -1; i--) {
-					tableModelHolonElementMulti.removeRow(i);
-				}
-				for (int i = tableModelHolonElementSingle.getRowCount() - 1; i > -1; i--) {
-					tableModelHolonElementSingle.removeRow(i);
-				}
-				for (int i = tableModelProperties.getRowCount() - 1; i > -1; i--) {
-					tableModelProperties.removeRow(i);
-				}
-				*/
+				/*
+				 * controller.setSelectedObjectID(0); for (int i =
+				 * tableModelHolonElementMulti.getRowCount() - 1; i > -1; i--) {
+				 * tableModelHolonElementMulti.removeRow(i); } for (int i =
+				 * tableModelHolonElementSingle.getRowCount() - 1; i > -1; i--)
+				 * { tableModelHolonElementSingle.removeRow(i); } for (int i =
+				 * tableModelProperties.getRowCount() - 1; i > -1; i--) {
+				 * tableModelProperties.removeRow(i); }
+				 */
 				canvas.repaint();
 				unitGraph.empty();
 			}
@@ -440,6 +451,10 @@ public class GUI<E> implements CategoryListener {
 		mnNewMenu_2.add(mntmEditEdges);
 
 		mnNewMenu_2.add(mntmResetCategory);
+
+		mnNewMenu_2.add(mnSimulationSpeed);
+
+		mnSimulationSpeed.add(simulationSpeedField);
 		mntmResetCategory.addActionListener(new ActionListener() {
 
 			@Override
@@ -495,13 +510,9 @@ public class GUI<E> implements CategoryListener {
 
 		menuBar.add(mnAlgorithm);
 
-		mnAlgorithm.add(chckbxmntmUseAlgorithm);
-
-		mnAlgorithm.add(splitPane_2);
+		mnAlgorithm.add(mntmSetFolder);
 
-		splitPane_2.setLeftComponent(lblSelect);
-
-		splitPane_2.setRightComponent(comboBoxAlgo);
+		mnAlgorithm.add(chckbxmntmUseAlgorithm);
 
 		canvas.setBackground(Color.WHITE);
 		canvas.setPreferredSize(new Dimension(1000, 1000));
@@ -514,21 +525,22 @@ public class GUI<E> implements CategoryListener {
 		tabbedPane.addTab("Simulation",
 				new ImageIcon(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
 						.getScaledInstance(30, 30, Image.SCALE_SMOOTH)),
-				scrollPane_2, "Simulate the CPS");
+				SimulationPane, "Simulate the CPS");
 		dtrpnHereWillBe.setText("Here will be the Simulation");
 
-		scrollPane_2.setViewportView(dtrpnHereWillBe);
+		SimulationPane.setViewportView(dtrpnHereWillBe);
 
 		/********************
 		 * RIGHT CONTAINER (INFORMATION)
 		 **********************/
 		// Set up of the HolonElements section
-		Object[] columnNamesMulti = { "Object", "Device", "Energy", "Quantity", "Activated" };
+		// Two different Models: Multi for multi-selection mode and Single for
+		// single-selection mode (CPS-Object)
+		Object[] columnNamesMulti = { "Object", "Nr.", "Device", "Energy", "Quantity", "Activated" };
 		tableModelHolonElementMulti.setColumnIdentifiers(columnNamesMulti);
-		Object[] columnNamesSingle = { "Device", "Energy", "Quantity", "Activated" };
+		Object[] columnNamesSingle = { "Nr.", "Device", "Energy", "Quantity", "Activated" };
 		tableModelHolonElementSingle.setColumnIdentifiers(columnNamesSingle);
 		tableHolonElement.setBorder(null);
-
 		tableHolonElement.setFillsViewportHeight(true);
 		tableHolonElement.setCellSelectionEnabled(true);
 		tableHolonElement.setColumnSelectionAllowed(true);
@@ -544,7 +556,7 @@ public class GUI<E> implements CategoryListener {
 
 		// Set up of the Properties section
 		Object[] colNames = { "Field", "Information" };
-		tableModelProperties = new DefaulTable(100, colNames.length);
+		tableModelProperties = new DefaulTable(1000, colNames.length);
 		tableModelProperties.setColumnIdentifiers(colNames);
 		tableProperties.setModel(tableModelProperties);
 		tableProperties.setFillsViewportHeight(true);
@@ -553,8 +565,6 @@ public class GUI<E> implements CategoryListener {
 		scrollProperties.setViewportView(tableProperties);
 
 		// Set up of the Graph section
-		Object[] tempText = { "Here comes the graph for each clicked HolonElement" };
-		tableModelGraph.setColumnIdentifiers(tempText);
 		tableGraph.setModel(tableModelGraph);
 		tableGraph.setFillsViewportHeight(true);
 		tableGraph.setCellSelectionEnabled(true);
@@ -596,25 +606,29 @@ public class GUI<E> implements CategoryListener {
 			}
 		});
 		/*
-		 * Delete the choosen HolonElement of the selected HolonObject
+		 * Delete the chosen HolonElement of the selected HolonObject,
+		 * Multi-Selection for CpsObjects as well as for HolonElements possible
 		 */
 		btnDelHolEL.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {
+				// For Single Selection of CpsObject
 				if (model.getSelectedCpsObjects().size() == 1) {
 					if (getActualCps().getClass() == HolonObject.class) {
 						HolonObject obj = (HolonObject) getActualCps();
 						for (HolonElement e : selectedElements) {
-							controller.deleteElementCanvas(obj.getID(), e.getEleName());
+							controller.deleteElementCanvas(obj.getID(), e.getId());
 							refreshTableHolonElement();
 							refreshTableProperties();
 							controller.calculateStateForTimeStep(model.getCurIteration());
 							// Names displayed in graph are not updated
 						}
+						selectedElements.clear();
 					}
+					// For MultiSelection of CpsObject
 				} else if (model.getSelectedCpsObjects().size() > 1) {
 					for (Integer i : eleToDelete.keySet()) {
 						for (HolonElement e : eleToDelete.get(i)) {
-							controller.deleteElementCanvas(i, e.getEleName());
+							controller.deleteElementCanvas(i, e.getId());
 						}
 					}
 					refreshTableHolonElement();
@@ -623,18 +637,22 @@ public class GUI<E> implements CategoryListener {
 			}
 		});
 		/*
-		 * Communication between HolonElement Table and displayed Graph
+		 * Communication between HolonElement Table and displayed Graph and
+		 * Properties, as well as selection of differet HolonElements
 		 */
 		tableHolonElement.addMouseListener(new MouseAdapter() {
 			public void mousePressed(MouseEvent e) {
 				HolonObject obj = (HolonObject) getActualCps();
 				yValueElements = e.getY();
 				HolonElement ele = null;
+				// Search for current clicked HolonElement
 				if (model.getSelectedCpsObjects().size() == 1) {
 					ele = getActualHolonElement(obj, yValueElements, 0);
 				} else {
 					ele = getActualHolonElement(null, yValueElements, 0);
 				}
+				// Multi-Selection of HolonElements through control button +
+				// mouse click
 				if (e.isControlDown() && ele != null) {
 					if (!selectedElements.contains(ele)) {
 						selectedElements.add(ele);
@@ -646,34 +664,29 @@ public class GUI<E> implements CategoryListener {
 						unitGraph.repaintWithNewElement(selectedElements);
 					}
 					getActualHolonElement(null, yValueElements, 2);
-				} else if (ele != null) {
+				} // if no control-button pressed but a HolonElement choose
+				else if (ele != null) {
 					selectedElements.clear();
 					selectedElements.add(ele);
 					getActualHolonElement(null, yValueElements, 1);
 					holonEleNamesDisplayed = ele.getEleName() + " ";
 					unitGraph.repaintWithNewElement(selectedElements);
-				} else {
+				} // If any empty space is clicked
+				else {
 					elementGraph.setText("None ");
 					unitGraph.empty();
 				}
-				// if any HolonElement is double-clicked --> Edit instance of
-				// selected HolonElement
+				// if any HolonElement is double-clicked --> Edit-Mode started
+				// for selected HolonElement
 				if (e.getClickCount() == 2) {
 					yTHIS = e.getY();
 					xTHIS = e.getX();
 				}
+				// for single click and empty slot
 				if (e.getClickCount() == 1 && ele == null) {
 					selectedElements.clear();
 					holonEleNamesDisplayed = "None ";
 				}
-				// for (int i = 0; i < selectedElements.size(); i++) {
-				// if (i == 0) {
-				// System.out.println("Selected Items: " +
-				// selectedElements.get(i).getEleName());
-				// } else {
-				// System.out.println(selectedElements.get(i).getEleName());
-				// }
-				// }
 				elementGraph.setText(holonEleNamesDisplayed);
 				yBTHIS = e.getY();
 				xBTHIS = e.getX();
@@ -682,8 +695,7 @@ public class GUI<E> implements CategoryListener {
 		});
 
 		/*
-		 * If the HolonElement Table enters to editing instance, than is the
-		 * propertyChangeListener triggered
+		 * Triggered every time a change is made
 		 */
 		tableHolonElement.addPropertyChangeListener(new PropertyChangeListener() {
 			@Override
@@ -693,57 +705,65 @@ public class GUI<E> implements CategoryListener {
 					int yBMouse = yBTHIS;
 					int selectedValueY = (int) Math.floor(yMouse / 16);
 					int selectedValueBY = (int) Math.floor(yBMouse / 16);
+					// for multi-selection mode
 					if (model.getSelectedCpsObjects().size() > 1) {
-						// Multiple Selection
-						int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 5));
-						int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 5));
+						int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 6));
+						int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 6));
 						if (getHolonObj(yMouse) != null) {
-							if (selectedValueBX == 4) {
+							// For last column (boolean with a checkbox)
+							if (selectedValueBX == 5) {
 								HolonElement eleBTemp = getActualHolonElement(null, yBMouse, 0);
 								String newBStuff = tableModelHolonElementMulti
 										.getValueAt(selectedValueBY, selectedValueBX).toString();
 								Boolean bTemp = Boolean.parseBoolean(newBStuff);
 								eleBTemp.setActive(bTemp);
 							} else {
+								// Update of HolonElement
 								HolonElement eleTemp = getActualHolonElement(null, yMouse, 0);
 								String newStuff = tableModelHolonElementMulti.getValueAt(selectedValueY, selectedValueX)
 										.toString();
-								// Small bug, when it comes to edit the name of
-								// the HolonElement
-								if (selectedValueX == 1) {
+								// Name update
+								if (selectedValueX == 2) {
 									eleTemp.setEleName(newStuff);
-								} else if (selectedValueX == 2) {
+								}
+								// Energy Update
+								else if (selectedValueX == 3) {
 									Float ftemp = Float.parseFloat(newStuff);
 									eleTemp.setEnergy(ftemp);
-								} else if (selectedValueX == 3) {
+								}
+								// Amount of Elements update
+								else if (selectedValueX == 4) {
 									Integer iTemp = Integer.parseInt(newStuff);
 									eleTemp.setAmount(iTemp);
 								}
 							}
 						}
-					} else if (model.getSelectedCpsObjects().size() == 1) {
-						// Single Selection
-						int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 4));
-						int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 4));
+					} // For single-selection mode
+					else if (model.getSelectedCpsObjects().size() == 1) {
+						int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 5));
+						int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 5));
 						if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
-							if (selectedValueBX == 3) {
+							// For last column (boolean with a checkbox)
+							if (selectedValueBX == 4) {
 								HolonElement eleBTemp = getActualHolonElement((HolonObject) getActualCps(), yBMouse, 0);
 								String newBStuff = tableModelHolonElementSingle
 										.getValueAt(selectedValueBY, selectedValueBX).toString();
 								Boolean bTemp = Boolean.parseBoolean(newBStuff);
 								eleBTemp.setActive(bTemp);
 							} else {
+								// Update of HolonElement
 								HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse, 0);
 								String newStuff = tableModelHolonElementSingle
 										.getValueAt(selectedValueY, selectedValueX).toString();
-								// Small bug, when it comes to edit the name of
-								// the HolonElement
-								if (selectedValueX == 0) {
+								// Name update
+								if (selectedValueX == 1) {
 									eleTemp.setEleName(newStuff);
-								} else if (selectedValueX == 1) {
+								} // Energy Update
+								else if (selectedValueX == 2) {
 									Float ftemp = Float.parseFloat(newStuff);
 									eleTemp.setEnergy(ftemp);
-								} else if (selectedValueX == 2) {
+								} // Amount of Elements update
+								else if (selectedValueX == 3) {
 									Integer iTemp = Integer.parseInt(newStuff);
 									eleTemp.setAmount(iTemp);
 								}
@@ -763,9 +783,7 @@ public class GUI<E> implements CategoryListener {
 		 * HolonElement Properties Actions
 		 **********************/
 		/*
-		 * If any value at the Properties Table enters to editing instance, than
-		 * is PropertyChangeListener triggered (For HolonObject, the only value
-		 * to be edited is the name and for CpsEdge the Max.flow)
+		 * Update any change in the Property table
 		 */
 		tableProperties.addPropertyChangeListener(new PropertyChangeListener() {
 
@@ -777,13 +795,23 @@ public class GUI<E> implements CategoryListener {
 						if (getActualCps() instanceof HolonObject) {
 							temp = tableModelProperties.getValueAt(0, 1);
 							getActualCps().setName(temp.toString());
-						} else if (getActualCps() instanceof HolonTransformer) {
-							// get Info of the Properties for Transformer
 						}
 					} else {
-						temp = tableModelProperties.getValueAt(2, 1);
-						Float ftemp = Float.parseFloat(temp.toString());
-						model.getSelectedEdge().setCapacity(ftemp);
+						Point mousePos = tableProperties.getMousePosition();
+						temp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
+								mousePos.x / (tableProperties.getWidth() / 2));
+						if (mousePos.y / tableProperties.getRowHeight() == 2) {
+							Float ftemp;
+							if (Float.parseFloat(temp.toString()) >= 0.0) {
+								ftemp = Float.parseFloat(temp.toString());
+							} else {
+								ftemp = model.getSelectedEdge().getCapacity();
+							}
+							model.getSelectedEdge().setCapacity(ftemp);
+						} else if (mousePos.y / tableProperties.getRowHeight() == 3) {
+							Boolean bTemp = Boolean.parseBoolean(temp.toString());
+							model.getSelectedEdge().setState(bTemp);
+						}
 					}
 					canvas.repaint();
 				} catch (Exception e) {
@@ -985,7 +1013,6 @@ public class GUI<E> implements CategoryListener {
 						controller.addCategory(catName);
 					}
 					break;
-
 				case "Object":
 					if (selectedNode == null) {
 						JOptionPane.showMessageDialog(new JFrame(),
@@ -1022,7 +1049,8 @@ public class GUI<E> implements CategoryListener {
 		/**
 		 * Update of every interaction between the user and the canvas (only on
 		 * the canvas). Basically the update of all the information concerning
-		 * the clicked HolonObject
+		 * the clicked HolonObject. For multi-selection, the propertyTable would
+		 * be disabled
 		 */
 		canvas.addMouseListener(new MouseAdapter() {
 
@@ -1030,19 +1058,13 @@ public class GUI<E> implements CategoryListener {
 			public void mousePressed(MouseEvent e) {
 				selectedElements.clear();
 				holonEleNamesDisplayed = "None ";
-
+				// If any empty space is clicked
 				if (temp == null || temp.getID() != model.getSelectedObjectID()) {
 					unitGraph.empty();
 					elementGraph.setText("None ");
 				}
 				temp = getActualCps();
-				// Update of the Information about the HolonElements - only for
-				// if (temp instanceof HolonObject) {
-				// refreshTableHolonElement();
-				// }
-				// Update of the Information about the Properties - only for
-				// CpsObjects
-				// Erase old data
+				// Erase old data in the PropertyTable
 				if (tableModelProperties.getRowCount() > 0) {
 					for (int i = tableModelProperties.getRowCount() - 1; i > -1; i--) {
 						tableModelProperties.removeRow(i);
@@ -1055,35 +1077,23 @@ public class GUI<E> implements CategoryListener {
 						controller.addSelectedObject(temp);
 					}
 				}
-				// } else if (e.isShiftDown() && model.getSelectedEdge() !=
-				// null) {
-				// selectedObjects.add(model.getSelectedEdge());
-				// }
-				// boolean nothingImportant = true;
-				// for (CpsObject c : model.getSelectedCpsObjects()) {
-				// if (nothingImportant) {
-				// System.out.println("Elements: " + c.getName() + " and ID: " +
-				// c.getID());
-				// nothingImportant = false;
-				// } else {
-				// System.out.println(c.getName() + " and ID: " + c.getID());
-				// }
-				// }
-				// Write new data
+				// Write new data in the PropertyTable
 				if (temp != null) {
+					// Name of the CpsObject
 					Object[] tempName = { "Name", temp.getName() };
 					tableModelProperties.addRow(tempName);
+					// Id of the CpsObject
 					Object[] tempId = { "ID", temp.getID() };
 					tableModelProperties.addRow(tempId);
+					// For HolonObjects the Total Energy (production or
+					// consumption) is calculated
 					if (temp instanceof HolonObject) {
 						refreshTableHolonElement();
 						Object[] tempEnergy = { "Total Energy", ((HolonObject) temp).getCurrentEnergy() };
 						tableModelProperties.addRow(tempEnergy);
-						// } else if (temp instanceof HolonTransformer) {
-						// deleteRows();
-						// Object[] tempRatioPerc = { "Ratio Type", true };
-						// tableModelProperties.addRow(tempRatioPerc);
-					} else if (temp instanceof HolonSwitch) {
+					} // For HolonSwitches is showed the actual status (active
+						// or inactive)
+					else if (temp instanceof HolonSwitch) {
 						deleteRows(tableModelHolonElementSingle);
 						deleteRows(tableModelHolonElementMulti);
 						Object[] tempActive = { "Active", ((HolonSwitch) temp).getActiveAt()[model.getCurIteration()] };
@@ -1094,9 +1104,12 @@ public class GUI<E> implements CategoryListener {
 						deleteRows(tableModelHolonElementSingle);
 						deleteRows(tableModelHolonElementMulti);
 					}
+					// For Objects the only editable cell is the name
 					tableModelProperties.setCellEditable(0, 1, true);
 					tableModelProperties.setCellEditable(2, 1, false);
+					tableModelProperties.setCellEditable(3, 1, false);
 					ArrayList<CpsEdge> temp_array = temp.getConnections();
+					// If the clicked object has connections
 					if (!temp_array.isEmpty()) {
 						boolean first = true;
 						for (CpsEdge temp2 : temp_array) {
@@ -1124,20 +1137,31 @@ public class GUI<E> implements CategoryListener {
 							}
 						}
 					}
-				} else if (model.getSelectedEdge() != null) {
+				} // If the clicked Object is an edge
+				else if (model.getSelectedEdge() != null) {
+					// Name displayed
 					Object[] tempName = { "Name", "Edge: " + model.getSelectedEdge().getA().getName() + " to "
 							+ model.getSelectedEdge().getB().getName() };
 					tableModelProperties.addRow(tempName);
+					// Current Flow displayed
 					Object[] tempFlow = { "Current flow", model.getSelectedEdge().getFlow() };
 					tableModelProperties.addRow(tempFlow);
+					// Max Capacity displayed
 					Object[] tempCapacity = { "Max. Capacity", model.getSelectedEdge().getCapacity() };
 					tableModelProperties.addRow(tempCapacity);
+					// Status displayed
+					Object[] tempStatus = { "Status", model.getSelectedEdge().getStateEdge() };
+					tableModelProperties.addRow(tempStatus);
+					// For edges, the only possible editable cell is the max
+					// flow
 					tableModelProperties.setCellEditable(0, 1, false);
 					tableModelProperties.setCellEditable(2, 1, true);
+					tableModelProperties.setCellEditable(3, 1, true);
 				} else if (getActualCps() == null) {
 					deleteRows(tableModelHolonElementSingle);
 					deleteRows(tableModelHolonElementMulti);
-				}
+				} // Update of the HolonElementTable (Single- or
+					// Multi-Selection)
 				if (model.getSelectedCpsObjects().size() > 1) {
 					tableHolonElement.setModel(tableModelHolonElementMulti);
 				} else if (model.getSelectedCpsObjects().size() == 1) {
@@ -1328,11 +1352,11 @@ public class GUI<E> implements CategoryListener {
 			@Override
 			public void actionPerformed(java.awt.event.ActionEvent evt) {
 
-				menuUndoActionPerformed(evt);
+				menuRedoActionPerformed(evt);
 
 			}
 
-			private void menuUndoActionPerformed(java.awt.event.ActionEvent evt) {
+			private void menuRedoActionPerformed(java.awt.event.ActionEvent evt) {
 				try {
 					controller.loadFile(controller.getRedoSave());
 					canvas.repaint();
@@ -1359,6 +1383,34 @@ public class GUI<E> implements CategoryListener {
 
 		});
 
+		mntmSetFolder.addActionListener(new java.awt.event.ActionListener() {
+
+			@Override
+			public void actionPerformed(java.awt.event.ActionEvent evt) {
+
+				menuSetFolderActionPerformed(evt);
+
+			}
+
+			private void menuSetFolderActionPerformed(java.awt.event.ActionEvent evt) {
+				JFileChooser fileChooser = new JFileChooser();
+				JFrame test = new JFrame();
+				fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+				fileChooser.setAcceptAllFileFilterUsed(false);
+
+				if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
+					comboBoxAlgo.removeAllItems();
+					File[] files = fileChooser.getSelectedFile().listFiles();
+					for (int i = 0; i < files.length; i++) {
+						if (files[i].toString().endsWith(".java") || files[i].toString().endsWith(".class")) {
+							comboBoxAlgo.addItem(files[i]);
+						}
+					}
+				}
+			}
+
+		});
+
 		timePanel = new TimePanel(model, controller);
 		timePanel.setBorder(null);
 		((JSlider) (timePanel.getComponent(1))).addChangeListener(new ChangeListener() {
@@ -1392,12 +1444,28 @@ public class GUI<E> implements CategoryListener {
 		splitPane_1.setBorder(null);
 		split_HolonEl_Pro.setBorder(null);
 		split_Graph_HolonEl.setBorder(null);
-		scrollPane_2.setBorder(null);
+		SimulationPane.setBorder(null);
 		panel_HolonEl.setBorder(null);
 
 		tableHolonElementScrollPane.setBorder(null);
 
 		frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
+
+		simulationSpeedField.setText(Integer.toString(timePanel.getTimerSpeed()));
+		btnApply.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent e) {
+				int speed = Integer.parseInt(simulationSpeedField.getText());
+				timePanel.setTimerSpeed(speed);
+				mnSimulationSpeed.setPopupMenuVisible(false);
+			}
+		});
+
+		mnSimulationSpeed.add(btnApply);
+		menuBar.add(comboBoxAlgo);
+
+		Dimension height = comboBoxAlgo.getPreferredSize();
+		comboBoxAlgo.setPreferredSize(new Dimension(200, (int) height.getHeight()));
+		comboBoxAlgo.setMaximumSize(comboBoxAlgo.getPreferredSize());
 	}
 
 	/*
@@ -1487,7 +1555,8 @@ public class GUI<E> implements CategoryListener {
 	 * Search for actual selected HolonElement
 	 * 
 	 * @param obj
-	 *            selected HolonObject
+	 *            selected HolonObject, if obj==null means multi-selection
+	 *            active
 	 * @param yValue
 	 *            Y-Coord in the HolonElementsTable
 	 * @param toMultiHash
@@ -1497,47 +1566,64 @@ public class GUI<E> implements CategoryListener {
 	 */
 	public HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash) {
 		final int yTemp = (int) Math.floor(yValue / 16);
-		int rowsTotal = tableModelHolonElementSingle.getRowCount();
+		int rowsTotal = 0;
+		// Filter for search --> single and multi selection
 		if (obj == null) {
 			rowsTotal = tableModelHolonElementMulti.getRowCount();
+		} else {
+			rowsTotal = tableModelHolonElementSingle.getRowCount();
 		}
+		// search for the clicked HolonObject and HolonElement --> in the
+		// HolonElementTable
 		HolonObject obtTemp = null;
-		String eleTempName = "";
+		HolonElement toReturnEle = null;
+		int id = 0;
 		if (rowsTotal != 0 && rowsTotal > yTemp) {
+			// Multi-Selection search
 			if (obj == null) {
-				String temp = tableModelHolonElementMulti.getValueAt(yTemp, 0).toString();
-				int idTemp = Integer.parseInt(temp.split(", ")[1]);
-				obtTemp = (HolonObject) controller.searchByID(idTemp);
-				eleTempName = tableModelHolonElementMulti.getValueAt(yTemp, 1).toString();
+				String tempStringObj = tableModelHolonElementMulti.getValueAt(yTemp, 0).toString();
+				int idTempObj = Integer.parseInt(tempStringObj.split(", ")[1]);
+				obtTemp = (HolonObject) controller.searchByID(idTempObj);
+				id = Integer.parseInt(tableModelHolonElementMulti.getValueAt(yTemp, 1).toString());
 				ArrayList<HolonElement> eleTemp = new ArrayList<HolonElement>();
-				if (eleToDelete.containsKey(idTemp) && toMultiHash == 2) {
-					eleTemp = eleToDelete.get(idTemp);
-					if (!eleTemp.contains(obtTemp.searchElement(eleTempName))) {
-						eleTemp.add(obtTemp.searchElement(eleTempName));
-						eleToDelete.replace(idTemp, eleTemp);
+				if (eleToDelete.containsKey(idTempObj) && toMultiHash == 2) {
+					eleTemp = eleToDelete.get(idTempObj);
+					if (!eleTemp.contains(obtTemp.searchElementById(id))) {
+						eleTemp.add(obtTemp.searchElementById(id));
+						eleToDelete.replace(idTempObj, eleTemp);
 					}
 				} else if (toMultiHash == 2) {
-					eleTemp.add(obtTemp.searchElement(eleTempName));
-					eleToDelete.put(idTemp, eleTemp);
+					eleTemp.add(obtTemp.searchElementById(id));
+					eleToDelete.put(idTempObj, eleTemp);
 				} else if (toMultiHash == 1) {
 					eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
-					eleTemp.add(obtTemp.searchElement(eleTempName));
-					eleToDelete.put(idTemp, eleTemp);
+					eleTemp.add(obtTemp.searchElementById(id));
+					eleToDelete.put(idTempObj, eleTemp);
+				} else if (toMultiHash == 0) {
+					toReturnEle = obtTemp.searchElementById(id);
 				}
-			} else {
+			} // Single-Selection search
+			else {
 				eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
-				obtTemp = obj;
-				eleTempName = tableModelHolonElementSingle.getValueAt(yTemp, 0).toString();
+				id = Integer.parseInt(tableModelHolonElementSingle.getValueAt(yTemp, 0).toString());
+				toReturnEle = obj.searchElementById(id);
 			}
-			model.setSelectedHolonElement(obtTemp.searchElement(eleTempName));
-			return obtTemp.searchElement(eleTempName);
-		} else {
+			model.setSelectedHolonElement(toReturnEle);
+			return toReturnEle;
+		} // If no HolonObject selected
+		else {
 			eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
 			model.setSelectedHolonElement(null);
 			return null;
 		}
 	}
 
+	/**
+	 * Search for clicked HolonObject through the mouse's y-Coord
+	 * 
+	 * @param yValue
+	 * @return clicked HolonObject
+	 */
 	public HolonObject getHolonObj(int yValue) {
 		final int yTemp = (int) Math.floor(yValue / 16);
 		HolonObject obtTemp = null;
@@ -1589,7 +1675,7 @@ public class GUI<E> implements CategoryListener {
 			for (CpsObject o : objects) {
 				if (o instanceof HolonObject) {
 					for (HolonElement he : ((HolonObject) o).getElements()) {
-						Object[] temp = { o.getName() + ", " + o.getID(), he.getEleName(), he.getEnergy(),
+						Object[] temp = { o.getName() + ", " + o.getID(), he.getId(), he.getEleName(), he.getEnergy(),
 								he.getAmount(), he.getActive() };
 						tableModelHolonElementMulti.addRow(temp);
 					}
@@ -1599,7 +1685,7 @@ public class GUI<E> implements CategoryListener {
 			CpsObject o = objects.get(0);
 			if (o instanceof HolonObject) {
 				for (HolonElement he : ((HolonObject) o).getElements()) {
-					Object[] temp = { he.getEleName(), he.getEnergy(), he.getAmount(), he.getActive() };
+					Object[] temp = { he.getId(), he.getEleName(), he.getEnergy(), he.getAmount(), he.getActive() };
 					tableModelHolonElementSingle.addRow(temp);
 				}
 			}

+ 10 - 19
src/ui/view/MyCanvas.java

@@ -79,13 +79,13 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	// contains the value of the Capacity for new created Edges
 	private float edgeCapacity;
 
-	public MyCanvas(Model model, Control control) {
+	public MyCanvas(Model mod, Control control) {
 		this.add(objectTT);
 		this.controller = control;
-		this.model = model;
+		this.model = mod;
 		
 		showedInformation[0] = true;
-		showedInformation[1] = false;
+		showedInformation[1] = true;
 		edgeCapacity = 10000;
 
 		popmenu.add(itemCut);
@@ -268,26 +268,18 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							controller.getScale() + ((controller.getScale() / 20) * 2),
 							controller.getScale() + ((controller.getScale() / 20) * 2));
 				} else if (cps instanceof HolonObject) {
-					if (((HolonObject) cps).getState() == 4) {
-						g2.setColor(Color.YELLOW);
-					}
-					if (((HolonObject) cps).getState() == 3) {
-						g2.setColor(Color.lightGray);
-					}
-					if (((HolonObject) cps).getState() == 2) {
-						g2.setColor(Color.GREEN);
-					}
-					if (((HolonObject) cps).getState() == 1) {
-						g2.setColor(Color.ORANGE);
-					}
-					if (((HolonObject) cps).getState() == 0) {
-						g2.setColor(Color.WHITE);
-					}
+					g2.setColor(((HolonObject) cps).getColor());
 
 					g2.fillRect(cps.getPosition().x - (controller.getScale() / 20),
 							cps.getPosition().y - (controller.getScale() / 20),
 							controller.getScale() + ((controller.getScale() / 20) * 2),
 							controller.getScale() + ((controller.getScale() / 20) * 2));
+					
+					if(showedInformation[1]){
+						g2.setColor(Color.BLACK);
+						float totalEnergy = ((HolonObject) cps).getCurrentEnergyAtTimeStep(model.getCurIteration());
+						g2.drawString(Float.toString(totalEnergy), cps.getPosition().x, cps.getPosition().y - 10);
+					}
 				}
 				File checkPath = new File(cps.getImage());
 				if (checkPath.exists()) {
@@ -457,7 +449,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 
 				tempCps.setPosition(x, y); // Drag Position
 				selectRect.setLocation(x - (controller.getScale() / 20), y - (controller.getScale() / 20)); // Highlighting-Position
-
 				// TipText Position and name
 				objectTT.setTipText(tempCps.getName() + ", " + tempCps.getID());
 				objectTT.setLocation(x, y + controller.getScale());

+ 4 - 4
src/ui/view/PropertyTable.java

@@ -9,15 +9,15 @@ public class PropertyTable extends DefaultTableModel {
 	@Override
 	public Class<?> getColumnClass(int columnIndex) {
 		Class clazz = String.class;
-		if (getColumnCount() == 5) {
+		if (getColumnCount() == 6) {
 			switch (columnIndex) {
-			case 4:
+			case 5:
 				clazz = Boolean.class;
 				break;
 			}
-		} else if (getColumnCount() == 4) {
+		} else if (getColumnCount() == 5) {
 			switch (columnIndex) {
-			case 3:
+			case 4:
 				clazz = Boolean.class;
 				break;
 			}

+ 12 - 1
src/ui/view/TimePanel.java

@@ -33,6 +33,7 @@ public class TimePanel extends JPanel {
 	private final JButton timeBackwardBtn = new JButton();
 	private Timer timer;
 	private boolean running = false;
+	private int timerSpeed;
 
 	/**
 	 * 
@@ -43,9 +44,10 @@ public class TimePanel extends JPanel {
 		super();
 		this.model = mod;
 		this.controller = cont;
+		timerSpeed = 1000;
 
 		// One Iteration
-		timer = new Timer(1000, new ActionListener() {
+		timer = new Timer(timerSpeed, new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getValue() + 1);
@@ -154,4 +156,13 @@ public class TimePanel extends JPanel {
 		this.add(timeBtnPanel, BorderLayout.WEST);
 		this.add(timeSlider);
 	}
+	
+	public int getTimerSpeed(){
+		return timerSpeed;
+	}
+	
+	public void setTimerSpeed(int toSet){
+		timerSpeed = toSet;
+		timer.setDelay(timerSpeed);
+	}
 }

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

@@ -360,7 +360,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 						// double p1, p2 um location der points zu bestimmen
 						double p1 = pointList.get(i - 1).getX();
 						double p2 = pointList.get(i).getX();
-						// Punkte hinzufügen, je nachdem ob true oder false
+						// Punkte hinzuf�gen, je nachdem ob true oder false
 						if (pointList.get(i - 1).getY() != 0 && pointList.get(i).getY() != 0) {
 							pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) height - 1));
 							pointList.add(i, new Point((int) ((x + p2) / 2 + dist), 0));
@@ -501,7 +501,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 		isSwitch = false;
 		isElement = true;
 		MAXIMUM = selectedElement.get(selectedElement.size() - 1).getEnergy();
-		// First time clicked on the Element
+  		// First time clicked on the Element
 		if (pointList.isEmpty()) {
 			pointList.addFirst(new Point(0, 0));
 			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));

+ 11 - 7
src/ui/view/searchPopUp.java

@@ -30,8 +30,12 @@ public class searchPopUp extends JDialog {
 	private JTextField findTextField;
 	private Control controller;
 	private MyCanvas canvas;
+	private JRadioButton rdbtnForward;
+	private JRadioButton rdbtnBackward;
+	private JRadioButton rdbtnAll;
+	private JRadioButton rdbtnSingle;
 
-	searchPopUp(Control controller, MyCanvas canvas) {
+	searchPopUp(Control contr, MyCanvas can) {
 		super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		this.setTitle("Search for Objects");
@@ -41,8 +45,8 @@ public class searchPopUp extends JDialog {
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);
 
-		this.controller = controller;
-		this.canvas = canvas;
+		this.controller = contr;
+		this.canvas = can;
 
 		JLabel lblFind = new JLabel("Find:");
 		lblFind.setFont(new Font("Tahoma", Font.PLAIN, 13));
@@ -71,13 +75,13 @@ public class searchPopUp extends JDialog {
 		lblNewLabel.setBounds(10, 90, 82, 14);
 		contentPanel.add(lblNewLabel);
 
-		JRadioButton rdbtnForward = new JRadioButton("Forward");
+		rdbtnForward = new JRadioButton("Forward");
 		rdbtnForward.setFont(new Font("Tahoma", Font.PLAIN, 13));
 		rdbtnForward.setBounds(10, 111, 109, 23);
 		contentPanel.add(rdbtnForward);
 		rdbtnForward.setSelected(true);
 
-		JRadioButton rdbtnBackward = new JRadioButton("Backward");
+		rdbtnBackward = new JRadioButton("Backward");
 		rdbtnBackward.setFont(new Font("Tahoma", Font.PLAIN, 13));
 		rdbtnBackward.setBounds(10, 137, 109, 23);
 		contentPanel.add(rdbtnBackward);
@@ -87,13 +91,13 @@ public class searchPopUp extends JDialog {
 		lblScope.setBounds(122, 90, 46, 14);
 		contentPanel.add(lblScope);
 
-		JRadioButton rdbtnAll = new JRadioButton("All");
+		rdbtnAll = new JRadioButton("All");
 		rdbtnAll.setFont(new Font("Tahoma", Font.PLAIN, 13));
 		rdbtnAll.setBounds(121, 112, 109, 23);
 		contentPanel.add(rdbtnAll);
 		rdbtnAll.setSelected(true);
 
-		JRadioButton rdbtnSingle = new JRadioButton("Single");
+		rdbtnSingle = new JRadioButton("Single");
 		rdbtnSingle.setFont(new Font("Tahoma", Font.PLAIN, 13));
 		rdbtnSingle.setBounds(121, 138, 109, 23);
 		contentPanel.add(rdbtnSingle);