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

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

# Conflicts:
#	src/ui/view/Languages.java
Teh-Hai Julian Zheng преди 7 години
родител
ревизия
e1f9d96904

+ 1 - 1
.classpath

@@ -6,6 +6,6 @@
 	<classpathentry kind="lib" path="jars/json-simple-1.1.1.jar"/>
 	<classpathentry kind="lib" path="jars/json-simple-1.1.1.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
-	<classpathentry kind="lib" path="jars/Cps Library.jar"/>
+	<classpathentry kind="lib" path="jars/CpsAlgorithm.jar"/>
 	<classpathentry kind="output" path="bin"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
 </classpath>

+ 47 - 0
API_Instruction

@@ -0,0 +1,47 @@
+Create a new Java Project and add the jars "CpsClassesModelController" and "CpsAlgorithm" to your Build Path.
+Then create a new Package and create a new Class.
+That Class has to implement the Interface "cpsAlgorithm".
+Your Class then has to implement the method RunAlgorithm.
+This Method gets a Model and the Controller.
+You can access all Data via the Model.
+The Controller has several Methods you can use as well.
+
+Your Class should look something like this:
+
+package projectPackage;
+
+import java.awt.Color;
+import classes.HolonObject;
+import classes.SubNet;
+import cpsAlgorithm.CpsAlgorithm;
+import ui.controller.Control;
+import ui.model.Model;
+
+public class Test implements CpsAlgorithm {
+
+	@Override
+	public void RunAlgorithm(Model model, Control control) {
+		Color c = Color.RED;
+		for (SubNet s : control.getSimManager().getSubNets()) {
+			if (c == Color.RED) {
+				c = Color.CYAN;
+			} else if (c == Color.CYAN) {
+				c = Color.PINK;
+			} else {
+				c = Color.RED;
+			}
+
+			for (HolonObject cps : s.getObjects()) {
+				cps.setBorderColor(c);
+				controller.addTextToConsole(cps.getName());
+			}
+		}
+	}
+}
+
+Then in the program click on the Algorithm Button in the Simulation Menu.
+Go to your project and select the folder where your .java files are.
+Then you can Select the Algorithm you want to use in the ComboBox.
+Then Click on the Simulation Radio Button to switch to Simulation Mode.
+
+Your algorithm will now be used.

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
Examples/Example_Big.json


BIN
QS-Gruppe14-FinalVersion.pdf


BIN
jars/Cps Library.jar


BIN
jars/CpsAlgorithm.jar


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

@@ -6,7 +6,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
-import com.scarekroow.exampleapi.interfaceTest;
+import cpsAlgorithm.*;
 
 
 import classes.Category;
 import classes.Category;
 import classes.CpsEdge;
 import classes.CpsEdge;
@@ -687,7 +687,7 @@ public class Control {
 	 */
 	 */
 	public void runAlgorithm(Model model, Control controller) {
 	public void runAlgorithm(Model model, Control controller) {
 		if (model.getAlgorithm() != null) {
 		if (model.getAlgorithm() != null) {
-			((interfaceTest) model.getAlgorithm()).RunAlgorithm(model, controller);
+			((CpsAlgorithm) model.getAlgorithm()).RunAlgorithm(model, controller);
 		}
 		}
 	}
 	}
 
 

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

@@ -576,6 +576,7 @@ public class Model {
 	 * @param obj the Algorithm
 	 * @param obj the Algorithm
 	 */
 	 */
 	public void setAlgorithm(Object obj) {
 	public void setAlgorithm(Object obj) {
+		this.algorithm = null;
 		this.algorithm = obj;
 		this.algorithm = obj;
 	}
 	}
 }
 }

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

@@ -28,10 +28,10 @@ public class AboutUsPopUp extends JFrame {
 	private JLabel credits = new JLabel();
 	private JLabel credits = new JLabel();
 
 
 	/**
 	/**
-	 * Constructor.
+	 * Constructor
 	 */
 	 */
 	public AboutUsPopUp() {
 	public AboutUsPopUp() {
-		super("About Us");
+		super(Languages.getLanguage()[14]);
 		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
 		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
 				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

+ 30 - 10
src/ui/view/GUI.java

@@ -223,7 +223,7 @@ public class GUI<E> implements CategoryListener {
 	private UnitGraph unitGraph;
 	private UnitGraph unitGraph;
 	private final JSplitPane splitPane3 = new JSplitPane();
 	private final JSplitPane splitPane3 = new JSplitPane();
 	private final JSlider sizeSlider = new JSlider();
 	private final JSlider sizeSlider = new JSlider();
-	private final JLabel lblImageSize = new JLabel("Image Size");
+	private final JLabel lblImageSize = new JLabel(Languages.getLanguage()[94]);
 	// Time Stuff
 	// Time Stuff
 	private TimePanel timePanel;
 	private TimePanel timePanel;
 	// Coord for all Cells with text
 	// Coord for all Cells with text
@@ -285,7 +285,7 @@ public class GUI<E> implements CategoryListener {
 		frmCyberPhysical.addWindowListener(new java.awt.event.WindowAdapter() {
 		frmCyberPhysical.addWindowListener(new java.awt.event.WindowAdapter() {
 			@Override
 			@Override
 			public void windowClosing(java.awt.event.WindowEvent windowEvent) {
 			public void windowClosing(java.awt.event.WindowEvent windowEvent) {
-				if (JOptionPane.showConfirmDialog(frmCyberPhysical, "Are you sure you want to exit?",
+				if (JOptionPane.showConfirmDialog(frmCyberPhysical, Languages.getLanguage()[88],
 						"Cyber Physical Systems Model", JOptionPane.YES_NO_OPTION,
 						"Cyber Physical Systems Model", JOptionPane.YES_NO_OPTION,
 						JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
 						JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
 					controller.deleteDirectory(new File(System.getProperty("user.home") + "/HolonGUI/Autosave"));
 					controller.deleteDirectory(new File(System.getProperty("user.home") + "/HolonGUI/Autosave"));
@@ -481,10 +481,20 @@ public class GUI<E> implements CategoryListener {
 		mnNewMenuEdit.add(mntmRedo);
 		mnNewMenuEdit.add(mntmRedo);
 
 
 		mnLanguage.add(englishBtn);
 		mnLanguage.add(englishBtn);
+		englishBtn.setIcon(new ImageIcon(new ImageIcon("res/Button_Images/FlagEN.png").getImage().getScaledInstance(20,
+				20, java.awt.Image.SCALE_SMOOTH)));
 		mnLanguage.add(spanishBtn);
 		mnLanguage.add(spanishBtn);
+		spanishBtn.setIcon(new ImageIcon(new ImageIcon("res/Button_Images/FlagES.png").getImage().getScaledInstance(20,
+				20, java.awt.Image.SCALE_SMOOTH)));
 		mnLanguage.add(germanBtn);
 		mnLanguage.add(germanBtn);
+		germanBtn.setIcon(new ImageIcon(new ImageIcon("res/Button_Images/FlagDE.png").getImage().getScaledInstance(20,
+				20, java.awt.Image.SCALE_SMOOTH)));
 		mnLanguage.add(czechBtn);
 		mnLanguage.add(czechBtn);
+		czechBtn.setIcon(new ImageIcon(new ImageIcon("res/Button_Images/FlagCZ.png").getImage().getScaledInstance(20,
+				20, java.awt.Image.SCALE_SMOOTH)));
 		mnLanguage.add(chineseBtn);
 		mnLanguage.add(chineseBtn);
+		chineseBtn.setIcon(new ImageIcon(new ImageIcon("res/Button_Images/FlagZH.png").getImage().getScaledInstance(20,
+				20, java.awt.Image.SCALE_SMOOTH)));
 
 
 		mntmFindReplace.addActionListener(new ActionListener() {
 		mntmFindReplace.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 			public void actionPerformed(ActionEvent e) {
@@ -867,8 +877,8 @@ public class GUI<E> implements CategoryListener {
 					Point mousePos = tableProperties.getMousePosition();
 					Point mousePos = tableProperties.getMousePosition();
 					int selValueY = (int) Math.floor(yProThis / 16);
 					int selValueY = (int) Math.floor(yProThis / 16);
 					int selValueX = (int) Math.floor(xProThis / (tableProperties.getWidth() / 2));
 					int selValueX = (int) Math.floor(xProThis / (tableProperties.getWidth() / 2));
-					temp = tableModelProperties.getValueAt(selValueY, selValueX);
 					if (getActualCps() != null) {
 					if (getActualCps() != null) {
+						temp = tableModelProperties.getValueAt(selValueY, selValueX);
 						if (getActualCps() instanceof HolonSwitch) {
 						if (getActualCps() instanceof HolonSwitch) {
 							btemp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
 							btemp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
 									mousePos.x / (tableProperties.getWidth() / 2));
 									mousePos.x / (tableProperties.getWidth() / 2));
@@ -894,7 +904,8 @@ public class GUI<E> implements CategoryListener {
 						}
 						}
 					} else {
 					} else {
 						temp = tableModelProperties.getValueAt(selValueY, selValueX);
 						temp = tableModelProperties.getValueAt(selValueY, selValueX);
-						System.out.println(temp.toString());
+						btemp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
+								mousePos.x / (tableProperties.getWidth() / 2));
 						if (selValueY == 2) {
 						if (selValueY == 2) {
 							Float ftemp;
 							Float ftemp;
 							if (Float.parseFloat(temp.toString()) >= 0.0) {
 							if (Float.parseFloat(temp.toString()) >= 0.0) {
@@ -903,17 +914,15 @@ public class GUI<E> implements CategoryListener {
 								ftemp = model.getSelectedEdge().getCapacity();
 								ftemp = model.getSelectedEdge().getCapacity();
 							}
 							}
 							model.getSelectedEdge().setCapacity(ftemp);
 							model.getSelectedEdge().setCapacity(ftemp);
-						} else if (selValueY == 3) {
-							Boolean bTemp = Boolean.parseBoolean(temp.toString());
-							model.getSelectedEdge().setState(bTemp);
+						} else if (mousePos.y / tableProperties.getRowHeight() == 3) {
+							Boolean bbTemp = Boolean.parseBoolean(btemp.toString());
+							model.getSelectedEdge().setState(bbTemp);
 						}
 						}
 					}
 					}
 					canvas.repaint();
 					canvas.repaint();
 				} catch (Exception e) {
 				} catch (Exception e) {
-
 				}
 				}
 			}
 			}
-
 		});
 		});
 
 
 		/***********************
 		/***********************
@@ -1944,6 +1953,17 @@ public class GUI<E> implements CategoryListener {
 		saveBeforeNew = tempArray[28];
 		saveBeforeNew = tempArray[28];
 		eraseCategory = tempArray[29];
 		eraseCategory = tempArray[29];
 		selectObjBeforeErase = tempArray[30];
 		selectObjBeforeErase = tempArray[30];
+		// SimMenu
+		simMenu.simButton.setText(Languages.getLanguage()[83]);
+		simMenu.simSpeedLabel.setText(Languages.getLanguage()[84]);
+		simMenu.algoFolderButton.setText(Languages.getLanguage()[85]);
+		// TimePanel
+		timePanel.playBtn.setToolTipText(Languages.getLanguage()[89]);
+		timePanel.timeResetBtn.setToolTipText(Languages.getLanguage()[90]);
+		timePanel.timeForwardBtn.setToolTipText(Languages.getLanguage()[91]);
+		timePanel.timeBackwardBtn.setToolTipText(Languages.getLanguage()[92]);
+		timePanel.timeSlider.setToolTipText(Languages.getLanguage()[93]);
+		// Image Size Slider
+		lblImageSize.setText(Languages.getLanguage()[94]);
 	}
 	}
-
 }
 }

+ 58 - 21
src/ui/view/Languages.java

@@ -36,44 +36,56 @@ public class Languages {
 			"Name", "Total Energy", "Manual", "Active", " is connected to", " with ID: ", "Edge: ", " to ",
 			"Name", "Total Energy", "Manual", "Active", " is connected to", " with ID: ", "Edge: ", " to ",
 			"Current flow", "Max. Capacity", "Status",
 			"Current flow", "Max. Capacity", "Status",
 			// Info SimulationMenu (83-87)
 			// Info SimulationMenu (83-87)
-			"Simulate", "Simulation Speed:", "Algorithm:", "non selected", "success" };
+			"Simulate", "Simulation Speed:", "Algorithm:", "non selected", "success",
+			// Exit Pop Up (88)
+			"Are you sure you want to exit?",
+			// Simulation ToolTip (89-93)
+			"Play", "Reset", "Forward", "Backward", "Time Slider",
+			// Image Size Slider (94)
+			"Image Size" };
 
 
 	static String[] arrayES = {
 	static String[] arrayES = {
 			// ToolBar (0-16)
 			// ToolBar (0-16)
 			"Archivo", "Nuevo", "Abrir", "Guardar", "Editar", "Deshacer", "Rehacer", "Buscar/Reemplazar",
 			"Archivo", "Nuevo", "Abrir", "Guardar", "Editar", "Deshacer", "Rehacer", "Buscar/Reemplazar",
-			"Editar Informacion a mostrar", "Opciones", "Resetear Categorias", "Vista", "Tamano de Vista", "Ayuda",
+			"Editar Información a mostrar", "Opciones", "Resetear Categorias", "Vista", "Tamaño de Vista", "Ayuda",
 			"Sobre Nosotros", "Editar Conexiones", "Idiomas",
 			"Sobre Nosotros", "Editar Conexiones", "Idiomas",
 			// Tables (17-24)
 			// Tables (17-24)
-			"Objeto", "Nr.", "Equipo", "Enegia", "Cantidad", "Activo", "Campo", "Informacion",
+			"Objeto", "Nr.", "Equipo", "Enegia", "Cantidad", "Activo", "Campo", "Información",
 			// Graph (25-26)
 			// Graph (25-26)
 			"Vacio ", "Resetear",
 			"Vacio ", "Resetear",
 			// Warning PopUps(27-30)
 			// Warning PopUps(27-30)
-			"Atencion", "Desea guardar su progreso?", "Esta seguro que quiere eliminar la categoria ",
-			"Por favor seleccione una categoria o un objecto para poder proceder a eliminarlo.",
+			"Atención", "Desea guardar su progreso?", "Esta seguro que quiere eliminar la categoría ",
+			"Por favor, seleccione una categoria o un objecto para poder proceder a eliminarlo.",
 			// Edit Edges Pop Up (31-34)
 			// Edit Edges Pop Up (31-34)
-			"Editar informacion a mostrar", "Mostrar energia total de los objetos",
+			"Editar información a mostrar", "Mostrar energia total de los objetos",
 			"Mostrar propiedades de las conexiones", "Cancelar",
 			"Mostrar propiedades de las conexiones", "Cancelar",
 			// Search/Replace Pop Up (35-45)
 			// Search/Replace Pop Up (35-45)
-			"Buscar Objetos", "Buscar", "Reemplazar", "Direccion", "Adelante", "Atras", "Alcance", "Todo", "Uno",
+			"Buscar Objetos", "Buscar", "Reemplazar", "Dirección", "Adelante", "Atrás", "Alcance", "Todo", "Uno",
 			"Reemplazar Todo", "Cerrar",
 			"Reemplazar Todo", "Cerrar",
 			// Edit Edges Pop Up (46-55)
 			// Edit Edges Pop Up (46-55)
 			"Editar Capacidad de las Conexiones", "Capacidad Max.:", "Cambiar para todas las conexiones existentes",
 			"Editar Capacidad de las Conexiones", "Capacidad Max.:", "Cambiar para todas las conexiones existentes",
 			"Cambiar solo para conexiones nuevas", "Cambiar para todas las conexiones existentes y nuevas", "Cancelar",
 			"Cambiar solo para conexiones nuevas", "Cambiar para todas las conexiones existentes y nuevas", "Cancelar",
-			"Por favor elija una de las opciones",
-			"Por favor ingrese un valor mayor o igual a 0 en el campo de Capacidad Max.",
+			"Por favor, elija una de las opciones",
+			"Por favor, ingrese un valor mayor o igual a 0 en el campo de Capacidad Max.",
 			"Editar capacidad de las conexiones", "(ingresar \"infinite\" para capacidad infinita)",
 			"Editar capacidad de las conexiones", "(ingresar \"infinite\" para capacidad infinita)",
 			// Add PopUp Tree (56-63)
 			// Add PopUp Tree (56-63)
-			"Por favor ingrese el nombre de la categoria ", "Por favor elija una categoria antes de agregar ",
+			"Por favor, ingrese el nombre de la categoria ", "Por favor, elija una categoria antes de agregar ",
 			"Menu para Agregar un Objeto", "Nombre:", "Buscar Imagen", "Agregar Elemento", "Eliminar Elemento",
 			"Menu para Agregar un Objeto", "Nombre:", "Buscar Imagen", "Agregar Elemento", "Eliminar Elemento",
 			"Cancelar",
 			"Cancelar",
 			// Add PopUp Element (64-71)
 			// Add PopUp Element (64-71)
-			"Agregar Elemento al Objecto", "Nombre del El.:", "Energia:", "Cantidad:",
-			"Por favor ingrese valores en los campos de cantidad y energia", "Sin nombre", "Nombre en uso", "Cancelar",
+			"Agregar Elemento al Objecto", "Nombre del El.:", "Energía:", "Cantidad:",
+			"Por favor, ingrese valores en los campos de cantidad y energía", "Sin nombre", "Nombre en uso", "Cancelar",
 			// Info for PropertyTable (72-82)
 			// Info for PropertyTable (72-82)
 			"Nombre", "Energia Total", "Manual", "Activo", " esta conectado a ", " con ID: ", "Canto: ", " a ",
 			"Nombre", "Energia Total", "Manual", "Activo", " esta conectado a ", " con ID: ", "Canto: ", " a ",
 			"Corriente actual", "Capacidad Max.", "Estado",
 			"Corriente actual", "Capacidad Max.", "Estado",
 			// Info SimulationMenu (83-87)
 			// Info SimulationMenu (83-87)
-			"Simular", "Velocidad de Simulacion:", "Algoritmo:", "nada seleccionado", "exito" };
+			"Simular", "Velocidad de Simulación:", "Algoritmo:", "nada seleccionado", "exito",
+			// Exit Pop Up (88)
+			"Esta seguro que quiere cerrar el programa?",
+			// Simulation ToolTip (89-93)
+			"Iniciar", "Resetear", "Adelante", "Atrás", "Linea de Tiempo",
+			// Image Size Slider (94)
+			"Tamaño de la Imagen" };
 
 
 	static String[] arrayDE = {
 	static String[] arrayDE = {
 			// ToolBar (0-16)
 			// ToolBar (0-16)
@@ -88,7 +100,8 @@ public class Languages {
 			"Warnung", "Möchten Sie ihre aktuellen Daten speichern?", "Möchten Sie wirklich die Kategorie löschen ",
 			"Warnung", "Möchten Sie ihre aktuellen Daten speichern?", "Möchten Sie wirklich die Kategorie löschen ",
 			"Bitte wählen Sie eine Kategorie oder ein Objekt um etwas löschen zu können.",
 			"Bitte wählen Sie eine Kategorie oder ein Objekt um etwas löschen zu können.",
 			// Edit Edges Pop Up (31-34)
 			// Edit Edges Pop Up (31-34)
-			"Gezeigte Informationen Ersetzen", "Gesamtenergie von Objekten zeigen", "Verbindungseigenschaften zeigen", "Abbrechen",
+			"Gezeigte Informationen Ersetzen", "Gesamtenergie von Objekten zeigen", "Verbindungseigenschaften zeigen",
+			"Abbrechen",
 			// Search/Replace Pop Up (35-45)
 			// Search/Replace Pop Up (35-45)
 			"Objekte suchen", "Suchen", "Ersetzen", "Richtung", "Vorwärts", "Rückwerts", "Scope", "Alle", "Einzeln",
 			"Objekte suchen", "Suchen", "Ersetzen", "Richtung", "Vorwärts", "Rückwerts", "Scope", "Alle", "Einzeln",
 			"Alle Ersetzen", "Schließen",
 			"Alle Ersetzen", "Schließen",
@@ -96,19 +109,27 @@ public class Languages {
 			"Kapazitäten von Kanten bearbeiten", "Max. Kapazität:", "Nur für alle existierenden Kanten ändern",
 			"Kapazitäten von Kanten bearbeiten", "Max. Kapazität:", "Nur für alle existierenden Kanten ändern",
 			"Nur für neu erstellte Kanten ändern", "Für alle existierenden und neuen Kanten ändern", "Abbrechen",
 			"Nur für neu erstellte Kanten ändern", "Für alle existierenden und neuen Kanten ändern", "Abbrechen",
 			"Bitte wählen Sie eine der Optionen",
 			"Bitte wählen Sie eine der Optionen",
-			"Bitte geben Sie eine Zahl größer-gleich 0 im Feld für Maximale Kapazität ein", "Kapazitäten von Kanten bearbeiten",
-			"(geben Sie \"infinite\" für unbeschränkte Kapazitäten ein)",
+			"Bitte geben Sie eine Zahl größer-gleich 0 im Feld für Maximale Kapazität ein",
+			"Kapazitäten von Kanten bearbeiten", "(geben Sie \"infinite\" für unbeschränkte Kapazitäten ein)",
 			// Add PopUp Tree (56-63)
 			// Add PopUp Tree (56-63)
-			"Bitte geben Sie einen Namen für die Kategorie ein ", "Bitte wählen Sie eine Kategorie vor dem hinzufügen ", "Objekt Hinzufügen Menü",
-			"Name:", "Bilder durchsuchen", "Element hinzufügen", "Element löschen", "Abbrechen",
+			"Bitte geben Sie einen Namen für die Kategorie ein ", "Bitte wählen Sie eine Kategorie vor dem hinzufügen ",
+			"Objekt Hinzufügen Menü", "Name:", "Bilder durchsuchen", "Element hinzufügen", "Element löschen",
+			"Abbrechen",
 			// Add PopUp Element (64-71)
 			// Add PopUp Element (64-71)
 			"Element zu Objekt hinzufügen", "Element Name:", "Bereitgestellte Energie:", "Menge:",
 			"Element zu Objekt hinzufügen", "Element Name:", "Bereitgestellte Energie:", "Menge:",
-			"Bitte geben Sie Nummern in den Feldern für Menge und Energie ein", "Kein Name", "Name bereits vergeben", "Abbrechen",
+			"Bitte geben Sie Nummern in den Feldern für Menge und Energie ein", "Kein Name", "Name bereits vergeben",
+			"Abbrechen",
 			// Info for PropertyTable (72-82)
 			// Info for PropertyTable (72-82)
 			"Name", "Gesamte Energie", "Manuell", "Aktive", " ist verbunden mit", " mit ID: ", "Kante: ", " nach ",
 			"Name", "Gesamte Energie", "Manuell", "Aktive", " ist verbunden mit", " mit ID: ", "Kante: ", " nach ",
 			"aktueller Fluss", "Max. Kapazität", "Status",
 			"aktueller Fluss", "Max. Kapazität", "Status",
 			// Info SimulationMenu (83-87)
 			// Info SimulationMenu (83-87)
-			"Simulieren", "Simulationsgeschwindigkeit:", "Algorithmus:", "nichts ausgewählt", "Erfolg" };
+			"Simulieren", "Simulationsgeschwindigkeit:", "Algorithmus:", "nichts ausgewählt", "Erfolg",
+			// Exit Pop Up (88)
+			"Sind Sie sich sicher, dass Sie das Programm beenden wollen?",
+			// Simulation ToolTip (89-93)
+			"Abspielen", "Zurücksetzen", "Vorwärts", "Rückwärts", "Zeitschieber",
+			// Image Size Slider (94)
+			"Bildgröße" };
 
 
 	static String[] arrayCZ = {
 	static String[] arrayCZ = {
 			// ToolBar (0-16)
 			// ToolBar (0-16)
@@ -142,7 +163,13 @@ public class Languages {
 			"Name", "Total Energy", "Manual", "Active", " is connected to", " with ID: ", "Edge: ", " to ",
 			"Name", "Total Energy", "Manual", "Active", " is connected to", " with ID: ", "Edge: ", " to ",
 			"Current flow", "Max. Capacity", "Status",
 			"Current flow", "Max. Capacity", "Status",
 			// Info SimulationMenu (83-87)
 			// Info SimulationMenu (83-87)
-			"Simulate", "Simulation Speed:", "Algorithm:", "choose folder", "success" };
+			"Simulate", "Simulation Speed:", "Algorithm:", "choose folder", "success",
+			// Exit Pop Up (88)
+			"Are you sure you want to exit?",
+			// Simulation ToolTip (89-93)
+			"Play", "Reset", "Forward", "Backward", "Time Slider",
+			// Image Size Slider (94)
+			"Image Size" };
 
 
 	static String[] arrayZH = {
 	static String[] arrayZH = {
 			// ToolBar (0-16)
 			// ToolBar (0-16)
@@ -176,7 +203,17 @@ public class Languages {
 			"名称", "总能量", "手册", "主动", " 链接至", " 通过ID: ", "边缘: ", " 至 ",
 			"名称", "总能量", "手册", "主动", " 链接至", " 通过ID: ", "边缘: ", " 至 ",
 			"电流流", "最大容量", "状态",
 			"电流流", "最大容量", "状态",
 			// Info SimulationMenu (83-87)
 			// Info SimulationMenu (83-87)
+<<<<<<< HEAD
 			"模拟", "仿真速度:", "计算程序:", "选择“文件夹", "成功" };
 			"模拟", "仿真速度:", "计算程序:", "选择“文件夹", "成功" };
+=======
+			"Simulate", "Simulation Speed:", "Algorithm:", "choose folder", "success",
+			// Exit Pop Up (88)
+			"Are you sure you want to exit?",
+			// Simulation ToolTip (89-93)
+			"Play", "Reset", "Forward", "Backward", "Time Slider",
+			// Image Size Slider (94)
+			"Image Size" };
+>>>>>>> 98a6bc16d400df041bc34fe5b1e27a65d551ff9a
 
 
 	public static String[] getLanguage() {
 	public static String[] getLanguage() {
 		switch (languageVar) {
 		switch (languageVar) {

+ 46 - 52
src/ui/view/SimulationMenu.java

@@ -11,51 +11,25 @@ import javax.swing.JRadioButton;
 import javax.swing.JTextField;
 import javax.swing.JTextField;
 import javax.swing.event.CaretEvent;
 import javax.swing.event.CaretEvent;
 import javax.swing.event.CaretListener;
 import javax.swing.event.CaretListener;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticCollector;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
 import javax.tools.ToolProvider;
 import javax.tools.ToolProvider;
 
 
-import com.sun.crypto.provider.JceKeyStore;
-
 import classes.AbstractCpsObject;
 import classes.AbstractCpsObject;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.HolonTransformer;
-import jdk.nashorn.api.scripting.URLReader;
 import ui.controller.Control;
 import ui.controller.Control;
 import ui.model.Model;
 import ui.model.Model;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashMap;
-import java.util.List;
 import java.awt.GridBagLayout;
 import java.awt.GridBagLayout;
 import java.awt.Color;
 import java.awt.Color;
-import java.awt.Cursor;
 import java.awt.Dimension;
 import java.awt.Dimension;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagConstraints;
 import java.awt.Insets;
 import java.awt.Insets;
+import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
+import java.io.FileReader;
 import java.net.URL;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLClassLoader;
-import java.nio.file.Files;
-import java.awt.FlowLayout;
-import com.scarekroow.exampleapi.*;
 
 
 /**
 /**
  * This Class represents the Menu, where you can edit stuff about the
  * This Class represents the Menu, where you can edit stuff about the
@@ -68,11 +42,11 @@ public class SimulationMenu extends JMenuBar {
 	private static final long serialVersionUID = 1L;
 	private static final long serialVersionUID = 1L;
 
 
 	private JPanel menuPanel = new JPanel();
 	private JPanel menuPanel = new JPanel();
-	private JRadioButton simButton = new JRadioButton(Languages.getLanguage()[83]);
-	private JLabel simSpeedLabel = new JLabel(Languages.getLanguage()[84]);
+	JRadioButton simButton = new JRadioButton(Languages.getLanguage()[83]);
+	JLabel simSpeedLabel = new JLabel(Languages.getLanguage()[84]);
 	private JTextField simSpeedText = new JTextField("1000");
 	private JTextField simSpeedText = new JTextField("1000");
 	private JComboBox algoCombo = new JComboBox<>();
 	private JComboBox algoCombo = new JComboBox<>();
-	private JButton algoFolderButton = new JButton(Languages.getLanguage()[85]);
+	JButton algoFolderButton = new JButton(Languages.getLanguage()[85]);
 	private HashMap<String, File> algosHash = new HashMap<>();
 	private HashMap<String, File> algosHash = new HashMap<>();
 
 
 	// root Directory
 	// root Directory
@@ -96,14 +70,10 @@ public class SimulationMenu extends JMenuBar {
 		this.controller = cont;
 		this.controller = cont;
 
 
 		// Algorithm ComboBox Action
 		// Algorithm ComboBox Action
-		algoCombo.addItemListener(new ItemListener() {
-
+		algoCombo.addActionListener(new ActionListener() {
 			@Override
 			@Override
-			public void itemStateChanged(ItemEvent e) {
-
-				setAlgorithm(algosHash.get(e.getItem()));
-				controller.addTextToConsole("" + e.getItem());
-
+			public void actionPerformed(ActionEvent e) {
+				setAlgorithm(algosHash.get(algoCombo.getSelectedItem()), algoCombo.getSelectedItem() + "");
 			}
 			}
 		});
 		});
 
 
@@ -124,10 +94,9 @@ public class SimulationMenu extends JMenuBar {
 				if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
 				if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
 					algoCombo.removeAllItems();
 					algoCombo.removeAllItems();
 					File[] files = fileChooser.getSelectedFile().listFiles();
 					File[] files = fileChooser.getSelectedFile().listFiles();
-					//Set Root Folder Path
+					// Set Root Folder Path
 					root = new File(fileChooser.getCurrentDirectory().getPath());
 					root = new File(fileChooser.getCurrentDirectory().getPath());
-					controller.addTextToConsole("roor Path" + root.getPath());
-					
+
 					for (int i = 0; i < files.length; i++) {
 					for (int i = 0; i < files.length; i++) {
 						if (files[i].toString()
 						if (files[i].toString()
 								.endsWith(".java") /*
 								.endsWith(".java") /*
@@ -157,14 +126,20 @@ public class SimulationMenu extends JMenuBar {
 		menuPanel.setLayout(gblmenuPanel);
 		menuPanel.setLayout(gblmenuPanel);
 
 
 		// isSimulation
 		// isSimulation
-		simButton.addPropertyChangeListener(new PropertyChangeListener() {
+		simButton.addActionListener(new ActionListener() {
 
 
 			@Override
 			@Override
-			public void propertyChange(PropertyChangeEvent evt) {
+			public void actionPerformed(ActionEvent e) {
 				controller.setIsSimulation(simButton.isSelected());
 				controller.setIsSimulation(simButton.isSelected());
+				if (!model.getIsSimulation()) {
+					for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
+						cps.setBorderColor(Color.WHITE);
+					}
+				}
 				controller.calculateStateForCurrentTimeStep();
 				controller.calculateStateForCurrentTimeStep();
 			}
 			}
 		});
 		});
+
 		GridBagConstraints gbcsimButton = new GridBagConstraints();
 		GridBagConstraints gbcsimButton = new GridBagConstraints();
 		gbcsimButton.anchor = GridBagConstraints.NORTHWEST;
 		gbcsimButton.anchor = GridBagConstraints.NORTHWEST;
 		gbcsimButton.insets = new Insets(0, 0, 0, 5);
 		gbcsimButton.insets = new Insets(0, 0, 0, 5);
@@ -216,29 +191,48 @@ public class SimulationMenu extends JMenuBar {
 		this.add(menuPanel);
 		this.add(menuPanel);
 	}
 	}
 
 
-	public void setAlgorithm(File file) {
+	public void setAlgorithm(File file, String name) {
 		try {
 		try {
+			BufferedReader br = new BufferedReader(new FileReader(file.getPath()));
+			String line = br.readLine();
+			// Package Name
+			String packageName = "";
+
+			while (line != null) {
+				line = line.trim();
+				if (!line.isEmpty()) {
+					if (line.length() >= 7 && line.substring(0, 7).equals("package")) {
+						packageName = line.substring(8, line.length() - 1);
+					}
+				}
+				if (packageName.isEmpty()) {
+					line = br.readLine();
+				} else {
+					line = null;
+				}
 
 
-			// Compile source file.
+			}
 
 
+			// Compile source file.
 			JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
 			JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
 
 
 			compiler.run(null, null, null, file.getPath());
 			compiler.run(null, null, null, file.getPath());
 
 
 			// Load and instantiate compiled class.
 			// Load and instantiate compiled class.
-			controller.addTextToConsole(root.toString());
 			URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { root.toURI().toURL() });
 			URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { root.toURI().toURL() });
-			Class<?> cls = Class.forName("projectPackage.APITest", true, classLoader);
 
 
-			Object t = cls.newInstance();
+			Class<?> cls;
+			if (packageName.isEmpty()) {
+				cls = Class.forName(name, true, classLoader);
+			} else {
+				cls = Class.forName(packageName + "." + name, true, classLoader);
+			}
 
 
-			controller.addTextToConsole(Languages.getLanguage()[87]);
+			Object t = cls.newInstance();
 
 
 			controller.setAlgorithm(t);
 			controller.setAlgorithm(t);
 
 
 		} catch (Exception e) {
 		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
 		}
 		}
 	}
 	}
 }
 }

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

@@ -22,9 +22,11 @@ import classes.SubNet;
 import ui.controller.Control;
 import ui.controller.Control;
 import ui.model.Model;
 import ui.model.Model;
 import javax.swing.BoxLayout;
 import javax.swing.BoxLayout;
+
 /**
 /**
- * This Class represents a Panel where the User can start and stop the Simulation.
- * He Can also reset the Simulation and click through every Iteration.
+ * This Class represents a Panel where the User can start and stop the
+ * Simulation. He Can also reset the Simulation and click through every
+ * Iteration.
  * 
  * 
  * @author Gruppe14
  * @author Gruppe14
  */
  */
@@ -35,10 +37,10 @@ public class TimePanel extends JPanel {
 
 
 	JSlider timeSlider = new JSlider();
 	JSlider timeSlider = new JSlider();
 	private final JPanel timeBtnPanel = new JPanel();
 	private final JPanel timeBtnPanel = new JPanel();
-	private final JButton playBtn = new JButton();
-	private final JButton timeResetBtn = new JButton();
-	private final JButton timeForwardBtn = new JButton();
-	private final JButton timeBackwardBtn = new JButton();
+	final JButton playBtn = new JButton();
+	final JButton timeResetBtn = new JButton();
+	final JButton timeForwardBtn = new JButton();
+	final JButton timeBackwardBtn = new JButton();
 	private Timer timer;
 	private Timer timer;
 	private boolean running = false;
 	private boolean running = false;
 
 
@@ -46,8 +48,11 @@ public class TimePanel extends JPanel {
 
 
 	/**
 	/**
 	 * Constructor.
 	 * Constructor.
-	 * @param mod the Model
-	 * @param cont the Controller
+	 * 
+	 * @param mod
+	 *            the Model
+	 * @param cont
+	 *            the Controller
 	 */
 	 */
 	public TimePanel(Model mod, Control cont) {
 	public TimePanel(Model mod, Control cont) {
 		super();
 		super();
@@ -78,7 +83,7 @@ public class TimePanel extends JPanel {
 		timeSlider.setPaintLabels(true);
 		timeSlider.setPaintLabels(true);
 		timeSlider.setMinorTickSpacing(1);
 		timeSlider.setMinorTickSpacing(1);
 		timeSlider.setMajorTickSpacing(5);
 		timeSlider.setMajorTickSpacing(5);
-		timeSlider.setToolTipText("Time Slider");
+		timeSlider.setToolTipText(Languages.getLanguage()[93]);
 		timeSlider.setMaximum(model.getIterations() - 1);
 		timeSlider.setMaximum(model.getIterations() - 1);
 		timeSlider.setValue(0);
 		timeSlider.setValue(0);
 		timeSlider.setBackground(Color.WHITE);
 		timeSlider.setBackground(Color.WHITE);
@@ -95,7 +100,7 @@ public class TimePanel extends JPanel {
 		timeBtnPanel.setLayout(new BoxLayout(timeBtnPanel, BoxLayout.X_AXIS));
 		timeBtnPanel.setLayout(new BoxLayout(timeBtnPanel, BoxLayout.X_AXIS));
 
 
 		// Buttons
 		// Buttons
-		playBtn.setToolTipText("Play");
+		playBtn.setToolTipText(Languages.getLanguage()[89]);
 
 
 		playBtn.setBackground(Color.WHITE);
 		playBtn.setBackground(Color.WHITE);
 		playBtn.setBorderPainted(false);
 		playBtn.setBorderPainted(false);
@@ -118,7 +123,7 @@ public class TimePanel extends JPanel {
 				}
 				}
 			}
 			}
 		});
 		});
-		timeResetBtn.setToolTipText("Reset");
+		timeResetBtn.setToolTipText(Languages.getLanguage()[90]);
 
 
 		timeResetBtn.setBorderPainted(false);
 		timeResetBtn.setBorderPainted(false);
 		timeResetBtn.setBackground(Color.WHITE);
 		timeResetBtn.setBackground(Color.WHITE);
@@ -132,7 +137,7 @@ public class TimePanel extends JPanel {
 				controller.calculateStateForCurrentTimeStep();
 				controller.calculateStateForCurrentTimeStep();
 			}
 			}
 		});
 		});
-		timeForwardBtn.setToolTipText("Forward");
+		timeForwardBtn.setToolTipText(Languages.getLanguage()[91]);
 
 
 		timeForwardBtn.setBorderPainted(false);
 		timeForwardBtn.setBorderPainted(false);
 		timeForwardBtn.setContentAreaFilled(false);
 		timeForwardBtn.setContentAreaFilled(false);
@@ -145,7 +150,7 @@ public class TimePanel extends JPanel {
 				controller.setCurIteration(timeSlider.getValue());
 				controller.setCurIteration(timeSlider.getValue());
 			}
 			}
 		});
 		});
-		timeBackwardBtn.setToolTipText("Backward");
+		timeBackwardBtn.setToolTipText(Languages.getLanguage()[92]);
 
 
 		timeBackwardBtn.setBackground(Color.WHITE);
 		timeBackwardBtn.setBackground(Color.WHITE);
 		timeBackwardBtn.setBorderPainted(false);
 		timeBackwardBtn.setBorderPainted(false);
@@ -167,13 +172,13 @@ public class TimePanel extends JPanel {
 		this.add(timeBtnPanel, BorderLayout.WEST);
 		this.add(timeBtnPanel, BorderLayout.WEST);
 		this.add(timeSlider);
 		this.add(timeSlider);
 	}
 	}
-	
+
 	/**
 	/**
 	 * Retunrs the TimeSlider.
 	 * Retunrs the TimeSlider.
 	 * 
 	 * 
 	 * @return the TimeSlider
 	 * @return the TimeSlider
 	 */
 	 */
-	public JSlider getTimeSlider(){
+	public JSlider getTimeSlider() {
 		return timeSlider;
 		return timeSlider;
 	}
 	}
 }
 }

Някои файлове не бяха показани, защото твърде много файлове са промени