Преглед на файлове

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

dominik.rieder преди 7 години
родител
ревизия
daa550f097

+ 1 - 1
.checkstyle

@@ -1,7 +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">
+  <fileset name="all" enabled="true" check-config-name="BP Configuration" local="false">
     <file-match-pattern match-pattern="." include-pattern="true"/>
   </fileset>
 </fileset-config>

BIN
.gradle/2.2.1/taskArtifacts/cache.properties.lock


BIN
.gradle/2.2.1/taskArtifacts/fileHashes.bin


BIN
.gradle/2.2.1/taskArtifacts/fileSnapshots.bin


BIN
.gradle/2.2.1/taskArtifacts/outputFileStates.bin


BIN
.gradle/2.2.1/taskArtifacts/taskArtifacts.bin


+ 9 - 1
build.gradle

@@ -10,6 +10,9 @@
 
 // Apply the java plugin to add support for Java
 apply plugin: 'java'
+apply plugin: 'application'
+
+mainClassName = 'ui.view.Main'
 
 jar {
     manifest {
@@ -20,7 +23,7 @@ jar {
 sourceSets {
     test{
 		java{
-			srcDir 'src/tests'
+			srcDirs = ["src/tests"]
 		}
 		resources{
 			srcDir 'res'
@@ -36,8 +39,13 @@ sourceSets {
     }
 }
 
+repositories {
+ mavenCentral()
+}
+
  dependencies {   
        compile fileTree(dir: 'jars', include: ['*.jar'])
+       testCompile group: 'junit', name: 'junit', version: '4.+'
 }
 /*
 // In this section you declare where to find the dependencies of your project

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Sat Sep 24 14:38:34 CEST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip

+ 1 - 1
src/classes/HolonElement.java

@@ -59,7 +59,7 @@ public class HolonElement {
 		setActive(true);
 		setSign(energy);
 		setEnergyAt(energy);
-		// setId(idCounterElem.nextId());
+		setId(idCounterElem.nextId());
 	}
 
 	/**

+ 83 - 4
src/classes/HolonSwitch.java

@@ -3,6 +3,14 @@ package classes;
 import java.awt.Point;
 import java.util.LinkedList;
 
+/**
+ * The class HolonSwitch represents an Object in the system, that has the
+ * capacity of manipulate the electricity flow. The switch can be manage
+ * automatically through a graph or direct manually.
+ * 
+ * @author Gruppe14
+ *
+ */
 public class HolonSwitch extends CpsObject {
 	/*
 	 * manual state True, if this wire is working (capable of carrying
@@ -29,6 +37,13 @@ public class HolonSwitch extends CpsObject {
 	// Points on the UnitGraph
 	LinkedList<Point> graphPoints = new LinkedList<>();
 
+	/**
+	 * Create a new HolonSwitch with the default name ("Switch"), a default
+	 * value of automatic handle and active status
+	 * 
+	 * @param ObjName
+	 *            String
+	 */
 	public HolonSwitch(String ObjName) {
 		super(ObjName);
 		setManualState(true);
@@ -37,6 +52,15 @@ public class HolonSwitch extends CpsObject {
 		setManualMode(false);
 	}
 
+	/**
+	 * Create a new HolonSwitch with user-defined name, a default value of
+	 * automatic handle and active status
+	 * 
+	 * @param ObjName
+	 *            String
+	 * @param obj
+	 *            String
+	 */
 	public HolonSwitch(String ObjName, String obj) {
 		super(ObjName);
 		super.setName(obj);
@@ -46,6 +70,11 @@ public class HolonSwitch extends CpsObject {
 		setManualMode(false);
 	}
 
+	/**
+	 * Create a copy of an existing HolonSwitch.
+	 * 
+	 * @param obj
+	 */
 	public HolonSwitch(CpsObject obj) {
 		super(obj);
 		super.setName(obj.getName());
@@ -55,6 +84,9 @@ public class HolonSwitch extends CpsObject {
 		setManualMode(false);
 	}
 
+	/**
+	 * Calculates the state of the Switch
+	 */
 	public void switchState() {
 		if (manualMode) {
 			if (this.manualActive == true) {
@@ -65,15 +97,27 @@ public class HolonSwitch extends CpsObject {
 			this.manualActive = !manualActive;
 		}
 	}
-	
-	public boolean getState(int timeStep){
-		if(manualMode){
+
+	/**
+	 * Getter for the status of the Switch at a given timestep
+	 * 
+	 * @param timeStep
+	 *            int
+	 * @return state value
+	 */
+	public boolean getState(int timeStep) {
+		if (manualMode) {
 			return this.manualActive;
 		} else {
 			return getActiveAt()[timeStep];
 		}
 	}
 
+	/**
+	 * Overall status of the switch (manual or automatic mode)
+	 * 
+	 * @return
+	 */
 	public boolean getState() {
 		if (manualMode) {
 			return this.manualActive;
@@ -83,16 +127,29 @@ public class HolonSwitch extends CpsObject {
 
 	}
 
+	/**
+	 * Change the state of the Switch to manual
+	 * 
+	 * @param state
+	 */
 	public void setManualState(boolean state) {
 		this.manualActive = state;
 		setImage();
 	}
 
+	/**
+	 * Set the state of the Switch to automatic
+	 * 
+	 * @param state
+	 */
 	public void setAutoState(boolean state) {
 		this.autoActive = state;
 		setImage();
 	}
 
+	/**
+	 * Set Image of the Switch
+	 */
 	private void setImage() {
 		if (manualMode) {
 			if (this.manualActive == false) {
@@ -110,6 +167,8 @@ public class HolonSwitch extends CpsObject {
 	}
 
 	/**
+	 * For automatic use only (throught the graph)
+	 * 
 	 * @return the Graph Points
 	 */
 	public LinkedList<Point> getGraphPoints() {
@@ -117,6 +176,8 @@ public class HolonSwitch extends CpsObject {
 	}
 
 	/**
+	 * Set the values of the switch in the graph (auto. mode only)
+	 * 
 	 * @param points,
 	 *            the Graph points
 	 */
@@ -125,17 +186,25 @@ public class HolonSwitch extends CpsObject {
 	}
 
 	/**
-	 * get the activeAt Array
+	 * All values of the graph for the selected Switch (only auto-Mode) get the
+	 * activeAt Array
 	 */
 	public boolean[] getActiveAt() {
 		return activeAt;
 	}
 
+	/**
+	 * Overall value of the Swtich (only manual-Mode)
+	 * 
+	 * @return
+	 */
 	public boolean getActiveManual() {
 		return this.manualActive;
 	}
 
 	/**
+	 * Set the value of the Switch
+	 * 
 	 * @param active,
 	 *            the default value
 	 */
@@ -145,10 +214,20 @@ public class HolonSwitch extends CpsObject {
 		}
 	}
 
+	/**
+	 * Set the overall value of the Switch (manual mode)
+	 * 
+	 * @param mode
+	 */
 	public void setManualMode(boolean mode) {
 		manualMode = mode;
 	}
 
+	/**
+	 * Get the value of the switch (manual mode)
+	 * 
+	 * @return
+	 */
 	public boolean getManualMode() {
 		return manualMode;
 	}

+ 22 - 5
src/classes/Position.java

@@ -1,16 +1,33 @@
 package classes;
 
+/**
+ * Coordinates of an Object on the canvas with a (int) x-coord and a (int)
+ * y-coord
+ * 
+ * @author Gruppe14
+ *
+ */
 public class Position {
 	public int x;
 	public int y;
-	
-	public Position(int x, int y){
+
+	/**
+	 * Constructor with an positive x and y coord on the canvas
+	 * 
+	 * @param x
+	 *            int
+	 * @param y
+	 *            int
+	 */
+	public Position(int x, int y) {
 		this.x = x;
 		this.y = y;
 	}
-	
-	//default Constructor
-	public Position(){
+
+	/**
+	 * Default constructor without defined position
+	 */
+	public Position() {
 		this.x = -1;
 		this.y = -1;
 	}

+ 14 - 8
src/classes/subNet.java

@@ -2,26 +2,32 @@ package classes;
 
 import java.util.ArrayList;
 
+/**
+ * The class "subNet" represents ....
+ * 
+ * @author Gruppe14
+ *
+ */
 public class subNet {
 	private ArrayList<HolonObject> subNetObjects;
 	private ArrayList<CpsEdge> subNetEdges;
 	private ArrayList<HolonSwitch> subNetSwitches;
-	
-	public subNet(ArrayList<HolonObject> objects, ArrayList<CpsEdge> edges, ArrayList<HolonSwitch> switches){
+
+	public subNet(ArrayList<HolonObject> objects, ArrayList<CpsEdge> edges, ArrayList<HolonSwitch> switches) {
 		subNetObjects = objects;
 		subNetEdges = edges;
 		subNetSwitches = switches;
 	}
-	
-	public ArrayList<HolonObject> getObjects(){
+
+	public ArrayList<HolonObject> getObjects() {
 		return subNetObjects;
 	}
-	
-	public ArrayList<CpsEdge> getEdges(){
+
+	public ArrayList<CpsEdge> getEdges() {
 		return subNetEdges;
 	}
-	
-	public ArrayList<HolonSwitch> getSwitches(){
+
+	public ArrayList<HolonSwitch> getSwitches() {
 		return subNetSwitches;
 	}
 }

+ 8 - 0
src/tests/praktikumHolonsTestClasses.java

@@ -0,0 +1,8 @@
+package tests;
+
+import classes.*;
+
+public class praktikumHolonsTestClasses {
+
+	
+}

+ 208 - 16
src/tests/praktikumHolonsTestLoadAndStoreController.java

@@ -1,11 +1,20 @@
 package tests;
 
+import java.awt.Point;
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedList;
 
 import org.junit.Before;
 import org.junit.Test;
 
+import com.sun.security.auth.UnixNumericGroupPrincipal;
+
+import classes.Category;
+import classes.CpsEdge;
+import classes.CpsObject;
+import classes.HolonElement;
 import classes.HolonObject;
 
 import static org.junit.Assert.assertEquals;
@@ -19,6 +28,8 @@ import ui.controller.MultiPurposeController;
 import ui.controller.ObjectController;
 import ui.controller.StoreController;
 import ui.model.Model;
+import ui.model.idCounter;
+import ui.view.UnitGraph;
 
 public class praktikumHolonsTestLoadAndStoreController {
 
@@ -30,9 +41,9 @@ public class praktikumHolonsTestLoadAndStoreController {
 	protected ObjectController obj;
 	protected StoreController storeController;
 	protected LoadController loadController;
+	protected idCounter id;
 	protected String path = System.getProperty("user.home") + "/HolonGUI/Test/";
-	
-	
+
 	@Before
 	public void setUp() {
 		adapter = new praktikumHolonsAdapter();
@@ -43,29 +54,139 @@ public class praktikumHolonsTestLoadAndStoreController {
 		obj = new ObjectController(model, mp);
 		storeController = new StoreController(model);
 		loadController = new LoadController(model, cg, cvs, obj, mp);
+		// cg.initCategories();
+		// obj.initHolonElements();
 		File file = new File(path);
 		file.mkdirs();
 	}
-	
+
 	@Test
-	public void testStoreMinimal(){
-		cg.initCategories();
-		obj.initHolonElements();
+	public void testStoreMinimal() {
 		try {
 			File sav = new File(path + "TestSavMinimal.json");
 			storeController.writeSaveFile(sav.getAbsolutePath());
 			assertTrue("Save File was not created", new File(path + "TestSavMinimal.json").exists());
-			
-			File cat = new File(path + "TestCatMinimal.json");
+
+			File cat = new File(path + "TestCategoryMinimal.json");
 			storeController.writeCategoryFile(cat.getAbsolutePath());
-			assertTrue("Category File was not created", new File(path + "TestCatMinimal.json").exists());
-			
+			assertTrue("Category File was not created", new File(path + "TestCategoryMinimal.json").exists());
+
 			File canvas = new File(path + "TestCanvasMinimal.json");
 			storeController.writeCanvasFile(canvas.getAbsolutePath());
 			assertTrue("Canvas File was not created", new File(path + "TestCanvasMinimal.json").exists());
-			
+
+			assertTrue("Non Existant File exist", !new File(path + "TestDummyMinimal.json").exists());
+
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	@Test
+	public void testStoreBasic() {
+
+		for (int i = 1; i <= 26; i++) {
+			cg.addNewCategory(adapter.generate(i));
+			assertTrue("Number of Categories does not match", model.getCategories().size() == i + 3);
+			assertTrue("Category was not created", mp.searchCat(adapter.generate(i)) != null);
+			for (int j = 1; j <= 10; j++) {
+				cg.addNewHolonObject(mp.searchCat(adapter.generate(i)), adapter.generate(j), new ArrayList<>(), "");
+				assertTrue("Number of Objects does not match",
+						mp.searchCat(adapter.generate(i)).getObjects().size() == j);
+				assertTrue("Object was not created", mp.searchCat(adapter.generate(i)).getObjects().get(j - 1) != null);
+			}
+		}
+
+		// here some Objects were dropped on the canvas
+		for (int i = 1; i <= 10; i++) {
+			cvs.addNewObject(new HolonObject(mp.searchCatObj(mp.searchCat("Building"), "House")));
+			assertTrue("Size of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == i);
+			assertTrue("Object was not added", model.getObjectsOnCanvas().get(i - 1) != null
+					&& model.getObjectsOnCanvas().get(i - 1).getObjName().equals("House"));
+		}
+
+		try {
+			File sav = new File(path + "TestSavBasic.json");
+			storeController.writeSaveFile(sav.getAbsolutePath());
+			assertTrue("Save File was not created", new File(path + "TestSavBasic.json").exists());
+
+			File canvas = new File(path + "TestCanvasBasic.json");
+			storeController.writeCanvasFile(canvas.getAbsolutePath());
+			assertTrue("Canvas File was not created", new File(path + "TestCanvasBasic.json").exists());
+
 			assertTrue("Non Existant File exist", !new File(path + "TestDummyMinimal.json").exists());
+
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	@Test
+	public void testStoreAdvanced() {
+
+		setGraphPoints((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"));
+
+		int n = 0;
+		for (int i = 0; i < 10; i++) {
+			for (int j = 0; j < 10; j++) {
+				HolonObject h = new HolonObject(mp.searchCatObj(mp.searchCat("Building"), "House"));
+				h.setPosition(j * 50, i * 50);
+				cvs.addNewObject(h);
+				setGraphPoints(h);
+				for (CpsObject cps : model.getObjectsOnCanvas()) {
+					if (!cps.equals(h))
+						cvs.addEdgeOnCanvas(new CpsEdge(h, cps));
+				}
+
+				// vollständiger Graph
+				n = model.getObjectsOnCanvas().size();
+				assertTrue("Number of Edges does not Match", model.getEdgesOnCanvas().size() == (n * (n - 1)) / 2);
+			}
+		}
+
+		try {
+			File sav = new File(path + "TestSavAdvanced.json");
+			storeController.writeSaveFile(sav.getAbsolutePath());
+			assertTrue("Save File was not created", new File(path + "TestSavAdvanced.json").exists());
+
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+	}
+
+	@Test
+	public void testLoadMinimal() {
+		try {
+			//Category Tests
+			Category building = mp.searchCat("Building");
+			assertTrue("Number of Categories does not match", model.getCategories().size() == 3);
+			assertTrue("TestFile was not found", new File(path + "TestCategoryMinimal.json").exists());
+			loadController.readJSON(path + "TestCategoryMinimal.json");
+			assertTrue("Number of Categories does not match", model.getCategories().size() == 3);
+			//Tests if its same instance and if Name is the same
+			assertTrue("Same instance of Category:Building", building != mp.searchCat("Building")
+					&& building.getName().equals(mp.searchCat("Building").getName()));
+			
+			//Canvas Tests.. basically nothing happens because nothing is on the Canvas
+			assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
+			assertTrue("TestFile was not found", new File(path + "TestCanvasMinimal.json").exists());
+			loadController.readJSON(path + "TestCanvasMinimal.json");
+			assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
 			
+			//Save File tests basically both Test from Above Combined
+			building = mp.searchCat("Building");
+			assertTrue("Number of Objects in Energy does not Match", mp.searchCat("Energy").getObjects().size() == 1);
+			assertTrue("TestFile was not found", new File(path + "TestSavMinimal.json").exists());
+			loadController.readJSON( path + "TestSavMinimal.json");
+			assertTrue("Number of Objects in Energy does not Match", mp.searchCat("Energy").getObjects().size() == 1);
+			assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
+			assertTrue("Same instance of Category:Building", building != mp.searchCat("Building")
+					&& building.getName().equals(mp.searchCat("Building").getName()));
+
 		} catch (IOException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
@@ -73,11 +194,82 @@ public class praktikumHolonsTestLoadAndStoreController {
 	}
 	
 	@Test
-	public void testStoreCanvas() {
-		for (int i = 1; i < 11; i++) {
-			cvs.addNewObject(new HolonObject(adapter.generate(i)));
-			assertTrue("Size of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == i);
-			assertTrue("Object was not created", mp.searchByID(i) != null && mp.searchByID(i).getObjName().equals(adapter.generate(i)));
+	public void testLoadBasic() {
+		assertTrue("Non-Existant Category Exists", mp.searchCat("J") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("U") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("L") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("I") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("A") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("N") == null);
+		
+		
+		try {
+			assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
+			assertTrue("Canvas File was not found", new File(path + "TestCanvasBasic.json").exists());
+			loadController.readJSON(path + "TestCanvasBasic.json");
+			assertTrue("NUmber of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 10);
+			for (CpsObject obj : model.getObjectsOnCanvas()) {
+				assertTrue("Not instance of HolonObject", obj instanceof HolonObject);
+			}
+			
+			assertTrue("NUmber of Categories not match", model.getCategories().size() == 3);
+			assertTrue("Canvas File was not found", new File(path + "TestSavBasic.json").exists());
+			loadController.readJSON(path + "TestSavBasic.json");
+			assertTrue("NUmber of Categories not match", model.getCategories().size() == 29);
+			assertTrue("Existant Category dont Exists", mp.searchCat("J") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("U") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("L") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("I") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("A") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("N") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "A") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "B") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "C") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "D") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "E") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "F") != null);
+			
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	@Test
+	public void testLoadAdvanced() {
+		
+		try {
+			assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
+			assertTrue("Save File was not found", new File(path + "TestSavAdvanced.json").exists());
+			loadController.readJSON(path + "TestSavAdvanced.json");
+			assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 100);
+			
+			int n = model.getObjectsOnCanvas().size();
+			assertTrue("Number of Edges does not Match", model.getEdgesOnCanvas().size() == (n * (n - 1)) / 2);
+			assertTrue("Element has no UnitGraph", !mp.searchEle((HolonObject)model.getObjectsOnCanvas().get(77), "Fridge").getGraphPoints().isEmpty());
+			assertTrue("Points in UnitGraph does not Match", mp.searchEle((HolonObject)model.getObjectsOnCanvas().get(77), "Fridge").getGraphPoints().size() == 3);
+
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
 		}
 	}
+
+	/**
+	 * 
+	 * @param obj
+	 */
+	public void setGraphPoints(HolonObject obj) {
+		LinkedList<Point> list = new LinkedList<>();
+		list.add(new Point(0, 0));
+		list.add(new Point(125, 50));
+		list.add(new Point(249, 0));
+		UnitGraph u = new UnitGraph(model, null);
+		u.repaintWithNewElement(obj.getElements());
+		u.fillArrayofValue();
+		for (HolonElement ele : obj.getElements()) {
+			ele.setGraphPoints(list);
+		}
+
+	}
 }

+ 5 - 0
src/tests/praktikumHolonsTestStressAnalysis.java

@@ -0,0 +1,5 @@
+package tests;
+
+public class praktikumHolonsTestStressAnalysis {
+
+}

+ 0 - 1
src/tests/praktikumHolonsTestSuite.java

@@ -14,7 +14,6 @@ public class praktikumHolonsTestSuite {
 		suite.addTest(new JUnit4TestAdapter(praktikumHolonsTestCanvasController.class));
 		suite.addTest(new JUnit4TestAdapter(praktikumHolonsTestObjectController.class));
 		suite.addTest(new JUnit4TestAdapter(praktikumHolonsTestLoadAndStoreController.class));
-//		suite.addTest(new JUnit4TestAdapter(praktikumHolonsTestLoadController.class));
 //		suite.addTest(new JUnit4TestAdapter(praktikumHolonsTestMultiPurposeController.class));
 //		suite.addTest(new JUnit4TestAdapter(praktikumHolonsTestGlobalController.class));
 //		suite.addTest(new JUnit4TestAdapter(praktikumHolonsTestAutoSaveController.class));

+ 0 - 1
src/ui/model/Model.java

@@ -77,7 +77,6 @@ public class Model {
 	 * default values.
 	 */
 	public Model() {
-
 		setCategories(new ArrayList<Category>());
 		setObjectsOnCanvas(new ArrayList<CpsObject>());
 		setEdgesOnCanvas(new ArrayList<CpsEdge>());

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

@@ -169,6 +169,7 @@ public class AddElementPopUp extends JDialog {
 				});
 			}
 		}
+
 	}
 
 	public void setActualCps(CpsObject cps) {

+ 48 - 25
src/ui/view/GUI.java

@@ -105,7 +105,7 @@ public class GUI<E> implements CategoryListener {
 	private final JLabel elementGraph = new JLabel("None ");
 	private final ArrayList<HolonElement> selectedElements = new ArrayList<HolonElement>();
 	private String holonEleNamesDisplayed = "None ";
-	HashMap<Integer, ArrayList<HolonElement>> eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
+	private HashMap<Integer, ArrayList<HolonElement>> eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
 	private final JTree tree = new JTree();
 	/******************************************
 	 ************* Right Container*************
@@ -210,6 +210,9 @@ public class GUI<E> implements CategoryListener {
 	// Coord for all Cells with boolean values (checkbox)
 	private int yBTHIS;
 	private int xBTHIS;
+	// Coord for the Edit-Modus in the PropertieTable
+	private int yProThis;
+	private int xProThis;
 	private CpsObject temp = null;
 	private final JButton btnTest = new JButton("test");
 	private final JMenuItem mntmUndo = new JMenuItem("Undo");
@@ -652,8 +655,10 @@ public class GUI<E> implements CategoryListener {
 						addElementPopUp.setActualCps(getActualCps());
 						addElementPopUp.setVisible(true);
 						HolonElement ele = addElementPopUp.getElement();
-						controller.addElementCanvasObject(tempCpsObject.getID(), ele.getEleName(), ele.getAmount(),
-								ele.getEnergy());
+						if (ele != null) {
+							controller.addElementCanvasObject(tempCpsObject.getID(), ele.getEleName(), ele.getAmount(),
+									ele.getEnergy());
+						}
 						refreshTableHolonElement();
 						refreshTableProperties();
 						controller.calculateStateForTimeStep(model.getCurIteration());
@@ -843,6 +848,20 @@ public class GUI<E> implements CategoryListener {
 		/***********************
 		 * HolonElement Properties Actions
 		 **********************/
+
+		/*
+		 * Update of the mouse coord for Edit-Mode
+		 */
+		tableProperties.addMouseListener(new MouseAdapter() {
+			public void mousePressed(MouseEvent e) {
+				if (e.getClickCount() == 2) {
+					yProThis = e.getY();
+					xProThis = e.getX();
+				}
+
+			}
+		});
+
 		/*
 		 * Update any change in the Property table
 		 */
@@ -851,17 +870,21 @@ public class GUI<E> implements CategoryListener {
 			public void propertyChange(PropertyChangeEvent evt) {
 				try {
 					Object temp;
+					Object btemp;
 					Point mousePos = tableProperties.getMousePosition();
+					int selValueY = (int) Math.floor(yProThis / 16);
+					int selValueX = (int) Math.floor(xProThis / (tableProperties.getWidth() / 2));
+					temp = tableModelProperties.getValueAt(selValueY, selValueX);
 					if (getActualCps() != null) {
-						temp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
-								mousePos.x / (tableProperties.getWidth() / 2));
-						if (getActualCps() instanceof HolonObject) {
-							getActualCps().setName(temp.toString());
-						} else if (getActualCps() instanceof HolonSwitch) {
-							if (mousePos.y / tableProperties.getRowHeight() == 2) {
-								Boolean bTemp = Boolean.parseBoolean(temp.toString());
-								((HolonSwitch) getActualCps()).setManualMode(bTemp);
-								if (bTemp) {
+						if (getActualCps() instanceof HolonSwitch) {
+							btemp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
+									mousePos.x / (tableProperties.getWidth() / 2));
+							if (mousePos.y / tableProperties.getRowHeight() == 0) {
+								getActualCps().setName(btemp.toString());
+							} else if (mousePos.y / tableProperties.getRowHeight() == 2) {
+								Boolean bbTemp = Boolean.parseBoolean(btemp.toString());
+								((HolonSwitch) getActualCps()).setManualMode(bbTemp);
+								if (bbTemp) {
 									tableModelProperties.setCellEditable(3, 1, true);
 								} else {
 									tableModelProperties.setCellEditable(3, 1, false);
@@ -873,11 +896,12 @@ public class GUI<E> implements CategoryListener {
 									((HolonSwitch) getActualCps()).setManualState(bTemp);
 								}
 							}
+						} else if (getActualCps() instanceof HolonObject) {
+							getActualCps().setName(temp.toString());
 						}
 					} else {
-						temp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
-								mousePos.x / (tableProperties.getWidth() / 2));
-						if (mousePos.y / tableProperties.getRowHeight() == 2) {
+						temp = tableModelProperties.getValueAt(selValueY, selValueX);
+						if (selValueY == 2) {
 							Float ftemp;
 							if (Float.parseFloat(temp.toString()) >= 0.0) {
 								ftemp = Float.parseFloat(temp.toString());
@@ -885,7 +909,7 @@ public class GUI<E> implements CategoryListener {
 								ftemp = model.getSelectedEdge().getCapacity();
 							}
 							model.getSelectedEdge().setCapacity(ftemp);
-						} else if (mousePos.y / tableProperties.getRowHeight() == 3) {
+						} else if (selValueY == 3) {
 							Boolean bTemp = Boolean.parseBoolean(temp.toString());
 							model.getSelectedEdge().setState(bTemp);
 						}
@@ -1005,8 +1029,7 @@ public class GUI<E> implements CategoryListener {
 					DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree
 							.getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
 					if (selectedNode.getLevel() == 2) {
-						controller.searchCategoryObject(selectedNode.getParent().toString(),
-								selectedNode.toString());
+						controller.searchCategoryObject(selectedNode.getParent().toString(), selectedNode.toString());
 						deleteRows(tableModelHolonElementSingle);
 						deleteRows(tableModelHolonElementMulti);
 						// if (selected instanceof HolonObject && selected !=
@@ -1600,7 +1623,7 @@ public class GUI<E> implements CategoryListener {
 	 * 
 	 * @return selected CpsObject
 	 */
-	public CpsObject getActualCps() {
+	private CpsObject getActualCps() {
 		int tempID = model.getSelectedObjectID();
 		CpsObject tempCps = controller.searchByID(tempID);
 		return tempCps;
@@ -1619,7 +1642,7 @@ public class GUI<E> implements CategoryListener {
 	 *            Control, 2 means MultiSelection with Control
 	 * @return the selected HolonElement
 	 */
-	public HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash) {
+	private HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash) {
 		final int yTemp = (int) Math.floor(yValue / 16);
 		int rowsTotal = 0;
 		// Filter for search --> single and multi selection
@@ -1679,7 +1702,7 @@ public class GUI<E> implements CategoryListener {
 	 * @param yValue
 	 * @return clicked HolonObject
 	 */
-	public HolonObject getHolonObj(int yValue) {
+	private HolonObject getHolonObj(int yValue) {
 		final int yTemp = (int) Math.floor(yValue / 16);
 		HolonObject obtTemp = null;
 		String temp = tableModelHolonElementMulti.getValueAt(yTemp, 0).toString();
@@ -1692,7 +1715,7 @@ public class GUI<E> implements CategoryListener {
 	 * Update the HolonElement Table, that means erase all rows and add the new
 	 * rows with new data
 	 */
-	public void refreshTableHolonElement() {
+	private void refreshTableHolonElement() {
 		// Update of the Information about the HolonElements - only for
 		// HolonObjects
 
@@ -1710,7 +1733,7 @@ public class GUI<E> implements CategoryListener {
 	/**
 	 * Erase all information of the HolonElement Model
 	 */
-	public void deleteRows(PropertyTable t) {
+	private void deleteRows(PropertyTable t) {
 		if (t.getRowCount() > 0) {
 			for (int i = t.getRowCount() - 1; i > -1; i--) {
 				t.removeRow(i);
@@ -1725,7 +1748,7 @@ public class GUI<E> implements CategoryListener {
 	 * @param elements
 	 *            ArrayList to be displayed
 	 */
-	public void fillElementTable(ArrayList<CpsObject> objects) {
+	private void fillElementTable(ArrayList<CpsObject> objects) {
 		if (objects.size() > 1) {
 			for (CpsObject o : objects) {
 				if (o instanceof HolonObject) {
@@ -1750,7 +1773,7 @@ public class GUI<E> implements CategoryListener {
 	/**
 	 * Update the information concerning properties of the selected CpsObject
 	 */
-	public void refreshTableProperties() {
+	private void refreshTableProperties() {
 		if (model.getSelectedCpsObjects().size() == 1) {
 			CpsObject tempCps = getActualCps();
 			if (tempCps != null && tempCps.getClass() == HolonObject.class) {

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

@@ -656,7 +656,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			e = new CpsEdge(n, tempCps, edgeCapacity);
 
 			controller.AddEdgeOnCanvas(e);
-			// System.out.println("node ID: " + n.getID());
 		}
 
 		// Wenn ein Node ohne Connections da ist

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

@@ -119,6 +119,7 @@ public class TimePanel extends JPanel {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getMinimum());
 				controller.setCurIteration(timeSlider.getValue());
+				controller.calculateStateForCurrentTimeStep();
 			}
 		});
 		timeForwardBtn.setToolTipText("Forward");

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

@@ -26,7 +26,7 @@ import classes.HolonSwitch;
 
 import java.awt.Cursor;
 
-class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, ComponentListener {
+public class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, ComponentListener {
 
 	private static final long serialVersionUID = 1L;
 	private float MAXIMUM = 0;