Browse Source

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

Teh-Hai Julian Zheng 8 years ago
parent
commit
6537fb8da6

+ 7 - 0
.checkstyle

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+  <fileset name="all" enabled="true" check-config-name="Google Checks" local="false">
+    <file-match-pattern match-pattern="." include-pattern="true"/>
+  </fileset>
+</fileset-config>

BIN
jars/junit-4.12.jar


+ 31 - 0
src/API/AlgorithmSuperClass.java

@@ -0,0 +1,31 @@
+package API;
+
+public abstract class AlgorithmSuperClass {
+	private CpsAPI API;
+	
+	/**
+	 * Constructor
+	 * @param api
+	 */
+	public AlgorithmSuperClass(CpsAPI api){
+		this.API = api;
+	}
+	
+	/**
+	 * 
+	 * @return API
+	 */
+	public CpsAPI getAPI(){
+		return API;
+	}
+	
+	/**
+	 * sets API
+	 * @param api
+	 */
+	public void setAPI(CpsAPI api){
+		this.API = api;
+	}
+	
+	abstract public void runAlgorithm();
+}

+ 129 - 0
src/API/CpsAPI.java

@@ -0,0 +1,129 @@
+package API;
+
+import java.awt.Color;
+import java.util.ArrayList;
+
+import classes.CpsEdge;
+import classes.CpsObject;
+import classes.HolonObject;
+import classes.HolonSwitch;
+import classes.subNet;
+import ui.controller.Control;
+import ui.controller.SimulationManager;
+
+public class CpsAPI {
+	private Control controller;
+	private SimulationManager simManager;
+	
+	public CpsAPI(Control cont){
+		this.controller = cont;
+		this.simManager = controller.getSimManager();
+	}
+	
+	/**
+	 * a SubNet contains all Components
+	 * @return all SubNets on Canvas
+	 */
+	public ArrayList<subNet> getSubNets(){
+		simManager.searchForSubNets();
+		return simManager.getSubNets();
+	}
+	
+	/**
+	 * 
+	 * @return all Objects on Canvas in no specific order
+	 */
+	public ArrayList<CpsObject> getAllObjOnCanvas(){
+
+		return controller.getModel().getObjectsOnCanvas();
+	}
+	
+	/**
+	 * 
+	 * @return all Edges on Canvas
+	 */
+	public ArrayList<CpsEdge> getAllEdges(){
+		ArrayList<CpsEdge> result = new ArrayList<CpsEdge>();
+		for(subNet sN: getSubNets()){
+			result.addAll(sN.getEdges());
+		}
+		return result;
+	}
+	
+	/**
+	 * 
+	 * @return all Switches on Canvas
+	 */
+	public ArrayList<HolonSwitch> getAllSwitches(){
+		ArrayList<HolonSwitch> result = new ArrayList<HolonSwitch>();
+		for(subNet sN: getSubNets()){
+			result.addAll(sN.getSwitches());
+		}
+		return result;
+	}
+	
+	public ArrayList<HolonObject> getAllHolonObjects(){
+		ArrayList<HolonObject> result = new ArrayList<HolonObject>();
+		for(subNet sN: getSubNets()){
+			result.addAll(sN.getObjects());
+		}
+		return result;
+	}
+	/**
+	 * prints a given text on the console
+	 * @param text
+	 */
+	public void consolePrint(String text){
+		controller.addTextToConsole(text);
+	}
+	
+	/**
+	 * prints a given text on the console with more details
+	 * @param text: the text that will be printed
+	 * @param color: the color the text will have
+	 * @param p: font size
+	 * @param bold: true or false
+	 * @param italic: true or false
+	 * @param nl: new line after text
+	 */
+	public void consolePrint(String text, Color color, int p, boolean bold, boolean italic, boolean nl){
+		controller.addTextToConsole(text, color, p, bold, italic, nl);
+	}
+	
+	/**
+	 * changes the bordercolor of given object to given color
+	 * @param toChange
+	 * @param color
+	 */
+	public void setBorderColorForObj(CpsObject toChange, Color color){
+		toChange.setBorderColor(color);
+	}
+	
+	/**
+	 * changes the borderColor for all objects in List to given color
+	 * @param objects
+	 * @param color
+	 */
+	public void setBorderColorForMultObj(ArrayList<CpsObject> objects, Color color){
+		for(CpsObject cps: objects){
+			setBorderColorForObj(cps, color);
+		}
+	}
+	
+	/**
+	 * resets the bordercolor of given object to default (white)
+	 * @param toReset
+	 */
+	public void resetBorderColor(CpsObject toReset){
+		toReset.setBorderColor(Color.WHITE);
+	}
+	
+	/**
+	 * resets the bordercolor for all objects on canvas
+	 */
+	public void resetBorderColorForAll(){
+		setBorderColorForMultObj(getAllObjOnCanvas(), Color.WHITE);
+	}
+	
+	
+}

+ 5 - 0
src/API/CpsAlgorithm.java

@@ -0,0 +1,5 @@
+package API;
+
+public interface CpsAlgorithm {
+	public void runAlgorithm();
+}

+ 36 - 29
src/classes/Category.java

@@ -3,37 +3,33 @@ package classes;
 import java.util.ArrayList;
 import java.util.HashMap;
 
+/**
+ * Class "Category" performs the functionality of listing elements into groups.
+ * Each Category contains an ArrayList of CpsObjects, a name and a HashMap of
+ * ObjIdx.
+ * 
+ * @author Gruppe14
+ *
+ */
 
-public class Category{
-	
-	private int ID;
+public class Category {
+	// objects: is a ArrayList of all Objects that belongs to the Category
 	private ArrayList<CpsObject> objects;
+	// name: is a String chosen by the User
 	private String name;
-	private HashMap<String, Integer> ObjIdx;
-	
-	public Category(String name){
+	// ObjIdx: Index of each Category that corresponds to the order in the tree
+	private HashMap<String, Integer> objIdx;
+
+	public Category(String name) {
 		setObjects(new ArrayList<CpsObject>());
 		setName(name);
-		setID(-1);
-		setObjIdx(new HashMap<String,Integer>());
-	
-	}
+		setObjIdx(new HashMap<String, Integer>());
 
-	/**
-	 * @return the id
-	 */
-	public int getID() {
-		return ID;
-	}
-
-	/**
-	 * @param id the id to set
-	 */
-	public void setID(int id) {
-		this.ID = id;
 	}
 
 	/**
+	 * Getter for all CpsObjects
+	 * 
 	 * @return the objects
 	 */
 	public ArrayList<CpsObject> getObjects() {
@@ -41,13 +37,18 @@ public class Category{
 	}
 
 	/**
-	 * @param objects the objects to set
+	 * Set a new ArrayList of CpsObjects
+	 * 
+	 * @param objects
+	 *            the objects to set
 	 */
 	public void setObjects(ArrayList<CpsObject> objects) {
 		this.objects = objects;
 	}
 
 	/**
+	 * Getter the name of the Category
+	 * 
 	 * @return the name
 	 */
 	public String getName() {
@@ -55,26 +56,32 @@ public class Category{
 	}
 
 	/**
-	 * @param name the name to set
+	 * Set the name of the Category to a new one
+	 * 
+	 * @param name
+	 *            the name to set
 	 */
 	public void setName(String name) {
 		this.name = name;
 	}
 
 	/**
+	 * Getter of the Objects in the Tree with their respective order
+	 * 
 	 * @return the objIdx
 	 */
 	public HashMap<String, Integer> getObjIdx() {
-		return ObjIdx;
+		return objIdx;
 	}
 
 	/**
-	 * @param objIdx the objIdx to set
+	 * Set a new sequence of Objects in the tree
+	 * 
+	 * @param objIdx
+	 *            the objIdx to set
 	 */
 	public void setObjIdx(HashMap<String, Integer> objIdx) {
-		ObjIdx = objIdx;
+		this.objIdx = objIdx;
 	}
 
-
-	
 }

+ 102 - 9
src/classes/CpsEdge.java

@@ -1,18 +1,44 @@
 package classes;
 
+import java.util.ArrayList;
+
+/**
+ * The class "CpsEdge" represents the connections on the GUI. Each connection
+ * contains a max. capacity, a flow, a status (isWorking), tags (for internal
+ * use of electricity flow), source and destination
+ * 
+ * @author Gruppe14
+ *
+ */
 public class CpsEdge {
 
+	// Max. capacity of the Edge, if flow is greater than the status --> is
+	// Working would be false
 	float maxCapacity;
+	// Current flow of electricity (through the edge)
 	float flow;
+	/*
+	 * Represents the actual status of the Edge (true = flows electricity; false
+	 * = no flow of electricity) 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 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;
-
+	// for internal use --> flow of electricity (simulation state)
+	ArrayList<Integer> tags;
+	// Source
 	CpsObject A;
+	// Destination
 	CpsObject B;
 
+	/**
+	 * Constructor without max. capacity (by default as 100)
+	 * 
+	 * @param A
+	 *            Source
+	 * @param B
+	 *            Destination
+	 */
 	public CpsEdge(CpsObject A, CpsObject B) {
 		setA(A);
 		setB(B);
@@ -23,6 +49,14 @@ public class CpsEdge {
 		isWorking = true;
 	}
 
+	/**
+	 * Constructor with a user-defined max. capacity
+	 * 
+	 * @param A
+	 *            Source
+	 * @param B
+	 *            Destination
+	 */
 	public CpsEdge(CpsObject A, CpsObject B, float maxCap) {
 		setA(A);
 		setB(B);
@@ -34,6 +68,8 @@ public class CpsEdge {
 	}
 
 	/**
+	 * Getter for the max. capacity
+	 * 
 	 * @return the capacity
 	 */
 	public float getCapacity() {
@@ -41,6 +77,8 @@ public class CpsEdge {
 	}
 
 	/**
+	 * Setter for the max. capacity
+	 * 
 	 * @param cap
 	 *            the Capacity to set
 	 */
@@ -49,6 +87,8 @@ public class CpsEdge {
 	}
 
 	/**
+	 * Getter fot the current flow
+	 * 
 	 * @return the flow
 	 */
 	public float getFlow() {
@@ -56,6 +96,8 @@ public class CpsEdge {
 	}
 
 	/**
+	 * Set the flow into a new one
+	 * 
 	 * @param flow
 	 *            the flow to set
 	 */
@@ -67,6 +109,12 @@ public class CpsEdge {
 		 **/
 	}
 
+	/**
+	 * Calculates the state of the edge (see description of isWorking)
+	 * 
+	 * @param simMode
+	 */
+
 	public void calculateState(boolean simMode) {
 		if (flow > maxCapacity && maxCapacity != -1) {
 			isWorking = false;
@@ -77,11 +125,9 @@ public class CpsEdge {
 		}
 	}
 
-	public void setState(boolean isActive) {
-		isWorking = isActive;
-	}
-
 	/**
+	 * Getter for the Source
+	 * 
 	 * @return the a
 	 */
 	public CpsObject getA() {
@@ -89,6 +135,8 @@ public class CpsEdge {
 	}
 
 	/**
+	 * Set the Source to a new one
+	 * 
 	 * @param a
 	 *            the a to set
 	 */
@@ -97,6 +145,8 @@ public class CpsEdge {
 	}
 
 	/**
+	 * Getter for the destination
+	 * 
 	 * @return the b
 	 */
 	public CpsObject getB() {
@@ -104,6 +154,8 @@ public class CpsEdge {
 	}
 
 	/**
+	 * Set the Destination to a new one
+	 * 
 	 * @param b
 	 *            the b to set
 	 */
@@ -111,8 +163,49 @@ public class CpsEdge {
 		B = b;
 	}
 
+	/**
+	 * Set the state manually to a new one
+	 * 
+	 * @param state
+	 */
+	public void setState(boolean state) {
+		isWorking = state;
+	}
+
+	/**
+	 * Getter for the status
+	 * 
+	 * @return
+	 */
 	public boolean getState() {
 		return isWorking;
 	}
 
+	/**
+	 * set the tags into a new set of tags
+	 * 
+	 * @param tags
+	 */
+	public void setTags(ArrayList<Integer> tags) {
+		this.tags = tags;
+	}
+
+	/**
+	 * Getter for the ArrayList of tags
+	 * 
+	 * @return
+	 */
+	public ArrayList<Integer> getTags() {
+		return tags;
+	}
+
+	/**
+	 * Add a new tag to the ArrayList
+	 * 
+	 * @param tag
+	 */
+	public void addTag(int tag) {
+		tags.add(tag);
+	}
+
 }

+ 13 - 1
src/classes/CpsNode.java

@@ -4,8 +4,21 @@ import java.util.ArrayList;
 
 import ui.model.idCounter;
 
+/**
+ * The class "CpsNode" represents empty Objects in the system. They are just
+ * nodes between Objects
+ * 
+ * @author Gruppe14
+ *
+ */
 public class CpsNode extends CpsObject {
 
+	/**
+	 * Create a new node in the system with an user-defined name
+	 * 
+	 * @param objName
+	 *            String
+	 */
 	public CpsNode(String objName) {
 		super(objName);
 		this.setConnections(new ArrayList<CpsEdge>());
@@ -13,5 +26,4 @@ public class CpsNode extends CpsObject {
 		this.setSav("CVS");
 		this.setID(idCounter.nextId());
 	}
-
 }

+ 136 - 31
src/classes/CpsObject.java

@@ -6,6 +6,14 @@ import java.util.HashMap;
 
 import ui.model.idCounter;
 
+/**
+ * The abstract class "CpsObject" represents any possible object in the system
+ * (except Edges). The representation of any object contains following
+ * variables: see description of variables
+ * 
+ * @author Gruppe14
+ *
+ */
 public abstract class CpsObject {
 	/* Type of the Object */
 	String objName;
@@ -19,17 +27,18 @@ public abstract class CpsObject {
 	ArrayList<CpsEdge> connections;
 	/* Position with a X and Y value */
 	Position position;
-	/* Energy input and output of each object in the grid */
-	/* Where the Object is Stored */
+	/*
+	 * Energy input and output of each object in the grid Where the Object is
+	 * Stored
+	 */
 	String sav;
 	/* BorderColor the user sets */
 	Color BorderColor = Color.WHITE;
-
-	float input;
-	float output;
+	/* a Tag that can be used */
+	ArrayList<Integer> tags;
 
 	/**
-	 * Constructor for an CpsObejct with an unique ID
+	 * Constructor for a CpsObejct with an unique ID
 	 */
 	public CpsObject(String objName) {
 		setObjName(objName);
@@ -37,41 +46,73 @@ public abstract class CpsObject {
 		setImage("/Images/Dummy_House.png");
 	}
 
+	/**
+	 * Constructor for a new CpsObject with an unique ID (This constructor
+	 * correspond to the interaction between the Categories and Canvas)-->
+	 * actually the "new" Object is a copy.
+	 * 
+	 * @param obj
+	 *            Object to be copied
+	 */
 	public CpsObject(CpsObject obj) {
 		setObjName(obj.getObjName());
 		setName(obj.getObjName());
 		setConnections(new ArrayList<CpsEdge>());
 		setPosition(new Position());
 		setID(idCounter.nextId());
-		setEnergyIn(obj.getEnergyIn());
-		setEnergyOut(obj.getEnergyOut());
 		setImage(obj.getImage());
 	}
 
-	/* Obj type */
+	/**
+	 * Getter for the type of the Object
+	 * 
+	 * @return String
+	 */
 	public String getObjName() {
 		return objName;
 	}
 
+	/**
+	 * Set the type of Object
+	 * 
+	 * @param objName
+	 *            String
+	 */
 	public void setObjName(String objName) {
 		this.objName = objName;
 	}
 
-	/* User defined Name */
+	/**
+	 * Getter for the user-defined name (no unique)
+	 * 
+	 * @return String
+	 */
 	public String getName() {
 		return name;
 	}
 
+	/**
+	 * Set the name
+	 * 
+	 * @param name
+	 *            String
+	 */
 	public void setName(String name) {
 		this.name = name;
 	}
 
-	/* Unique ID number */
+	/**
+	 * Getter of the unique ID
+	 * 
+	 * @return int
+	 */
 	public int getID() {
 		return ID;
 	}
 
 	/**
+	 * Set the ID to a new one
+	 * 
 	 * @param iD
 	 *            the iD to set
 	 */
@@ -79,12 +120,18 @@ public abstract class CpsObject {
 		this.ID = ID;
 	}
 
-	/* Image path */
+	/**
+	 * Get the path of the image for the selected Object
+	 * 
+	 * @return String
+	 */
 	public String getImage() {
 		return image;
 	}
 
 	/**
+	 * Set the path of the image
+	 * 
 	 * @param image
 	 *            the Image to set
 	 */
@@ -93,13 +140,17 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * @return the connections
+	 * List of all existing connections
+	 * 
+	 * @return the connections ArrayList
 	 */
 	public ArrayList<CpsEdge> getConnections() {
 		return connections;
 	}
 
 	/**
+	 * Set a new ArrayList of connections (Update)
+	 * 
 	 * @param arrayList
 	 *            the connections to set
 	 */
@@ -107,24 +158,52 @@ public abstract class CpsObject {
 		this.connections = arrayList;
 	}
 
-	/* Neighbors array */
+	/**
+	 * List of all existing connections
+	 * 
+	 * @return the connections ArrayList
+	 */
 	public ArrayList<CpsEdge> getConnectedTo() {
 		return connections;
 	}
 
+	/**
+	 * Add a new connection to the selected Object
+	 * 
+	 * @param toConnect
+	 *            Edge
+	 */
 	public void AddConnection(CpsEdge toConnect) {
 		connections.add(toConnect);
 	}
 
+	/**
+	 * Set the position of the Object in the canvas
+	 * 
+	 * @param pos
+	 *            Coordinates
+	 */
 	public void setPosition(Position pos) {
 		this.position = pos;
 	}
 
-	/* Position (x and Y) */
+	/**
+	 * Set the position of the Object in the canvas
+	 * 
+	 * @param x
+	 *            X-Coord
+	 * @param y
+	 *            Y-Coord
+	 */
 	public void setPosition(int x, int y) {
 		setPosition(new Position(x, y));
 	}
 
+	/**
+	 * Get the actual position of the Object
+	 * 
+	 * @return
+	 */
 	public Position getPosition() {
 		return position;
 	}
@@ -144,35 +223,61 @@ public abstract class CpsObject {
 		this.sav = sav;
 	}
 
-	/* Getter and Setters for the energy input and output */
-	public float getEnergyIn() {
-		return input;
+	/**
+	 * Get the color of the border
+	 * 
+	 * @return the BorderColor
+	 */
+	public Color getBorderColor() {
+		return BorderColor;
 	}
 
-	public void setEnergyIn(float energyIn) {
-		this.input = energyIn;
+	/**
+	 * Set the Border Color of this CpsObject
+	 * 
+	 * @param the
+	 *            BorderColor
+	 */
+	public void setBorderColor(Color c) {
+		this.BorderColor = c;
 	}
 
-	public float getEnergyOut() {
-		return output;
+	/**
+	 * Set the Color of the edges
+	 * 
+	 * @param Color
+	 *            the Color to set
+	 */
+	public void setConnections(Color color) {
+		this.BorderColor = color;
 	}
 
-	public void setEnergyOut(float energyOut) {
-		this.output = energyOut;
+	/**
+	 * For internal purpose (energy flow)
+	 * 
+	 * @param tag
+	 */
+	public void addTag(int tag) {
+		this.tags.add(tag);
 	}
 
 	/**
-	 * @return the BorderColor
+	 * Get the actual tags
+	 * 
+	 * @return ArrayList
 	 */
-	public Color getBorderColor() {
-		return BorderColor;
+	public ArrayList<Integer> getTag() {
+		return tags;
 	}
 
 	/**
-	 * @param Color
-	 *            the Color to set
+	 * Rest the tags to Null
 	 */
-	public void setConnections(Color color) {
-		this.BorderColor = color;
+	public void resetTags() {
+		this.tags = new ArrayList<Integer>();
+	}
+
+	public void setTags(ArrayList<Integer> tags) {
+		this.tags = tags;
 	}
 }

+ 100 - 15
src/classes/HolonElement.java

@@ -4,35 +4,54 @@ import java.awt.Point;
 import java.util.LinkedList;
 import ui.model.idCounterElem;
 
+/**
+ * The class "HolonElement" represents any possible element that can be added to
+ * a CpsObject (such as TV (consumer) or any energy source/producer)
+ * 
+ * @author Gruppe14
+ *
+ */
 public class HolonElement {
 
 	/* Name of the gadget */
-	String eleName;
+	private String eleName;
 	/* Quantity */
-	int amount;
+	private int amount;
 	/* Energy per gadget */
-	float energy;
+	private float energy;
 	/* If the gadget is working xor not (true xor false) */
-	boolean active;
+	private boolean active;
 	/* Total Energy */
-	float totalEnergy;
+	private float totalEnergy;
 	/* Path of the image for the Obj. */
-	String image;
+	private String image;
 	/* +: for Consumers and -: Producers */
-	char sign;
+	private char sign;
 	/* Place where the Object is Stored */
-	String sav;
+	private String sav;
 	/* Object where the Element is Stored */
-	String obj;
-	int id;
+	private String obj;
+	/* Unique Id of the Element */
+	private 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];
+	private float[] energyAt = new float[100];
 	// Points on the UnitGraph
 	LinkedList<Point> graphPoints = new LinkedList<>();
 
+	/**
+	 * Create a new HolonElement with a user-defined name, amount of the same
+	 * element and energy per element
+	 * 
+	 * @param eleName
+	 *            String
+	 * @param amount
+	 *            int
+	 * @param energy
+	 *            float
+	 */
 	public HolonElement(String eleName, int amount, float energy) {
 		setEleName(eleName);
 		setAmount(amount);
@@ -40,9 +59,14 @@ public class HolonElement {
 		setActive(true);
 		setSign(energy);
 		setEnergyAt(energy);
-		setId(idCounterElem.nextId());
+		// setId(idCounterElem.nextId());
 	}
 
+	/**
+	 * Create a copy of the HolonElement given each one a new ID
+	 * 
+	 * @param element
+	 */
 	public HolonElement(HolonElement element) {
 		setEleName(element.getEleName());
 		setAmount(element.getAmount());
@@ -56,13 +80,17 @@ public class HolonElement {
 	}
 
 	/**
-	 * get the EnergyAt Array
+	 * Get the Array of energy (100 values)
+	 * 
+	 * @return Array of floats
 	 */
 	public float[] getEnergyAt() {
 		return energyAt;
 	}
 
 	/**
+	 * Set energy to any value to the whole array
+	 * 
 	 * @param energy,
 	 *            the value
 	 */
@@ -72,18 +100,30 @@ public class HolonElement {
 		}
 	}
 
+	/**
+	 * Set energy to any value at a given position
+	 * 
+	 * @param pos
+	 *            int
+	 * @param energy
+	 *            float
+	 */
 	public void setEnergyAt(int pos, float energy) {
 		this.energyAt[pos] = energy;
 	}
 
 	/**
-	 * @return the name
+	 * Get the user-defined Name
+	 * 
+	 * @return the name String
 	 */
 	public String getEleName() {
 		return eleName;
 	}
 
 	/**
+	 * Set the name to any new name
+	 * 
 	 * @param name
 	 *            the name to set
 	 */
@@ -92,13 +132,17 @@ public class HolonElement {
 	}
 
 	/**
-	 * @return the amount
+	 * Get the actual amount of Elements in the selected Object
+	 * 
+	 * @return the amount int
 	 */
 	public int getAmount() {
 		return amount;
 	}
 
 	/**
+	 * Set the amount of the Element in the selected Object
+	 * 
 	 * @param amount
 	 *            the amount to set
 	 */
@@ -107,6 +151,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Get the energy value of the selected Element
+	 * 
 	 * @return the energy
 	 */
 	public float getEnergy() {
@@ -114,6 +160,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Set the energy value of the selected Element
+	 * 
 	 * @param energy
 	 *            the energy to set
 	 */
@@ -122,6 +170,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Get the Status of the Element (see description of variables)
+	 * 
 	 * @return the active
 	 */
 	public boolean getActive() {
@@ -129,6 +179,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Set the Status of the Element (see description of variables)
+	 * 
 	 * @param active
 	 *            the active to set
 	 */
@@ -137,6 +189,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Get Image path
+	 * 
 	 * @return the image
 	 */
 	public String getImage() {
@@ -144,6 +198,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Set Image path
+	 * 
 	 * @param image
 	 *            the image to set
 	 */
@@ -163,12 +219,21 @@ public class HolonElement {
 		return totalEnergy;
 	}
 
+	/**
+	 * Get the energy value at a selected time x
+	 * 
+	 * @param x
+	 *            int
+	 * @return energy value
+	 */
 	public float getTotalEnergyAtTimeStep(int x) {
 		float result = ((float) amount) * energyAt[x];
 		return result;
 	}
 
 	/**
+	 * Get the symbol of the value (see variable description)
+	 * 
 	 * @return the sign
 	 */
 	public char getSign() {
@@ -176,6 +241,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Set symbol of the value
+	 * 
 	 * @param energy
 	 *            the sign to set
 	 */
@@ -202,6 +269,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Get the actual object
+	 * 
 	 * @return the obj
 	 */
 	public String getObj() {
@@ -209,6 +278,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Set the object to a new one
+	 * 
 	 * @param obj
 	 *            the obj to set
 	 */
@@ -217,6 +288,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Get the points (values) in the graph
+	 * 
 	 * @return the Graph Points
 	 */
 	public LinkedList<Point> getGraphPoints() {
@@ -224,6 +297,8 @@ public class HolonElement {
 	}
 
 	/**
+	 * Set the points (values) in the graph
+	 * 
 	 * @param points,
 	 *            the Graph points
 	 */
@@ -231,10 +306,20 @@ public class HolonElement {
 		this.graphPoints = points;
 	}
 
+	/**
+	 * Set the ID of the HolonElement (one time only)
+	 * 
+	 * @param id
+	 */
 	private void setId(int id) {
 		this.id = id;
 	}
 
+	/**
+	 * Get the Id of the selected HolonElement
+	 * 
+	 * @return
+	 */
 	public int getId() {
 		return id;
 	}

+ 2 - 0
src/classes/HolonObject.java

@@ -91,6 +91,8 @@ public class HolonObject extends CpsObject {
 	}
 
 	/**
+	 * doesnt take into account which timestep is watched,
+	 * calculates the max values
 	 * @return the currentEnergy
 	 */
 	public float getCurrentEnergy() {

+ 0 - 8
src/classes/HolonSwitch.java

@@ -63,15 +63,7 @@ public class HolonSwitch extends CpsObject {
 				setImage("/Images/switch-on.png");
 			}
 			this.manualActive = !manualActive;
-		} else {
-			if (this.autoActive == true) {
-				setImage("/Images/switch-off.png");
-			} else {
-				setImage("/Images/switch-on.png");
-			}
-			this.autoActive = !autoActive;
 		}
-
 	}
 
 	public boolean getState() {

+ 1 - 1
src/ui/controller/Control.java

@@ -94,7 +94,7 @@ public class Control {
 	}
 
 	public void addSwitch(Category cat, String obj) {
-		categoryController.addNewHolonSwitch(cat, obj, "/Images/switch-off.png");
+		categoryController.addNewHolonSwitch(cat, obj, "/Images/switch-on.png");
 	}
 
 	public void deleteCategory(String cat) {

+ 1 - 1
src/ui/controller/ObjectController.java

@@ -118,7 +118,7 @@ public class ObjectController {
 	}
 
 	/**
-	 * adds a selectedObject
+	 * 	s a selectedObject
 	 * 
 	 * @param Cpsobject
 	 */

+ 101 - 2
src/ui/controller/SimulationManager.java

@@ -1,6 +1,7 @@
 package ui.controller;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 
 import classes.CpsEdge;
 import classes.CpsNode;
@@ -20,6 +21,7 @@ public class SimulationManager {
 	private MyCanvas canvas;
 	private int timeStep;
 	private boolean simMode;
+	private HashMap<Integer, Float> tagTable = new HashMap<Integer, Float>();
 	
 	public SimulationManager(Model m){
 		canvas = null;
@@ -44,7 +46,7 @@ public class SimulationManager {
 			float production = calculateEnergy("prod", singleSubNet, timeStep);
 			float consumption = calculateEnergy("cons", singleSubNet, timeStep);
 			float minConsumption = calculateMinimumEnergy( singleSubNet, timeStep);
-			setFlow(singleSubNet);
+			setFlow(singleSubNet, simMode);
 			for(HolonObject hl: singleSubNet.getObjects()){
 				if(!(hl.getState() == 0) && !(hl.getState() == 3)){
 					for(int i = 0; i < hl.getConnections().size(); i++){
@@ -76,7 +78,15 @@ public class SimulationManager {
 		canvas.repaint();
 	}
 	
-	public void setFlow(subNet sN){
+	public void setFlow(subNet sN, boolean simulation){
+		if(simulation){
+			setFlowSimulation(sN);
+		} else {
+			setFlowModelation(sN);
+		}
+	}
+	
+	public void setFlowModelation(subNet sN){
 		for(HolonObject hl: sN.getObjects()){
 			float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
 			if(energy > 0){
@@ -88,18 +98,103 @@ public class SimulationManager {
 		}
 	}
 	
+	public void setFlowSimulation(subNet sN){
+		ArrayList<CpsObject> producers = new ArrayList<CpsObject>();
+		CpsObject tmp = null;
+		tagTable = new HashMap<Integer, Float>();
+		for(HolonObject hl: sN.getObjects()){
+			float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
+			if(energy > 0){
+				tagTable.put(hl.getID(), energy);
+				for(CpsEdge edge: hl.getConnections()){
+					if(edge.getState()){
+						if(edge.getA().getID() == hl.getID()){
+							edge.getB().addTag(hl.getID());
+							tmp = edge.getB();
+						}
+						if(edge.getB().getID() == hl.getID()){
+							edge.getA().addTag(hl.getID());
+							tmp = edge.getA();
+						}
+						edge.setFlow(edge.getFlow() + energy);
+						edge.calculateState(true);
+						edge.addTag(hl.getID());
+						if(edge.getState() && !producers.contains(tmp)){
+							producers.add(tmp);
+						}
+					}
+				}
+			}
+		}
+		setFlowSimRec(producers);
+	}
+	
+	public void setFlowSimRec(ArrayList<CpsObject> nodes){
+		ArrayList<CpsObject> newNodes = new ArrayList<CpsObject>();
+		CpsObject tmp = null;
+		if(nodes.size() != 0){
+			for(CpsObject cps: nodes){
+				for(CpsEdge edge: cps.getConnections()){
+					for(Integer tag: cps.getTag()){
+						if(edge.getState() && !(edge.getTags().contains(tag))){
+							edge.setFlow(edge.getFlow() + tagTable.get(tag));
+							System.out.println(cps.getID() + " has tags:" + getString(cps));
+							edge.addTag(tag);
+							if(edge.getA().getID() == cps.getID()){
+								tmp = edge.getB();
+								tmp.setTags(mergeLists(tmp.getTag(), cps.getTag()));
+							}
+							if(edge.getB().getID() == cps.getID()){
+								tmp = edge.getA();
+								tmp.setTags(mergeLists(tmp.getTag(), cps.getTag()));
+							}
+							if(edge.getState() && !(newNodes.contains(tmp))){
+								newNodes.add(tmp);
+							}	
+						}
+					}
+				edge.calculateState(true);
+				}
+			}
+			setFlowSimRec(newNodes);
+		}
+	}
+	
+	public String getString(CpsObject cps){
+		String result = "";
+		for(Integer i:cps.getTag()){
+			result = result + ", " + i;
+		}
+		return result;
+	}
+	
+	public ArrayList<Integer> mergeLists(ArrayList<Integer> A, ArrayList<Integer> B){
+		ArrayList<Integer> result = new ArrayList<Integer>();
+		for(Integer i: A){
+			if(!(B.contains(i))){
+				result.add(i);
+			}
+		}
+		result.addAll(B);
+		return result;
+	}
+	
 	public void ResetConnections(CpsObject cps, ArrayList<Integer> visitedObj, ArrayList<CpsEdge> visitedEdges){
 		visitedObj.add(cps.getID());
+		cps.resetTags();
 		for(CpsEdge e: cps.getConnections()){
 			if(!(visitedEdges.contains(e))){
 				e.setFlow(0);
 				e.calculateState(simMode);
+				e.setTags(new ArrayList<Integer>());
 				visitedEdges.add(e);
 				if(!(visitedObj.contains(e.getA().getID()))){
 					ResetConnections(e.getA(), visitedObj, visitedEdges);
+					e.getA().resetTags();
 				}
 				if(!(visitedObj.contains(e.getB().getID()))){
 					ResetConnections(e.getB(), visitedObj, visitedEdges);
+					e.getB().resetTags();
 				}
 			}
 		}
@@ -292,5 +387,9 @@ public class SimulationManager {
 		copyObjects(model.getObjectsOnCanvas());
 	}
 	
+	public ArrayList<subNet> getSubNets(){
+		return subNets;
+	}
+	
 	
 }

+ 2 - 0
src/ui/view/CategoryPanel.java

@@ -3,3 +3,5 @@ package ui.view;
 public class CategoryPanel {
 
 }
+
+//hier müsste das Panel eigentlich sein

+ 1 - 0
src/ui/view/Console.java

@@ -77,6 +77,7 @@ public class Console extends JScrollPane {
 			public void mouseReleased(MouseEvent e) {
 				if (e.getButton() == e.BUTTON3) {
 					itemClear.setEnabled(!consoleText.getText().isEmpty());
+					itemCopy.setEnabled(consoleText.getSelectedText() != null);
 					popmenu.show(e.getComponent(), e.getX(), e.getY());
 				}
 			}

+ 86 - 44
src/ui/view/GUI.java

@@ -27,11 +27,9 @@ import javax.swing.DefaultComboBoxModel;
 import javax.swing.ImageIcon;
 import javax.swing.InputMap;
 import javax.swing.JButton;
-import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
-import javax.swing.JEditorPane;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
@@ -109,7 +107,6 @@ public class GUI<E> implements CategoryListener {
 	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();
 	/******************************************
 	 ************* Right Container*************
 	 ******************************************/
@@ -135,6 +132,11 @@ public class GUI<E> implements CategoryListener {
 	// 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 static final long serialVersionUID = 1L;
+
 		@Override
 		public TableCellRenderer getCellRenderer(int row, int column) {
 			if (getValueAt(row, column) instanceof Boolean) {
@@ -231,6 +233,7 @@ public class GUI<E> implements CategoryListener {
 		simMenu = new SimulationMenu(model, control);
 		initialize();
 		updateCategories(model.getCategories());
+
 	}
 
 	/**
@@ -278,6 +281,11 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control Z"), cntrlZDown);
 		actionMap.put(cntrlZDown, new AbstractAction() {
 
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				try {
@@ -310,6 +318,11 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control Y"), cntrlYDown);
 		actionMap.put(cntrlYDown, new AbstractAction() {
 
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				try {
@@ -341,6 +354,11 @@ public class GUI<E> implements CategoryListener {
 		String cntrlADown = "controlA";
 		inputMap.put(KeyStroke.getKeyStroke("control A"), cntrlADown);
 		actionMap.put(cntrlADown, new AbstractAction() {
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				model.getSelectedCpsObjects().clear();
@@ -354,6 +372,11 @@ public class GUI<E> implements CategoryListener {
 		String delDown = "delete";
 		inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false), delDown);
 		actionMap.put(delDown, new AbstractAction() {
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				for (CpsObject cps : model.getSelectedCpsObjects()) {
@@ -373,11 +396,16 @@ public class GUI<E> implements CategoryListener {
 				unitGraph.empty();
 			}
 		});
-		
+
 		String cntrlFDown = "controlF";
 		inputMap.put(KeyStroke.getKeyStroke("control F"), cntrlFDown);
 		actionMap.put(cntrlFDown, new AbstractAction() {
 
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				searchPopUp dialog = new searchPopUp(controller, canvas);
@@ -386,13 +414,15 @@ public class GUI<E> implements CategoryListener {
 			}
 		});
 
-		
-		
-
 		String cntrlCDown = "controlC";
 		inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
 		actionMap.put(cntrlCDown, new AbstractAction() {
 
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				if (!model.getSelectedCpsObjects().isEmpty()) {
@@ -408,6 +438,11 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control V"), cntrlVDown);
 		actionMap.put(cntrlVDown, new AbstractAction() {
 
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				controller.pasteObjects(canvas.getMousePosition());
@@ -419,6 +454,11 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control X"), cntrlXDown);
 		actionMap.put(cntrlXDown, new AbstractAction() {
 
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				if (!model.getSelectedCpsObjects().isEmpty()) {
@@ -888,12 +928,11 @@ public class GUI<E> implements CategoryListener {
 							if (value.toString().compareTo(cps.getObjName()) == 0) {
 								File checkPath = new File(cps.getImage());
 								if (checkPath.exists()) {
-									imgR = new ImageIcon(cps.getImage()).getImage().getScaledInstance(
-											50, 50, java.awt.Image.SCALE_SMOOTH);
+									imgR = new ImageIcon(cps.getImage()).getImage().getScaledInstance(50, 50,
+											java.awt.Image.SCALE_SMOOTH);
 								} else {
 									imgR = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
-											.getScaledInstance(50, 50,
-													java.awt.Image.SCALE_SMOOTH);
+											.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
 								}
 								if (imgR != null) {
 									label.setIcon(new ImageIcon(imgR));
@@ -966,7 +1005,7 @@ public class GUI<E> implements CategoryListener {
 					DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree
 							.getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
 					if (selectedNode.getLevel() == 2) {
-						CpsObject selected = controller.searchCategoryObject(selectedNode.getParent().toString(),
+						controller.searchCategoryObject(selectedNode.getParent().toString(),
 								selectedNode.toString());
 						deleteRows(tableModelHolonElementSingle);
 						deleteRows(tableModelHolonElementMulti);
@@ -995,13 +1034,11 @@ public class GUI<E> implements CategoryListener {
 								if (actualObjectClicked.compareTo(cps.getObjName()) == 0) {
 									File checkPath = new File(cps.getImage());
 									if (checkPath.exists()) {
-										img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(
-												50, 50,
+										img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(50, 50,
 												java.awt.Image.SCALE_SMOOTH);
 									} else {
 										img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
-												.getScaledInstance(50, 50,
-														java.awt.Image.SCALE_SMOOTH);
+												.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
 									}
 									tempCps = cps;
 									dragging = true;
@@ -1034,7 +1071,7 @@ public class GUI<E> implements CategoryListener {
 
 		panel.add(toolBar);
 		toolBar.add(comboBox);
-		comboBox.setModel(new DefaultComboBoxModel(new String[] { "Category", "Object", "Transformer", "Switch" }));
+		comboBox.setModel(new DefaultComboBoxModel(new String[] { "Category", "Object", "Switch" }));
 		// Add Button
 		btnAdd.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {
@@ -1042,32 +1079,36 @@ public class GUI<E> implements CategoryListener {
 				Object nodeInfo = tree.getLastSelectedPathComponent();
 				String selectedOption = comboBox.getSelectedItem().toString();
 				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) nodeInfo;
+				try {
 
-				switch (selectedOption) {
+					switch (selectedOption) {
 
-				case "Category":
-					String catName = JOptionPane.showInputDialog("Please enter a Name for Category ");
-					if (catName.length() != 0) {
-						controller.addCategory(catName);
-					}
-					break;
-				case "Object":
-					if (selectedNode == null) {
-						JOptionPane.showMessageDialog(new JFrame(),
-								"Please select a Category first before adding " + selectedOption + ".");
-					}
-					if (selectedNode.getLevel() == 1) {
-						CpsObject tmp = new HolonObject("");
-						addObjectPopUP = new AddObjectPopUp(false, tmp, null);
-						addObjectPopUP.setVisible(true);
-						addObjectPopUP.setController(controller);
-						addObjectPopUP.setCategory(selectedNode.toString());
-					}
-					break;
+					case "Category":
+						String catName = JOptionPane.showInputDialog("Please enter a Name for Category ");
+						if (catName.length() != 0) {
+							controller.addCategory(catName);
+						}
+						break;
+					case "Object":
+						if (selectedNode == null) {
+							JOptionPane.showMessageDialog(new JFrame(),
+									"Please select a Category first before adding " + selectedOption + ".");
+						}
+						if (selectedNode.getLevel() == 1) {
+							CpsObject tmp = new HolonObject("");
+							addObjectPopUP = new AddObjectPopUp(false, tmp, null);
+							addObjectPopUP.setVisible(true);
+							addObjectPopUP.setController(controller);
+							addObjectPopUP.setCategory(selectedNode.toString());
+						}
+						break;
 
-				default:
-					addObjectAction(selectedOption, selectedNode);
-					break;
+					default:
+						addObjectAction(selectedOption, selectedNode);
+						break;
+					}
+				} catch (Exception e) {
+					// TODO: handle exception
 				}
 				tree.repaint();
 			}
@@ -1502,10 +1543,6 @@ public class GUI<E> implements CategoryListener {
 					case "Switch":
 						controller.addSwitch(cat, objname);
 						break;
-
-					case "Transformer":
-						controller.addTransformer(cat, objname);
-						break;
 					}
 				}
 			} else {
@@ -1520,6 +1557,11 @@ public class GUI<E> implements CategoryListener {
 	 */
 	public void updateCategories(final ArrayList<Category> categories) {
 		tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Categories") {
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
 			{
 				DefaultMutableTreeNode node_1;
 				for (Category c : categories) {

+ 11 - 4
src/ui/view/MyCanvas.java

@@ -156,8 +156,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 		g2.setRenderingHints(rh);
 
-		// drawEdges
-		// g2.setColor(Color.BLACK);
+		// drawEdges that is being dragged
 		if (drawEdge) {
 			g2.setColor(Color.BLACK);
 			g2.setStroke(new BasicStroke(2));
@@ -230,7 +229,11 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			}
 		} else if (edgeHighlight != null) {
 			g2.setColor(Color.BLUE);
-			g2.setStroke(new BasicStroke(2));
+			if (edgeHighlight.getFlow() <= edgeHighlight.getCapacity()) {
+				g2.setStroke(new BasicStroke(Math.min((edgeHighlight.getFlow() / edgeHighlight.getCapacity() * 4), 4)));
+			} else {
+				g2.setStroke(new BasicStroke(2));
+			}
 			g2.drawLine(edgeHighlight.getA().getPosition().x + controller.getScaleDiv2(),
 					edgeHighlight.getA().getPosition().y + controller.getScaleDiv2(),
 					edgeHighlight.getB().getPosition().x + controller.getScaleDiv2(),
@@ -379,7 +382,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			sx = e.getX();
 			sy = e.getY();
 			doMark = true;
-		}
+		}		
 		// Object Selection Highlighting (selectRect)
 		objectSelectionHighlighting();
 
@@ -428,6 +431,10 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			}
 			TempSelected.clear();
 		}
+		
+		if (doubleClick() && tempCps != null && tempCps instanceof HolonSwitch) {
+			((HolonSwitch)tempCps).switchState();
+		}
 
 		controller.calculateStateForTimeStep(model.getCurIteration());
 

+ 6 - 6
src/ui/view/SimulationMenu.java

@@ -51,7 +51,7 @@ public class SimulationMenu extends JMenuBar {
 	private JComboBox algoCombo = new JComboBox<>();
 	private JButton algoFolderButton = new JButton("Algorithm:");
 	private HashMap<String, File> algosHash = new HashMap<>();
-	
+
 	Model model;
 	Control controller;
 
@@ -80,10 +80,9 @@ public class SimulationMenu extends JMenuBar {
 					File[] files = fileChooser.getSelectedFile().listFiles();
 					for (int i = 0; i < files.length; i++) {
 						if (files[i].toString().endsWith(".java") || files[i].toString().endsWith(".class")) {
-							String name = files[i].toString();
-							int tmpA = name.lastIndexOf('/');
+							String name = files[i].getName();
 							int tmpB = name.lastIndexOf('.');
-							name = name.substring(tmpA+1, tmpB);
+							name = name.substring(0, tmpB);
 							algosHash.put(name, files[i]);
 							algoCombo.addItem(name);
 						}
@@ -107,6 +106,7 @@ public class SimulationMenu extends JMenuBar {
 			@Override
 			public void propertyChange(PropertyChangeEvent evt) {
 				controller.setIsSimulation(simButton.isSelected());
+				controller.calculateStateForCurrentTimeStep();
 			}
 		});
 		GridBagConstraints gbc_simButton = new GridBagConstraints();
@@ -155,8 +155,8 @@ public class SimulationMenu extends JMenuBar {
 		gbc_algoCombo.gridy = 0;
 		menuPanel.add(algoCombo, gbc_algoCombo);
 		algoCombo.addItem("choose folder");
-		
-		//Add Panel to SimulationMenu
+
+		// Add Panel to SimulationMenu
 		this.add(menuPanel);
 	}
 }

+ 32 - 8
src/ui/view/UnitGraph.java

@@ -19,8 +19,6 @@ import java.awt.Point;
 
 import javax.swing.JPanel;
 
-import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;
-
 import classes.HolonElement;
 import ui.controller.Control;
 import ui.model.Model;
@@ -33,12 +31,17 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	private static final long serialVersionUID = 1L;
 	private float MAXIMUM = 0;
 
+	// Information shown when a Point is Dragged
+	private String dragInformation = "";
+
+	// Points
 	private Point recSize = new Point(8, 8); // Point Size
 	private Graphics2D g2;
 	private CubicCurve2D c = new CubicCurve2D.Double();
 	private CubicCurve2D cr = new CubicCurve2D.Double();
 	private CubicCurve2D cl = new CubicCurve2D.Double();
 	private LinkedList<Point> pointList;
+	// Scale for the Graph
 	private double scaleX;
 	private double scaleY;
 
@@ -52,7 +55,6 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	private boolean isSwitch = false;
 
 	private ArrayList<HolonElement> tempElements = new ArrayList<>();
-	private HolonSwitch tempSwitch;
 	private Model model;
 	private Control controller;
 	private Line2D.Double line = null;
@@ -105,6 +107,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 		if (isElement) {
 			// array fillen
 			fillArrayofValue();
+
 			if (arrayOfFloats != null) {
 				// Draw the Lines
 				g2.setStroke(new BasicStroke(2));
@@ -130,6 +133,12 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 							this.getHeight() - 10);
 				}
 			}
+			// drag Information
+			if (tempP != null) {
+				dragInformation = "" + convertToValueY(getYValueAt((int) tempP.getX()));
+				g2.drawString(dragInformation, (int) (tempP.getX() * scaleX) + 10, (int) (tempP.getY() * scaleY) + 10);
+			}
+
 			/*
 			 * // Actual Iteration Point Visualization g2.setColor(Color.RED);
 			 * if (arrayOfValue != null) { for (int i = 0; i <
@@ -169,7 +178,21 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 							this.getHeight() - 10);
 				}
 			}
+			if (tempP != null) {
+				try {
+					int i;
+					for (i = 0; (i * this.getWidth() / (model.getIterations() - 1) < getMousePosition().getX()); i++) {
+
+					}
+					dragInformation = "" + i;
+					g2.drawString(dragInformation, (int) (getMousePosition().getX()) + 10,
+							(int) (getMousePosition().getY()) + 10);
+				} catch (Exception e) {
+					// TODO: handle exception
+				}
+			}
 		}
+
 		// Iteration Line
 		g2.setColor(Color.BLUE);
 		g2.setStroke(new BasicStroke(1));
@@ -212,6 +235,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 				x = tempP.getX();
 			}
 			tempP.setLocation(x, y);
+
 			repaint();
 		}
 	}
@@ -334,7 +358,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 		boolean deletePoint = false;
 
 		double x = e.getX() / scaleX;
-		double y = e.getY() / scaleY;
+		e.getY();
 
 		// Halbe Iterations Distanz
 		double dist = (width / (model.getIterations() - 1)) / 2;
@@ -407,6 +431,8 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 			pointDrag = false;
 			tempP = null;
 		}
+		dragInformation = "";
+		repaint();
 	}
 
 	public void componentResized(ComponentEvent e) {
@@ -443,12 +469,11 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	}
 
 	/*
-	 * Emptys the Graph
+	 * Empty the Graph
 	 */
 	public void empty() {
 		pointList = null;
 		tempElements = null;
-		tempSwitch = null;
 		arrayOfFloats = null;
 		arrayOfBooleans = null;
 		isSwitch = false;
@@ -501,7 +526,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));
@@ -517,7 +542,6 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	 */
 	public void repaintWithNewSwitch(HolonSwitch s) {
 		arrayOfBooleans = s.getActiveAt();
-		tempSwitch = s;
 		pointList = s.getGraphPoints();
 		isSwitch = true;
 		isElement = false;