Bladeren bron

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

dominik.rieder 7 jaren geleden
bovenliggende
commit
5ac0cf28a1

+ 10 - 25
src/ui/controller/ClipboardController.java

@@ -50,7 +50,6 @@ public class ClipboardController {
 	private CanvasController cvsC;
 	private ObjectController objC;
 	private NodeController uppC;
-	private Gson gson;
 	private JsonParser parser;
 	private Clipboard clipboard;
 	private HashMap<Integer, Integer> objIDMap;
@@ -67,8 +66,7 @@ public class ClipboardController {
 		this.objC = obj;
 		this.uppC = uppC;
 		this.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
-		initGson();
-
+		parser = new JsonParser();
 	}
 
 	/**
@@ -85,7 +83,7 @@ public class ClipboardController {
 
 		file.add("SAV", new JsonPrimitive((upperNode == null ? "CVS" : "" + upperNode.getId())));
 		Position pos = uppC.calculatePos(model.getSelectedCpsObjects());
-		file.add("CENTER", gson.toJsonTree(pos, Position.class));
+		file.add("CENTER", model.getGson().toJsonTree(pos, Position.class));
 
 		for (AbstractCpsObject abs : model.getSelectedCpsObjects()) {
 			queue.add(abs);
@@ -96,7 +94,7 @@ public class ClipboardController {
 			u = queue.pop();
 
 			String key = "CVSOBJECT" + store.getNumerator(NUMTYPE.OBJECT);
-			file.add(key, gson.toJsonTree(u, AbstractCpsObject.class));
+			file.add(key, model.getGson().toJsonTree(u, AbstractCpsObject.class));
 			edgeToJson(EDGETYPE.CONNECTION, file, u.getId(), u.getConnections());
 
 			if (u instanceof HolonObject)
@@ -119,7 +117,7 @@ public class ClipboardController {
 		else
 			edgeToJson(EDGETYPE.LAYER, file, upperNode.getId(), upperNode.getNodeEdges());
 
-		StringSelection selection = new StringSelection(gson.toJson(file));
+		StringSelection selection = new StringSelection(model.getGson().toJson(file));
 		clipboard.setContents(selection, selection);
 
 	}
@@ -162,7 +160,7 @@ public class ClipboardController {
 		eleIDMap = new HashMap<>();
 		sav = json.get("SAV").getAsString();
 
-		Position old = gson.getAdapter(Position.class).fromJsonTree(json.get("CENTER"));
+		Position old = model.getGson().getAdapter(Position.class).fromJsonTree(json.get("CENTER"));
 		point = new Point(old.x - p.x, old.y - p.y);
 
 		forwardObjects(keys, json, objDispatch, eleDispatch, upperNode);
@@ -227,7 +225,7 @@ public class ClipboardController {
 	private void loadCanvasObject(JsonElement jsonElement, HashMap<Integer, AbstractCpsObject> objDispatch,
 			CpsUpperNode upperNode) {
 		// TODO Auto-generated method stub
-		AbstractCpsObject temp = gson.fromJson(jsonElement.getAsJsonObject(), AbstractCpsObject.class);
+		AbstractCpsObject temp = model.getGson().fromJson(jsonElement.getAsJsonObject(), AbstractCpsObject.class);
 		load.initObjects(temp);
 		objIDMapper(temp);
 		updatePosition(temp, upperNode);
@@ -254,7 +252,7 @@ public class ClipboardController {
 		// TODO Auto-generated method stub
 		JsonObject object = jsonElement.getAsJsonObject();
 
-		HolonElement temp = gson.fromJson(object.get("properties"), HolonElement.class);
+		HolonElement temp = model.getGson().fromJson(object.get("properties"), HolonElement.class);
 		load.initElements(temp);
 		eleIDMapper(temp);
 		// id which Object it was stored before
@@ -313,7 +311,7 @@ public class ClipboardController {
 			CpsUpperNode upperNode) {
 		// TODO Auto-generated method stub
 		JsonObject object = jsonElement.getAsJsonObject();
-		CpsEdge temp = gson.fromJson(object.get("properties"), CpsEdge.class);
+		CpsEdge temp = model.getGson().fromJson(object.get("properties"), CpsEdge.class);
 		load.initCpsEdge(temp);
 		// look for A and B inside the Table
 		temp.setA(objDispatch.get(objIDMap.get(object.get("A").getAsInt())));
@@ -371,7 +369,7 @@ public class ClipboardController {
 			if (model.getClipboradObjects().contains(edge.getA())
 					&& model.getClipboradObjects().contains(edge.getB())) {
 				// add properties and only the ids from a and b
-				temp.add("properties", gson.toJsonTree(edge));
+				temp.add("properties", model.getGson().toJsonTree(edge));
 				temp.add("A", new JsonPrimitive(edge.getA().getId()));
 				temp.add("B", new JsonPrimitive(edge.getB().getId()));
 
@@ -400,7 +398,7 @@ public class ClipboardController {
 						&& !type.equals(EDGETYPE.CONNECTION))
 					b = true;
 				temp.add("connection", new JsonPrimitive(b));
-				file.add(k, gson.toJsonTree(temp));
+				file.add(k, model.getGson().toJsonTree(temp));
 				temp = new JsonObject();
 			}
 		}
@@ -434,19 +432,6 @@ public class ClipboardController {
 
 	}
 
-	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();
-		this.parser = new JsonParser();
-
-	}
-
 	private void objIDMapper(AbstractCpsObject temp) {
 		// TODO Auto-generated method stub
 		int id = temp.getId();

+ 12 - 0
src/ui/controller/Control.java

@@ -152,6 +152,10 @@ public class Control {
 	public AbstractCpsObject searchByIDUpperNode(int id, CpsUpperNode upperNode) {
 		return multiPurposeController.searchByIDUpperNode(id, upperNode);
 	}
+	
+	public AbstractCpsObject searchTracked(int id) {
+		return multiPurposeController.searchByID(id);
+	}
 
 	/**
 	 * Search for Object in a Category.
@@ -966,5 +970,13 @@ public class Control {
 	public void setIsSimRunning(boolean isRunning) {
 		globalController.setIsSimRunning(isRunning);
 	}
+	
+	/**
+	 * Sets showConsoleLog.
+	 * @param showConsoleLog
+	 */
+	public void setShowConsoleLog(boolean showConsoleLog) {
+		globalController.setShowConsoleLog(showConsoleLog);
+	}
 
 }

+ 8 - 0
src/ui/controller/GlobalController.java

@@ -156,4 +156,12 @@ public class GlobalController {
 			}
 		}
 	}
+	
+	/**
+	 * Sets showConsoleLog.
+	 * @param showConsoleLog
+	 */
+	public void setShowConsoleLog(boolean showConsoleLog) {
+		model.setShowConsoleLog(showConsoleLog);
+	}
 }

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

@@ -77,7 +77,7 @@ public class HolonCanvasController {
 		// adding new HolonBodys
 		for (int i = bodies.size(); i < subCount; i++) {
 			float radius = (subnets.get(i).getObjects().size() * 5 + 10) * HolonBodyScale / 100;
-			HolonBody temp = new HolonBody((float) (center.width + Math.pow(-1, i)), center.height + 1, radius,
+			HolonBody temp = new HolonBody((float) (center.width + Math.pow(-1, i)), (float)(center.height + Math.pow(-1, i)), radius,
 					(float) Math.pow((subnets.get(i).getObjects().size() + 1) * 5, 3), model.getSubNetColors().get(i));
 			temp.setId(i);
 			bodies.add(temp);

+ 16 - 40
src/ui/controller/LoadController.java

@@ -1,6 +1,5 @@
 package ui.controller;
 
-import java.awt.Color;
 import java.awt.Point;
 import java.io.File;
 import java.io.FileInputStream;
@@ -12,29 +11,20 @@ import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.zip.ZipException;
-import java.util.zip.ZipInputStream;
-
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.ArchiveException;
 import org.apache.commons.compress.archivers.ArchiveInputStream;
 import org.apache.commons.compress.archivers.ArchiveStreamFactory;
-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.utils.IOUtils;
 
-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 TypeAdapter.AbstractCpsObjectAdapter;
-import TypeAdapter.ColorAdapter;
-import TypeAdapter.PositionAdapter;
 import classes.Category;
 import classes.CpsEdge;
 import classes.CpsUpperNode;
@@ -44,7 +34,6 @@ import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.IdCounter;
 import classes.IdCounterElem;
-import classes.Position;
 import ui.model.Model;
 
 /**
@@ -74,7 +63,6 @@ public class LoadController {
 	private ObjectController objC;
 	private NodeController uppC;
 	private MultiPurposeController mpC;
-	private Gson gson;
 	private JsonParser parser;
 
 	/**
@@ -99,7 +87,7 @@ public class LoadController {
 		this.objC = obj;
 		this.uppC = uppC;
 		this.mpC = mp;
-		initGson();
+		this.parser = new JsonParser();
 	}
 
 	/**
@@ -219,6 +207,8 @@ public class LoadController {
 				loadUnitGraph(GRAPHTYPE.ELEMENT, json.get(key), null, eleDispatch);
 			if (key.contains("TRACKED"))
 				loadTracked(json.get(key), objDispatch);
+			if(key.contains("STATSGRAPH"))
+				loadStatisticGraph(json.get(key), objDispatch);
 		}
 
 	}
@@ -237,6 +227,7 @@ public class LoadController {
 			model.setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
 			model.setEdgesOnCanvas(new ArrayList<CpsEdge>());
 			model.setTrackingObj(new ArrayList<>());
+			model.setStatisticData(new ArrayList<>());
 			model.setCanvasX(json.get("CANVAS_SIZE_X").getAsInt());
 			model.setCanvasX(json.get("CANVAS_SIZE_Y").getAsInt());
 			IdCounter.setCounter(json.get("IDCOUNTER").getAsInt());
@@ -280,7 +271,7 @@ public class LoadController {
 	private void loadCategoryObject(JsonElement jsonElement) {
 		// TODO Auto-generated method stub
 
-		AbstractCpsObject temp = gson.fromJson(jsonElement.getAsJsonObject(), AbstractCpsObject.class);
+		AbstractCpsObject temp = model.getGson().fromJson(jsonElement.getAsJsonObject(), AbstractCpsObject.class);
 		temp.setImage(checkOS(temp.getImage()));
 		initObjects(temp);
 		if (mpC.searchCatObj(mpC.searchCat(temp.getSav()), temp.getObjName()) != null)
@@ -289,14 +280,6 @@ public class LoadController {
 
 	}
 
-	private String refreshPath(String image) {
-		// TODO Auto-generated method stub
-		if (!image.contains("/HolonGUI/"))
-			return image;
-		return (System.getProperty("user.home") + "/.config" + image.substring(image.indexOf("/HolonGUI/"), image.length()))
-				.replace("\\", "/");
-	}
-
 	/**
 	 * Load a given Element in Category by Deserialization
 	 * 
@@ -304,7 +287,7 @@ public class LoadController {
 	 */
 	private void loadCategoryElements(JsonElement jsonElement) {
 		// TODO Auto-generated method stub
-		HolonElement temp = gson.fromJson(jsonElement.getAsJsonObject().get("properties").getAsJsonObject(),
+		HolonElement temp = model.getGson().fromJson(jsonElement.getAsJsonObject().get("properties").getAsJsonObject(),
 				HolonElement.class);
 		initElements(temp);
 		objC.addElementIntoCategoryObject(temp.getSav(), temp.getObj(), temp);
@@ -318,7 +301,7 @@ public class LoadController {
 	 */
 	private void loadCanvasObject(JsonElement jsonElement, HashMap<Integer, AbstractCpsObject> objDispatch) {
 		// TODO Auto-generated method stub
-		AbstractCpsObject temp = gson.fromJson(jsonElement.getAsJsonObject(), AbstractCpsObject.class);
+		AbstractCpsObject temp = model.getGson().fromJson(jsonElement.getAsJsonObject(), AbstractCpsObject.class);
 		initObjects(temp);
 		temp.setImage(checkOS(temp.getImage()));
 		// if its stored before on the canvas just put it there
@@ -348,7 +331,7 @@ public class LoadController {
 
 		JsonObject object = jsonElement.getAsJsonObject();
 
-		HolonElement temp = gson.fromJson(object.get("properties"), HolonElement.class);
+		HolonElement temp = model.getGson().fromJson(object.get("properties"), HolonElement.class);
 		initElements(temp);
 		// id which Object it was stored before
 		int stored = object.get("ID").getAsInt();
@@ -370,7 +353,7 @@ public class LoadController {
 	private void loadEdge(EDGETYPE type, JsonElement jsonElement, HashMap<Integer, AbstractCpsObject> objDispatch) {
 		// TODO Auto-generated method stub
 		JsonObject object = jsonElement.getAsJsonObject();
-		CpsEdge temp = gson.fromJson(object.get("properties"), CpsEdge.class);
+		CpsEdge temp = model.getGson().fromJson(object.get("properties"), CpsEdge.class);
 		initCpsEdge(temp);
 		// look for A and B inside the Table
 		temp.setA(objDispatch.get(object.get("A").getAsInt()));
@@ -458,6 +441,12 @@ public class LoadController {
 		}
 	}
 
+	private void loadStatisticGraph(JsonElement jsonElement, HashMap<Integer, AbstractCpsObject> objDispatch) {
+		// TODO Auto-generated method stub
+		JsonObject object = jsonElement.getAsJsonObject();
+		model.getStatisticData().add(object);
+	}
+
 	private void loadTracked(JsonElement jsonElement, HashMap<Integer, AbstractCpsObject> objDispatch) {
 		// TODO Auto-generated method stub
 		JsonObject object = jsonElement.getAsJsonObject();
@@ -474,20 +463,7 @@ public class LoadController {
 
 	}
 
-	/**
-	 * Initialize the Gson with wanted parameters
-	 */
-	private void initGson() {
-		// TODO Auto-generated method stub
-		GsonBuilder builder = new GsonBuilder();
-		builder.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
-		this.gson = builder.create();
-		this.parser = new JsonParser();
-	}
+
 
 	private File readArchive(String path, File src) throws IOException, ArchiveException {
 		File tmp = Files.createTempDirectory("tmpHolon").toFile();

+ 16 - 1
src/ui/controller/MultiPurposeController.java

@@ -132,6 +132,20 @@ public class MultiPurposeController {
 			return upperNode.getNodes().get(idx);
 	}
 
+	/**
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public AbstractCpsObject searchTracked(int id) {
+
+		for (AbstractCpsObject cps : model.getTrackingObj()) {
+			if (cps.getId() == id)
+				return cps;
+		}
+		return null;
+	}
+
 	/**
 	 * Search Edge between 2 Objects.
 	 * 
@@ -195,6 +209,7 @@ public class MultiPurposeController {
 
 	/**
 	 * Returns the highest Id
+	 * 
 	 * @param map
 	 * @return
 	 */
@@ -205,7 +220,7 @@ public class MultiPurposeController {
 			if (map.get(i) > max)
 				max = map.get(i);
 		}
-		
+
 		return max;
 	}
 

+ 16 - 32
src/ui/controller/SaveController.java

@@ -75,7 +75,6 @@ public class SaveController {
 	}
 
 	private Model model;
-	private Gson gson;
 	private int nCat, nObj, nEle, nEdge, nConn, nNodeEdge, nOldEdge, nUnitGraph, nStatsGraph;
 
 	/**
@@ -86,7 +85,6 @@ public class SaveController {
 	 */
 	public SaveController(Model model) {
 		this.model = model;
-		initGson();
 	}
 
 	/**
@@ -119,7 +117,7 @@ public class SaveController {
 		storeData(stream);
 
 		FileWriter writer = new FileWriter(holonFile);
-		writer.write(gson.toJson(file));
+		writer.write(model.getGson().toJson(file));
 		writer.flush();
 		writer.close();
 
@@ -146,7 +144,7 @@ public class SaveController {
 		storeCanvas(file);
 
 		FileWriter writer = new FileWriter(path);
-		writer.write(gson.toJson(file));
+		writer.write(model.getGson().toJson(file));
 
 		writer.flush();
 		writer.close();
@@ -166,7 +164,7 @@ public class SaveController {
 		storeCategory(file);
 
 		FileWriter writer = new FileWriter(path);
-		writer.write(gson.toJson(file));
+		writer.write(model.getGson().toJson(file));
 
 		writer.flush();
 		writer.close();
@@ -219,7 +217,7 @@ public class SaveController {
 			file.add(key, new JsonPrimitive(cat.getName()));
 			// forall object in the category store them into the jsontree
 			for (AbstractCpsObject obj : cat.getObjects()) {
-				file.add("CGOBJECT" + getNumerator(NUMTYPE.OBJECT), gson.toJsonTree(obj, AbstractCpsObject.class));
+				file.add("CGOBJECT" + getNumerator(NUMTYPE.OBJECT), model.getGson().toJsonTree(obj, AbstractCpsObject.class));
 				// if its a holonobject add elements too
 				if (obj instanceof HolonObject)
 					elementsToJson(TYPE.CATEGORY, file, obj);
@@ -247,7 +245,7 @@ public class SaveController {
 			u = queue.pop();
 			// add currentnode into jsontree
 			String key = "CVSOBJECT" + getNumerator(NUMTYPE.OBJECT);
-			file.add(key, gson.toJsonTree(u, AbstractCpsObject.class));
+			file.add(key, model.getGson().toJsonTree(u, AbstractCpsObject.class));
 			// and its connections too
 			edgeToJson(EDGETYPE.CONNECTION, file, u.getId(), u.getConnections());
 			// if holonobject elements too
@@ -306,7 +304,7 @@ public class SaveController {
 		String key = null;
 		// forall elements store them into json and include the id of the object
 		for (HolonElement ele : ((HolonObject) obj).getElements()) {
-			temp.add("properties", gson.toJsonTree(ele));
+			temp.add("properties", model.getGson().toJsonTree(ele));
 			temp.add("ID", new JsonPrimitive(obj.getId()));
 			// switch for deciding the key
 			switch (type) {
@@ -319,7 +317,7 @@ public class SaveController {
 			default:
 				break;
 			}
-			file.add(key, gson.toJsonTree(temp));
+			file.add(key, model.getGson().toJsonTree(temp));
 			// if there are gps add them into
 			if (ele.getGraphPoints().size() != 0)
 				unitgraphToJson(GRAPHTYPE.ELEMENT, file, ele.getId(), ele.getGraphPoints());
@@ -355,7 +353,7 @@ public class SaveController {
 		// add id of element so it can be found again
 		temp.add("ID", new JsonPrimitive(id));
 
-		file.add(key, gson.toJsonTree(temp));
+		file.add(key, model.getGson().toJsonTree(temp));
 	}
 
 	/**
@@ -374,7 +372,7 @@ public class SaveController {
 
 		for (CpsEdge edge : arr) {
 			// add properties and only the ids from a and b
-			temp.add("properties", gson.toJsonTree(edge));
+			temp.add("properties", model.getGson().toJsonTree(edge));
 			temp.add("A", new JsonPrimitive(edge.getA().getId()));
 			temp.add("B", new JsonPrimitive(edge.getB().getId()));
 
@@ -402,7 +400,7 @@ public class SaveController {
 					&& !type.equals(EDGETYPE.CONNECTION))
 				b = true;
 			temp.add("connection", new JsonPrimitive(b));
-			file.add(k, gson.toJsonTree(temp));
+			file.add(k, model.getGson().toJsonTree(temp));
 			temp = new JsonObject();
 		}
 
@@ -417,29 +415,29 @@ public class SaveController {
 			temp.add("" + i, new JsonPrimitive(model.getTrackingObj().get(i).getId()));
 		}
 
-		file.add(key, gson.toJsonTree(temp));
+		file.add(key, model.getGson().toJsonTree(temp));
 	}
 
 	private void statisticgraphToJson(JsonObject file) {
 		// TODO Auto-generated method stub
 		JsonObject temp = new JsonObject();
-		String key = null;
+		
 		List<String> keys = model.getGraphTable().keySet().parallelStream()
 				.collect(Collectors.toCollection(ArrayList::new));
 
 		for (String k : keys) {
-			temp.add("KEY", new JsonPrimitive(k));
 			JsonObject dataSet = new JsonObject();
 			for (int i = 0; i < model.getGraphTable().get(k).getStatGraph().getDataSets().size(); i++) {
 				TrackedDataSet set = model.getGraphTable().get(k).getStatGraph().getDataSets().get(i);
 				dataSet.add("ID", new JsonPrimitive(set.getCpsObject().getId()));
-				dataSet.add("COLOR", gson.toJsonTree(set.getColor(), Color.class));
+				dataSet.add("COLOR", model.getGson().toJsonTree(set.getColor(), Color.class));
 				dataSet.add("PROPERTY", new JsonPrimitive(set.getProperty()));
-				temp.add("" + i, gson.toJsonTree(dataSet));
+				temp.add("" + i, model.getGson().toJsonTree(dataSet));
 				dataSet = new JsonObject();
 			}
+			temp.add("KEY", new JsonPrimitive(k));
 
-			file.add("STATSGRAPH" + getNumerator(NUMTYPE.STATSGRAPH), gson.toJsonTree(temp));
+			file.add("STATSGRAPH" + getNumerator(NUMTYPE.STATSGRAPH), model.getGson().toJsonTree(temp));
 			temp = new JsonObject();
 		}
 
@@ -515,20 +513,6 @@ public class SaveController {
 		return ret;
 	}
 
-	/**
-	 * 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..
 	 */

+ 97 - 14
src/ui/model/Model.java

@@ -9,12 +9,21 @@ import java.util.List;
 
 import javax.swing.JTable;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+
+import TypeAdapter.AbstractCpsObjectAdapter;
+import TypeAdapter.ColorAdapter;
+import TypeAdapter.PositionAdapter;
 import classes.AbstractCpsObject;
 import classes.Category;
 import classes.CpsEdge;
 import classes.CpsUpperNode;
 import classes.HolonElement;
 import classes.HolonSwitch;
+import classes.Position;
 import interfaces.CategoryListener;
 import interfaces.GraphListener;
 import interfaces.ObjectListener;
@@ -72,6 +81,8 @@ public class Model {
 	private int numberOfSaves = 35;
 	// if the simulation is running and has not been reseted
 	private boolean isSimRunning = false;
+	// if the console log of the program should be displayed
+	private boolean showConsoleLog = true;
 	/*
 	 * Array of all categories in the model. It is set by default with the
 	 * categories ENERGY, BUILDINGS and COMPONENTS
@@ -115,7 +126,12 @@ public class Model {
 	private Object algorithm = null;
 	private int selectedHolonBody;
 
+	// Statistic Graph Data
 	private Hashtable<String, StatisticGraphPanel> statisticGraphTable = new Hashtable<String, StatisticGraphPanel>();
+	private ArrayList<JsonObject> statisticData = new ArrayList<>();
+	
+	private Gson gson;
+
 	/**
 	 * Constructor for the model. It initializes the categories and
 	 * objectsOnCanvas by default values. Listeners are also initialized by
@@ -137,6 +153,7 @@ public class Model {
 		setPropertyTable(new DefaulTable(1000, colNames.length));
 		getPropertyTable().setColumnIdentifiers(colNames);
 		setTableHolonElement(new JTable());
+		initGson();
 	}
 
 	/**
@@ -818,7 +835,7 @@ public class Model {
 	public int getCanvasImageWidth() {
 		return backgroundWidth;
 	}
-	
+
 	/**
 	 * Returns the Custom height of the background Image of the Canvas.
 	 * 
@@ -827,11 +844,12 @@ public class Model {
 	public int getCanvasImageHeight() {
 		return backgroundHeight;
 	}
-	
+
 	/**
 	 * Set the Path for the background Image of the Canvas.
 	 * 
-	 * @param paththe Path
+	 * @param paththe
+	 *            Path
 	 */
 	public void setCanvasImagePath(String path) {
 		imgPath = path;
@@ -842,7 +860,8 @@ public class Model {
 	 * 
 	 * 0 take size of the Image, 1 stretch the Image, 2 Custom Image size
 	 * 
-	 * @param backgroundMode the mode
+	 * @param backgroundMode
+	 *            the mode
 	 */
 	public void setCanvasImageMode(int mode) {
 		backgroundMode = mode;
@@ -851,48 +870,112 @@ public class Model {
 	/**
 	 * Set the Custom width of the background Image of the Canvas.
 	 * 
-	 * @param width the Width
+	 * @param width
+	 *            the Width
 	 */
 	public void setCanvasImageWidth(int width) {
 		backgroundWidth = width;
 	}
-	
+
 	/**
 	 * Set the Custom height of the background Image of the Canvas.
 	 * 
-	 * @param height the height
+	 * @param height
+	 *            the height
 	 */
 	public void setCanvasImageHeight(int height) {
 		backgroundHeight = height;
 	}
-	
+
 	/**
 	 * Set the graphtable for Statistic Graphs
 	 */
-	public void setGraphTable(Hashtable<String, StatisticGraphPanel> gT){
+	public void setGraphTable(Hashtable<String, StatisticGraphPanel> gT) {
 		statisticGraphTable = gT;
 	}
-	
+
 	/**
 	 * Returns the graphtable for Statistic Graphs.
 	 */
-	public Hashtable<String, StatisticGraphPanel> getGraphTable(){
+	public Hashtable<String, StatisticGraphPanel> getGraphTable() {
 		return statisticGraphTable;
 	}
-	
+
 	/**
 	 * Returns if the Simulation is running.
 	 */
-	public boolean getIsSimRunning(){
+	public boolean getIsSimRunning() {
 		return isSimRunning;
 	}
 
 	/**
 	 * Sets isSimRunning.
+	 * 
 	 * @param isRunning
 	 */
 	public void setIsSimRunning(boolean isRunning) {
 		isSimRunning = isRunning;
 	}
-}
 
+	/**
+	 * @return the statisticData
+	 */
+	public ArrayList<JsonObject> getStatisticData() {
+		return statisticData;
+	}
+
+	/**
+	 * @param statisticData
+	 *            the statisticData to set
+	 */
+	public void setStatisticData(ArrayList<JsonObject> statisticData) {
+		this.statisticData = statisticData;
+	}
+
+	/**
+	 * Returns showConsoleLog.
+	 */
+	public boolean getShowConsoleLog() {
+		return this.showConsoleLog;
+	}
+
+	/**
+	 * Sets showConsoleLog.
+	 * 
+	 * @param showConsoleLog
+	 */
+	public void setShowConsoleLog(boolean showConsoleLog) {
+		this.showConsoleLog = showConsoleLog;
+
+	}
+	
+	/**
+	 * Initialize the Gson with wanted parameters
+	 */
+	private void initGson() {
+		// TODO Auto-generated method stub
+		GsonBuilder builder = new GsonBuilder();
+		builder.serializeNulls();
+		builder.excludeFieldsWithoutExposeAnnotation();
+		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.setGson(builder.create());
+
+	}
+
+	/**
+	 * @return the gson
+	 */
+	public Gson getGson() {
+		return gson;
+	}
+
+	/**
+	 * @param gson the gson to set
+	 */
+	public void setGson(Gson gson) {
+		this.gson = gson;
+	}
+}

+ 13 - 5
src/ui/view/AlgorithmMenu.java

@@ -32,7 +32,7 @@ public class AlgorithmMenu extends JMenu {
 	JMenuItem algoFolderButton = new JMenuItem("Select Algorithm Folder");
 	private JMenu mnSelectAlgorithm = new JMenu("Select Algorithm");
 	private HashMap<String, File> algosHash = new HashMap<>();
-	private JMenuItem noneItem= new JMenuItem("none");
+	private JMenuItem noneItem = new JMenuItem("none");
 
 	// root Directory
 	File root = null;
@@ -55,7 +55,6 @@ public class AlgorithmMenu extends JMenu {
 		this.controller = cont;
 		this.setText("Algorithm");
 
-
 		// algoFolderButton Action
 		algoFolderButton.addActionListener(new ActionListener() {
 
@@ -71,7 +70,7 @@ public class AlgorithmMenu extends JMenu {
 				fileChooser.setAcceptAllFileFilterUsed(false);
 
 				if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
-					//empty everything and reset the selected algorithm
+					// empty everything and reset the selected algorithm
 					controller.setAlgorithm(null);
 					mnSelectAlgorithm.removeAll();
 					mnSelectAlgorithm.add(noneItem);
@@ -93,7 +92,7 @@ public class AlgorithmMenu extends JMenu {
 							algosHash.put(name, files[i]);
 							JMenuItem tempItem = new JMenuItem(name);
 							tempItem.addActionListener(new ActionListener() {
-								
+
 								@Override
 								public void actionPerformed(ActionEvent e) {
 									for (int i = 0; i < mnSelectAlgorithm.getItemCount(); i++) {
@@ -130,6 +129,7 @@ public class AlgorithmMenu extends JMenu {
 	}
 
 	public void setAlgorithm(File file, String name) {
+		boolean missinConsole = false;
 		try {
 			BufferedReader br = new BufferedReader(new FileReader(file.getPath()));
 			String line = br.readLine();
@@ -154,6 +154,10 @@ public class AlgorithmMenu extends JMenu {
 			// Compile source file.
 			JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
 
+			if (ToolProvider.getSystemJavaCompiler() == null) {
+				missinConsole = true;
+			}
+
 			compiler.run(null, null, null, file.getPath());
 
 			// Load and instantiate compiled class.
@@ -171,7 +175,11 @@ public class AlgorithmMenu extends JMenu {
 			controller.setAlgorithm(t);
 
 		} catch (Exception e) {
-			controller.addTextToConsole(e.toString());
+			if (missinConsole) {
+				controller.addTextToConsole("missing Compiiler! Please install JDK");
+			} else {
+				controller.addTextToConsole(e.toString());
+			}
 		}
 	}
 }

+ 7 - 7
src/ui/view/FlexibleData.java

@@ -16,7 +16,7 @@ public class FlexibleData extends JPanel {
 	private JLabel lblProdConsVal;
 	private JPanel subnetColorPanel;
 	public FlexibleData(String name, float prod, float cons, float maxProd, float maxCons) {
-		setPreferredSize(new Dimension(563, 100));
+		setPreferredSize(new Dimension(570, 100));
 		setMinimumSize(new Dimension(550, 100));
 		setLayout(null);
 		
@@ -28,22 +28,22 @@ public class FlexibleData extends JPanel {
 		
 		JLabel lblFlProd = new JLabel("Flex. Prod.:");
 		lblFlProd.setForeground(new Color(0, 204, 51));
-		lblFlProd.setBounds(31, 46, 64, 27);
+		lblFlProd.setBounds(10, 46, 85, 27);
 		add(lblFlProd);
 		
 		JLabel lblFlexCons = new JLabel("Flex. Cons.:\r\n");
 		lblFlexCons.setForeground(new Color(255, 0, 0));
-		lblFlexCons.setBounds(188, 46, 64, 27);
+		lblFlexCons.setBounds(188, 46, 85, 27);
 		add(lblFlexCons);
 		
 		JLabel lblProdCons = new JLabel("Prod./Cons.:");
 		lblProdCons.setForeground(new Color(218, 165, 32));
-		lblProdCons.setBounds(348, 46, 85, 27);
+		lblProdCons.setBounds(365, 46, 113, 27);
 		add(lblProdCons);
 		
 		prodVal = new JProgressBar();
 		setProd(maxProd, prod);
-		prodVal.setBounds(94, 46, 85, 24);
+		prodVal.setBounds(94, 48, 85, 24);
 		prodVal.setBorder(new EmptyBorder(0, 0, 0, 0));
 		prodVal.setStringPainted(true);
 		prodVal.setForeground(new Color(0, 204, 51));
@@ -51,7 +51,7 @@ public class FlexibleData extends JPanel {
 		
 		consVal = new JProgressBar();
 		setCons(maxCons, cons);
-		consVal.setBounds(253, 46, 85, 24);
+		consVal.setBounds(270, 46, 85, 24);
 		consVal.setBorder(new EmptyBorder(0, 0, 0, 0));
 		consVal.setStringPainted(true);
 		consVal.setForeground(Color.RED);
@@ -59,7 +59,7 @@ public class FlexibleData extends JPanel {
 		
 		lblProdConsVal = new JLabel();
 		setProdConsVal(prod, cons);
-		lblProdConsVal.setBounds(415, 46, 103, 24);
+		lblProdConsVal.setBounds(453, 46, 103, 24);
 		add(lblProdConsVal);
 		
 		subnetColorPanel = new JPanel();

+ 46 - 2
src/ui/view/GUI.java

@@ -22,8 +22,10 @@ import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.stream.Collectors;
 
 import javax.swing.AbstractAction;
 import javax.swing.ActionMap;
@@ -32,6 +34,7 @@ import javax.swing.DefaultComboBoxModel;
 import javax.swing.ImageIcon;
 import javax.swing.InputMap;
 import javax.swing.JButton;
+import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
@@ -67,6 +70,7 @@ import javax.swing.tree.TreeCellRenderer;
 
 import org.apache.commons.compress.archivers.ArchiveException;
 
+import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
 
 import classes.AbstractCpsObject;
@@ -78,6 +82,7 @@ import classes.HolonSwitch;
 import classes.HolonTransformer;
 import classes.IdCounter;
 import classes.IdCounterElem;
+import classes.TrackedDataSet;
 import interfaces.CategoryListener;
 import ui.controller.Control;
 import ui.controller.UpdateController;
@@ -109,7 +114,7 @@ public class GUI<E> implements CategoryListener {
 	private final JMenu mnNewMenuOptions = new JMenu("Options");
 	private final JMenu mnNewMenuView = new JMenu("View");
 	private final JMenu mnHelp = new JMenu("Help");
-	private final JMenu mnAlgorithm = new JMenu("Algorithm");
+	private JCheckBox consoleLogCheckBox = new JCheckBox("Show program console log");
 	private final JMenuItem mntmOpen = new JMenuItem("Open");
 	private final JMenuItem mntmNew = new JMenuItem("New");
 	private final JMenuItem mntmSave = new JMenuItem("Save");
@@ -318,13 +323,15 @@ public class GUI<E> implements CategoryListener {
 		frmCyberPhysical.setTitle("Cyber Physical Systems Model");
 		frmCyberPhysical.setBounds(100, 100, 1000, 800);
 		frmCyberPhysical.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+		frmCyberPhysical.setExtendedState(JFrame.MAXIMIZED_BOTH);
 		frmCyberPhysical.addWindowListener(new java.awt.event.WindowAdapter() {
 			@Override
 			public void windowClosing(java.awt.event.WindowEvent windowEvent) {
 				if (JOptionPane.showConfirmDialog(frmCyberPhysical, Languages.getLanguage()[88],
 						"Cyber Physical Systems Model", JOptionPane.YES_NO_OPTION,
 						JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
-					controller.deleteDirectory(new File(System.getProperty("user.home") + "/.config/HolonGUI/Autosave"));
+					controller
+							.deleteDirectory(new File(System.getProperty("user.home") + "/.config/HolonGUI/Autosave"));
 					System.exit(0);
 				}
 			}
@@ -701,6 +708,14 @@ public class GUI<E> implements CategoryListener {
 				tree.repaint();
 			}
 		});
+		mnNewMenuOptions.add(consoleLogCheckBox);
+		consoleLogCheckBox.setSelected(true);
+		consoleLogCheckBox.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent arg0) {
+				controller.setShowConsoleLog(consoleLogCheckBox.isSelected());
+			}
+		});
 
 		menuBar.add(mnNewMenuView);
 
@@ -1709,6 +1724,9 @@ public class GUI<E> implements CategoryListener {
 						canvas.repaint();
 						unitGraph.update(model.getObjectsOnCanvas());
 						tree.repaint();
+						for (JsonObject json : model.getStatisticData()) {
+							readStatistics(json);
+						}
 					} catch (IOException | ArchiveException e) {
 						// TODO Auto-generated catch block
 						e.printStackTrace();
@@ -2289,4 +2307,30 @@ public class GUI<E> implements CategoryListener {
 			temp = null;
 		}
 	}
+
+	private void readStatistics(JsonObject json) {
+
+		List<String> keys = json.entrySet().stream().map(i -> i.getKey())
+				.collect(Collectors.toCollection(ArrayList::new));
+
+		// Saved Values
+		JsonObject obj = null;
+		AbstractCpsObject cps = null;
+		int prop = 0;
+		Color color = null;
+
+		StatisticGraphPanel stat = new StatisticGraphPanel(model, controller, json.get("KEY").getAsString(),
+				model.getGraphTable());
+
+		for (String k : keys) {
+			if (!k.equals("KEY")) {
+				obj = json.get(k).getAsJsonObject();
+				cps = controller.searchTracked(obj.get("ID").getAsInt());
+				prop = obj.get("PROPERTY").getAsInt();
+				color = model.getGson().fromJson(obj.get("COLOR"), Color.class);
+				stat.getStatGraph().addObject(new TrackedDataSet(cps, prop, color));
+			}
+			model.getGraphTable().put(json.get("KEY").getAsString(), stat);
+		}
+	}
 }

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

@@ -141,7 +141,7 @@ public class HolonCanvas extends JPanel implements MouseWheelListener, MouseList
 			totalElapsedTime = 0;
 		}
 
-		// check if HolonBodys should bes sorted after size
+		// check if HolonBodys should be sorted after size
 		if (chckbxSort.isSelected() && sizeChange) {
 			hCController.rearrangeAfterSize();
 			sizeChange = false;
@@ -171,7 +171,7 @@ public class HolonCanvas extends JPanel implements MouseWheelListener, MouseList
 		this.g2.fillRect(0, 0, getWidth(), getHeight());
 
 		bodies = hCController.getBodies();
-		// Render Game Objects
+		// Render Objects
 		for (int i = 0; i < subCount; i++) {
 			bodyNr = bodies.get(i).getId();
 			switch (comboChoice) {

+ 22 - 20
src/ui/view/MyCanvas.java

@@ -65,8 +65,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	private float scalediv20;
 	private Position unPos;
 	private ArrayList<Position> savePos;
-	private UnitGraph unitGraph;
-
 	private UpdateController updCon;
 
 	ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
@@ -125,8 +123,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		toolTip = false;
 		this.controller = control;
 		this.model = mod;
-		this.unitGraph = unitGraph;
-
 		scalediv20 = model.getScale() / 20;
 
 		showedInformation[0] = true;
@@ -290,10 +286,12 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							((HolonObject) o).updateTrackingInfo();
 						}
 					}
-					controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
-					controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+					if (model.getShowConsoleLog()) {
+						controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
+						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+					}
 				}
 			}
 		});
@@ -321,10 +319,12 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							((HolonObject) o).setTrackingProd(new float[100]);
 							((HolonObject) o).setTrackingCons(new float[100]);
 						}
-						controller.addTextToConsole("Untracking: ", Color.BLACK, 12, false, false, false);
-						controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
-						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-						controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+						if (model.getShowConsoleLog()) {
+							controller.addTextToConsole("Untracking: ", Color.BLACK, 12, false, false, false);
+							controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
+							controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+							controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+						}
 					}
 				}
 			}
@@ -358,7 +358,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							tabbedPane = (JTabbedPane) tempSplit.getLeftComponent();
 							tabbedPane2 = null;
 						}
-						//Look if the uppernode is open in a Tab
+						// Look if the uppernode is open in a Tab
 						for (int i = 4; i < tabbedPane.getTabCount(); i++) {
 							if (tabbedPane.getComponentAt(i) == null) {
 							} else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
@@ -373,8 +373,8 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							if (tabbedPane2 != null
 									&& ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
 											.getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
-								((ButtonTabComponent) tabbedPane
-										.getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
+								((ButtonTabComponent) tabbedPane.getTabComponentAt(tabbedPane2.getSelectedIndex()))
+										.removeTabs();
 							}
 						} catch (Exception e2) {
 						}
@@ -457,7 +457,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			}
 		}
 
-		//SubNet Coloring
+		// SubNet Coloring
 		int i = 0;
 		for (SubNet s : controller.getSimManager().getSubNets()) {
 
@@ -723,10 +723,12 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			cy = cps.getPosition().y - controller.getScaleDiv2();
 			if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
 				tempCps = cps;
-				controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
-				controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
-				controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-				controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+				if (model.getShowConsoleLog()) {
+					controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
+					controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
+					controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+					controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+				}
 				dragging = true;
 				if (e.isControlDown() && tempCps != null) {
 					if (model.getSelectedCpsObjects().contains(tempCps)) {

+ 6 - 3
src/ui/view/StatisticGraphPanel.java

@@ -12,7 +12,10 @@ import java.awt.event.MouseEvent;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
+import java.util.stream.Collectors;
 
 import javax.imageio.ImageIO;
 import javax.swing.BorderFactory;
@@ -24,6 +27,8 @@ import javax.swing.JPanel;
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
+import com.google.gson.JsonObject;
+
 import classes.TrackedDataSet;
 import ui.controller.Control;
 import ui.model.Model;
@@ -232,9 +237,6 @@ public class StatisticGraphPanel extends JPanel {
 		//b.setBackground(set.getColor());
 		b.setBorder(BorderFactory.createLineBorder(set.getColor()));
 		int color = Math.max(Math.max(set.getColor().getRed(), set.getColor().getGreen()), set.getColor().getBlue());
-		if (color <= 128) {
-			b.setForeground(Color.WHITE);
-		}
 
 		b.setOpaque(true);
 		b.addMouseListener(new MouseAdapter() {
@@ -302,5 +304,6 @@ public class StatisticGraphPanel extends JPanel {
 	public void resetGraph(){
 		sGraph.resetGraph();
 	}
+
 	
 }

+ 25 - 13
src/ui/view/TimePanel.java

@@ -38,6 +38,7 @@ public class TimePanel extends JPanel {
 
 	private Model model;
 	private Control controller;
+	private int dragResetIteration = 0;
 
 	JSlider timeSlider = new JSlider() {
 		/**
@@ -136,19 +137,18 @@ public class TimePanel extends JPanel {
 		timeSlider.addMouseListener(new MouseAdapter() {
 			@Override
 			public void mousePressed(MouseEvent e) {
-				controller.resetSimulation();
-				if (running) {
-					playBtn.doClick();
-				}
+				dragResetIteration = model.getCurIteration();
 			}
 		});
 
 		timeSlider.addMouseMotionListener(new MouseAdapter() {
 			@Override
 			public void mouseDragged(MouseEvent e) {
-				controller.resetSimulation();
-				if (running) {
-					playBtn.doClick();
+				if (dragResetIteration != model.getCurIteration()) {
+					controller.resetSimulation();
+					if (running) {
+						playBtn.doClick();
+					}
 				}
 			}
 		});
@@ -229,10 +229,10 @@ public class TimePanel extends JPanel {
 		});
 
 		timeBtnPanel.add(playBtn);
-		timeBtnPanel.add(Box.createRigidArea(new Dimension(10,0)));
+		timeBtnPanel.add(Box.createRigidArea(new Dimension(10, 0)));
 		timeBtnPanel.add(timeResetBtn);
-		timeBtnPanel.add(Box.createRigidArea(new Dimension(10,0)));
-		timeBtnPanel.add(timeForwardBtn);	
+		timeBtnPanel.add(Box.createRigidArea(new Dimension(10, 0)));
+		timeBtnPanel.add(timeForwardBtn);
 
 		// Speed Panel
 		speedPanel.add(simSpeedLabel);
@@ -259,26 +259,38 @@ public class TimePanel extends JPanel {
 
 		this.add(btnAndSpeedPanel, BorderLayout.WEST);
 		this.add(timeSlider);
+
+		//Disable Keys
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), "UP_ARROW");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), "DOWN_ARROW");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0, false), "PAGE_DOWN");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0, false), "PAGE_UP");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0, false), "END");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0, false), "HOME");
 		
-		//Left arrow Key
+		// Left arrow Key
 		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), "LEFT_ARROW");
 		timeSlider.getActionMap().put("LEFT_ARROW", new AbstractAction() {
 			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				timeSlider.setValue(timeSlider.getValue()-1);
+				timeSlider.setValue(timeSlider.getValue() - 1);
 				controller.resetSimulation();
 			}
 		});
+		
+		//Right arrow Key
 		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), "Right_ARROW");
 		timeSlider.getActionMap().put("Right_ARROW", new AbstractAction() {
 			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				if (!model.getIsSimRunning()) {
 					controller.setIsSimRunning(true);
 				}
-				timeSlider.setValue(timeSlider.getValue()+1);
+				timeSlider.setValue(timeSlider.getValue() + 1);
 			}
 		});
 	}

+ 120 - 65
src/ui/view/UnitGraph.java

@@ -76,6 +76,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	private double x = 0, y = 0;
 	private int x1, x2, y1, y2, ctrlx1, ctrly1, ctrlx2, ctrly2;
 
+	private int border = 4;
+	private int textWidth = 0;
+
 	/**
 	 * Constructor.
 	 * 
@@ -113,15 +116,18 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 
 		graphCurve.reset();
 
+		border = (int) recSize.getX() >> 1;
 		// Draw the Vertical Lines
 		g2.setColor(Color.BLACK);
-		for (int i = 0; i < this.getWidth(); i += 7) {
-			g2.drawLine(i, 0, i, this.getHeight());
+		for (int i = border; i < this.getWidth() - border; i += border * 2) {
+			g2.drawLine(i, border, i, this.getHeight() - border);
 		}
+		g2.drawLine(this.getWidth() - border, border, this.getWidth() - border, this.getHeight() - border);
 
-		for (int i = 0; i < this.getHeight(); i += 7) {
-			g2.drawLine(0, i, this.getWidth(), i);
+		for (int i = border; i < this.getHeight() - border; i += border * 2) {
+			g2.drawLine(border, i, this.getWidth() - border, i);
 		}
+		g2.drawLine(border, this.getHeight() - border, this.getWidth() - border, this.getHeight() - border);
 
 		if (isElement) {
 			// array fillen
@@ -133,6 +139,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				g2.setColor(Color.BLACK);
 				for (int i = 0; i < pointList.size() - 1; i++) {
 					c = buildCurve(pointList.get(i), pointList.get(i + 1));
+					c.setCurve((x1 * scaleX) + border, (y1 * scaleY) + border, (ctrlx1 * scaleX) + border,
+							(ctrly1 * scaleY) + border, (ctrlx2 * scaleX) + border, (ctrly2 * scaleY) + border,
+							(x2 * scaleX) + border, (y2 * scaleY) + border);
 					graphCurve.append(c, true);
 				}
 				g2.draw(graphCurve);
@@ -140,32 +149,49 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				// Draw the Points
 				g2.setColor(Color.BLUE);
 				for (int i = 0; i < pointList.size() - 0; i++) {
-					g2.fillOval((int) (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
-							(int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2), (int) recSize.getX(),
-							(int) recSize.getY());
+					g2.fillOval((int) (pointList.get(i).getX() * scaleX - recSize.getX() / 2) + border,
+							(int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2) + border,
+							(int) recSize.getX(), (int) recSize.getY());
 				}
 
 				// Iteration Value
-				if (arrayOfFloats != null) {
+				textWidth = g.getFontMetrics().stringWidth("" + arrayOfFloats[model.getCurIteration()]) + 2;
+				if (textWidth
+						+ (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1) + 2
+						+ border <= this.getWidth()) {
 					g2.drawString("" + arrayOfFloats[model.getCurIteration()],
-							(model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
+							(model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+									+ 2 + border,
+							this.getHeight() - 10);
+				} else {
+					g2.drawString("" + arrayOfFloats[model.getCurIteration()],
+							(model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+									+ border - textWidth,
 							this.getHeight() - 10);
 				}
+
 			}
 			// drag Information
-			if (tempP != null) {
+			if (tempP != null && pointDrag) {
 				dragInformation = "" + convertToValueY(getYValueAt((int) tempP.getX()));
-				g2.drawString(dragInformation, (int) (tempP.getX() * scaleX) + 10, (int) (tempP.getY() * scaleY) + 10);
+				textWidth = g.getFontMetrics().stringWidth("" + convertToValueY(getYValueAt((int) tempP.getX()))) + 2;
+				if (textWidth + (tempP.getX() * scaleX) + 10 + border <= this.getWidth()) {
+					g2.drawString(dragInformation, (int) (tempP.getX() * scaleX) + 10 + border,
+							(int) (tempP.getY() * scaleY) + 10);
+				} else {
+					g2.drawString(dragInformation, (int) (tempP.getX() * scaleX) - textWidth,
+							(int) (tempP.getY() * scaleY) + 10);
+				}
 			}
 
 			/*
 			 * // Actual Iteration Point Visualization g2.setColor(Color.RED);
 			 * if (arrayOfFloats != null) { for (int i = 0; i <
 			 * arrayOfFloats.length; i++) { g2.fillOval((int) (i * width /
-			 * (model.getIterations() - 1) * scaleX - recSize.getX() / 2), (int)
-			 * (convertToCanvasY((int) arrayOfFloats[i]) * scaleY -
-			 * recSize.getY() / 2), (int) recSize.getX(), (int) recSize.getY());
-			 * } }
+			 * (model.getIterations() - 1) * scaleX - recSize.getX() /
+			 * 2)+border, (int) (convertToCanvasY((int) arrayOfFloats[i]) *
+			 * scaleY - recSize.getY() / 2)+border, (int) recSize.getX(), (int)
+			 * recSize.getY()); } }
 			 */
 
 		} else if (isSwitch) {
@@ -177,8 +203,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				g2.setStroke(new BasicStroke(2));
 				g2.setColor(Color.BLACK);
 				for (int i = 0; i < pointList.size() - 1; i++) {
-					line = new Line2D.Double(pointList.get(i).getX() * scaleX, pointList.get(i).getY() * scaleY,
-							pointList.get(i + 1).getX() * scaleX, pointList.get(i + 1).getY() * scaleY);
+					if ((i == 1 || i == 2) && pointList.get(i).getX() < 0) {
+						line = new Line2D.Double(border, pointList.get(i).getY() * scaleY, border,
+								pointList.get(i + 1).getY() * scaleY);
+					} else {
+						line = new Line2D.Double(pointList.get(i).getX() * scaleX + border,
+								pointList.get(i).getY() * scaleY, pointList.get(i + 1).getX() * scaleX + border,
+								pointList.get(i + 1).getY() * scaleY);
+					}
 					graphCurve.append(line, true);
 				}
 				g2.draw(graphCurve);
@@ -186,27 +218,47 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				/*
 				 * // Draw the Points g2.setColor(Color.BLUE); for (int i = 0; i
 				 * < pointList.size() - 0; i++) { g2.fillOval((int)
-				 * (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
-				 * (int) (pointList.get(i).getY() * scaleY - recSize.getY() /
-				 * 2), (int) recSize.getX(), (int) recSize.getY()); }
+				 * (pointList.get(i).getX() * scaleX - recSize.getX() / 2) +
+				 * border, (int) (pointList.get(i).getY() * scaleY -
+				 * recSize.getY() / 2), (int) recSize.getX(), (int)
+				 * recSize.getY()); }
 				 */
 
 				// Iteration Value
-				if (arrayOfBooleans != null) {
+				g2.setColor(Color.BLUE);
+				textWidth = g.getFontMetrics().stringWidth("" + arrayOfBooleans[model.getCurIteration()]) + 2;
+				if (textWidth
+						+ (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1) + 2
+						+ border <= this.getWidth()) {
 					g2.drawString("" + arrayOfBooleans[model.getCurIteration()],
-							(model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
+							(model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+									+ 2 + border,
+							this.getHeight() - 10);
+				} else {
+					g2.drawString("" + arrayOfBooleans[model.getCurIteration()],
+							(model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+									+ border - textWidth,
 							this.getHeight() - 10);
 				}
+
 			}
-			if (tempP != null) {
+			// When the switch graph is dragged
+			if (tempP != null && pointDrag) {
 				try {
 					int i;
-					for (i = 0; (i * this.getWidth() / (model.getIterations() - 1) < getMousePosition().getX()); i++) {
-
+					for (i = 0; (i * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+							+ border < getMousePosition().getX()); i++) {
 					}
 					dragInformation = "" + i;
-					g2.drawString(dragInformation, (int) (getMousePosition().getX()) + 10,
-							(int) (getMousePosition().getY()) + 10);
+					textWidth = g.getFontMetrics().stringWidth("" + convertToValueY(getYValueAt((int) tempP.getX())))
+							+ 2;
+					if (textWidth + (tempP.getX() * scaleX) + 10 + border <= this.getWidth()) {
+						g2.drawString(dragInformation, (int) (getMousePosition().getX()) + 10 + border,
+								(int) (getMousePosition().getY() * scaleY) + 10);
+					} else {
+						g2.drawString(dragInformation, (int) (getMousePosition().getX()) - textWidth,
+								(int) (getMousePosition().getY() * scaleY) + 10);
+					}
 				} catch (Exception e) {
 				}
 			}
@@ -215,8 +267,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		// Iteration Line
 		g2.setColor(Color.BLUE);
 		g2.setStroke(new BasicStroke(1));
-		g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
-				(model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
+		g2.drawLine(border + (model.getCurIteration()) * (this.getWidth() - border * 2) / (model.getIterations() - 1),
+				0, border + (model.getCurIteration()) * (this.getWidth() - border * 2) / (model.getIterations() - 1),
+				this.getHeight());
 
 		// algorithmus
 		controller.calculateStateForTimeStep(model.getCurIteration());
@@ -241,17 +294,18 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		if (pointDrag && tempP != null) {
 			// Out of Bounds verhindern
 			int i = pointList.indexOf(tempP);
-			x = e.getX() / scaleX;
-			y = e.getY() / scaleY;
+			x = (e.getX() - border) / scaleX;
+			y = (e.getY() - border) / scaleY;
 			// y
-			if (e.getY() <= 0) {
+			if (e.getY() <= border) {
 				y = 0;
-			} else if (this.getHeight() <= e.getY()) {
-				y = this.getHeight() / scaleY;
+			} else if (this.getHeight() - border <= e.getY()) {
+				y = (this.getHeight() - border * 2) / scaleY;
 			}
 			// x
-			if (tempP == pointList.getFirst() || tempP == pointList.getLast() || pointList.get(i + 1).getX() < x+3
-					|| pointList.get(i - 1).getX() > x-3 || pointList.getFirst().getX() > x-3 || pointList.getLast().getX() < x+3) {
+			if (tempP == pointList.getFirst() || tempP == pointList.getLast() || pointList.get(i + 1).getX() < x + 2
+					|| pointList.get(i - 1).getX() > x - 2 || pointList.getFirst().getX() > x - 2
+					|| pointList.getLast().getX() < x + 2) {
 				x = tempP.getX();
 			}
 			tempP.setLocation(x, y);
@@ -269,7 +323,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	public void switchDragged(MouseEvent e) {
 		if (pointDrag && tempP != null && tempP != pointList.getFirst() && tempP != pointList.getLast()) {
 			int i = pointList.indexOf(tempP);
-			x = e.getX() / scaleX;
+			x = (e.getX() - border) / scaleX;
 
 			if (pointList.get(i + 1).getY() == tempP.getY()) {
 				// x
@@ -325,8 +379,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		boolean added = false;
 		boolean deletePoint = false;
 
-		int x = (int) (e.getX() / scaleX);
-		double y = e.getY() / scaleY;
+		int x = (int) ((e.getX() - border) / scaleX);
+		double y = (e.getY() - border) / scaleY;
 
 		// Click on Point
 		tempP = null;
@@ -353,7 +407,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 						break;
 					}
 					if (x < pointList.get(i).getX() && !added) {
-						if (e.getY() <= 0) {
+						if (e.getY() <= border) {
 							pointList.add(i, new Point((int) (x), 0));
 						} else {
 							pointList.add(i, new Point((int) (x), (int) y));
@@ -384,7 +438,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		boolean added = false;
 		boolean deletePoint = false;
 
-		double x = e.getX() / scaleX;
+		double x = (e.getX() - border) / scaleX;
 		e.getY();
 
 		// Halbe Iterations Distanz
@@ -411,7 +465,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 						// double p1, p2 um location der points zu bestimmen
 						double p1 = pointList.get(i - 1).getX();
 						double p2 = pointList.get(i).getX();
-						// Punkte hinzufgen, je nachdem ob true oder false
+						// Punkte hinzufügen, je nachdem ob true oder false
 						if (pointList.get(i - 1).getY() != (int) (height / 6)
 								&& pointList.get(i).getY() != (int) (height / 6)) {
 							pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) (height - height / 6)));
@@ -435,13 +489,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 			if (deletePoint && tempP.getX() != 0
 					&& (tempP.getX() != this.getWidth() / scaleX || tempP != pointList.getLast())) {
 				int i = pointList.indexOf(tempP);
-				if (tempP.getY() == (int) (height / 6)) {
+				// If Right, else if Left
+				if (tempP.getY() == (int) (height / 6) && i < pointList.size() - 1 && i > 0) {
 					pointList.remove(i);
 					pointList.remove(i - 1);
 					pointList.remove(i - 2);
 					pointList.remove(i - 3);
-				}
-				if (tempP.getY() == (int) (height - height / 6)) {
+				} else if (tempP.getY() == (int) (height - height / 6)) {
 					pointList.remove(i + 2);
 					pointList.remove(i + 1);
 					pointList.remove(i);
@@ -478,17 +532,17 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 			init = false;
 			// for scale on the first initialisation
 			if (width == -1 && height == -1) {
-				width = this.getWidth();
-				height = this.getHeight();
+				width = this.getWidth() - (border * 2);
+				height = this.getHeight() - (border * 2);
 			}
-
-			scaleX = this.getWidth() / width;
-			scaleY = this.getHeight() / height;
+			// Scale
+			scaleX = (this.getWidth() - (border * 2)) / width;
+			scaleY = (this.getHeight() - (border * 2)) / height;
 		}
 
 		// Scale
-		scaleX = this.getWidth() / width;
-		scaleY = this.getHeight() / height;
+		scaleX = (this.getWidth() - (border * 2)) / width;
+		scaleY = (this.getHeight() - (border * 2)) / height;
 		repaint();
 	}
 
@@ -524,11 +578,11 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	public void reset() {
 		pointList.removeAll(pointList);
 		if (isSwitch) {
-			pointList.addFirst(new Point(-4, (int) (height / 6)));
+			pointList.addFirst(new Point(-border, (int) (height / 6)));
 			pointList.addLast(new Point((int) (width) + 4, (int) (height / 6)));
 		} else {
 			pointList.addFirst(new Point(0, 0));
-			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
+			pointList.addLast(new Point((int) ((this.getWidth() - (border * 2)) / scaleX), 0));
 		}
 		repaint();
 	}
@@ -571,7 +625,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		// First time clicked on the Element
 		if (pointList.isEmpty()) {
 			pointList.addFirst(new Point(0, 0));
-			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
+			pointList.addLast(new Point((int) ((this.getWidth() - (border * 2)) / scaleX), 0));
 		}
 		repaint();
 	}
@@ -589,8 +643,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		isElement = false;
 		// First time clicked on the Element
 		if (pointList.isEmpty()) {
-			pointList.addFirst(new Point(-4, (int) (height / 6)));
-			pointList.addLast(new Point((int) (width) + 4, (int) (height / 6)));
+			pointList.addFirst(new Point(-border, (int) (height / 6)));
+			pointList.addLast(new Point((int) ((this.getWidth() - border) / scaleX), (int) (height / 6)));
 		}
 		repaint();
 	}
@@ -612,14 +666,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		y2 = (int) p2.getY();
 
 		// calculate the controllpoints
-		ctrlx1 = (int) p1.getX() + ((int) p2.getX() - (int) p1.getX()) / 2;
-		ctrlx2 = (int) p2.getX() - ((int) p2.getX() - (int) p1.getX()) / 2;
+		ctrlx1 = x1 + (x2 - x1) / 2;
+		ctrlx2 = x2 - (x2 - x1) / 2;
 		if (y1 < y2) {
-			ctrly1 = (int) p1.getY() + ((int) p2.getY() - (int) p1.getY()) / 10;
-			ctrly2 = (int) p2.getY() - ((int) p2.getY() - (int) p1.getY()) / 10;
+			ctrly1 = y1 + (y2 - y1) / 10;
+			ctrly2 = y2 - (y2 - y1) / 10;
 		} else {
-			ctrly1 = (int) p1.getY() - ((int) p1.getY() - (int) p2.getY()) / 10;
-			ctrly2 = (int) p2.getY() + ((int) p1.getY() - (int) p2.getY()) / 10;
+			ctrly1 = y1 - (y1 - y2) / 10;
+			ctrly2 = y2 + (y1 - y2) / 10;
 		}
 
 		// set the curve
@@ -633,8 +687,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 */
 	public void fillArrayofBooleans() {
 		for (int i = 0; i < arrayOfBooleans.length; i++) {
-			int t = (int) getYValueAt2((int) (i * width / (model.getIterations() - 1)));
-			if (t == (int) (height / 6)) {
+			int t = (int) getYValueAt((int) (i * width / (model.getIterations() - 1)));
+			if (t <= height / 2) {
 				arrayOfBooleans[i] = true;
 			} else {
 				arrayOfBooleans[i] = false;
@@ -729,6 +783,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				}
 			}
 		}
+		// else
 		return getYValueAt(xVal);
 	}
 

+ 161 - 144
src/ui/view/UpperNodeCanvas.java

@@ -305,10 +305,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 							controller.addTrackingObj((HolonObject) o);
 							((HolonObject) o).updateTrackingInfo();
 						}
-						controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
-						controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
-						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-						controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+						if (model.getShowConsoleLog()) {
+							controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
+							controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
+							controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+							controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+						}
 					}
 				}
 			}
@@ -555,136 +557,6 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 			}
 		}
 
-		// Highlighted Edge
-		if (model.getSelectedObjectID() > 0 || !model.getSelectedCpsObjects().isEmpty() || !tempSelected.isEmpty()) {
-			g2.setColor(Color.BLUE);
-			for (CpsEdge con : upperNode.getNodeEdges()) {
-				if (con.getFlow() <= con.getCapacity()) {
-					g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 3) + 1, 4)));
-				} else {
-					g2.setStroke(new BasicStroke(2));
-				}
-				if (con.getA().getId() == model.getSelectedObjectID()
-						|| model.getSelectedCpsObjects().contains(con.getA()) || tempSelected.contains(con.getA())
-						|| con.getB().getId() == model.getSelectedObjectID()
-						|| model.getSelectedCpsObjects().contains(con.getB())
-						|| tempSelected.contains(con.getB()) && con != edgeHighlight) {
-					g2.drawLine(con.getA().getPosition().x, con.getA().getPosition().y, con.getB().getPosition().x,
-							con.getB().getPosition().y);
-
-					if (con.getCapacity() == -1) {
-						maxCap = Character.toString('\u221e');
-					} else if (con.getCapacity() == -2) {
-						maxCap = "???";
-					} else {
-						maxCap = String.valueOf(con.getCapacity());
-					}
-					if (showedInformation[0]) {
-						if (con.getConnected() == 0 || con.getConnected() == 1) {
-							g2.drawString(con.getFlow() + "/" + maxCap,
-									(con.getA().getPosition().x + con.getB().getPosition().x) / 2,
-									(con.getA().getPosition().y + con.getB().getPosition().y) / 2);
-						} else {
-							g2.drawString("not connected",
-									(con.getA().getPosition().x + con.getB().getPosition().x) / 2,
-									(con.getA().getPosition().y + con.getB().getPosition().y) / 2);
-						}
-					}
-				}
-			}
-		} else if (edgeHighlight != null) {
-			g2.setColor(Color.BLUE);
-			if (edgeHighlight.getFlow() <= edgeHighlight.getCapacity()) {
-				g2.setStroke(
-						new BasicStroke(Math.min((edgeHighlight.getFlow() / edgeHighlight.getCapacity() * 3) + 1, 4)));
-			} else {
-				g2.setStroke(new BasicStroke(2));
-			}
-			if (upperNode.getNodeEdges().contains(edgeHighlight)) {
-				g2.drawLine(edgeHighlight.getA().getPosition().x, edgeHighlight.getA().getPosition().y,
-						edgeHighlight.getB().getPosition().x, edgeHighlight.getB().getPosition().y);
-
-				if (edgeHighlight.getCapacity() == -1) {
-					maxCap = Character.toString('\u221e');
-				} else if (edgeHighlight.getCapacity() == -2) {
-					maxCap = "???";
-				} else {
-					maxCap = String.valueOf(edgeHighlight.getCapacity());
-				}
-				if (showedInformation[0]) {
-					g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
-							(edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2,
-							(edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2);
-				}
-			}
-		}
-
-		// Objects in upper node
-		for (AbstractCpsObject cps : upperNode.getNodes()) {
-			// Border Highlighting
-			if (showedInformation[3]) {
-				g2.setColor(cps.getBorderColor());
-				if (g2.getColor() != Color.WHITE) {
-					g2.fillRect((int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
-							(int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20 - 3),
-							(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
-							(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
-				}
-			}
-
-			// node image
-			if (cps instanceof CpsNode && (cps == tempCps || model.getSelectedCpsObject() == cps
-					|| model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps))) {
-				img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
-			} else {
-				if (cps instanceof HolonSwitch) {
-					if (((HolonSwitch) cps).getActiveAt()[model.getCurIteration()]) {
-						((HolonSwitch) cps).setAutoState(true);
-					} else {
-						((HolonSwitch) cps).setAutoState(false);
-					}
-				}
-				// Highlighting
-				if ((cps == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
-						|| model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps)) {
-					g2.setColor(Color.BLUE);
-					g2.fillRect((int) (cps.getPosition().x - model.getScaleDiv2() - scalediv20),
-							(int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20),
-							(int) (controller.getScale() + (scalediv20 * 2)),
-							(int) (controller.getScale() + (scalediv20 * 2)));
-					if (showedInformation[1] && cps instanceof HolonObject) {
-						g2.setColor(Color.BLACK);
-						float totalEnergy = ((HolonObject) cps).getCurrentEnergyAtTimeStep(model.getCurIteration());
-						g2.drawString(Float.toString(totalEnergy), cps.getPosition().x - model.getScaleDiv2(),
-								cps.getPosition().y - model.getScaleDiv2() - 10);
-					}
-				} else if (cps instanceof HolonObject) {
-					g2.setColor(((HolonObject) cps).getColor());
-
-					g2.fillRect((int) (cps.getPosition().x - model.getScaleDiv2() - scalediv20),
-							(int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20),
-							(int) (controller.getScale() + (scalediv20 * 2)),
-							(int) (controller.getScale() + (scalediv20 * 2)));
-
-					if (showedInformation[1]) {
-						g2.setColor(Color.BLACK);
-						float totalEnergy = ((HolonObject) cps).getCurrentEnergyAtTimeStep(model.getCurIteration());
-						g2.drawString(Float.toString(totalEnergy), cps.getPosition().x - model.getScaleDiv2(),
-								cps.getPosition().y - model.getScaleDiv2() - 10);
-					}
-				}
-				// draw image
-				File checkPath = new File(cps.getImage());
-				if (checkPath.exists()) {
-					img = new ImageIcon(cps.getImage()).getImage();
-				} else {
-					img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
-				}
-			}
-			g2.drawImage(img, cps.getPosition().x - model.getScaleDiv2(), cps.getPosition().y - model.getScaleDiv2(),
-					controller.getScale(), controller.getScale(), null);
-		}
-
 		// Objects connected to upperNode
 		int count = 0;
 		for (CpsEdge e : upperNode.getConnections()) {
@@ -725,8 +597,15 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 						g2.drawLine(obj.getPosition().x, obj.getPosition().y, (upperNode.getLeftBorder() >> 1),
 								(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + 25);
 						if (showedInformation[0]) {
+							if (ed.getCapacity() == -1) {
+								maxCap = Character.toString('\u221e');
+							} else if (ed.getCapacity() == -2) {
+								maxCap = "???";
+							} else {
+								maxCap = String.valueOf(ed.getCapacity());
+							}
 							if (ed.getConnected() == 0 || ed.getConnected() == 1) {
-								g2.drawString(ed.getFlow() + "/" + ed.getCapacity(),
+								g2.drawString(ed.getFlow() + "/" + maxCap,
 										(obj.getPosition().x + (upperNode.getLeftBorder() >> 1)) / 2,
 										(obj.getPosition().y + (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count)
 												+ 25) / 2);
@@ -741,6 +620,140 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 				}
 			}
 
+			// Highlighted Edge
+			if (model.getSelectedObjectID() > 0 || !model.getSelectedCpsObjects().isEmpty()
+					|| !tempSelected.isEmpty()) {
+				g2.setColor(Color.BLUE);
+				for (CpsEdge con : upperNode.getNodeEdges()) {
+					if (con.getFlow() <= con.getCapacity()) {
+						g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 3) + 1, 4)));
+					} else {
+						g2.setStroke(new BasicStroke(2));
+					}
+					if (con.getA().getId() == model.getSelectedObjectID()
+							|| model.getSelectedCpsObjects().contains(con.getA()) || tempSelected.contains(con.getA())
+							|| con.getB().getId() == model.getSelectedObjectID()
+							|| model.getSelectedCpsObjects().contains(con.getB())
+							|| tempSelected.contains(con.getB()) && con != edgeHighlight) {
+						g2.drawLine(con.getA().getPosition().x, con.getA().getPosition().y, con.getB().getPosition().x,
+								con.getB().getPosition().y);
+
+						if (con.getCapacity() == -1) {
+							maxCap = Character.toString('\u221e');
+						} else if (con.getCapacity() == -2) {
+							maxCap = "???";
+						} else {
+							maxCap = String.valueOf(con.getCapacity());
+						}
+						if (showedInformation[0]) {
+							if (con.getConnected() == 0 || con.getConnected() == 1) {
+								g2.drawString(con.getFlow() + "/" + maxCap,
+										(con.getA().getPosition().x + con.getB().getPosition().x) / 2,
+										(con.getA().getPosition().y + con.getB().getPosition().y) / 2);
+							} else {
+								g2.drawString("not connected",
+										(con.getA().getPosition().x + con.getB().getPosition().x) / 2,
+										(con.getA().getPosition().y + con.getB().getPosition().y) / 2);
+							}
+						}
+					}
+				}
+			} else if (edgeHighlight != null) {
+				g2.setColor(Color.BLUE);
+				if (edgeHighlight.getFlow() <= edgeHighlight.getCapacity()) {
+					g2.setStroke(new BasicStroke(
+							Math.min((edgeHighlight.getFlow() / edgeHighlight.getCapacity() * 3) + 1, 4)));
+				} else {
+					g2.setStroke(new BasicStroke(2));
+				}
+				if (upperNode.getNodeEdges().contains(edgeHighlight)) {
+					g2.drawLine(edgeHighlight.getA().getPosition().x, edgeHighlight.getA().getPosition().y,
+							edgeHighlight.getB().getPosition().x, edgeHighlight.getB().getPosition().y);
+
+					if (edgeHighlight.getCapacity() == -1) {
+						maxCap = Character.toString('\u221e');
+					} else if (edgeHighlight.getCapacity() == -2) {
+						maxCap = "???";
+					} else {
+						maxCap = String.valueOf(edgeHighlight.getCapacity());
+					}
+					if (showedInformation[0]) {
+						g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
+								(edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2,
+								(edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2);
+					}
+				}
+			}
+
+			// Objects in upper node
+			for (AbstractCpsObject cps1 : upperNode.getNodes()) {
+				// Border Highlighting
+				if (showedInformation[3]) {
+					g2.setColor(cps1.getBorderColor());
+					if (g2.getColor() != Color.WHITE) {
+						g2.fillRect((int) (cps1.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
+								(int) (cps1.getPosition().y - model.getScaleDiv2() - scalediv20 - 3),
+								(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
+								(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
+					}
+				}
+
+				// node image
+				if (cps1 instanceof CpsNode && (cps1 == tempCps || model.getSelectedCpsObject() == cps1
+						|| model.getSelectedCpsObjects().contains(cps1) || tempSelected.contains(cps1))) {
+					img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
+				} else {
+					if (cps1 instanceof HolonSwitch) {
+						if (((HolonSwitch) cps1).getActiveAt()[model.getCurIteration()]) {
+							((HolonSwitch) cps1).setAutoState(true);
+						} else {
+							((HolonSwitch) cps1).setAutoState(false);
+						}
+					}
+					// Highlighting
+					if ((cps1 == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
+							|| model.getSelectedCpsObjects().contains(cps1) || tempSelected.contains(cps1)) {
+						g2.setColor(Color.BLUE);
+						g2.fillRect((int) (cps1.getPosition().x - model.getScaleDiv2() - scalediv20),
+								(int) (cps1.getPosition().y - model.getScaleDiv2() - scalediv20),
+								(int) (controller.getScale() + (scalediv20 * 2)),
+								(int) (controller.getScale() + (scalediv20 * 2)));
+						if (showedInformation[1] && cps1 instanceof HolonObject) {
+							g2.setColor(Color.BLACK);
+							float totalEnergy = ((HolonObject) cps1)
+									.getCurrentEnergyAtTimeStep(model.getCurIteration());
+							g2.drawString(Float.toString(totalEnergy), cps1.getPosition().x - model.getScaleDiv2(),
+									cps1.getPosition().y - model.getScaleDiv2() - 10);
+						}
+					} else if (cps1 instanceof HolonObject) {
+						g2.setColor(((HolonObject) cps1).getColor());
+
+						g2.fillRect((int) (cps1.getPosition().x - model.getScaleDiv2() - scalediv20),
+								(int) (cps1.getPosition().y - model.getScaleDiv2() - scalediv20),
+								(int) (controller.getScale() + (scalediv20 * 2)),
+								(int) (controller.getScale() + (scalediv20 * 2)));
+
+						if (showedInformation[1]) {
+							g2.setColor(Color.BLACK);
+							float totalEnergy = ((HolonObject) cps1)
+									.getCurrentEnergyAtTimeStep(model.getCurIteration());
+							g2.drawString(Float.toString(totalEnergy), cps1.getPosition().x - model.getScaleDiv2(),
+									cps1.getPosition().y - model.getScaleDiv2() - 10);
+						}
+					}
+					// draw image
+					File checkPath = new File(cps1.getImage());
+					if (checkPath.exists()) {
+						img = new ImageIcon(cps1.getImage()).getImage();
+					} else {
+						img = new ImageIcon(this.getClass().getResource(cps1.getImage())).getImage();
+					}
+				}
+				g2.drawImage(img, cps1.getPosition().x - model.getScaleDiv2(),
+						cps1.getPosition().y - model.getScaleDiv2(), controller.getScale(), controller.getScale(),
+						null);
+			}
+
 			// Border Highlighting
 			if (showedInformation[3]) {
 				g2.setColor(cps.getBorderColor());
@@ -874,10 +887,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 				cy = cps.getPosition().y - model.getScaleDiv2();
 				if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
 					tempCps = cps;
-					controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
-					controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+					if (model.getShowConsoleLog()) {
+						controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
+						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+					}
 					dragging = true;
 					if (e.isControlDown() && tempCps != null) {
 						if (model.getSelectedCpsObjects().contains(tempCps)) {
@@ -914,11 +929,13 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 						&& x >= (upperNode.getLeftBorder() >> 1) - model.getScaleDiv2()
 						&& y >= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)) {
 					tempCps = cps;
-					controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
-					controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
-					controller.setSelectedObjectID(tempCps.getId());
+					if (model.getShowConsoleLog()) {
+						controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
+						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+						controller.setSelectedObjectID(tempCps.getId());
+					}
 					// If drawing an Edge (CTRL down)
 					if (tempCps.getClass() == HolonObject.class) {
 						HolonObject tempObj = ((HolonObject) tempCps);