Browse Source

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

dominik.rieder 7 years ago
parent
commit
009d6f2790

BIN
res/Button_Images/FlagCZ.png


BIN
res/Button_Images/FlagDE.png


BIN
res/Button_Images/FlagEN.png


BIN
res/Button_Images/FlagES.png


BIN
res/Button_Images/FlagZH.png


+ 25 - 16
src/ui/controller/Control.java

@@ -62,7 +62,7 @@ public class Control {
 		this.consoleController = new ConsoleController(model);
 		autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
 		File dest = new File(autoPath);
-		//deleteDirectory(dest);
+		// deleteDirectory(dest);
 		dest.mkdirs();
 		try {
 			autoSave();
@@ -97,7 +97,8 @@ public class Control {
 	/**
 	 * Search for Object by ID.
 	 * 
-	 * @param id the id of the Object
+	 * @param id
+	 *            the id of the Object
 	 * @return the CpsObject
 	 */
 	public AbstractCpsObject searchByID(int id) {
@@ -120,7 +121,8 @@ public class Control {
 	/**
 	 * search for category.
 	 * 
-	 * @param cat name of the Category
+	 * @param cat
+	 *            name of the Category
 	 * @return the Category
 	 */
 	public Category searchCategory(String cat) {
@@ -128,7 +130,7 @@ public class Control {
 	}
 
 	/* Operations for Categories and Objects */
-	
+
 	/**
 	 * init default category and objects.
 	 */
@@ -153,7 +155,8 @@ public class Control {
 	 *            Category
 	 * @param obj
 	 *            New Object Name
-	 *            @param ele Array of Elements
+	 * @param ele
+	 *            Array of Elements
 	 * @param img
 	 *            the image Path
 	 */
@@ -468,7 +471,9 @@ public class Control {
 	public void calculateStateForCurrentTimeStep() {
 		simulationManager.reset();
 		simulationManager.calculateStateForTimeStep(model.getCurIteration());
-		runAlgorithm(model, this);
+		if (model.getIsSimulation()) {
+			runAlgorithm(model, this);
+		}
 	}
 
 	/**
@@ -480,7 +485,9 @@ public class Control {
 	public void calculateStateForTimeStep(int x) {
 		simulationManager.reset();
 		simulationManager.calculateStateForTimeStep(x);
-		runAlgorithm(model, this);
+		if (model.getIsSimulation()) {
+			runAlgorithm(model, this);
+		}
 	}
 
 	/**
@@ -644,42 +651,44 @@ public class Control {
 	public void setIsSimulation(boolean b) {
 		globalController.setIsSimulation(b);
 	}
-	
+
 	/**
 	 * Set the Canvas X Size.
 	 * 
-	 * @param canvasX the cANVAS_X to set
+	 * @param canvasX
+	 *            the cANVAS_X to set
 	 */
 	public void setCanvasX(int canvasX) {
 		globalController.setCanvasX(canvasX);
 	}
 
-
 	/**
 	 * Set the Canvas Y Size.
 	 * 
-	 * @param canvasY the cANVAS_Y to set
+	 * @param canvasY
+	 *            the cANVAS_Y to set
 	 */
 	public void setCanvasY(int canvasY) {
 		globalController.setCanvasY(canvasY);
 	}
-	
+
 	/**
 	 * Set the Algorithm.
 	 * 
-	 * @param obj the Algorithm
+	 * @param obj
+	 *            the Algorithm
 	 */
 	public void setAlgorithm(Object obj) {
 		multiPurposeController.setAlgorithm(obj);
 	}
-	
+
 	/**
 	 * Run the Algorithm.
 	 */
 	public void runAlgorithm(Model model, Control controller) {
 		if (model.getAlgorithm() != null) {
-			((interfaceTest)model.getAlgorithm()).RunAlgorithm(model, controller);
+			((interfaceTest) model.getAlgorithm()).RunAlgorithm(model, controller);
 		}
 	}
-	
+
 }

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

@@ -149,11 +149,11 @@ public class AddElementPopUp extends JDialog {
 
 							if (elementName.getText().length() == 0) {
 								JLabel errorString = new JLabel(Languages.getLanguage()[69]);
-								errorString.setBounds(200, 8, 200, 20);
+								errorString.setBounds(240, 8, 100, 20);
 								contentPanel.add(errorString);
 							} else if (repeated) {
 								JLabel errorString = new JLabel(Languages.getLanguage()[70]);
-								errorString.setBounds(240, 8, 100, 20);
+								errorString.setBounds(250, 8, 100, 20);
 								contentPanel.add(errorString);
 							}
 							elementName.setBackground(new Color(255, 50, 50));

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

@@ -5,6 +5,7 @@ import java.awt.Color;
 import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Dimension;
+import java.awt.Graphics;
 import java.awt.Image;
 import java.awt.Point;
 import java.awt.Toolkit;
@@ -24,6 +25,7 @@ import javax.swing.AbstractAction;
 import javax.swing.ActionMap;
 import javax.swing.BoxLayout;
 import javax.swing.DefaultComboBoxModel;
+import javax.swing.Icon;
 import javax.swing.ImageIcon;
 import javax.swing.InputMap;
 import javax.swing.JButton;

+ 20 - 20
src/ui/view/Languages.java

@@ -31,12 +31,12 @@ public class Languages {
 			"Name:", "Browse Image", "Add Element", "Delete Element", "Cancel",
 			// Add PopUp Element (64-71)
 			"Add Element to Object", "Element Name:", "Provided Energy:", "Amount:",
-			"Please enter numbers in the Fields amount and providedEnergy", "No name", "Name already given", "Cancel",
+			"Please enter numbers in the Fields amount and Energy", "No name", "Name already given", "Cancel",
 			// Info for PropertyTable (72-82)
 			"Name", "Total Energy", "Manual", "Active", " is connected to", " with ID: ", "Edge: ", " to ",
 			"Current flow", "Max. Capacity", "Status",
 			// Info SimulationMenu (83-87)
-			"Simulate", "Simulation Speed:", "Algorithm:", "choose folder", "success" };
+			"Simulate", "Simulation Speed:", "Algorithm:", "non selected", "success" };
 
 	static String[] arrayES = {
 			// ToolBar (0-16)
@@ -73,7 +73,7 @@ public class Languages {
 			"Nombre", "Energia Total", "Manual", "Activo", " esta conectado a ", " con ID: ", "Canto: ", " a ",
 			"Corriente actual", "Capacidad Max.", "Estado",
 			// Info SimulationMenu (83-87)
-			"Simular", "Velocidad de Simulacion:", "Algoritmo:", "elija carpeta", "exito" };
+			"Simular", "Velocidad de Simulacion:", "Algoritmo:", "nada seleccionado", "exito" };
 
 	static String[] arrayDE = {
 			// ToolBar (0-16)
@@ -85,30 +85,30 @@ public class Languages {
 			// Graph (25-26)
 			"Nichts ", "Zurücksetzen",
 			// Warning PopUps(27-30)
-			"Warning", "Do you want to save your current data?", "Do you really want to delete the Category ",
-			"Please select a Category or an Object in order to delete something.",
+			"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.",
 			// Edit Edges Pop Up (31-34)
-			"Edit Showed Informations", "Show Total Energy of Objects", "Show Connection Properties", "Cancel",
+			"Gezeigte Informationen Ersetzen", "Gesamtenergie von Objekten zeigen", "Verbindungseigenschaften zeigen", "Abbrechen",
 			// Search/Replace Pop Up (35-45)
-			"Search for Objects", "Find", "Replace", "Direction", "Forward", "Backward", "Scope", "All", "Single",
-			"Replace All", "Close",
+			"Objekte suchen", "Suchen", "Ersetzen", "Richtung", "Vorwärts", "Rückwerts", "Scope", "Alle", "Einzeln",
+			"Alle Ersetzen", "Schließen",
 			// Edit Edges Pop Up (46-55)
-			"Edit Capacities of Edges", "Maximum Capacity:", "Change for all existing Edges only",
-			"Change for new created Edges only", "Change for all existing and new created Edges", "Cancel",
-			"Please select one of the options",
-			"Please enter a number greater or equal 0 in the Field for Maximum Capacity", "Edit Edge Capacities",
-			"(enter \"infinite\" for infinite Capacity)",
+			"Kapazitäten von Kanten bearbeiten", "Maximale 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",
+			"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)",
 			// Add PopUp Tree (56-63)
-			"Please enter a Name for Category ", "Please select a Category first before adding ", "Add Object Menu",
-			"Name:", "Browse Image", "Add Element", "Delete Element", "Cancel",
+			"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 Element to Object", "Element Name:", "Provided Energy:", "Amount:",
-			"Please enter numbers in the Fields amount and providedEnergy", "No name", "Name already given", "Cancel",
+			"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",
 			// Info for PropertyTable (72-82)
-			"Name", "Total Energy", "Manual", "Active", " is connected to", " with ID: ", "Edge: ", " to ",
-			"Current flow", "Max. Capacity", "Status",
+			"Name", "Gesamte Energie", "Manuell", "Aktive", " ist verbunden mit", " mit ID: ", "Kante: ", " nach ",
+			"aktueller Fluss", "Max. Kapazität", "Status",
 			// Info SimulationMenu (83-87)
-			"Simulate", "Simulation Speed:", "Algorithm:", "choose folder", "success" };
+			"Simulieren", "Simulationsgeschwindigkeit:", "Algorithmus:", "nichts ausgewählt", "Erfolg" };
 
 	static String[] arrayCZ = {
 			// ToolBar (0-16)

+ 20 - 2
src/ui/view/SimulationMenu.java

@@ -41,6 +41,8 @@ import java.awt.Dimension;
 import java.awt.GridBagConstraints;
 import java.awt.Insets;
 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;
@@ -93,6 +95,18 @@ public class SimulationMenu extends JMenuBar {
 		this.model = mod;
 		this.controller = cont;
 
+		// Algorithm ComboBox Action
+		algoCombo.addItemListener(new ItemListener() {
+
+			@Override
+			public void itemStateChanged(ItemEvent e) {
+
+				setAlgorithm(algosHash.get(e.getItem()));
+				controller.addTextToConsole("" + e.getItem());
+
+			}
+		});
+
 		// algoFolderButton Action
 		algoFolderButton.addActionListener(new ActionListener() {
 
@@ -110,6 +124,10 @@ public class SimulationMenu extends JMenuBar {
 				if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
 					algoCombo.removeAllItems();
 					File[] files = fileChooser.getSelectedFile().listFiles();
+					//Set Root Folder Path
+					root = new File(fileChooser.getCurrentDirectory().getPath());
+					controller.addTextToConsole("roor Path" + root.getPath());
+					
 					for (int i = 0; i < files.length; i++) {
 						if (files[i].toString()
 								.endsWith(".java") /*
@@ -121,10 +139,10 @@ public class SimulationMenu extends JMenuBar {
 							name = name.substring(0, tmpB);
 							algosHash.put(name, files[i]);
 							algoCombo.addItem(name);
-							root = new File(fileChooser.getCurrentDirectory().getPath());
-							setAlgorithm(files[i]);
+
 						}
 					}
+
 				}
 			}