package fortiss.simulation;

import java.io.FileNotFoundException;

import fortiss.gui.listeners.button.AcceptListener;
import fortiss.results.Reporter;
import fortiss.simulation.listeners.helper.ProgressManager;
import linprogMPC.controller.GuiController;
import linprogMPC.helper.DirectoryConfiguration;

/**
 * Based on class MemapTopology ( @author andreas.thut)
 */
public class Simulation implements Runnable {

	/**
	 * @par topology
	 * @par result an instance of Reporter
	 * @par pm an instance of progress manager
	 * @par pmt a thread for progress manager
	 * @par ready a flag for class ProgressManager
	 */
	private GuiController gc;
	public static Reporter result;
	private ProgressManager pm = new ProgressManager();
	private Thread pmt;
	public static boolean ready = false;

	private void execute() throws InterruptedException, FileNotFoundException {

		System.out.println(">> Interactive simulator: Setting up the topology.");
		AcceptListener.loadingScreen.lbMessage.setText("Setting up the topology");
		
		String location = System.getProperty("user.dir") + "/" + DirectoryConfiguration.mainDir + "/" + DirectoryConfiguration.configDir + "/parameterConfig.json";
		gc = new GuiController(location);
		
		System.out.println(">> Interactive simulator: Starting simulation.");
		ready = true;
		gc.startSimulation();
	}

	public static void createAndRun() {
		try {
			try {
				new Simulation().execute();
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void run() {
		AcceptListener.loadingScreen.setVisible(true);
		AcceptListener.loadingScreen.lbMessage.setText("Interactive Simulator is initializing");
		pmt = new Thread(pm);
		pmt.start();

		createAndRun();

		AcceptListener.loadingScreen.dispose();
		result = new Reporter();
		result.setVisible(true);
	}
}

@@ -304,318 +304,311 @@
 n;%0A%0A
-/**%0A * Based on class MemapTopology ( @author andreas.thut)%0A */%0Apublic class Simulation implements Runnable %7B%0A%0A%09/**%0A%09 * @par topology%0A%09 * @par result an instance of Reporter%0A%09 * @par pm an instance of progress manager%0A%09 * @par pmt a thread for p
+public class Simulation implements Runnable %7B%0A%0A%09/** Controller for the GUI */%0A%09private GuiController gc;%0A%09/** an instance of Reporter window */%0A%09public static Reporter result;%0A%09/** an instance of progress manager */%0A%09private ProgressManager pm = new P
 rogress
- m
+M
 anager
-%0A%09 * @par ready a flag for class P
+();%0A%09/** a thread for p
 rogress
-M
+ m
 anager
-%0A%09
  */%0A
@@ -620,131 +620,60 @@
 ate 
-GuiController gc;%0A%09public static Reporter result;%0A%09private ProgressManager pm = new ProgressManager();%0A%09private Thread pmt;
+Thread pmt;%0A%09/** a flag for class ProgressManager */
 %0A%09pu
@@ -939,18 +939,16 @@
 logy%22);%0A
-%09%09
 %0A%09%09Strin
@@ -1031,25 +1031,29 @@
 ainDir + %22/%22
- 
+%0A%09%09%09%09
 + DirectoryC
@@ -1138,18 +1138,16 @@
 ation);%0A
-%09%09
 %0A%09%09Syste
@@ -1304,18 +1304,8 @@
 y %7B%0A
-%09%09%09try %7B%0A%09
 %09%09%09n
@@ -1331,17 +1331,16 @@
 cute();%0A
-%09
 %09%09%7D catc
@@ -1368,54 +1368,10 @@
 ion 
-e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D catch (
+%7C 
 Inte

Update javadoc information and rewrite exceptions