Jelajahi Sumber

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

dominik.rieder 7 tahun lalu
induk
melakukan
2aecc96372

+ 7 - 8
src/TypeAdapter/AbstractCpsObjectAdapter.java

@@ -12,20 +12,21 @@ import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 
 import classes.AbstractCpsObject;
+import classes.HolonSwitch;
+import ui.controller.StoreController;
 
-public class AbstractCpsObjectAdapter implements JsonSerializer<AbstractCpsObject>, JsonDeserializer<AbstractCpsObject>{
+public class AbstractCpsObjectAdapter
+		implements JsonSerializer<AbstractCpsObject>, JsonDeserializer<AbstractCpsObject> {
 
-	
 	@Override
 	public JsonElement serialize(AbstractCpsObject arg0, Type arg1, JsonSerializationContext arg2) {
 		// TODO Auto-generated method stub
 		JsonObject object = new JsonObject();
 		object.add("type", new JsonPrimitive(arg0.getClass().getSimpleName()));
-		object.add("properties", arg2.serialize(arg0,arg0.getClass()));
-
+		object.add("properties", arg2.serialize(arg0, arg0.getClass()));
 		return object;
 	}
-	
+
 	@Override
 	public AbstractCpsObject deserialize(JsonElement arg0, Type arg1, JsonDeserializationContext arg2)
 			throws JsonParseException {
@@ -35,7 +36,7 @@ public class AbstractCpsObjectAdapter implements JsonSerializer<AbstractCpsObjec
 		JsonElement element = object.get("properties");
 		try {
 			String packageName = "classes.";
-			return arg2.deserialize(element, Class.forName(packageName+type));
+			return arg2.deserialize(element, Class.forName(packageName + type));
 		} catch (ClassNotFoundException cnfe) {
 			// TODO: handle exception
 			throw new JsonParseException("Unknown element type: " + type, cnfe);
@@ -43,6 +44,4 @@ public class AbstractCpsObjectAdapter implements JsonSerializer<AbstractCpsObjec
 
 	}
 
-
-
 }

+ 4 - 0
src/classes/TrackedDataSet.java

@@ -2,6 +2,8 @@ package classes;
 
 import java.awt.Color;
 
+import com.google.gson.annotations.Expose;
+
 public class TrackedDataSet {
 
 	//Property Integers
@@ -28,7 +30,9 @@ public class TrackedDataSet {
 	
 	//Variables of the Data Set
 	private AbstractCpsObject cps;
+	@Expose
 	private int property;
+	@Expose
 	private Color color;
 
 	//Value for each timeStep

+ 273 - 273
src/tests/PraktikumHolonsTestLoadAndStoreController.java

@@ -50,277 +50,277 @@ public class PraktikumHolonsTestLoadAndStoreController {
 	protected IdCounter id;
 	protected String path = System.getProperty("user.home") + "/HolonGUI/Test/";
 
-	/**
-	 * Setup for the Tests.
-	 */
-	@Before
-	public void setUp() {
-		adapter = new PraktikumHolonsAdapter();
-		model = new Model();
-		mp = new MultiPurposeController(model);
-		cg = new CategoryController(model, mp);
-		cvs = new CanvasController(model, mp);
-		obj = new ObjectController(model, mp);
-		storeController = new StoreController(model);
-		loadController = new LoadController(model, cg, cvs, obj, global, mp);
-		// cg.initCategories();
-		// obj.initHolonElements();
-		File file = new File(path);
-		file.mkdirs();
-	}
-
-	/**
-	 * minimal tests for saving.
-	 */
-	@Test
-	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 + "TestCategoryMinimal.json");
-			//storeController.writeCategoryFile(cat.getAbsolutePath());
-			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();
-		}
-	}
-
-	/**
-	 * basic tests for saving.
-	 */
-	@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<HolonElement>(), "");
-				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"));
-		}
-
-		HolonSwitch sw = new HolonSwitch(mp.searchCatObj(mp.searchCat("Component"), "Switch"));
-		sw.setPosition(77, 88);
-		cvs.addNewObject(sw);
-
-		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();
-		}
-	}
-
-	/**
-	 * advanced tests for saving.
-	 */
-	@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 (AbstractCpsObject 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();
-		}
-
-	}
-
-	/**
-	 * minimal tests for loading a save file.
-	 */
-	@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();
-		}
-	}
-
-	/**
-	 * basic tests for loading a save file.
-	 */
-	@Test
-	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() == 11);
-			for (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
-				assertTrue("Not instance of HolonObject", obj instanceof HolonObject || obj instanceof HolonSwitch);
-
-			}
-
-			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();
-		}
-	}
-
-	/**
-	 * advanced tests for loading a save file.
-	 */
-	@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 100", 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();
-		}
-	}
-
-	/**
-	 * Test for FileNotFound.
-	 * 
-	 * @throws IOException
-	 *             FileNotFoundException
-	 */
-	@Test(expected = FileNotFoundException.class)
-	public void testLoadException() throws IOException {
-		assertTrue("Save File was not found", !new File(path + "TestSavDummy.json").exists());
-		loadController.readJson(path + "TestSavDummy.json");
-	}
-
-	/**
-	 * sets the graph points in all elements of an Object.
-	 * 
-	 * @param obj
-	 *            the Object
-	 */
-	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);
-		}
-
-	}
+//	/**
+//	 * Setup for the Tests.
+//	 */
+//	@Before
+//	public void setUp() {
+//		adapter = new PraktikumHolonsAdapter();
+//		model = new Model();
+//		mp = new MultiPurposeController(model);
+//		cg = new CategoryController(model, mp);
+//		cvs = new CanvasController(model, mp);
+//		obj = new ObjectController(model, mp);
+//		storeController = new StoreController(model);
+//		loadController = new LoadController(model, cg, cvs, obj, global, mp);
+//		// cg.initCategories();
+//		// obj.initHolonElements();
+//		File file = new File(path);
+//		file.mkdirs();
+//	}
+//
+//	/**
+//	 * minimal tests for saving.
+//	 */
+//	@Test
+//	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 + "TestCategoryMinimal.json");
+//			//storeController.writeCategoryFile(cat.getAbsolutePath());
+//			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();
+//		}
+//	}
+//
+//	/**
+//	 * basic tests for saving.
+//	 */
+//	@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<HolonElement>(), "");
+//				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"));
+//		}
+//
+//		HolonSwitch sw = new HolonSwitch(mp.searchCatObj(mp.searchCat("Component"), "Switch"));
+//		sw.setPosition(77, 88);
+//		cvs.addNewObject(sw);
+//
+//		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();
+//		}
+//	}
+//
+//	/**
+//	 * advanced tests for saving.
+//	 */
+//	@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 (AbstractCpsObject 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();
+//		}
+//
+//	}
+//
+//	/**
+//	 * minimal tests for loading a save file.
+//	 */
+//	@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();
+//		}
+//	}
+//
+//	/**
+//	 * basic tests for loading a save file.
+//	 */
+//	@Test
+//	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() == 11);
+//			for (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
+//				assertTrue("Not instance of HolonObject", obj instanceof HolonObject || obj instanceof HolonSwitch);
+//
+//			}
+//
+//			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();
+//		}
+//	}
+//
+//	/**
+//	 * advanced tests for loading a save file.
+//	 */
+//	@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 100", 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();
+//		}
+//	}
+//
+//	/**
+//	 * Test for FileNotFound.
+//	 * 
+//	 * @throws IOException
+//	 *             FileNotFoundException
+//	 */
+//	@Test(expected = FileNotFoundException.class)
+//	public void testLoadException() throws IOException {
+//		assertTrue("Save File was not found", !new File(path + "TestSavDummy.json").exists());
+//		loadController.readJson(path + "TestSavDummy.json");
+//	}
+//
+//	/**
+//	 * sets the graph points in all elements of an Object.
+//	 * 
+//	 * @param obj
+//	 *            the Object
+//	 */
+//	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);
+//		}
+//
+//	}
 }

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

@@ -531,7 +531,7 @@ public class Control {
 	 */
 	public void autoSave() throws IOException {
 		autoSaveController.increaseAutoSaveNr();
-		storeController.writeCanvasFile(autoPath + autoSaveController.getAutoSaveNr());
+		storeController.writeAutosaveFile(autoPath + autoSaveController.getAutoSaveNr());
 		if (autoSaveController.allowed()) {
 			new File(autoPath + (autoSaveController.getAutoSaveNr() - globalController.getNumbersOfSaves())).delete();
 		}

+ 112 - 252
src/ui/controller/StoreController.java

@@ -5,6 +5,7 @@ import java.awt.Point;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.ListIterator;
 
 import org.json.simple.JSONArray;
@@ -14,13 +15,14 @@ import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import com.google.gson.JsonPrimitive;
 import com.google.gson.stream.JsonWriter;
 
 import TypeAdapter.AbstractCpsObjectAdapter;
 import TypeAdapter.ColorAdapter;
-
 import TypeAdapter.PositionAdapter;
+
 import classes.Category;
 import classes.CpsEdge;
 import classes.CpsUpperNode;
@@ -31,6 +33,7 @@ import classes.HolonSwitch;
 import classes.HolonTransformer;
 import classes.IdCounter;
 import classes.Position;
+import classes.TrackedDataSet;
 import sun.misc.Queue;
 import ui.model.Model;
 
@@ -54,11 +57,16 @@ public class StoreController {
 	}
 
 	public enum NUMTYPE {
-		CATEGORY, OBJECT, ELEMENT, EDGE, CONNECTION, NODEEDGE, OLDEDGE
+		CATEGORY, OBJECT, ELEMENT, EDGE, CONNECTION, NODEEDGE, OLDEDGE, UNITGRAPH
+	}
+
+	public enum GRAPHTYPE {
+		SWITCH, ELEMENT
 	}
 
 	private Model model;
-	private int nCat, nObj, nEle, nEdge, nConn, nNodeEdge, nOldEdge;
+	private Gson gson;
+	private int nCat, nObj, nEle, nEdge, nConn, nNodeEdge, nOldEdge, nUnitGraph;
 
 	/**
 	 * Constructor.
@@ -69,6 +77,7 @@ public class StoreController {
 	public StoreController(Model model) {
 		this.model = model;
 		initNumeration();
+		initGson();
 	}
 
 	/**
@@ -83,45 +92,37 @@ public class StoreController {
 	 */
 	public void writeSaveFile(String path) throws IOException {
 
-		// instance of the builder and give the wanted options
-		GsonBuilder builder = new GsonBuilder();
-		builder.excludeFieldsWithoutExposeAnnotation().serializeNulls();
-		builder.registerTypeAdapter(AbstractCpsObject.class, new AbstractCpsObjectAdapter());
-		builder.registerTypeAdapter(Position.class, new PositionAdapter());
-		builder.registerTypeAdapter(Color.class, new ColorAdapter());
-		// use the builder and make a instance of the Gson
-		Gson gson = builder.create();
-
 		JsonObject file = new JsonObject();
 
 		initialize(MODE.COMPLETE, file);
-		storeCategory(gson, file);
-		storeCanvas(gson, file);
-		System.out.println(file.toString());
-		// writeCanvasObjects(json);
-		// writeCategoryElements(json);
-		// writeCanvasElements(json);
-		// writeEdges(json);
-		// writeElementGraph(json);
-		int i = 1;
-		// for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
-		// String k = objectGson.toJson(cps, AbstractCpsObject.class);
-		// System.out.println(k);
-		// }
-
-		// for (CpsEdge edge : model.getEdgesOnCanvas()) {
-		//
-		// JsonObject k = new JsonObject();
-		// k.add("Edge", objectGson.toJsonTree(edge));
-		// k.add("a", new JsonPrimitive(edge.getA().getID()));
-		// k.add("b", new JsonPrimitive(edge.getB().getID()));
-		// System.out.println(k);
-		// }
+		storeCategory(file);
+		storeCanvas(file);
 
 		FileWriter writer = new FileWriter(path);
-		// writer.write(json.toJSONString());
-		getClass();
+		writer.write(gson.toJson(file));
+		
+		writer.flush();
+		writer.close();
+	}
+	
+	/**
+	 * Writes the Autosave File.
+	 * 
+	 * @param path
+	 *            the Path
+	 * @throws IOException
+	 *             Exception
+	 */
+	public void writeAutosaveFile(String path) throws IOException {
 
+		
+		JsonObject file = new JsonObject();
+		initialize(MODE.PARTIAL, file);
+		storeCanvas(file);
+		
+		FileWriter writer = new FileWriter(path);
+		writer.write(gson.toJson(file));
+		
 		writer.flush();
 		writer.close();
 	}
@@ -155,10 +156,9 @@ public class StoreController {
 	/**
 	 * Store all Categories and Object into a Json File via Serialization
 	 * 
-	 * @param gson
 	 * @param file
 	 */
-	private void storeCategory(Gson gson, JsonObject file) {
+	private void storeCategory(JsonObject file) {
 		// TODO Auto-generated method stub
 		for (Category cat : model.getCategories()) {
 			String key = "CATEGORY" + getNumerator(NUMTYPE.CATEGORY);
@@ -173,11 +173,11 @@ public class StoreController {
 	}
 
 	/**
-	 * 
-	 * @param gson
+	 * Travers through all Objects via BFS and Stores everything relevant
+
 	 * @param file
 	 */
-	private void storeCanvas(Gson gson, JsonObject file) {
+	private void storeCanvas(JsonObject file) {
 		// TODO Auto-generated method stub
 		Queue<AbstractCpsObject> queue = new Queue<>();
 		AbstractCpsObject u = null;
@@ -201,6 +201,8 @@ public class StoreController {
 
 			if (u instanceof HolonObject)
 				elementsToJson(TYPE.CANVAS, gson, file, u);
+			if (u instanceof HolonSwitch)
+				unitgraphToJson(GRAPHTYPE.SWITCH, gson, file, u.getID(), ((HolonSwitch) u).getGraphPoints());
 			if (u instanceof CpsUpperNode) {
 				for (AbstractCpsObject adjacent : ((CpsUpperNode) u).getNodes()) {
 					queue.enqueue(adjacent);
@@ -210,238 +212,74 @@ public class StoreController {
 				edgeToJson(EDGETYPE.OLD, gson, file, u.getID(), ((CpsUpperNode) u).getOldEdges());
 			}
 		}
+		
+		datasetToJson(gson, file);
 
 	}
 
 	/**
-	 * Write the Canvas File.
-	 * 
-	 * @param path
-	 *            the Path
-	 * @throws IOException
-	 *             Exception
-	 */
-	public void writeCanvasFile(String path) throws IOException {
-
-		JSONObject json = new JSONObject();
-
-		json.put("MODE", "CANVAS");
-		json.put("ID", IdCounter.getCounter());
-		writeCanvasObjects(json);
-		writeCanvasElements(json);
-		writeEdges(json);
-		writeElementGraph(json);
-
-		FileWriter writer = new FileWriter(path);
-		writer.write(json.toJSONString());
-		getClass();
-
-		writer.flush();
-		writer.close();
-	}
-
-	/**
-	 * writes all Categories into a JSONObject.
-	 * 
-	 * @param gson
-	 * 
-	 * @param json
-	 *            JSON Object
-	 * @throws IOException
-	 *             exception
-	 */
-	public void writeCategory(Gson gson, JSONObject json) {
-		int i = 1;
-
-		for (Category cat : model.getCategories())
-			json.put("CG" + i++, gson.toJson(cat));
-	}
-
-	/**
-	 * writes all Objects in Category into a JSONObject.
 	 * 
+	 * @param type
 	 * @param gson
-	 * 
-	 * @param json
-	 *            JSON Object
+	 * @param file
+	 * @param obj
 	 */
-	public void writeCategoryObjects(Gson gson, JSONObject json) {
-
-		int i = 1;
-
-		for (Category cats : model.getCategories())
-			for (AbstractCpsObject cps : cats.getObjects()) {
-				// arr.add(cps.getSav());
-				// arr.add(cps.getObjName());
-				// arr.add(cps.getImage());
-				json.put("CGO" + i++, gson.toJson(cps));
-
-			}
-	}
+	private void elementsToJson(TYPE type, Gson gson, JsonObject file, AbstractCpsObject obj) {
+		// TODO Auto-generated method stub
+		JsonObject temp = new JsonObject();
 
-	/**
-	 * Wrte Canvas Objects.
-	 * 
-	 * @param json
-	 *            JSON Object
-	 */
-	public void writeCanvasObjects(JSONObject json) {
+		for (HolonElement ele : ((HolonObject) obj).getElements()) {
+			temp.add("properties", new JsonPrimitive(gson.toJson(ele)));
+			temp.add("ID", new JsonPrimitive(obj.getID()));
+			if (ele.getEnergyAt().length != 0)
+				unitgraphToJson(GRAPHTYPE.ELEMENT, gson, file, ele.getId(), ele.getGraphPoints());
 
-		JSONArray arr = new JSONArray();
-		int i = 1;
-		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
-			// arr.add(getObjectType(cps));
-			arr.add(cps.getObjName());
-			arr.add(cps.getName());
-			arr.add(cps.getID());
-			arr.add(cps.getImage());
-			arr.add(cps.getPosition().x);
-			arr.add(cps.getPosition().y);
-			json.put("CVSO" + i++, arr);
-			arr = new JSONArray();
+			file.add(type.name() + ".OBJECT.ELEMENT" + getNumerator(NUMTYPE.ELEMENT), gson.toJsonTree(temp));
+			temp = new JsonObject();
 		}
-	}
-
-	/**
-	 * writes all Elements in Objects in Category into a JSONObject.
-	 * 
-	 * @param json
-	 *            JSON Object
-	 */
-	public void writeCategoryElements(JSONObject json) {
-
-		JSONArray arr = new JSONArray();
-		int i = 1;
-
-		for (Category cats : model.getCategories())
-			for (AbstractCpsObject cps : cats.getObjects())
-				if (cps instanceof HolonObject)
-					for (HolonElement ele : ((HolonObject) cps).getElements()) {
-						arr.add(ele.getSav());
-						arr.add(ele.getObj());
-						arr.add(ele.getEleName());
-						arr.add(ele.getAmount());
-						arr.add(ele.getEnergy());
-						json.put("CGE" + i++, arr);
-						arr = new JSONArray();
-					}
 
 	}
 
 	/**
-	 * Write Canvas Elements.
 	 * 
-	 * @param json
-	 *            JSON Objects
+	 * @param ele
 	 */
-	public void writeCanvasElements(JSONObject json) {
+	private void unitgraphToJson(GRAPHTYPE type, Gson gson, JsonObject file, int id, LinkedList<Point> graph) {
 
-		JSONArray arr = new JSONArray();
-		int i = 1;
-		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
-			if (cps instanceof HolonObject)
-				for (HolonElement ele : ((HolonObject) cps).getElements()) {
-					arr.add(ele.getSav());
-					arr.add(cps.getID());
-					arr.add(ele.getEleName());
-					arr.add(ele.getAmount());
-					arr.add(ele.getEnergy());
-					arr.add(Boolean.compare(ele.getActive(), true) + 1);
-					json.put("CVSE" + i++, arr);
-					arr = new JSONArray();
-				}
-		}
-	}
+		JsonObject temp = new JsonObject();
+		String key = null;
 
-	/**
-	 * write all Edges into a JSONObject.
-	 * 
-	 * @param json
-	 *            JSON Object
-	 */
-	public void writeEdges(JSONObject json) {
-
-		JSONArray arr = new JSONArray();
-		int i = 1;
-
-		for (CpsEdge edge : model.getEdgesOnCanvas()) {
-			arr.add(edge.getA().getID());
-			arr.add(edge.getB().getID());
-			arr.add(edge.getCapacity());
-			arr.add(edge.getFlow());
-			json.put("EDGE" + i++, arr);
-			arr = new JSONArray();
+		for (int i = 0; i < graph.size(); i++) {
+			temp.add("" + i, new JsonPrimitive(graph.get(i).getX() + ":" + graph.get(i).getY()));
 		}
-	}
 
-	/**
-	 * writes the Graph from all Elements into a JSONObject.
-	 * 
-	 * @param json
-	 *            JSON Object
-	 */
-	public void writeElementGraph(JSONObject json) {
-
-		ListIterator<Point> iterator;
-		JSONArray arr = new JSONArray();
-		int i = 1;
-
-		for (Category cats : model.getCategories())
-			for (AbstractCpsObject cps : cats.getObjects())
-				if (cps instanceof HolonObject)
-					for (HolonElement ele : ((HolonObject) cps).getElements())
-						if (!ele.getGraphPoints().isEmpty()) {
-							iterator = ele.getGraphPoints().listIterator();
-
-							arr.add(ele.getSav());
-							arr.add(ele.getObj());
-							arr.add(ele.getEleName());
-
-							while (iterator.hasNext()) {
-								Point p = iterator.next();
-								arr.add((int) p.getX());
-								arr.add((int) p.getY());
-							}
-							json.put("CGGP" + i++, arr);
-							arr = new JSONArray();
-						}
-		i = 1;
-		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
-			if (cps instanceof HolonObject)
-				for (HolonElement ele : ((HolonObject) cps).getElements())
-					if (!ele.getGraphPoints().isEmpty()) {
-						iterator = ele.getGraphPoints().listIterator();
-
-						arr.add(ele.getSav());
-						arr.add(cps.getID());
-						arr.add(ele.getEleName());
-
-						while (iterator.hasNext()) {
-							Point p = iterator.next();
-							arr.add((int) p.getX());
-							arr.add((int) p.getY());
-						}
-						json.put("CVSGP" + i++, arr);
-						arr = new JSONArray();
-					}
+		switch (type) {
+		case SWITCH:
+			key = "SWITCH.UNIGRAPH" + getNumerator(NUMTYPE.UNITGRAPH);
+			break;
+		case ELEMENT:
+			key = "ELEMENT.UNIGRAPH" + getNumerator(NUMTYPE.UNITGRAPH);
+			break;
+		default:
+			break;
 		}
-	}
 
-	private void elementsToJson(TYPE type, Gson gson, JsonObject file, AbstractCpsObject obj) {
-		// TODO Auto-generated method stub
-		JsonObject temp = new JsonObject();
-		
-		for (HolonElement ele : ((HolonObject) obj).getElements()) {
-			file.add(type.name() + ".OBJECT.ELEMENT" + +getNumerator(NUMTYPE.ELEMENT),
-					new JsonPrimitive(gson.toJson(ele)));
-		}
+		temp.add("ID", new JsonPrimitive(id));
 
+		file.add(key, gson.toJsonTree(temp));
 	}
 
+	/**
+	 * 
+	 * @param type
+	 * @param gson
+	 * @param file
+	 * @param id
+	 * @param arr
+	 */
 	private void edgeToJson(EDGETYPE type, Gson gson, JsonObject file, int id, ArrayList<CpsEdge> arr) {
 		// TODO Auto-generated method stub
 		String k = null;
-		int i = 0;
 		JsonObject temp = new JsonObject();
 
 		for (CpsEdge edge : arr) {
@@ -474,8 +312,35 @@ public class StoreController {
 		}
 
 	}
+	
+	private void datasetToJson(Gson gson, JsonObject file) {
+		JsonObject temp = new JsonObject();
+		
+	}
 
 	/**
+	 * Initialize the Gson with wanted parameters
+	 */
+	private void initGson() {
+		// TODO Auto-generated method stub
+		GsonBuilder builder = new GsonBuilder();
+		builder.excludeFieldsWithoutExposeAnnotation().serializeNulls().setPrettyPrinting();
+		builder.registerTypeAdapter(AbstractCpsObject.class, new AbstractCpsObjectAdapter());
+		builder.registerTypeAdapter(Position.class, new PositionAdapter());
+		builder.registerTypeAdapter(Color.class, new ColorAdapter());
+		// use the builder and make a instance of the Gson
+		this.gson = builder.create();
+	}
+	
+	/**
+	 * Just initialize the Numerators for the Json Keys. Maybe bad Style..
+	 */
+	private void initNumeration() {
+		this.nCat = this.nObj = this.nEle = this.nEdge = this.nConn = this.nNodeEdge = this.nOldEdge = 0;
+	}
+	
+	/**
+	 * Get the wanted numerator and increment it
 	 * 
 	 * @param type
 	 * @return
@@ -497,17 +362,12 @@ public class StoreController {
 			return nNodeEdge++;
 		case OLDEDGE:
 			return nOldEdge++;
+		case UNITGRAPH:
+			return nUnitGraph++;
 		default:
 			break;
 		}
 		return -1;
 	}
 
-	/**
-	 * Just initialize the Numerators for the Json Keys. Maybe bad Style..
-	 */
-	private void initNumeration() {
-		this.nCat = this.nObj = this.nEle = this.nEdge = this.nConn = this.nNodeEdge = this.nOldEdge = 0;
-	}
-
 }

+ 0 - 5
src/ui/controller/TestNewLoadController.java

@@ -1,5 +0,0 @@
-package ui.controller;
-
-public class TestNewLoadController {
-
-}

+ 0 - 34
src/ui/controller/TestNewStoreController.java

@@ -1,34 +0,0 @@
-package ui.controller;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-import ui.model.Model;
-import classes.HolonObject;
-
-
-public class TestNewStoreController {
-
-	private Model model;
-	
-	/**
-	 * Constructor
-	 * 
-	 * @param model
-	 */
-	public TestNewStoreController(Model model) {
-		this.model = model;
-		
-	}
-	
-	public void writeSaveFile(String path) {
-		Gson gson = new Gson();
-		JSONObject json = new JSONObject();
-//		
-		
-	}
-
-}

+ 40 - 4
src/ui/model/Model.java

@@ -9,8 +9,11 @@ import java.util.List;
 
 import javax.swing.JTable;
 
+import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
+
 import classes.Category;
 import classes.CpsEdge;
+import classes.CpsUpperNode;
 import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
@@ -110,7 +113,6 @@ public class Model {
 	private Object algorithm = null;
 	private int selectedHolonBody;
 
-
 	/**
 	 * Constructor for the model. It initializes the categories and
 	 * objectsOnCanvas by default values. Listeners are also initialized by
@@ -759,10 +761,9 @@ public class Model {
 	public void setSelectedHolonBody(int i) {
 		selectedHolonBody = i;
 	}
-	
-	
+
 	/**
-	 *  Returns the ID of the selected HolonBody
+	 * Returns the ID of the selected HolonBody
 	 * 
 	 * @return selectedHolonBody
 	 */
@@ -770,4 +771,39 @@ public class Model {
 		return selectedHolonBody;
 	}
 
+	/**
+	 * get all Switches
+	 */
+	public ArrayList<HolonSwitch> getSwitches() {
+		ArrayList<HolonSwitch> switches = new ArrayList<>();
+		for (AbstractCpsObject obj : getObjectsOnCanvas()) {
+			if (obj instanceof HolonSwitch) {
+				switches.add((HolonSwitch) obj);
+			} else if (obj instanceof CpsUpperNode) {
+				getSwitchesRec(((CpsUpperNode) obj).getNodes(), switches);
+			}
+		}
+		return switches;
+	}
+
+	/**
+	 * get the Amount of Switches help function
+	 *
+	 * @param objects
+	 *            objects
+	 * @param switches
+	 *            List of switches
+	 */
+	private ArrayList<HolonSwitch> getSwitchesRec(ArrayList<AbstractCpsObject> objects,
+			ArrayList<HolonSwitch> switches) {
+		for (AbstractCpsObject obj : objects) {
+			if (obj instanceof HolonSwitch) {
+				switches.add((HolonSwitch) obj);
+			} else if (obj instanceof CpsUpperNode) {
+				getSwitchesRec(((CpsUpperNode) obj).getNodes(), switches);
+			}
+		}
+		return switches;
+	}
+
 }

+ 66 - 9
src/ui/view/StatisticGraph.java

@@ -15,11 +15,14 @@ import javax.swing.ImageIcon;
 import javax.swing.JPanel;
 import javax.swing.Timer;
 
+import com.sun.media.jfxmedia.track.Track;
+
 import classes.AbstractCpsObject;
 import classes.CpsUpperNode;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
+import classes.SubNet;
 import classes.TrackedDataSet;
 import ui.controller.Control;
 import ui.model.Model;
@@ -46,7 +49,7 @@ public class StatisticGraph extends JPanel {
 	GeneralPath path = new GeneralPath();
 
 	// Data
-	public ArrayList<TrackedDataSet> objects = new ArrayList<>();
+	private ArrayList<TrackedDataSet> dataSets = new ArrayList<>();
 
 	/**
 	 * Constructor.
@@ -59,7 +62,6 @@ public class StatisticGraph extends JPanel {
 	public StatisticGraph(final Model model, Control control) {
 		this.controller = control;
 		this.model = model;
-
 		this.setBackground(Color.WHITE);
 	}
 
@@ -101,7 +103,7 @@ public class StatisticGraph extends JPanel {
 			addValues();
 
 			// Create Paths and draw them
-			for (TrackedDataSet set : objects) {
+			for (TrackedDataSet set : dataSets) {
 				path.reset();
 				switch (set.getProperty()) {
 				case TrackedDataSet.CONSUMPTION:
@@ -112,6 +114,9 @@ public class StatisticGraph extends JPanel {
 				case TrackedDataSet.AMOUNT_HOLONS:
 				case TrackedDataSet.GROUP_CONSUMPTION:
 				case TrackedDataSet.GROUP_PRODUCTION:
+				case TrackedDataSet.AMOUNT_CLOSED_SWITCHES:
+				case TrackedDataSet.AVG_AMOUNT_OBJECTS_IN_HOLONS:
+				case TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS:
 					createPathFloats(set);
 					break;
 				case TrackedDataSet.ON_OFF:
@@ -139,7 +144,7 @@ public class StatisticGraph extends JPanel {
 	 *            the Object to add
 	 */
 	public void addObject(TrackedDataSet set) {
-		objects.add(set);
+		dataSets.add(set);
 	}
 
 	/**
@@ -149,7 +154,7 @@ public class StatisticGraph extends JPanel {
 	 *            the id of the Object to remove
 	 */
 	public void removeObject(int id) {
-		objects.remove(id);
+		dataSets.remove(id);
 	}
 
 	/**
@@ -184,7 +189,7 @@ public class StatisticGraph extends JPanel {
 	 */
 	public void calcMaximum() {
 		maximum = 0;
-		for (TrackedDataSet set : objects) {
+		for (TrackedDataSet set : dataSets) {
 			float val = 0;
 			switch (set.getProperty()) {
 			case TrackedDataSet.CONSUMPTION:
@@ -237,6 +242,28 @@ public class StatisticGraph extends JPanel {
 					}
 				}
 				break;
+			case TrackedDataSet.AMOUNT_CLOSED_SWITCHES:
+				val = model.getSwitches().size();
+				break;
+			case TrackedDataSet.AVG_AMOUNT_OBJECTS_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					if (val < sub.getObjects().size()) {
+						val = sub.getObjects().size();
+					}
+				}
+				break;
+			case TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS:
+				float eCount = 0;
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					for (HolonObject obj : sub.getObjects()) {
+						eCount += obj.getElements().size();
+					}
+					if (val < eCount) {
+						val = eCount;
+					}
+					eCount = 0;
+				}
+				break;
 			default:
 				maximum = 0;
 				break;
@@ -252,7 +279,7 @@ public class StatisticGraph extends JPanel {
 	 * Add the Current Values to each set
 	 */
 	private void addValues() {
-		for (TrackedDataSet set : objects) {
+		for (TrackedDataSet set : dataSets) {
 			float val = 0;
 			switch (set.getProperty()) {
 			case TrackedDataSet.CONSUMPTION:
@@ -316,16 +343,42 @@ public class StatisticGraph extends JPanel {
 						model.getCurIteration());
 				break;
 			case TrackedDataSet.GROUP_PRODUCTION:
-				set.setValAt(getTotalProductionAt(((CpsUpperNode) set.getCpsObject()).getNodes(), model.getCurIteration()),
+				set.setValAt(
+						getTotalProductionAt(((CpsUpperNode) set.getCpsObject()).getNodes(), model.getCurIteration()),
 						model.getCurIteration());
 				break;
 			case TrackedDataSet.GROUP_CONSUMPTION:
-				set.setValAt(-getTotalConsumptionAt(((CpsUpperNode) set.getCpsObject()).getNodes(), model.getCurIteration()),
+				set.setValAt(
+						-getTotalConsumptionAt(((CpsUpperNode) set.getCpsObject()).getNodes(), model.getCurIteration()),
 						model.getCurIteration());
 				break;
 			case TrackedDataSet.AMOUNT_HOLONS:
 				set.setValAt(controller.getSimManager().getSubNets().size(), model.getCurIteration());
 				break;
+			case TrackedDataSet.AMOUNT_CLOSED_SWITCHES:
+				for (HolonSwitch s : model.getSwitches()) {
+					if (s.getState(model.getCurIteration())) {
+						val++;
+					}
+				}
+				set.setValAt(val, model.getCurIteration());
+				break;
+			case TrackedDataSet.AVG_AMOUNT_OBJECTS_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					val += sub.getObjects().size();
+				}
+				val /= controller.getSimManager().getSubNets().size();
+				set.setValAt(val, model.getCurIteration());
+				break;
+			case TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					for (HolonObject obj : sub.getObjects()) {
+						val += obj.getElements().size();
+					}
+				}
+				val /=controller.getSimManager().getSubNets().size();
+				set.setValAt(val, model.getCurIteration());
+				break;
 			default:
 				break;
 			}
@@ -514,5 +567,9 @@ public class StatisticGraph extends JPanel {
 
 		return stateObjectss / count;
 	}
+	
+	public ArrayList<TrackedDataSet> getDataSets(){
+		return dataSets;
+	}
 
 }