Browse Source

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

dominik.rieder 8 years ago
parent
commit
bceb2711f2

+ 5 - 5
src/classes/HolonObject.java

@@ -402,16 +402,16 @@ public class HolonObject extends AbstractCpsObject {
 		float tempFlex = 0;
 		for (HolonElement e : getElements()) {
 			if (e.getActiveFlex()) {
-				tempFlex += e.getFlexibility();
+				tempFlex += e.getFlexibility() * e.getAmount();
 			}
 		}
 		this.totalFlex = tempFlex;
 	}
-	
+
 	/**
 	 * calculates total flexible Production
 	 */
-	public float getFlexProd(){
+	public float getFlexProd() {
 		float tempFlex = 0;
 		for (HolonElement e : getElements()) {
 			if (e.getFlexibility() > 0) {
@@ -420,11 +420,11 @@ public class HolonObject extends AbstractCpsObject {
 		}
 		return tempFlex;
 	}
-	
+
 	/**
 	 * calculates total flexible Concumption
 	 */
-	public float getFlexCons(){
+	public float getFlexCons() {
 		float tempFlex = 0;
 		for (HolonElement e : getElements()) {
 			if (e.getFlexibility() < 0) {

+ 10 - 3
src/classes/TrackedDataSet.java

@@ -58,9 +58,7 @@ public class TrackedDataSet {
 		this.property = property;
 		this.color = color;
 		this.values = new float[100];
-		for (int i = 0; i < values.length; i++) {
-			values[i] = -1;
-		}
+		resetValues();
 	}
 
 	public AbstractCpsObject getCpsObject() {
@@ -82,4 +80,13 @@ public class TrackedDataSet {
 	public void setValAt(float val, int at){
 		this.values[at] = val;
 	}
+	
+	/**
+	 * Resets all values.
+	 */
+	public void resetValues(){
+		for (int i = 0; i < values.length; i++) {
+			values[i] = -1;
+		}
+	}
 }

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

@@ -551,6 +551,7 @@ public class Control {
 	 * including a reset of all Edges to the default "is working" state
 	 */
 	public void resetSimulation(){
+		setIsSimRunning(false);
 		simulationManager.resetSimulation();
 	}
 
@@ -939,5 +940,12 @@ public class Control {
 	public Hashtable<String, StatisticGraphPanel> getGraphTable(){
 		return model.getGraphTable();
 	}
+	
+	/**
+	 * Sets if the Simulation is running
+	 */
+	public void setIsSimRunning(boolean isRunning){
+		globalController.setIsSimRunning(isRunning);
+	}
 
 }

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

@@ -3,6 +3,7 @@ package ui.controller;
 import java.awt.Color;
 
 import ui.model.Model;
+import ui.view.StatisticGraphPanel;
 
 /**
  * Controller for the Global Variables.
@@ -142,4 +143,17 @@ public class GlobalController {
 	public int getHolonBodyScale() {
 		return model.getHolonBodyScale();
 	}
+	
+	/**
+	 * Sets if the Simulation is running
+	 */
+	public void setIsSimRunning(boolean isRunning){
+		model.setIsSimRunning(isRunning);
+		//Reset the Graph if isRunning == true
+		if (isRunning) {
+			for (StatisticGraphPanel sg : model.getGraphTable().values()) {
+				sg.resetGraph();
+			}
+		}
+	}
 }

+ 69 - 4
src/ui/controller/LoadController.java

@@ -217,6 +217,8 @@ public class LoadController {
 				loadUnitGraph(GRAPHTYPE.SWITCH, json.get(key), objDispatch, null);
 			if (key.contains("ELEUNITGRAPH"))
 				loadUnitGraph(GRAPHTYPE.ELEMENT, json.get(key), null, eleDispatch);
+			if (key.contains("TRACKED"))
+				loadTracked(json.get(key), objDispatch);
 		}
 
 	}
@@ -234,11 +236,20 @@ public class LoadController {
 			model.setCvsObjIdx(new HashMap<Integer, Integer>());
 			model.setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
 			model.setEdgesOnCanvas(new ArrayList<CpsEdge>());
+			model.setTrackingObj(new ArrayList<>());
+			model.setCanvasX(json.get("CANVAS_SIZE_X").getAsInt());
+			model.setCanvasX(json.get("CANVAS_SIZE_Y").getAsInt());
+			IdCounter.setCounter(json.get("IDCOUNTER").getAsInt());
+			IdCounterElem.setCounter(json.get("IDCOUNTERELEMENT").getAsInt());
 			break;
 		case PARTIAL:
 			model.setCvsObjIdx(new HashMap<Integer, Integer>());
 			model.setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
 			model.setEdgesOnCanvas(new ArrayList<CpsEdge>());
+			model.setCanvasX(json.get("CANVAS_SIZE_X").getAsInt());
+			model.setCanvasX(json.get("CANVAS_SIZE_Y").getAsInt());
+			IdCounter.setCounter(json.get("IDCOUNTER").getAsInt());
+			IdCounterElem.setCounter(json.get("IDCOUNTERELEMENT").getAsInt());
 			break;
 		case CATEGORY:
 			model.setCgIdx(new HashMap<String, Integer>());
@@ -247,10 +258,7 @@ public class LoadController {
 		default:
 			break;
 		}
-		model.setCanvasX(json.get("CANVAS_SIZE_X").getAsInt());
-		model.setCanvasX(json.get("CANVAS_SIZE_Y").getAsInt());
-		IdCounter.setCounter(json.get("IDCOUNTER").getAsInt());
-		IdCounterElem.setCounter(json.get("IDCOUNTERELEMENT").getAsInt());
+
 	}
 
 	/**
@@ -273,6 +281,7 @@ public class LoadController {
 		// TODO Auto-generated method stub
 
 		AbstractCpsObject temp = gson.fromJson(jsonElement.getAsJsonObject(), AbstractCpsObject.class);
+		temp.setImage(checkOS(temp.getImage()));
 		initObjects(temp);
 		if (mpC.searchCatObj(mpC.searchCat(temp.getSav()), temp.getObjName()) != null)
 			cgC.deleteObject(temp.getSav(), temp.getObjName());
@@ -280,6 +289,14 @@ public class LoadController {
 
 	}
 
+	private String refreshPath(String image) {
+		// TODO Auto-generated method stub
+		if (!image.contains("/HolonGUI/"))
+			return image;
+		return (System.getProperty("user.home") + image.substring(image.indexOf("/HolonGUI/"), image.length()))
+				.replace("\\", "/");
+	}
+
 	/**
 	 * Load a given Element in Category by Deserialization
 	 * 
@@ -303,6 +320,7 @@ public class LoadController {
 		// TODO Auto-generated method stub
 		AbstractCpsObject temp = gson.fromJson(jsonElement.getAsJsonObject(), AbstractCpsObject.class);
 		initObjects(temp);
+		temp.setImage(checkOS(temp.getImage()));
 		// if its stored before on the canvas just put it there
 		if (temp.getSav().equals("CVS")) {
 			cvsC.addObject(temp);
@@ -440,6 +458,22 @@ public class LoadController {
 		}
 	}
 
+	private void loadTracked(JsonElement jsonElement, HashMap<Integer, AbstractCpsObject> objDispatch) {
+		// TODO Auto-generated method stub
+		JsonObject object = jsonElement.getAsJsonObject();
+		List<String> keys = getKeys(object);
+
+		for (String k : keys) {
+			int id = object.get(k).getAsInt();
+			model.getTrackingObj().add(objDispatch.get(id));
+			model.addObjectsToGraphListeners();
+			if (objDispatch.get(id) instanceof HolonObject) {
+				((HolonObject) objDispatch.get(id)).updateTrackingInfo();
+			}
+		}
+
+	}
+
 	/**
 	 * Initialize the Gson with wanted parameters
 	 */
@@ -464,6 +498,7 @@ public class LoadController {
 
 		ArchiveEntry entry = stream.getNextEntry();
 		while (entry != null) {
+			// String entryName = checkOS(entry.getName());
 			File file = new File(tmp, entry.getName());
 			file.getParentFile().mkdirs();
 			OutputStream output = new FileOutputStream(file);
@@ -479,6 +514,36 @@ public class LoadController {
 		return tmp;
 	}
 
+	private String checkOS(String entryName) {
+		// TODO Auto-generated method stub
+		String os = System.getProperty("os.name").toLowerCase();
+		String ret = entryName;
+		String partition = System.getProperty("user.home");
+
+		if (!ret.contains("HolonGUI"))
+			return ret;
+
+		if (os.contains("windows")) {
+			ret = ret.replace("/", "\\");
+			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("\\HolonGUI\\"), ret.length());
+
+		}
+		if (os.contains("mac")) {
+			// dosmth
+			ret = ret.replace("\\", "/");
+			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("/HolonGUI/"), ret.length());
+		}
+		if (os.contains("linux")) {
+			// dosmth
+			ret = ret.replace("\\", "/");
+			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("/HolonGUI/"), ret.length());
+		}
+		if (os.contains("solaris")) {
+			// dosmth
+		}
+		return ret;
+	}
+
 	/**
 	 * Init new Arrays which havent been serialized along the object
 	 * 

+ 64 - 13
src/ui/controller/SaveController.java

@@ -60,7 +60,7 @@ public class SaveController {
 	}
 
 	public enum NUMTYPE {
-		CATEGORY, OBJECT, ELEMENT, EDGE, CONNECTION, NODEEDGE, OLDEDGE, UNITGRAPH, IMAGE
+		CATEGORY, OBJECT, ELEMENT, EDGE, CONNECTION, NODEEDGE, OLDEDGE, UNITGRAPH, STATSGRAPH
 	}
 
 	public enum GRAPHTYPE {
@@ -69,7 +69,7 @@ public class SaveController {
 
 	private Model model;
 	private Gson gson;
-	private int nCat, nObj, nEle, nEdge, nConn, nNodeEdge, nOldEdge, nUnitGraph, nImg;
+	private int nCat, nObj, nEle, nEdge, nConn, nNodeEdge, nOldEdge, nUnitGraph, nStatsGraph;
 
 	/**
 	 * Constructor.
@@ -108,6 +108,7 @@ public class SaveController {
 		initialize(MODE.COMPLETE, file);
 		storeCategory(file);
 		storeCanvas(file);
+		storeStatistics(file);
 		storeData(stream);
 
 		FileWriter writer = new FileWriter(holonFile);
@@ -177,19 +178,24 @@ public class SaveController {
 		switch (mode) {
 		case COMPLETE:
 			file.add("MODE", new JsonPrimitive(mode.name()));
+			file.add("IDCOUNTER", new JsonPrimitive(IdCounter.getCounter()));
+			file.add("IDCOUNTERELEMENT", new JsonPrimitive(IdCounterElem.getCounter()));
+			file.add("CANVAS_SIZE_X", new JsonPrimitive(model.getCanvasX()));
+			file.add("CANVAS_SIZE_Y", new JsonPrimitive(model.getCanvasY()));
 			break;
 		case PARTIAL:
 			file.add("MODE", new JsonPrimitive(mode.name()));
+			file.add("IDCOUNTER", new JsonPrimitive(IdCounter.getCounter()));
+			file.add("IDCOUNTERELEMENT", new JsonPrimitive(IdCounterElem.getCounter()));
+			file.add("CANVAS_SIZE_X", new JsonPrimitive(model.getCanvasX()));
+			file.add("CANVAS_SIZE_Y", new JsonPrimitive(model.getCanvasY()));
 			break;
 		case CATEGORY:
 			file.add("MODE", new JsonPrimitive(mode.name()));
 		default:
 			break;
 		}
-		file.add("IDCOUNTER", new JsonPrimitive(IdCounter.getCounter()));
-		file.add("IDCOUNTERELEMENT", new JsonPrimitive(IdCounterElem.getCounter()));
-		file.add("CANVAS_SIZE_X", new JsonPrimitive(model.getCanvasX()));
-		file.add("CANVAS_SIZE_Y", new JsonPrimitive(model.getCanvasY()));
+
 	}
 
 	/**
@@ -260,7 +266,8 @@ public class SaveController {
 	}
 
 	private void storeStatistics(JsonObject file) {
-
+		trackedToJson(file);
+		statisticgraphToJson(file);
 	}
 
 	/**
@@ -394,6 +401,25 @@ public class SaveController {
 
 	}
 
+	private void trackedToJson(JsonObject file) {
+		// TODO Auto-generated method stub
+		JsonObject temp = new JsonObject();
+		String key = "TRACKED";
+		// forall points add them
+		for (int i = 0; i < model.getTrackingObj().size(); i++) {
+			temp.add("" + i, new JsonPrimitive(model.getTrackingObj().get(i).getId()));
+		}
+
+		file.add(key, gson.toJsonTree(temp));
+	}
+
+	private void statisticgraphToJson(JsonObject file) {
+		// TODO Auto-generated method stub
+		JsonObject temp = new JsonObject();
+		String key = null;
+
+	}
+
 	/**
 	 * Differs Between Single file or whole Directory to Store
 	 * 
@@ -427,9 +453,8 @@ public class SaveController {
 	 */
 	private void addFileToSave(File src, ArchiveOutputStream stream, boolean dir) throws IOException {
 		String entryName = (dir == true ? src.getCanonicalPath() : src.getName());
-		String partition = entryName.substring(0, entryName.indexOf(":"));
-		entryName = entryName.replace(partition, "");
-		entryName = entryName.replace(System.getProperty("user.home") + "/HolonGUI/", "");
+
+		entryName = checkOS(entryName);
 
 		ZipArchiveEntry entry = new ZipArchiveEntry(entryName);
 		stream.putArchiveEntry(entry);
@@ -440,6 +465,31 @@ public class SaveController {
 		stream.closeArchiveEntry();
 	}
 
+	private String checkOS(String entryName) {
+		// TODO Auto-generated method stub
+		String os = System.getProperty("os.name").toLowerCase();
+		String ret = entryName;
+		String partition = null;
+
+		if (os.contains("windows")) {
+			partition = ret.substring(0, ret.indexOf(":") + 1);
+			ret = ret.replace(System.getProperty("user.home") + "\\HolonGUI\\", "");
+			ret = ret.replace(partition, "");
+		}
+		if (os.contains("mac")) {
+			// dosmth
+			ret = ret.replace(System.getProperty("user.home") + "/HolonGUI/", "");
+		}
+		if (os.contains("linux")) {
+			// dosmth
+			ret = ret.replace(System.getProperty("user.home") + "/HolonGUI/", "");
+		}
+		if (os.contains("solaris")) {
+			// dosmth
+		}
+		return ret;
+	}
+
 	/**
 	 * Initialize the Gson with wanted parameters
 	 */
@@ -458,7 +508,7 @@ public class SaveController {
 	 * Just initialize the Numerators for the Json Keys. Maybe bad Style..
 	 */
 	public void initNumeration() {
-		this.nCat = this.nObj = this.nEle = this.nEdge = this.nConn = this.nNodeEdge = this.nOldEdge = this.nImg = 0;
+		this.nCat = this.nObj = this.nEle = this.nEdge = this.nConn = this.nNodeEdge = this.nOldEdge = this.nStatsGraph = 0;
 	}
 
 	/**
@@ -486,8 +536,9 @@ public class SaveController {
 			return nOldEdge++;
 		case UNITGRAPH:
 			return nUnitGraph++;
-		case IMAGE:
-			return nImg++;
+		case STATSGRAPH:
+			return nStatsGraph++;
+
 		default:
 			break;
 		}

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

@@ -70,6 +70,8 @@ public class Model {
 	private int autoSaveNr = -1;
 	// number of max simultaneous autosaves
 	private int numberOfSaves = 35;
+	// if the simulation is running and has not been reseted
+	private boolean isSimRunning = false;
 	/*
 	 * Array of all categories in the model. It is set by default with the
 	 * categories ENERGY, BUILDINGS and COMPONENTS
@@ -872,9 +874,25 @@ public class Model {
 	}
 	
 	/**
-	 * Returns the graphtable for Statistic Graphs
+	 * Returns the graphtable for Statistic Graphs.
 	 */
 	public Hashtable<String, StatisticGraphPanel> getGraphTable(){
 		return statisticGraphTable;
 	}
+	
+	/**
+	 * Returns if the Simulation is running.
+	 */
+	public boolean getIsSimRunning(){
+		return isSimRunning;
+	}
+
+	/**
+	 * Sets isSimRunning.
+	 * @param isRunning
+	 */
+	public void setIsSimRunning(boolean isRunning) {
+		isSimRunning = isRunning;
+	}
 }
+

+ 4 - 61
src/ui/view/SimulationMenu.java → src/ui/view/AlgorithmMenu.java

@@ -1,8 +1,5 @@
 package ui.view;
 
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.BufferedReader;
@@ -16,7 +13,6 @@ import javax.swing.JButton;
 import javax.swing.JComboBox;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
-import javax.swing.JMenuBar;
 import javax.swing.JPanel;
 import javax.tools.JavaCompiler;
 import javax.tools.ToolProvider;
@@ -30,13 +26,10 @@ import ui.model.Model;
  * 
  * @author Gruppe14
  */
-public class SimulationMenu extends JMenuBar {
+public class AlgorithmMenu extends JPanel {
 
 	private static final long serialVersionUID = 1L;
 
-	private JPanel menuPanel = new JPanel();
-	//JLabel simSpeedLabel = new JLabel(Languages.getLanguage()[84]);
-	//private JTextField simSpeedText = new JTextField("1000");
 	private JComboBox<Object> algoCombo = new JComboBox<>();
 	JButton algoFolderButton = new JButton(Languages.getLanguage()[85]);
 	private HashMap<String, File> algosHash = new HashMap<>();
@@ -55,14 +48,12 @@ public class SimulationMenu extends JMenuBar {
 	 * @param cont
 	 *            the Controller
 	 */
-	public SimulationMenu(Model mod, Control cont) {
+	public AlgorithmMenu(Model mod, Control cont) {
 		super();
 		// Init Stuff
 		this.model = mod;
 		this.controller = cont;
 		
-		//simSpeedLabel.setMaximumSize(simSpeedLabel.getPreferredSize());
-		//simSpeedLabel.setMinimumSize(simSpeedLabel.getPreferredSize());
 		algoCombo.addItem("None");
 
 		// Algorithm ComboBox Action
@@ -119,57 +110,9 @@ public class SimulationMenu extends JMenuBar {
 		});
 
 		// Add to Panel
-		GridBagLayout gblmenuPanel = new GridBagLayout();
-		gblmenuPanel.columnWidths = new int[] { 79, 105, 34, 60, 31, 151, 0 };
-		gblmenuPanel.rowHeights = new int[] { 25, 0 };
-		gblmenuPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
-		gblmenuPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
-		menuPanel.setLayout(gblmenuPanel);
-
-		GridBagConstraints gbcsimSpeedLabel = new GridBagConstraints();
-		gbcsimSpeedLabel.anchor = GridBagConstraints.WEST;
-		gbcsimSpeedLabel.insets = new Insets(0, 0, 0, 5);
-		gbcsimSpeedLabel.gridx = 1;
-		gbcsimSpeedLabel.gridy = 0;
-		//menuPanel.add(simSpeedLabel, gbcsimSpeedLabel);
-
-		// timerSpeed
-		/*simSpeedText.setMaximumSize(new Dimension(300, 300));
-		// simSpeedText.setMinimumSize(new Dimension(300, 300));
-		simSpeedText.addCaretListener(new CaretListener() {
-			@Override
-			public void caretUpdate(CaretEvent e) {
-				try {
-					controller.setTimerSpeed(Integer.parseInt(simSpeedText.getText()));
-				} catch (Exception ex) {
-					// TODO: handle exception
-				}
+		this.add(algoFolderButton);
 
-			}
-		});*/
-		GridBagConstraints gbcSimSpeedText = new GridBagConstraints();
-		gbcSimSpeedText.anchor = GridBagConstraints.WEST;
-		gbcSimSpeedText.insets = new Insets(0, 0, 0, 5);
-		gbcSimSpeedText.gridx = 2;
-		gbcSimSpeedText.gridy = 0;
-		//menuPanel.add(simSpeedText, gbcSimSpeedText);
-		GridBagConstraints gbcAlgoFolderButton = new GridBagConstraints();
-		gbcAlgoFolderButton.anchor = GridBagConstraints.WEST;
-		gbcAlgoFolderButton.insets = new Insets(0, 0, 0, 5);
-		gbcAlgoFolderButton.gridx = 3;
-		gbcAlgoFolderButton.gridy = 0;
-		menuPanel.add(algoFolderButton, gbcAlgoFolderButton);
-
-		GridBagConstraints gbcAlgoCombo = new GridBagConstraints();
-		gbcAlgoCombo.anchor = GridBagConstraints.WEST;
-		gbcAlgoCombo.insets = new Insets(0, 0, 0, 5);
-		gbcAlgoCombo.gridx = 4;
-		gbcAlgoCombo.gridy = 0;
-		menuPanel.add(algoCombo, gbcAlgoCombo);
-		// algoCombo.addItem(Languages.getLanguage()[86]);
-
-		// Add Panel to SimulationMenu
-		this.add(menuPanel);
+		this.add(algoCombo);
 	}
 
 	public void setAlgorithm(File file, String name) {

+ 113 - 82
src/ui/view/GUI.java

@@ -98,7 +98,7 @@ public class GUI<E> implements CategoryListener {
 
 	private JFrame frmCyberPhysical;
 
-	private final SimulationMenu simMenu;
+	private final AlgorithmMenu simMenu;
 
 	private JTabbedPane tabTemp; // tabbedPane or tabbedPane2
 	private final JMenuBar menuBar = new JMenuBar();
@@ -107,12 +107,14 @@ 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 final JMenuItem mntmOpen = new JMenuItem("Open");
 	private final JMenuItem mntmNew = new JMenuItem("New");
 	private final JMenuItem mntmSave = new JMenuItem("Save");
-	private final JMenuItem aboutUs = new JMenuItem("About Us");
-	private final JMenuItem canvasSize = new JMenuItem("View Size");
-	private final JMenuItem background = new JMenuItem("Background Image");
+	private final JMenuItem mntmAboutUs = new JMenuItem("About Us");
+	private final JMenuItem mntmCanvasSize = new JMenuItem("View Size");
+	private final JMenuItem mntmBackground = new JMenuItem("Background Image");
+	private final JMenuItem mntmSplitView = new JMenuItem("Split View");
 	private final JSplitPane splitPane = new JSplitPane();
 	private final JSplitPane splitPane1 = new JSplitPane();
 	private final JSplitPane splitPaneCanvasConsole = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
@@ -122,16 +124,12 @@ public class GUI<E> implements CategoryListener {
 	// private final JScrollPane holonSP = new JScrollPane();
 	private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
 	private final JTabbedPane tabbedPane2 = new JTabbedPane(JTabbedPane.TOP);
-	private final JButton splitButton = new JButton("Split View Test");
 	private JSplitPane tempSplit;
 	private boolean initSplit = true;
 
-	private final JPanel panelTapped_SimMenu = new JPanel();
 	private JPopupMenu popmenuEdit = new JPopupMenu();
 	private JMenuItem editItem = new JMenuItem("Edit Object");
 	private String catOfObjToBeEdited;
-	private final JScrollPane statTab = new JScrollPane();
-
 	private FlexiblePane flexPane;
 	private StatPanel2 statSplitPane;
 	private JScrollPane statScrollPane;
@@ -301,7 +299,7 @@ public class GUI<E> implements CategoryListener {
 		control.initListener(this);
 		controller.setCanvas(canvas);
 		model.setConsole(console);
-		simMenu = new SimulationMenu(model, control);
+		simMenu = new AlgorithmMenu(model, control);
 		initialize();
 		updateCategories(model.getCategories());
 		updCon = new UpdateController(model, controller);
@@ -416,22 +414,41 @@ public class GUI<E> implements CategoryListener {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
+				if (tabbedPane.getMousePosition() != null) {
+					tabTemp = tabbedPane;
+				} else {
+					tabTemp = tabbedPane2;
+				}
 				// Uppernode Canvas?
-				if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
+				if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
 						.getComponent(0) instanceof UpperNodeCanvas) {
-					UpperNodeCanvas uNC = (UpperNodeCanvas) ((JScrollPane) tabbedPane.getSelectedComponent())
-							.getViewport().getComponent(0);
+					UpperNodeCanvas uNC = (UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
+							.getComponent(0);
 					for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
 						if (uNC.upperNode.getNodes().contains(cps)) {
 							controller.delObjUpperNode(cps, uNC.upperNode);
 							// Remove UpperNodeTab if UpperNode deleted
 							if (cps instanceof CpsUpperNode) {
+								boolean splitView = false;
 								for (int i = 4; i < tabbedPane.getTabCount(); i++) {
-									if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
-											.getComponent(0)).upperNode.getId() == cps.getId()) {
-										tabbedPane.remove(i);
-										i = tabbedPane.getTabCount();
+									if (tabbedPane.getComponentAt(i) == null) {
+										splitView = true;
+									} else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i))
+											.getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
+										((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
+										break;
+									}
+								}
+								// If SplitView is on and the view on
+								// tabbedPane2 is the deleted upperNode
+								try {
+									if (splitView
+											&& ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
+													.getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
+										((ButtonTabComponent) tabbedPane
+												.getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
 									}
+								} catch (Exception e2) {
 								}
 							}
 						}
@@ -439,7 +456,7 @@ public class GUI<E> implements CategoryListener {
 					uNC.repaint();
 
 					// or Canvas?
-				} else if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
+				} else if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
 						.getComponent(0) instanceof MyCanvas) {
 					boolean save = false;
 					for (int j = 0; j < model.getSelectedCpsObjects().size(); j++) {
@@ -449,13 +466,26 @@ public class GUI<E> implements CategoryListener {
 						controller.delCanvasObject(cps, save);
 						// Remove UpperNodeTab if UpperNode deleted
 						if (cps instanceof CpsUpperNode) {
+							boolean splitView = false;
 							for (int i = 4; i < tabbedPane.getTabCount(); i++) {
-								if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
+								if (tabbedPane.getComponentAt(i) == null) {
+									splitView = true;
+								} else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
 										.getComponent(0)).upperNode.getId() == cps.getId()) {
-									tabbedPane.remove(i);
-									i = tabbedPane.getTabCount();
+									((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
+									break;
 								}
 							}
+							// If SplitView is on and the view on
+							// tabbedPane2 is the deleted upperNode
+							try {
+								if (splitView && ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
+										.getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
+									((ButtonTabComponent) tabbedPane.getTabComponentAt(tabbedPane2.getSelectedIndex()))
+											.removeTabs();
+								}
+							} catch (Exception e2) {
+							}
 						}
 					}
 					canvas.repaint();
@@ -670,8 +700,8 @@ public class GUI<E> implements CategoryListener {
 
 		menuBar.add(mnNewMenuView);
 
-		mnNewMenuView.add(canvasSize);
-		canvasSize.addActionListener(new ActionListener() {
+		mnNewMenuView.add(mntmCanvasSize);
+		mntmCanvasSize.addActionListener(new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				JPanel myPanel = new JPanel();
@@ -712,10 +742,53 @@ public class GUI<E> implements CategoryListener {
 			}
 		});
 
-		mnNewMenuView.add(canvasSize);
+		mnNewMenuView.add(mntmCanvasSize);
+		mnNewMenuView.add(mntmSplitView);
+		
+		// Split View
+				mntmSplitView.addActionListener(new ActionListener() {
+					@Override
+					public void actionPerformed(ActionEvent e) {
+						if (splitPaneCanvasConsole.getLeftComponent() instanceof JSplitPane) {
+							initSplit = true;
+							Component tempC = tabbedPane2.getSelectedComponent();
+							tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
+							tabbedPane2.removeAll();
+							splitPaneCanvasConsole.setLeftComponent(tabbedPane);
+						} else {
+							for (int i = 0; i < tabbedPane.getTabCount(); i++) {
+								tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
+								if (i >= 4) {
+									// tabbedPane2.setTabComponentAt(tabbedPane.getTabCount()
+									// - 1,
+									// new ButtonTabComponent(tabbedPane, tabbedPane2));
+								}
+							}
+							if (tabbedPane.getSelectedComponent() == statScrollPane) {
+								tabbedPane.setComponentAt(0, null);
+								tabbedPane2.setComponentAt(0, canvasSP);
+								tabbedPane2.setSelectedIndex(0);
+							} else {
+								tabbedPane.setComponentAt(1, null);
+								tabbedPane2.setComponentAt(1, statScrollPane);
+								tabbedPane2.setSelectedIndex(1);
+							}
+							tempSplit = new JSplitPane();
+							tempSplit.setBorder(null);
+							tempSplit.setRightComponent(tabbedPane2);
+							tempSplit.setLeftComponent(tabbedPane);
+							tempSplit.setDividerLocation(tabbedPane.getWidth() / 2);
+							tempSplit.setResizeWeight(0.9);
+							splitPaneCanvasConsole.setLeftComponent(tempSplit);
+							initSplit = false;
+						}
+						contentPane.updateUI();
+					}
 
-		mnNewMenuView.add(background);
-		background.addActionListener(new ActionListener() {
+				});
+		mnNewMenuView.add(mntmBackground);
+		
+		mntmBackground.addActionListener(new ActionListener() {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
@@ -759,57 +832,15 @@ public class GUI<E> implements CategoryListener {
 
 		splitPane_1.setLeftComponent(lblHolonBodySize);
 
-		menuBar.add(mnHelp);
+		mnAlgorithm.add(simMenu);
 
-		mnHelp.add(aboutUs);
+		menuBar.add(mnAlgorithm);
 
-		// Testing
-		menuBar.add(splitButton);
-		// Split View
-		splitButton.addActionListener(new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				if (panelTapped_SimMenu
-						.getComponent(panelTapped_SimMenu.getComponentCount() - 1) instanceof JSplitPane) {
-					initSplit = true;
-					Component tempC = tabbedPane2.getSelectedComponent();
-					tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
-					tabbedPane2.removeAll();
-					panelTapped_SimMenu
-							.remove(panelTapped_SimMenu.getComponent(panelTapped_SimMenu.getComponentCount() - 1));
-					panelTapped_SimMenu.add(tabbedPane);
-				} else {
-					for (int i = 0; i < tabbedPane.getTabCount(); i++) {
-						tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
-						if (i >= 4) {
-							// tabbedPane2.setTabComponentAt(tabbedPane.getTabCount()
-							// - 1,
-							// new ButtonTabComponent(tabbedPane, tabbedPane2));
-						}
-					}
-					if (tabbedPane.getSelectedComponent() == statScrollPane) {
-						tabbedPane.setComponentAt(0, null);
-						tabbedPane2.setComponentAt(0, canvasSP);
-						tabbedPane2.setSelectedIndex(0);
-					} else {
-						tabbedPane.setComponentAt(1, null);
-						tabbedPane2.setComponentAt(1, statScrollPane);
-						tabbedPane2.setSelectedIndex(1);
-					}
-					tempSplit = new JSplitPane();
-					tempSplit.setBorder(null);
-					tempSplit.setRightComponent(tabbedPane2);
-					tempSplit.setLeftComponent(tabbedPane);
-					tempSplit.setDividerLocation(tabbedPane.getWidth() / 2);
-					tempSplit.setResizeWeight(0.9);
-					panelTapped_SimMenu.remove(tabbedPane);
-					panelTapped_SimMenu.add(tempSplit);
-					initSplit = false;
-				}
-				contentPane.updateUI();
-			}
+		menuBar.add(mnHelp);
 
-		});
+		mnHelp.add(mntmAboutUs);
+
+		
 
 		tabbedPane.addChangeListener(new ChangeListener() {
 
@@ -1502,7 +1533,7 @@ public class GUI<E> implements CategoryListener {
 		 * Pop up - About Us with some important information about the
 		 * developers, source and programming stuff
 		 */
-		aboutUs.addMouseListener(new MouseAdapter() {
+		mntmAboutUs.addMouseListener(new MouseAdapter() {
 			@Override
 			public void mousePressed(MouseEvent e) {
 				aboutUsPopUp = new AboutUsPopUp();
@@ -1560,6 +1591,7 @@ public class GUI<E> implements CategoryListener {
 				} else if (model.getSelectedCpsObjects().size() == 1) {
 					model.getTableHolonElement().setModel(model.getSingleTable());
 				}
+
 			}
 		});
 
@@ -1851,7 +1883,9 @@ public class GUI<E> implements CategoryListener {
 				controller.runAlgorithm(model, controller);
 				controller.calculateStateForTimeStep(i);
 				unitGraph.repaint();
-				statSplitPane.repaintGraphs();
+				if (model.getIsSimRunning()) {
+					statSplitPane.repaintGraphs();
+				}
 				contentPane.updateUI();
 			}
 		});
@@ -1863,7 +1897,7 @@ public class GUI<E> implements CategoryListener {
 		splitPaneCanvasConsole.setResizeWeight(0.9);
 
 		splitPane.setLeftComponent(scrollPane1);
-		splitPaneCanvasConsole.setLeftComponent(panelTapped_SimMenu);
+		splitPaneCanvasConsole.setLeftComponent(tabbedPane);
 		tabbedPane.addTab("View", canvasSP);
 		tabbedPane.addTab("Statistics", statScrollPane);
 		tabbedPane.addTab("Holon", holonCanvas);
@@ -1885,12 +1919,8 @@ public class GUI<E> implements CategoryListener {
 		splitGraphHolonEl.setBottomComponent(scrollElements);
 		canvasSP.setViewportView(canvas);
 		// holonSP.setViewportView(holonCanvas);
-		panelTapped_SimMenu.setLayout(new BorderLayout());
-		panelTapped_SimMenu.add(simMenu, BorderLayout.NORTH);
-		panelTapped_SimMenu.add(tabbedPane);
 		simMenu.setBackground(new Color(240, 240, 240));
 
-		panelTapped_SimMenu.setBorder(null);
 		tabbedPane.setBorder(null);
 		scrollProperties.setBorder(null);
 		scrollGraph.setBorder(null);
@@ -2092,9 +2122,9 @@ public class GUI<E> implements CategoryListener {
 		mnNewMenuOptions.setText(tempArray[9]);
 		mntmResetCategory.setText(tempArray[10]);
 		mnNewMenuView.setText(tempArray[11]);
-		canvasSize.setText(tempArray[12]);
+		mntmCanvasSize.setText(tempArray[12]);
 		mnHelp.setText(tempArray[13]);
-		aboutUs.setText(tempArray[14]);
+		mntmAboutUs.setText(tempArray[14]);
 		mntmEditEdges.setText(tempArray[15]);
 		mnLanguage.setText(tempArray[16]);
 		canvas.updateLanguages();
@@ -2221,6 +2251,7 @@ public class GUI<E> implements CategoryListener {
 
 			JScrollPane sp = new JScrollPane(unc);
 			sp.setBorder(null);
+			// Selected tabbed Pane = tabbedPane or tabbedPane2
 			if (tabTemp == tabbedPane) {
 				tabbedPane.add(temp.getName(), sp);
 				tabbedPane.setSelectedComponent(sp);

+ 34 - 6
src/ui/view/MyCanvas.java

@@ -27,6 +27,7 @@ import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
 
 import com.google.gson.JsonParseException;
@@ -343,16 +344,40 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 					controller.removeTrackingObj(cps);
 					// Remove UpperNodeTab if UpperNode deleted
 					if (cps instanceof CpsUpperNode) {
-						JTabbedPane tabbedPane = (JTabbedPane) getParent().getParent().getParent();
+						boolean splitView = false;
+						JSplitPane tempSplit = (JSplitPane) getParent().getParent().getParent().getParent();
+						JTabbedPane tabbedPane;
+						JTabbedPane tabbedPane2;
+						// if SplitView is activated
+						if (tempSplit.getLeftComponent() instanceof JTabbedPane
+								&& tempSplit.getRightComponent() instanceof JTabbedPane) {
+							splitView = true;
+							tabbedPane = (JTabbedPane) tempSplit.getLeftComponent();
+							tabbedPane2 = (JTabbedPane) tempSplit.getRightComponent();
+						} else {
+							tabbedPane = (JTabbedPane) tempSplit.getLeftComponent();
+							tabbedPane2 = null;
+						}
+						//Look if the uppernode is open in a Tab
 						for (int i = 4; i < tabbedPane.getTabCount(); i++) {
-							if (tabbedPane.getComponentAt(i) != null
-									&& ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
-											.getComponent(0)).upperNode.getId() == cps.getId()) {
-
+							if (tabbedPane.getComponentAt(i) == null) {
+							} else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
+									.getComponent(0)).upperNode.getId() == cps.getId()) {
 								((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
 								break;
 							}
 						}
+						// If SplitView is on and the view on
+						// tabbedPane2 is the deleted upperNode
+						try {
+							if (tabbedPane2 != null
+									&& ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
+											.getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
+								((ButtonTabComponent) tabbedPane
+										.getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
+							}
+						} catch (Exception e2) {
+						}
 					}
 					toolTip = false;
 				}
@@ -819,6 +844,9 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 
 		controller.calculateStateForTimeStep(model.getCurIteration());
 
+		updCon.refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
+		updCon.refreshTableProperties(model.getPropertyTable());
+
 		repaint();
 
 	}
@@ -1113,7 +1141,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	 *            boolean for conecction
 	 * @param object
 	 *            boolean for objects
-	 * @param nodeOfnode 
+	 * @param nodeOfnode
 	 */
 	public void setShowedInformation(boolean connection, boolean object, boolean border, boolean nodeOfnode) {
 		showedInformation[0] = connection;

+ 70 - 58
src/ui/view/StatisticGraph.java

@@ -83,60 +83,54 @@ public class StatisticGraph extends JPanel {
 			g2.drawLine(0, i, this.getWidth(), i);
 		}
 
-		isSimRunning = true;
-
-		// if sim is on
-		if (isSimRunning) {
-			g2.setStroke(new BasicStroke(3));
-
-			// Calculate the Maximum
-			// calcMaximum();
-
-			// Calculate values for each set and add them
-			// addValues();
-
-			// Create Paths and draw them
-			for (TrackedDataSet set : dataSets) {
-				path.reset();
-				switch (set.getProperty()) {
-				case TrackedDataSet.CONSUMPTION:
-				case TrackedDataSet.PRODUCTION:
-				case TrackedDataSet.ACTIVATED_ELEMENTS:
-				case TrackedDataSet.TOTAL_PRODUCTION:
-				case TrackedDataSet.TOTAL_CONSUMPTION:
-				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:
-				case TrackedDataSet.AVG_AMOUNT_PRODUCERS_IN_HOLONS:
-				case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
-				case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
-				case TrackedDataSet.AMOUNT_BROKEN_EDGES:
-				case TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS:
-				case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
-				case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
-				case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
-					createPathFloats(set);
-					break;
-				case TrackedDataSet.ON_OFF:
-					createPathBooleans(set);
-					break;
-				case TrackedDataSet.PERCENT_SUPPLIED:
-				case TrackedDataSet.PERCENT_NOT_SUPPLIED:
-				case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
-				case TrackedDataSet.RATIO_PRODUCERS_CONSUMERS:
-					createPathPercent(set);
-					break;
-				default:
-					break;
-				}
-				g2.setColor(set.getColor());
-				g2.draw(path);
+		g2.setStroke(new BasicStroke(3));
+
+		// Calculate the Maximum
+		// calcMaximum();
+
+		// Calculate values for each set and add them
+		// addValues();
+
+		// Create Paths and draw them
+		for (TrackedDataSet set : dataSets) {
+			path.reset();
+			switch (set.getProperty()) {
+			case TrackedDataSet.CONSUMPTION:
+			case TrackedDataSet.PRODUCTION:
+			case TrackedDataSet.ACTIVATED_ELEMENTS:
+			case TrackedDataSet.TOTAL_PRODUCTION:
+			case TrackedDataSet.TOTAL_CONSUMPTION:
+			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:
+			case TrackedDataSet.AVG_AMOUNT_PRODUCERS_IN_HOLONS:
+			case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
+			case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
+			case TrackedDataSet.AMOUNT_BROKEN_EDGES:
+			case TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS:
+			case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
+			case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
+			case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
+				createPathFloats(set);
+				break;
+			case TrackedDataSet.ON_OFF:
+				createPathBooleans(set);
+				break;
+			case TrackedDataSet.PERCENT_SUPPLIED:
+			case TrackedDataSet.PERCENT_NOT_SUPPLIED:
+			case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
+			case TrackedDataSet.RATIO_PRODUCERS_CONSUMERS:
+				createPathPercent(set);
+				break;
+			default:
+				break;
 			}
+			g2.setColor(set.getColor());
+			g2.draw(path);
 		}
-
 	}
 
 	/**
@@ -335,16 +329,16 @@ public class StatisticGraph extends JPanel {
 			switch (set.getProperty()) {
 			case TrackedDataSet.CONSUMPTION:
 				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
-					if (h.getEnergy() < 0 && h.getActive()) {
-						val += Math.abs(h.getEnergyAt()[model.getCurIteration()]) * h.getAmount();
+					if (h.getTotalEnergyAtTimeStep(model.getCurIteration()) < 0 && h.getActive()) {
+						val += Math.abs(h.getTotalEnergyAtTimeStep(model.getCurIteration()));
 					}
 					set.setValAt(val, model.getCurIteration());
 				}
 				break;
 			case TrackedDataSet.PRODUCTION:
 				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
-					if (h.getEnergy() > 0 && h.getActive()) {
-						val += Math.abs(h.getEnergyAt()[model.getCurIteration()]) * h.getAmount();
+					if (h.getTotalEnergyAtTimeStep(model.getCurIteration()) > 0 && h.getActive()) {
+						val += Math.abs(h.getTotalEnergyAtTimeStep(model.getCurIteration()));
 					}
 					set.setValAt(val, model.getCurIteration());
 				}
@@ -537,17 +531,21 @@ public class StatisticGraph extends JPanel {
 	 * @param set
 	 */
 	private void createPathFloats(TrackedDataSet set) {
+		int range = model.getCurIteration(); //to which iteration
+		if (!model.getIsSimRunning()) {
+			range = model.getIterations()-1;
+		}
 		if (set.getValues()[0] != -1) {
 			path.moveTo(0, convertToCanvasY(set.getValues()[0]));
 		} else {
 			path.moveTo(1 * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1]));
 		}
-		for (int i = 0; i < model.getCurIteration(); i++) {
+		for (int i = 0; i < range; i++) {
 			if (set.getValues()[i + 1] != -1) {
 				path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
 						convertToCanvasY(set.getValues()[i + 1]));
 			} else {
-				if (i + 2 < model.getCurIteration()) {
+				if (i + 2 < range) {
 					path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
 							convertToCanvasY(set.getValues()[i + 2]));
 				}
@@ -714,8 +712,22 @@ public class StatisticGraph extends JPanel {
 		return stateObjectss / count;
 	}
 
+	/**
+	 * Return all TrackedDataSets
+	 * 
+	 * @return ArrayList of TrackedDataSet
+	 */
 	public ArrayList<TrackedDataSet> getDataSets() {
 		return dataSets;
 	}
 
+	/**
+	 * Reset the Graph. Delete all calculated values.
+	 */
+	public void resetGraph() {
+		for (TrackedDataSet s : dataSets) {
+			s.resetValues();
+		}
+	}
+
 }

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

@@ -296,5 +296,11 @@ public class StatisticGraphPanel extends JPanel {
 	public void setStatisticGraph(StatisticGraph sG){
 		this.sGraph = sG;
 	}
+	/**
+	 *	Reset the Graph. Delete all calculated values.
+	 */
+	public void resetGraph(){
+		sGraph.resetGraph();
+	}
 	
 }

+ 15 - 3
src/ui/view/TimePanel.java

@@ -128,6 +128,9 @@ public class TimePanel extends JPanel {
 			@Override
 			public void mousePressed(MouseEvent e) {
 				controller.resetSimulation();
+				if (running) {
+					playBtn.doClick();
+				}
 			}
 		});
 
@@ -135,6 +138,9 @@ public class TimePanel extends JPanel {
 			@Override
 			public void mouseDragged(MouseEvent e) {
 				controller.resetSimulation();
+				if (running) {
+					playBtn.doClick();
+				}
 			}
 		});
 
@@ -155,6 +161,9 @@ public class TimePanel extends JPanel {
 			public void actionPerformed(ActionEvent e) {
 				running = !running;
 				if (running) {
+					if (!model.getIsSimRunning()) {
+						controller.setIsSimRunning(true);
+					}
 					timer.start();
 					timer.setDelay(model.getTimerSpeed());
 					playBtn.setIcon(new ImageIcon(new ImageIcon(this.getClass().getResource("/Button_Images/pause.png"))
@@ -178,6 +187,9 @@ public class TimePanel extends JPanel {
 				controller.setCurIteration(timeSlider.getValue());
 				// controller.calculateStateForCurrentTimeStep();
 				controller.resetSimulation();
+				if (running) {
+					playBtn.doClick();
+				}
 			}
 		});
 		timeForwardBtn.setToolTipText(Languages.getLanguage()[91]);
@@ -222,17 +234,17 @@ public class TimePanel extends JPanel {
 		speedSlider.setMaximum(5000);
 		speedSlider.setMinimum(500);
 		speedSlider.setValue(1000);
-		//speedSlider.setMajorTickSpacing(100);
+		// speedSlider.setMajorTickSpacing(100);
 		speedSlider.addChangeListener(new ChangeListener() {
 			@Override
 			public void stateChanged(ChangeEvent e) {
 				controller.setTimerSpeed(speedSlider.getValue());
-				speedSlider.setToolTipText("Speed: "+speedSlider.getValue());
+				speedSlider.setToolTipText("Speed: " + speedSlider.getValue());
 			}
 		});
 
 		// Buttons and Speed Panel
-		btnAndSpeedPanel.setLayout(new BorderLayout(0,0));
+		btnAndSpeedPanel.setLayout(new BorderLayout(0, 0));
 		btnAndSpeedPanel.setBorder(null);
 		btnAndSpeedPanel.add(timeBtnPanel, BorderLayout.NORTH);
 		btnAndSpeedPanel.add(speedPanel, BorderLayout.CENTER);

+ 47 - 8
src/ui/view/UpperNodeCanvas.java

@@ -27,6 +27,7 @@ import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
 
 import com.google.gson.JsonParseException;
@@ -358,14 +359,41 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 						controller.removeTrackingObj(cps);
 						// Remove UpperNodeTab if UpperNode deleted
 						if (cps instanceof CpsUpperNode) {
-							JTabbedPane tabbedPane = (JTabbedPane) getParent().getParent().getParent();
+							boolean splitView = false;
+							JSplitPane tempSplit = (JSplitPane) getParent().getParent().getParent().getParent();
+							JTabbedPane tabbedPane;
+							JTabbedPane tabbedPane2;
+							// if SplitView is activated
+							if (tempSplit.getLeftComponent() instanceof JTabbedPane
+									&& tempSplit.getRightComponent() instanceof JTabbedPane) {
+								splitView = true;
+								tabbedPane = (JTabbedPane) tempSplit.getLeftComponent();
+								tabbedPane2 = (JTabbedPane) tempSplit.getRightComponent();
+							} else {
+								tabbedPane = (JTabbedPane) tempSplit.getLeftComponent();
+								tabbedPane2 = null;
+							}
+							//Look if the uppernode is open in a Tab
 							for (int i = 4; i < tabbedPane.getTabCount(); i++) {
-								if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
+								if (tabbedPane.getComponentAt(i) == null) {
+								} else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
 										.getComponent(0)).upperNode.getId() == cps.getId()) {
-									tabbedPane.remove(i);
-									i = tabbedPane.getTabCount();
+									((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
+									break;
 								}
 							}
+							// If SplitView is on and the view on
+							// tabbedPane2 is the deleted upperNode
+							try {
+								if (tabbedPane2 != null
+										&& ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
+												.getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
+									((ButtonTabComponent) tabbedPane
+											.getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
+								}
+							} catch (Exception e2) {
+							}
+
 						}
 					}
 				}
@@ -676,10 +704,21 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 						obj = ed.getB();
 					}
 					if (obj != null) {
-						if (ed.getFlow() == 0)
-							g2.setColor(Color.RED);
-						else
-							g2.setColor(Color.BLUE);
+						if (ed.getConnected() == 0) {
+							if (ed.getState()) {
+								g2.setColor(Color.GREEN);
+								if (ed.getCapacity() != -1) {
+									g2.setStroke(
+											new BasicStroke(Math.min(((ed.getFlow() / ed.getCapacity() * 3) + 1), 4)));
+								}
+							} else {
+								g2.setColor(Color.RED);
+								g2.setStroke(new BasicStroke(2));
+							}
+						} else {
+							g2.setColor(Color.DARK_GRAY);
+							g2.setStroke(new BasicStroke(2));
+						}
 						g2.drawLine(obj.getPosition().x, obj.getPosition().y, (borderPos >> 1),
 								(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + 25);
 						if (showedInformation[0]) {