Browse Source

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

# Conflicts:
#	src/tests/PraktikumHolonsTestAutoSaveControlle.java
Teh-Hai Julian Zheng 7 years ago
parent
commit
b8bac3ed8d

+ 0 - 1
src/classes/AbstractCpsObject.java

@@ -2,7 +2,6 @@ package classes;
 
 import java.awt.Color;
 import java.util.ArrayList;
-import ui.model.IdCounter;
 
 /**
  * The abstract class "CpsObject" represents any possible object in the system

+ 0 - 2
src/classes/CpsNode.java

@@ -2,8 +2,6 @@ package classes;
 
 import java.util.ArrayList;
 
-import ui.model.IdCounter;
-
 /**
  * The class "CpsNode" represents empty Objects in the system. They are just
  * nodes between Objects

+ 0 - 1
src/classes/HolonElement.java

@@ -2,7 +2,6 @@ package classes;
 
 import java.awt.Point;
 import java.util.LinkedList;
-import ui.model.IdCounterElem;
 
 /**
  * The class "HolonElement" represents any possible element that can be added to

+ 1 - 1
src/ui/model/IdCounter.java → src/classes/IdCounter.java

@@ -1,4 +1,4 @@
-package ui.model;
+package classes;
 
 /**
  * ID-Counter for all Cps Objects.

+ 1 - 1
src/ui/model/IdCounterElem.java → src/classes/IdCounterElem.java

@@ -1,4 +1,4 @@
-package ui.model;
+package classes;
 
 /**
  * ID-Counter for all Holon Elements.

+ 1 - 2
src/tests/PraktikumHolonsTestCanvasController.java

@@ -4,12 +4,11 @@ import classes.AbstractCpsObject;
 import classes.CpsEdge;
 import classes.HolonObject;
 import classes.HolonSwitch;
-
+import classes.IdCounter;
 import ui.controller.CanvasController;
 import ui.controller.CategoryController;
 import ui.controller.MultiPurposeController;
 import ui.model.Model;
-import ui.model.IdCounter;
 
 import org.junit.Test;
 import org.junit.Before;

+ 1 - 1
src/tests/PraktikumHolonsTestClasses.java

@@ -75,7 +75,7 @@ public class PraktikumHolonsTestClasses {
 		test3.setState(4);
 		assertTrue("Should be state 4", test3.getState() == 4);
 		assertTrue("Element not Found", test3.searchElement("Element") != null);
-		test1.setElements(new ArrayList<>());
+		test1.setElements(new ArrayList<HolonElement>());
 		assertTrue("Not Empty", !test1.checkIfPartiallySupplied(1));
 		test3.addElements(new HolonElement("Element2", 1, -10));
 		assertTrue("Not Partially Supplied", test3.checkIfPartiallySupplied(1));

+ 2 - 2
src/tests/PraktikumHolonsTestLoadAndStoreController.java

@@ -23,6 +23,7 @@ import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
+import classes.IdCounter;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -35,7 +36,6 @@ import ui.controller.MultiPurposeController;
 import ui.controller.ObjectController;
 import ui.controller.StoreController;
 import ui.model.Model;
-import ui.model.IdCounter;
 import ui.view.UnitGraph;
 
 public class PraktikumHolonsTestLoadAndStoreController {
@@ -107,7 +107,7 @@ public class PraktikumHolonsTestLoadAndStoreController {
 			assertTrue("Number of Categories does not match", model.getCategories().size() == i + 3);
 			assertTrue("Category was not created", mp.searchCat(adapter.generate(i)) != null);
 			for (int j = 1; j <= 10; j++) {
-				cg.addNewHolonObject(mp.searchCat(adapter.generate(i)), adapter.generate(j), new ArrayList<>(), "");
+				cg.addNewHolonObject(mp.searchCat(adapter.generate(i)), adapter.generate(j), new ArrayList<HolonElement>(), "");
 				assertTrue("Number of Objects does not match",
 						mp.searchCat(adapter.generate(i)).getObjects().size() == j);
 				assertTrue("Object was not created", mp.searchCat(adapter.generate(i)).getObjects().get(j - 1) != null);

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

@@ -246,7 +246,7 @@ public class Control {
 		simulationManager.setCanvas(can);
 	}
 
-	private void autoSave() throws IOException {
+	public void autoSave() throws IOException {
 		autoSaveController.increaseAutoSaveNr();
 		storeController.writeCanvasFile(autoPath + autoSaveController.getAutoSaveNr());
 		if (autoSaveController.allowed()) {

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

@@ -21,8 +21,8 @@ import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonTransformer;
+import classes.IdCounter;
 import ui.model.Model;
-import ui.model.IdCounter;
 
 public class LoadController {
 

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

@@ -15,8 +15,8 @@ import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonTransformer;
+import classes.IdCounter;
 import ui.model.Model;
-import ui.model.IdCounter;
 
 public class StoreController {
 

+ 0 - 5
src/ui/view/AddObjectPopUp.java

@@ -199,11 +199,6 @@ public class AddObjectPopUp extends JDialog {
 					addElement.setActualCps(toEdit);
 					addElement.setVisible(true);
 					HolonElement hl = addElement.getElement();
-					
-					if (hl != null) {
-						addElement(hl);
-					}
-
 					hl.setSav(givenCategory);
 					hl.setObj(objectName.getText());
 					addElement(hl);

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

@@ -8,6 +8,8 @@ import javax.swing.table.DefaultTableModel;
  * @author Gruppe14
  */
 public class DefaulTable extends DefaultTableModel {
+
+	private static final long serialVersionUID = 1L;
 	private boolean[][] editableCells; // 2d array to represent rows and
 										// columns
 

+ 132 - 142
src/ui/view/GUI.java

@@ -68,16 +68,18 @@ import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonTransformer;
+import classes.IdCounter;
+import classes.IdCounterElem;
 import ui.controller.Control;
-import ui.model.Model;
-import ui.model.IdCounter;
-import ui.model.IdCounterElem;;
+import ui.model.Model;;
 
 /**
  * Graphical User Interface.
+ * 
  * @author Gruppe14
  * 
- * @param <E> Generic
+ * @param <E>
+ *            Generic
  */
 public class GUI<E> implements CategoryListener {
 
@@ -87,9 +89,9 @@ public class GUI<E> implements CategoryListener {
 
 	private final JMenuBar menuBar = new JMenuBar();
 	private final JMenu mnNewMenu = new JMenu("File");
-	private final JMenu mnNewMenu_1 = new JMenu("Edit");
-	private final JMenu mnNewMenu_2 = new JMenu("Options");
-	private final JMenu mnNewMenu_3 = new JMenu("View");
+	private final JMenu mnNewMenuEdit = new JMenu("Edit");
+	private final JMenu mnNewMenuOptions = new JMenu("Options");
+	private final JMenu mnNewMenuView = new JMenu("View");
 	private final JMenu mnHelp = new JMenu("Help");
 	private final JMenuItem mntmOpen = new JMenuItem("Open");
 	private final JMenuItem mntmNew = new JMenuItem("New");
@@ -97,11 +99,11 @@ public class GUI<E> implements CategoryListener {
 	private final JMenuItem aboutUs = new JMenuItem("About Us");
 	private final JMenuItem canvasSize = new JMenuItem("View Size");
 	private final JSplitPane splitPane = new JSplitPane();
-	private final JSplitPane splitPane_1 = new JSplitPane();
-	private final JSplitPane splitPane_tree_console = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+	private final JSplitPane splitPane1 = new JSplitPane();
+	private final JSplitPane splitPaneTreeConsole = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
 
 	private final JScrollPane canvasSP = new JScrollPane();
-	private final JScrollPane scrollPane_1 = new JScrollPane();
+	private final JScrollPane scrollPane1 = new JScrollPane();
 	private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
 	private JPopupMenu popmenuEdit = new JPopupMenu();
 	private JMenuItem editItem = new JMenuItem("Edit Object");
@@ -117,12 +119,13 @@ public class GUI<E> implements CategoryListener {
 	private final JTree tree = new JTree();
 	/******************************************
 	 ************* Right Container*************
-	 ******************************************/
-	// Right Container: here comes the information about the HolonObject, such
-	// as HolonElements Information, Properties and Consumption/Production graph
-
-	private final JSplitPane split_HolonEl_Pro = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
-	private final JSplitPane split_Graph_HolonEl = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+	 ******************************************
+	 * Right Container: here comes the information about the HolonObject, such
+	 * as HolonElements Information, Properties and Consumption/Production
+	 * graph.
+	 **/
+	private final JSplitPane splitHolonElPro = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+	private final JSplitPane splitGraphHolonEl = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
 
 	// In this section are all the Holonelements that correspond to the clicked
 	// HolonObject with consumption/production, name and amount.
@@ -140,9 +143,7 @@ public class GUI<E> implements CategoryListener {
 	// Table for Properties --> Cell with (0,1) is editable by CpsObjt and
 	// Cell(3,1) is editable by Edges
 	private JTable tableProperties = new JTable() {
-		/**
-		 * 
-		 */
+
 		private static final long serialVersionUID = 1L;
 
 		@Override
@@ -182,7 +183,7 @@ public class GUI<E> implements CategoryListener {
 	private AddElementPopUp addElementPopUp;
 
 	private final JPanel panel = new JPanel();
-	private final JPanel panel_HolonEl = new JPanel();
+	private final JPanel panelHolonEl = new JPanel();
 	private final JComboBox comboBox = new JComboBox();
 	// private final JComboBox comboBoxGraph = new JComboBox();
 
@@ -207,22 +208,21 @@ public class GUI<E> implements CategoryListener {
 	private Console console = new Console();
 	private MyCanvas canvas;
 	private UnitGraph unitGraph;
-	private final JSplitPane splitPane_3 = new JSplitPane();
+	private final JSplitPane splitPane3 = new JSplitPane();
 	private final JSlider sizeSlider = new JSlider();
 	private final JLabel lblImageSize = new JLabel("Image Size");
 	// Time Stuff
 	private TimePanel timePanel;
 	// Coord for all Cells with text
-	private int yTHIS;
-	private int xTHIS;
+	private int yThis;
+	private int xThis;
 	// Coord for all Cells with boolean values (checkbox)
-	private int yBTHIS;
-	private int xBTHIS;
+	private int yBTis;
+	private int xBThis;
 	// Coord for the Edit-Modus in the PropertieTable
 	private int yProThis;
 	private int xProThis;
 	private AbstractCpsObject temp = null;
-	private final JButton btnTest = new JButton("test");
 	private final JMenuItem mntmUndo = new JMenuItem("Undo");
 	private final JMenuItem mntmRedo = new JMenuItem("Redo");
 	private final JMenuItem mntmEditEdges = new JMenuItem("Edit Edges");
@@ -232,6 +232,9 @@ public class GUI<E> implements CategoryListener {
 
 	/**
 	 * Create the application.
+	 * 
+	 * @param control
+	 *            the Controller
 	 */
 	public GUI(Control control) {
 		this.controller = control;
@@ -278,9 +281,6 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control Z"), cntrlZDown);
 		actionMap.put(cntrlZDown, new AbstractAction() {
 
-			/**
-			 * 
-			 */
 			private static final long serialVersionUID = 1L;
 
 			@Override
@@ -304,9 +304,9 @@ public class GUI<E> implements CategoryListener {
 					}
 					unitGraph.empty();
 					controller.addTextToConsole("undo", Color.BLACK, 12, false, false, true);
-				} catch (IOException f) {
+				} catch (IOException eex) {
 					// TODO Auto-generated catch block
-					f.printStackTrace();
+					eex.printStackTrace();
 				}
 			}
 		});
@@ -315,9 +315,6 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control Y"), cntrlYDown);
 		actionMap.put(cntrlYDown, new AbstractAction() {
 
-			/**
-			 * 
-			 */
 			private static final long serialVersionUID = 1L;
 
 			@Override
@@ -341,9 +338,9 @@ public class GUI<E> implements CategoryListener {
 					}
 					unitGraph.empty();
 					controller.addTextToConsole("redo", Color.BLACK, 12, false, false, true);
-				} catch (IOException f) {
+				} catch (IOException ex) {
 					// TODO Auto-generated catch block
-					f.printStackTrace();
+					ex.printStackTrace();
 				}
 			}
 		});
@@ -351,9 +348,7 @@ public class GUI<E> implements CategoryListener {
 		String cntrlADown = "controlA";
 		inputMap.put(KeyStroke.getKeyStroke("control A"), cntrlADown);
 		actionMap.put(cntrlADown, new AbstractAction() {
-			/**
-			 * 
-			 */
+
 			private static final long serialVersionUID = 1L;
 
 			@Override
@@ -369,9 +364,7 @@ public class GUI<E> implements CategoryListener {
 		String delDown = "delete";
 		inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false), delDown);
 		actionMap.put(delDown, new AbstractAction() {
-			/**
-			 * 
-			 */
+
 			private static final long serialVersionUID = 1L;
 
 			@Override
@@ -380,15 +373,6 @@ public class GUI<E> implements CategoryListener {
 					controller.delCanvasObject(cps);
 				}
 				model.getSelectedCpsObjects().clear();
-				/*
-				 * controller.setSelectedObjectID(0); for (int i =
-				 * tableModelHolonElementMulti.getRowCount() - 1; i > -1; i--) {
-				 * tableModelHolonElementMulti.removeRow(i); } for (int i =
-				 * tableModelHolonElementSingle.getRowCount() - 1; i > -1; i--)
-				 * { tableModelHolonElementSingle.removeRow(i); } for (int i =
-				 * tableModelProperties.getRowCount() - 1; i > -1; i--) {
-				 * tableModelProperties.removeRow(i); }
-				 */
 				canvas.repaint();
 				unitGraph.empty();
 			}
@@ -398,9 +382,6 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control F"), cntrlFDown);
 		actionMap.put(cntrlFDown, new AbstractAction() {
 
-			/**
-			 * 
-			 */
 			private static final long serialVersionUID = 1L;
 
 			@Override
@@ -415,9 +396,6 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
 		actionMap.put(cntrlCDown, new AbstractAction() {
 
-			/**
-			 * 
-			 */
 			private static final long serialVersionUID = 1L;
 
 			@Override
@@ -435,9 +413,6 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control V"), cntrlVDown);
 		actionMap.put(cntrlVDown, new AbstractAction() {
 
-			/**
-			 * 
-			 */
 			private static final long serialVersionUID = 1L;
 
 			@Override
@@ -451,9 +426,6 @@ public class GUI<E> implements CategoryListener {
 		inputMap.put(KeyStroke.getKeyStroke("control X"), cntrlXDown);
 		actionMap.put(cntrlXDown, new AbstractAction() {
 
-			/**
-			 * 
-			 */
 			private static final long serialVersionUID = 1L;
 
 			@Override
@@ -481,11 +453,11 @@ public class GUI<E> implements CategoryListener {
 
 		mnNewMenu.add(mntmSave);
 
-		menuBar.add(mnNewMenu_1);
+		menuBar.add(mnNewMenuEdit);
 
-		mnNewMenu_1.add(mntmUndo);
+		mnNewMenuEdit.add(mntmUndo);
 
-		mnNewMenu_1.add(mntmRedo);
+		mnNewMenuEdit.add(mntmRedo);
 		mntmFindReplace.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				try {
@@ -493,28 +465,28 @@ public class GUI<E> implements CategoryListener {
 					SearchPopUp dialog = new SearchPopUp(controller, canvas);
 					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
 					dialog.setVisible(true);
-				} catch (Exception e1) {
-					e1.printStackTrace();
+				} catch (Exception ex) {
+					ex.printStackTrace();
 				}
 			}
 		});
 
-		mnNewMenu_1.add(mntmFindReplace);
+		mnNewMenuEdit.add(mntmFindReplace);
 		mntmEditShowedInformation.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				try {
 					ShowedInformationPopUp dialog = new ShowedInformationPopUp(canvas);
 					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
 					dialog.setVisible(true);
-				} catch (Exception e1) {
-					e1.printStackTrace();
+				} catch (Exception ex) {
+					ex.printStackTrace();
 				}
 			}
 		});
 
-		mnNewMenu_1.add(mntmEditShowedInformation);
+		mnNewMenuEdit.add(mntmEditShowedInformation);
 
-		menuBar.add(mnNewMenu_2);
+		menuBar.add(mnNewMenuOptions);
 		mntmEditEdges.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				EditEdgesPopUp edgePopUp = new EditEdgesPopUp();
@@ -524,9 +496,9 @@ public class GUI<E> implements CategoryListener {
 			}
 		});
 
-		mnNewMenu_2.add(mntmEditEdges);
+		mnNewMenuOptions.add(mntmEditEdges);
 
-		mnNewMenu_2.add(mntmResetCategory);
+		mnNewMenuOptions.add(mntmResetCategory);
 		mntmResetCategory.addActionListener(new ActionListener() {
 
 			@Override
@@ -541,9 +513,9 @@ public class GUI<E> implements CategoryListener {
 			}
 		});
 
-		menuBar.add(mnNewMenu_3);
+		menuBar.add(mnNewMenuView);
 
-		mnNewMenu_3.add(canvasSize);
+		mnNewMenuView.add(canvasSize);
 		canvasSize.addActionListener(new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
@@ -559,7 +531,7 @@ public class GUI<E> implements CategoryListener {
 			}
 		});
 
-		mnNewMenu_3.add(splitPane_3);
+		mnNewMenuView.add(splitPane3);
 
 		sizeSlider.setMinimum(15);
 		sizeSlider.setMaximum(115);
@@ -568,13 +540,12 @@ public class GUI<E> implements CategoryListener {
 			public void stateChanged(ChangeEvent e) {
 				controller.setScale(sizeSlider.getValue());
 				tree.setRowHeight(50);
-				canvas.objectSelectionHighlighting();
 				canvas.repaint();
 			}
 		});
-		splitPane_3.setRightComponent(sizeSlider);
+		splitPane3.setRightComponent(sizeSlider);
 
-		splitPane_3.setLeftComponent(lblImageSize);
+		splitPane3.setLeftComponent(lblImageSize);
 
 		menuBar.add(mnHelp);
 
@@ -599,13 +570,13 @@ public class GUI<E> implements CategoryListener {
 		tableHolonElement.setColumnSelectionAllowed(true);
 		tableHolonElementScrollPane.setViewportView(tableHolonElement);
 		scrollElements.setLayout(new BorderLayout(0, 0));
-		scrollElements.add(panel_HolonEl, BorderLayout.NORTH);
+		scrollElements.add(panelHolonEl, BorderLayout.NORTH);
 		scrollElements.add(tableHolonElementScrollPane);
-		panel_HolonEl.setLayout(new BoxLayout(panel_HolonEl, BoxLayout.X_AXIS));
+		panelHolonEl.setLayout(new BoxLayout(panelHolonEl, BoxLayout.X_AXIS));
 		toolBarHolonEl.add(btnAddHolEL);
 		toolBarHolonEl.add(btnDelHolEL);
 		toolBarHolonEl.setFloatable(false);
-		panel_HolonEl.add(toolBarHolonEl);
+		panelHolonEl.add(toolBarHolonEl);
 
 		// Set up of the Properties section
 		Object[] colNames = { "Field", "Information" };
@@ -739,8 +710,8 @@ public class GUI<E> implements CategoryListener {
 				// if any HolonElement is double-clicked --> Edit-Mode started
 				// for selected HolonElement
 				if (e.getClickCount() == 2) {
-					yTHIS = e.getY();
-					xTHIS = e.getX();
+					yThis = e.getY();
+					xThis = e.getX();
 				}
 				// for single click and empty slot
 				if (e.getClickCount() == 1 && ele == null) {
@@ -748,8 +719,8 @@ public class GUI<E> implements CategoryListener {
 					holonEleNamesDisplayed = "None ";
 				}
 				elementGraph.setText(holonEleNamesDisplayed);
-				yBTHIS = e.getY();
-				xBTHIS = e.getX();
+				yBTis = e.getY();
+				xBThis = e.getX();
 
 			}
 		});
@@ -761,14 +732,14 @@ public class GUI<E> implements CategoryListener {
 			@Override
 			public void propertyChange(PropertyChangeEvent evt) {
 				try {
-					int yMouse = yTHIS;
-					int yBMouse = yBTHIS;
+					int yMouse = yThis;
+					int yBMouse = yBTis;
 					int selectedValueY = (int) Math.floor(yMouse / 16);
 					int selectedValueBY = (int) Math.floor(yBMouse / 16);
 					// for multi-selection mode
 					if (model.getSelectedCpsObjects().size() > 1) {
-						int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 6));
-						int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 6));
+						int selectedValueX = (int) Math.floor(xThis / (tableHolonElement.getWidth() / 6));
+						int selectedValueBX = (int) Math.floor(xBThis / (tableHolonElement.getWidth() / 6));
 						if (getHolonObj(yMouse) != null) {
 							// For last column (boolean with a checkbox)
 							if (selectedValueBX == 5) {
@@ -800,8 +771,8 @@ public class GUI<E> implements CategoryListener {
 						}
 					} // For single-selection mode
 					else if (model.getSelectedCpsObjects().size() == 1) {
-						int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 5));
-						int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 5));
+						int selectedValueX = (int) Math.floor(xThis / (tableHolonElement.getWidth() / 5));
+						int selectedValueBX = (int) Math.floor(xBThis / (tableHolonElement.getWidth() / 5));
 						if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
 							// For last column (boolean with a checkbox)
 							if (selectedValueBX == 4) {
@@ -1001,7 +972,7 @@ public class GUI<E> implements CategoryListener {
 						canvas.repaint();
 						dragging = false;
 					}
-				} catch (Exception e2) {
+				} catch (Exception eex) {
 				}
 				frmCyberPhysical.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
 			}
@@ -1066,7 +1037,7 @@ public class GUI<E> implements CategoryListener {
 							}
 						}
 					}
-				} catch (Exception e2) {
+				} catch (Exception eex) {
 				}
 			}
 		});
@@ -1080,9 +1051,9 @@ public class GUI<E> implements CategoryListener {
 				addObjectPopUP.setVisible(true);
 			}
 		});
-		scrollPane_1.setViewportView(tree);
+		scrollPane1.setViewportView(tree);
 
-		scrollPane_1.setColumnHeaderView(panel);
+		scrollPane1.setColumnHeaderView(panel);
 		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
 		toolBar.setFloatable(false);
 
@@ -1216,11 +1187,11 @@ public class GUI<E> implements CategoryListener {
 						deleteRows(tableModelHolonElementMulti);
 					}
 					// For Objects the only editable cell is the name
-					ArrayList<CpsEdge> temp_array = temp.getConnections();
+					ArrayList<CpsEdge> tempArray = temp.getConnections();
 					// If the clicked object has connections
-					if (!temp_array.isEmpty()) {
+					if (!tempArray.isEmpty()) {
 						boolean first = true;
-						for (CpsEdge temp2 : temp_array) {
+						for (CpsEdge temp2 : tempArray) {
 							if (first) {
 								first = false;
 								if (temp.getID() != temp2.getA().getID()) {
@@ -1343,7 +1314,6 @@ public class GUI<E> implements CategoryListener {
 				unitGraph.empty();
 				elementGraph.setText("None ");
 				canvas.tempCps = null;
-				canvas.objectSelectionHighlighting();
 				canvas.repaint();
 				IdCounter.resetCounter();
 				IdCounterElem.resetCounter();
@@ -1504,23 +1474,23 @@ public class GUI<E> implements CategoryListener {
 				unitGraph.repaint();
 			}
 		});
-		splitPane.setRightComponent(splitPane_1);
+		splitPane.setRightComponent(splitPane1);
 		splitPane.setDividerLocation(200);
-		splitPane_1.setDividerLocation(500);
-		splitPane_tree_console.setDividerLocation(500);
-
-		splitPane.setLeftComponent(splitPane_tree_console);
-		splitPane_tree_console.setLeftComponent(scrollPane_1);
-		splitPane_tree_console.setRightComponent(console);
-		splitPane_1.setLeftComponent(canvasSP);
-		splitPane_1.setRightComponent(split_HolonEl_Pro);
-
-		split_HolonEl_Pro.setDividerLocation(400);
-		split_HolonEl_Pro.setTopComponent(split_Graph_HolonEl);
-		split_HolonEl_Pro.setBottomComponent(scrollProperties);
-		split_Graph_HolonEl.setDividerLocation(150);
-		split_Graph_HolonEl.setTopComponent(scrollGraph);
-		split_Graph_HolonEl.setBottomComponent(scrollElements);
+		splitPane1.setDividerLocation(500);
+		splitPaneTreeConsole.setDividerLocation(500);
+
+		splitPane.setLeftComponent(splitPaneTreeConsole);
+		splitPaneTreeConsole.setLeftComponent(scrollPane1);
+		splitPaneTreeConsole.setRightComponent(console);
+		splitPane1.setLeftComponent(canvasSP);
+		splitPane1.setRightComponent(splitHolonElPro);
+
+		splitHolonElPro.setDividerLocation(400);
+		splitHolonElPro.setTopComponent(splitGraphHolonEl);
+		splitHolonElPro.setBottomComponent(scrollProperties);
+		splitGraphHolonEl.setDividerLocation(150);
+		splitGraphHolonEl.setTopComponent(scrollGraph);
+		splitGraphHolonEl.setBottomComponent(scrollElements);
 		canvasSP.setViewportView(canvas);
 		canvasSP.setColumnHeaderView(simMenu);
 		simMenu.setBackground(new Color(240, 240, 240));
@@ -1530,20 +1500,25 @@ public class GUI<E> implements CategoryListener {
 		scrollGraph.setBorder(null);
 		scrollElements.setBorder(null);
 		splitPane.setBorder(null);
-		splitPane_1.setBorder(null);
-		splitPane_tree_console.setBorder(null);
-		split_HolonEl_Pro.setBorder(null);
-		split_Graph_HolonEl.setBorder(null);
-		panel_HolonEl.setBorder(null);
+		splitPane1.setBorder(null);
+		splitPaneTreeConsole.setBorder(null);
+		splitHolonElPro.setBorder(null);
+		splitGraphHolonEl.setBorder(null);
+		panelHolonEl.setBorder(null);
 
 		tableHolonElementScrollPane.setBorder(null);
 
 		frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
 	}
 
-	/*
+	/**
 	 * adds a specific object type to selected Category also handles input
-	 * windows and illegal inputs
+	 * windows and illegal inputs.
+	 * 
+	 * @param objType
+	 *            type of the Object
+	 * @param selectedNode
+	 *            The selected Node
 	 */
 	public void addObjectAction(String objType, DefaultMutableTreeNode selectedNode) {
 		if (selectedNode == null) {
@@ -1572,25 +1547,26 @@ public class GUI<E> implements CategoryListener {
 	}
 
 	/**
-	 * reloads the Categories from Model
+	 * reloads the Categories from Model.
+	 * 
+	 * @param categories
+	 *            the current categories
 	 */
 	public void updateCategories(final ArrayList<Category> categories) {
 		tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Categories") {
-			/**
-			 * 
-			 */
+
 			private static final long serialVersionUID = 1L;
 
 			{
-				DefaultMutableTreeNode node_1;
+				DefaultMutableTreeNode node1;
 				for (Category c : categories) {
-					node_1 = new DefaultMutableTreeNode(c.getName());
+					node1 = new DefaultMutableTreeNode(c.getName());
 
 					// kann eventuell umgeändert werden
 					for (AbstractCpsObject obj : c.getObjects()) {
-						node_1.add(new DefaultMutableTreeNode(obj.getObjName()));
+						node1.add(new DefaultMutableTreeNode(obj.getObjName()));
 					}
-					add(node_1);
+					add(node1);
 				}
 
 			}
@@ -1598,7 +1574,10 @@ public class GUI<E> implements CategoryListener {
 	}
 
 	/**
+	 * When changes are made to the Categories.
 	 * 
+	 * @param categories
+	 *            the Categories
 	 */
 	public void onChange(ArrayList<Category> categories) {
 		DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
@@ -1607,15 +1586,16 @@ public class GUI<E> implements CategoryListener {
 	}
 
 	/**
+	 * Get the Frame.
 	 * 
-	 * @return
+	 * @return the Frame
 	 */
 	public JFrame getFrmCyberPhysical() {
 		return frmCyberPhysical;
 	}
 
 	/**
-	 * Getter for selected CpsObject
+	 * Getter for selected CpsObject.
 	 * 
 	 * @return selected CpsObject
 	 */
@@ -1626,7 +1606,7 @@ public class GUI<E> implements CategoryListener {
 	}
 
 	/**
-	 * Search for actual selected HolonElement
+	 * Search for actual selected HolonElement.
 	 * 
 	 * @param obj
 	 *            selected HolonObject, if obj==null means multi-selection
@@ -1693,9 +1673,10 @@ public class GUI<E> implements CategoryListener {
 	}
 
 	/**
-	 * Search for clicked HolonObject through the mouse's y-Coord
+	 * Search for clicked HolonObject through the mouse's y-Coord.
 	 * 
 	 * @param yValue
+	 *            the Y Coordination
 	 * @return clicked HolonObject
 	 */
 	private HolonObject getHolonObj(int yValue) {
@@ -1709,7 +1690,7 @@ public class GUI<E> implements CategoryListener {
 
 	/**
 	 * Update the HolonElement Table, that means erase all rows and add the new
-	 * rows with new data
+	 * rows with new data.
 	 */
 	private void refreshTableHolonElement() {
 		// Update of the Information about the HolonElements - only for
@@ -1727,7 +1708,10 @@ public class GUI<E> implements CategoryListener {
 	}
 
 	/**
-	 * Erase all information of the HolonElement Model
+	 * Erase all information of the HolonElement Model.
+	 * 
+	 * @param t
+	 *            the Table
 	 */
 	private void deleteRows(PropertyTable t) {
 		if (t.getRowCount() > 0) {
@@ -1739,9 +1723,9 @@ public class GUI<E> implements CategoryListener {
 
 	/**
 	 * Add the Information of the given ArrayList in the HolonElement Model as
-	 * Name,Energy and Amount
+	 * Name,Energy and Amount.
 	 * 
-	 * @param elements
+	 * @param objects
 	 *            ArrayList to be displayed
 	 */
 	private void fillElementTable(ArrayList<AbstractCpsObject> objects) {
@@ -1767,7 +1751,7 @@ public class GUI<E> implements CategoryListener {
 	}
 
 	/**
-	 * Update the information concerning properties of the selected CpsObject
+	 * Update the information concerning properties of the selected CpsObject.
 	 */
 	private void refreshTableProperties() {
 		if (model.getSelectedCpsObjects().size() == 1) {
@@ -1780,6 +1764,12 @@ public class GUI<E> implements CategoryListener {
 		}
 	}
 
+	/**
+	 * Adds a Popup.
+	 * 
+	 * @param component Component
+	 * @param popup PopupMenu
+	 */
 	private static void addPopup(Component component, final JPopupMenu popup) {
 		component.addMouseListener(new MouseAdapter() {
 			public void mousePressed(MouseEvent e) {

+ 18 - 6
src/ui/view/Main.java

@@ -9,27 +9,39 @@ import javax.swing.UnsupportedLookAndFeelException;
 import ui.controller.*;
 import ui.model.*;
 
+/**
+ * The main Class in this Program. The GUI is created in this Class.
+ * 
+ * @author Gruppe14
+ * 
+ */
 public class Main {
 
+	/**
+	 * main method of this program.
+	 * 
+	 * @param args
+	 *            standard
+	 */
 	public static void main(String[] args) {
 
 		// *Design
 		try {
 			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
-				| UnsupportedLookAndFeelException e1) {
+				| UnsupportedLookAndFeelException e) {
 			// TODO Auto-generated catch block
-			e1.printStackTrace();
+			e.printStackTrace();
 		}
 
 		EventQueue.invokeLater(new Runnable() {
 			public void run() {
 				try {
-					Model MODEL = new Model();
-					Control CONTROL = new Control(MODEL);
-					GUI VIEW = new GUI(CONTROL);
+					Model model = new Model();
+					Control control = new Control(model);
+					GUI view = new GUI(control);
 
-					VIEW.getFrmCyberPhysical().setVisible(true);
+					view.getFrmCyberPhysical().setVisible(true);
 
 				} catch (Exception e) {
 					e.printStackTrace();

+ 64 - 47
src/ui/view/MyCanvas.java

@@ -15,6 +15,7 @@ import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
 import java.awt.geom.Line2D;
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Timer;
 import java.util.TimerTask;
@@ -34,10 +35,13 @@ import classes.HolonSwitch;
 import ui.controller.Control;
 import ui.model.Model;
 
+/**
+ * This Class is the Canvas. All Objects will be visualized here
+ * 
+ * @author Gruppe14
+ */
 public class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
-	/**
-	 * 
-	 */
+
 	private static final long serialVersionUID = 1L;
 	private Image img = null; // Contains the image to draw on MyCanvas
 	private int x = 0;
@@ -51,7 +55,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	private float scalediv20;
 
 	ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
-	ArrayList<AbstractCpsObject> TempSelected = new ArrayList<AbstractCpsObject>();
+	ArrayList<AbstractCpsObject> tempSelected = new ArrayList<AbstractCpsObject>();
 
 	private boolean[] showedInformation = new boolean[3];
 	private boolean dragging = false; // for dragging
@@ -60,7 +64,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	private boolean click = false; // for double click
 	private boolean doMark = false; // for double click
 	public AbstractCpsObject tempCps = null;
-	private Rectangle selectRect = new Rectangle();
 	private CpsEdge edgeHighlight = null;
 
 	// PopUpMenu
@@ -77,6 +80,14 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	// contains the value of the Capacity for new created Edges
 	private float edgeCapacity;
 
+	/**
+	 * Constructor.
+	 * 
+	 * @param mod
+	 *            the Model
+	 * @param control
+	 *            the Controller
+	 */
 	public MyCanvas(Model mod, Control control) {
 		this.add(objectTT);
 		this.controller = control;
@@ -107,7 +118,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				}
 				model.getSelectedCpsObjects().clear();
 				tempCps = null;
-				selectRect.setRect(0, 0, 0, 0);
 				repaint();
 			}
 		});
@@ -143,10 +153,10 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	}
 
 	/**
-	 * Paints all Components on the Canvas
-	 * 
-	 * @param Graphics
+	 * Paints all Components on the Canvas.
 	 * 
+	 * @param g
+	 *            Graphics
 	 */
 	public void paintComponent(Graphics g) {
 		String maxCap;
@@ -195,7 +205,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		}
 
 		// Highlighted Edge
-		if (model.getSelectedObjectID() > 0 || !model.getSelectedCpsObjects().isEmpty() || !TempSelected.isEmpty()) {
+		if (model.getSelectedObjectID() > 0 || !model.getSelectedCpsObjects().isEmpty() || !tempSelected.isEmpty()) {
 			g2.setColor(Color.BLUE);
 			for (CpsEdge con : model.getEdgesOnCanvas()) {
 				if (con.getFlow() <= con.getCapacity()) {
@@ -204,10 +214,10 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 					g2.setStroke(new BasicStroke(2));
 				}
 				if (con.getA().getID() == model.getSelectedObjectID()
-						|| model.getSelectedCpsObjects().contains(con.getA()) || TempSelected.contains(con.getA())
+						|| model.getSelectedCpsObjects().contains(con.getA()) || tempSelected.contains(con.getA())
 						|| con.getB().getID() == model.getSelectedObjectID()
 						|| model.getSelectedCpsObjects().contains(con.getB())
-						|| TempSelected.contains(con.getB()) && con != edgeHighlight) {
+						|| tempSelected.contains(con.getB()) && con != edgeHighlight) {
 					g2.drawLine(con.getA().getPosition().x + controller.getScaleDiv2(),
 							con.getA().getPosition().y + controller.getScaleDiv2(),
 							con.getB().getPosition().x + controller.getScaleDiv2(),
@@ -265,7 +275,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 
 			// node image
 			if (cps instanceof CpsNode && (cps == tempCps || model.getSelectedCpsObject() == cps
-					|| model.getSelectedCpsObjects().contains(cps) || TempSelected.contains(cps))) {
+					|| model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps))) {
 				img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
 			} else {
 				if (cps instanceof HolonSwitch) {
@@ -276,8 +286,8 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 					}
 				}
 				// Highlighting
-				if ((cps == tempCps && model.getSelectedCpsObjects().size() == 0 && TempSelected.size() == 0)
-						|| model.getSelectedCpsObjects().contains(cps) || TempSelected.contains(cps)) {
+				if ((cps == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
+						|| model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps)) {
 					g2.setColor(Color.BLUE);
 					g2.fillRect((int) (cps.getPosition().x - scalediv20), (int) (cps.getPosition().y - scalediv20),
 							(int) (controller.getScale() + (scalediv20 * 2)),
@@ -382,9 +392,8 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			sx = e.getX();
 			sy = e.getY();
 			doMark = true;
-		}		
-		// Object Selection Highlighting (selectRect)
-		objectSelectionHighlighting();
+		}
+
 
 		repaint();
 	}
@@ -402,6 +411,14 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			model.getSelectedCpsObjects().clear();
 			controller.addSelectedObject(tempCps);
 		}
+		if (dragged == true) {
+			try {
+				controller.autoSave();
+			} catch (IOException ex) {
+				// TODO Auto-generated catch block
+				ex.printStackTrace();
+			}
+		}
 		dragged = false;
 
 		// Rightclick List
@@ -424,16 +441,16 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 
 		if (doMark) {
 			doMark = false;
-			for (AbstractCpsObject cps : TempSelected) {
+			for (AbstractCpsObject cps : tempSelected) {
 				if (!model.getSelectedCpsObjects().contains(cps)) {
 					controller.addSelectedObject(cps);
 				}
 			}
-			TempSelected.clear();
+			tempSelected.clear();
 		}
-		
+
 		if (doubleClick() && tempCps != null && tempCps instanceof HolonSwitch) {
-			((HolonSwitch)tempCps).switchState();
+			((HolonSwitch) tempCps).switchState();
 		}
 
 		controller.calculateStateForTimeStep(model.getCurIteration());
@@ -476,7 +493,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				yDist = y - tempCps.getPosition().y;
 
 				tempCps.setPosition(x, y); // Drag Position
-				selectRect.setLocation(x - (controller.getScale() / 20), y - (controller.getScale() / 20)); // Highlighting-Position
 				// TipText Position and name
 				objectTT.setTipText(tempCps.getName() + ", " + tempCps.getID());
 				objectTT.setLocation(x, y + controller.getScale());
@@ -501,14 +517,14 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 					}
 				}
 				repaint();
-			} catch (Exception e2) {
+			} catch (Exception eex) {
 
 			}
 		}
 
 		// Mark Objects
 		if (doMark) {
-			TempSelected.clear();
+			tempSelected.clear();
 			for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 				int x1 = sx, x2 = x, y1 = sy, y2 = y;
 
@@ -523,7 +539,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				if (x1 <= cps.getPosition().x + model.getScaleDiv2() && y1 <= cps.getPosition().y + model.getScaleDiv2()
 						&& x2 >= cps.getPosition().x + model.getScaleDiv2()
 						&& y2 >= cps.getPosition().y + model.getScaleDiv2()) {
-					TempSelected.add(cps);
+					tempSelected.add(cps);
 
 				}
 			}
@@ -557,24 +573,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	}
 
 	/**
-	 * Sets the Highlighting of the Selected Object
-	 */
-	public void objectSelectionHighlighting() {
-		if (tempCps != null) {
-			selectRect.setBounds(tempCps.getPosition().x - (controller.getScale() / 20),
-					tempCps.getPosition().y - (controller.getScale() / 20),
-					controller.getScale() + ((controller.getScale() / 20) * 2),
-					controller.getScale() + ((controller.getScale() / 20) * 2));
-
-			controller.setSelectedObjectID(tempCps.getID());
-		} else {
-			controller.setSelectedObjectID(0);
-			selectRect.setRect(0, 0, 0, 0);
-		}
-	}
-
-	/**
-	 * Draws or Deletes an Edge
+	 * Draws or Deletes an Edge.
 	 */
 	private void drawDeleteEdge() {
 		boolean node = true;
@@ -664,12 +663,11 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			controller.delCanvasObject(tempCPS);
 			tempCPS = null;
 			tempCps = null;
-			objectSelectionHighlighting();
 		}
 	}
 
 	/**
-	 * Checks if the mouse is on an Edge
+	 * Checks if the mouse is on an Edge.
 	 * 
 	 * @param x
 	 *            Position of the Mouse
@@ -708,7 +706,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	}
 
 	/**
-	 * Checks if a double click was made
+	 * Checks if a double click was made.
 	 * 
 	 * @return true if doublecklick, false if not
 	 */
@@ -729,15 +727,34 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		return false;
 	}
 
+	/**
+	 * sets the Edge Capacity.
+	 * 
+	 * @param cap
+	 *            capacity
+	 */
 	public void setEdgeCapacity(float cap) {
 		edgeCapacity = cap;
 	}
 
+	/**
+	 * Set if Information should be shown.
+	 * 
+	 * @param connection
+	 *            boolean for conecction
+	 * @param object
+	 *            boolean for objects
+	 */
 	public void setShowedInformation(boolean connection, boolean object) {
 		showedInformation[0] = connection;
 		showedInformation[1] = object;
 	}
 
+	/**
+	 * Returns if Information should be shown.
+	 * 
+	 * @return Array of boolean [0] = connection, [1] = objects
+	 */
 	public boolean[] getShowedInformation() {
 		return showedInformation;
 	}

+ 5 - 1
src/ui/view/PropertyTable.java

@@ -1,7 +1,11 @@
 package ui.view;
 
 import javax.swing.table.DefaultTableModel;
-
+/**
+ * Property Table.
+ * 
+ * @author Gruppe14
+ */
 public class PropertyTable extends DefaultTableModel {
 
 	@Override

+ 27 - 13
src/ui/view/SearchPopUp.java

@@ -18,13 +18,18 @@ import javax.swing.JRadioButton;
 import javax.swing.JButton;
 
 import ui.controller.Control;
-import ui.controller.MultiPurposeController;
-
 import java.awt.event.ActionListener;
 import java.util.ArrayList;
 import java.awt.event.ActionEvent;
 
+/**
+ * This Class represents a popup to seatch for Objects on the Canvas.
+ * 
+ * @author Gruppe14
+ */
 public class SearchPopUp extends JDialog {
+
+	private static final long serialVersionUID = 1L;
 	private final JPanel contentPanel = new JPanel();
 	private JTextField replaceTextField;
 	private JTextField findTextField;
@@ -36,6 +41,11 @@ public class SearchPopUp extends JDialog {
 	private JRadioButton rdbtnSingle;
 	private int idx;
 
+	/**
+	 * Constructor.
+	 * @param contr Controller
+	 * @param can Canvas
+	 */
 	SearchPopUp(Control contr, MyCanvas can) {
 		super((java.awt.Frame) null, true);
 		idx = -1;
@@ -162,7 +172,7 @@ public class SearchPopUp extends JDialog {
 		btnReplaceAll.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				canvas.tempCps = null;
-				canvas.TempSelected = new ArrayList<>();
+				canvas.tempSelected = new ArrayList<>();
 				controller.getModel().getSelectedCpsObjects().clear();
 
 				for (AbstractCpsObject cps : controller.getModel().getObjectsOnCanvas()) {
@@ -204,35 +214,38 @@ public class SearchPopUp extends JDialog {
 	}
 
 	/**
-	 * 
-	 * @param obj
+	 * add the searched Objects to the Selected Objects.
+	 * @param obj The Object
 	 */
 	public void selectObj(AbstractCpsObject obj) {
 		controller.getModel().getSelectedCpsObjects().add(obj);
 	}
 
 	/**
+	 * Rename an Object.
 	 * 
-	 * @param obj
-	 * @param name
+	 * @param obj the Object
+ 	 * @param name the new name
 	 */
 	public void renameObj(AbstractCpsObject obj, String name) {
 		obj.setName(name);
 	}
 
 	/**
+	 * get the Object with the specific ID.
 	 * 
-	 * @param idx
-	 * @return
+	 * @param idx the ID
+	 * @return the Object with that ID
 	 */
 	public AbstractCpsObject getObj(int idx) {
 		return controller.getModel().getObjectsOnCanvas().get(idx);
 	}
 
 	/**
+	 * Get the next Object ID.
 	 * 
-	 * @param idx
-	 * @return
+	 * @param idx the Index
+	 * @return the next Index
 	 */
 	public int getNext(int idx) {
 		for (int i = idx; i < controller.getModel().getObjectsOnCanvas().size(); i++) {
@@ -249,9 +262,10 @@ public class SearchPopUp extends JDialog {
 	}
 
 	/**
+	 * Get the previous Index.
 	 * 
-	 * @param idx
-	 * @return
+	 * @param idx the Index
+	 * @return the previousIndex
 	 */
 	public int getPrev(int idx) {
 		for (int i = idx; i >= 0; i--) {

+ 30 - 9
src/ui/view/ShowedInformationPopUp.java

@@ -10,14 +10,27 @@ import javax.swing.JButton;
 import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
 
-public class ShowedInformationPopUp extends JDialog{
+/**
+ * This Class represents a Popup to edit the shown Information.
+ * 
+ * @author Gruppe14
+ */
+public class ShowedInformationPopUp extends JDialog {
+
+	private static final long serialVersionUID = 1L;
 	private final JPanel contentPanel = new JPanel();
 	private final JButton btnOk = new JButton("OK");
 	private MyCanvas canvas;
 	private JCheckBox objectEnergyCheckbox;
 	private JCheckBox connectionCheckbox;
-	
-	public ShowedInformationPopUp(MyCanvas canvas){
+
+	/**
+	 * Constructor.
+	 * 
+	 * @param canvas
+	 *            the Canvas
+	 */
+	public ShowedInformationPopUp(MyCanvas canvas) {
 		super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		this.setTitle("Edit Showed Informations");
@@ -27,15 +40,15 @@ public class ShowedInformationPopUp extends JDialog{
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);
 		this.canvas = canvas;
-		
+
 		objectEnergyCheckbox = new JCheckBox("Show Total Energy of Objects");
 		objectEnergyCheckbox.setBounds(19, 19, 181, 23);
 		contentPanel.add(objectEnergyCheckbox);
-		
+
 		connectionCheckbox = new JCheckBox("Show Connection Properties");
 		connectionCheckbox.setBounds(19, 57, 181, 23);
 		contentPanel.add(connectionCheckbox);
-		
+
 		objectEnergyCheckbox.setSelected(canvas.getShowedInformation()[1]);
 		connectionCheckbox.setSelected(canvas.getShowedInformation()[0]);
 		btnOk.addActionListener(new ActionListener() {
@@ -46,7 +59,7 @@ public class ShowedInformationPopUp extends JDialog{
 		});
 		btnOk.setBounds(169, 98, 82, 23);
 		contentPanel.add(btnOk);
-		
+
 		JButton btnCancel = new JButton("Cancel");
 		btnCancel.setActionCommand("Cancel");
 		btnCancel.addActionListener(new ActionListener() {
@@ -57,8 +70,16 @@ public class ShowedInformationPopUp extends JDialog{
 		btnCancel.setBounds(70, 98, 89, 23);
 		contentPanel.add(btnCancel);
 	}
-	
-	private void setInformation(boolean connection, boolean object){
+
+	/**
+	 * Set the Information true or false.
+	 * 
+	 * @param connection
+	 *            conecction Information
+	 * @param object
+	 *            Object Information
+	 */
+	private void setInformation(boolean connection, boolean object) {
 		canvas.setShowedInformation(connection, object);
 		canvas.repaint();
 	}

+ 53 - 41
src/ui/view/SimulationMenu.java

@@ -38,10 +38,14 @@ import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.awt.FlowLayout;
 
+/**
+ * This Class represents the Menu, where you can edit stuff about the
+ * Simulation.
+ * 
+ * @author Gruppe14
+ */
 public class SimulationMenu extends JMenuBar {
-	/**
-	 * 
-	 */
+
 	private static final long serialVersionUID = 1L;
 
 	private JPanel menuPanel = new JPanel();
@@ -55,6 +59,14 @@ public class SimulationMenu extends JMenuBar {
 	Model model;
 	Control controller;
 
+	/**
+	 * Constructor.
+	 * 
+	 * @param mod
+	 *            the Model
+	 * @param cont
+	 *            the Controller
+	 */
 	public SimulationMenu(Model mod, Control cont) {
 		super();
 		// Init Stuff
@@ -93,12 +105,12 @@ public class SimulationMenu extends JMenuBar {
 		});
 
 		// Add to Panel
-		GridBagLayout gbl_menuPanel = new GridBagLayout();
-		gbl_menuPanel.columnWidths = new int[] { 79, 105, 34, 60, 31, 151, 0 };
-		gbl_menuPanel.rowHeights = new int[] { 25, 0 };
-		gbl_menuPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
-		gbl_menuPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
-		menuPanel.setLayout(gbl_menuPanel);
+		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);
 
 		// isSimulation
 		simButton.addPropertyChangeListener(new PropertyChangeListener() {
@@ -109,18 +121,18 @@ public class SimulationMenu extends JMenuBar {
 				controller.calculateStateForCurrentTimeStep();
 			}
 		});
-		GridBagConstraints gbc_simButton = new GridBagConstraints();
-		gbc_simButton.anchor = GridBagConstraints.NORTHWEST;
-		gbc_simButton.insets = new Insets(0, 0, 0, 5);
-		gbc_simButton.gridx = 0;
-		gbc_simButton.gridy = 0;
-		menuPanel.add(simButton, gbc_simButton);
-		GridBagConstraints gbc_simSpeedLabel = new GridBagConstraints();
-		gbc_simSpeedLabel.anchor = GridBagConstraints.WEST;
-		gbc_simSpeedLabel.insets = new Insets(0, 0, 0, 5);
-		gbc_simSpeedLabel.gridx = 1;
-		gbc_simSpeedLabel.gridy = 0;
-		menuPanel.add(simSpeedLabel, gbc_simSpeedLabel);
+		GridBagConstraints gbcsimButton = new GridBagConstraints();
+		gbcsimButton.anchor = GridBagConstraints.NORTHWEST;
+		gbcsimButton.insets = new Insets(0, 0, 0, 5);
+		gbcsimButton.gridx = 0;
+		gbcsimButton.gridy = 0;
+		menuPanel.add(simButton, gbcsimButton);
+		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));
@@ -129,31 +141,31 @@ public class SimulationMenu extends JMenuBar {
 			public void caretUpdate(CaretEvent e) {
 				try {
 					controller.setTimerSpeed(Integer.parseInt(simSpeedText.getText()));
-				} catch (Exception e2) {
+				} catch (Exception ex) {
 					// TODO: handle exception
 				}
 
 			}
 		});
-		GridBagConstraints gbc_simSpeedText = new GridBagConstraints();
-		gbc_simSpeedText.anchor = GridBagConstraints.WEST;
-		gbc_simSpeedText.insets = new Insets(0, 0, 0, 5);
-		gbc_simSpeedText.gridx = 2;
-		gbc_simSpeedText.gridy = 0;
-		menuPanel.add(simSpeedText, gbc_simSpeedText);
-		GridBagConstraints gbc_algoFolderButton = new GridBagConstraints();
-		gbc_algoFolderButton.anchor = GridBagConstraints.WEST;
-		gbc_algoFolderButton.insets = new Insets(0, 0, 0, 5);
-		gbc_algoFolderButton.gridx = 3;
-		gbc_algoFolderButton.gridy = 0;
-		menuPanel.add(algoFolderButton, gbc_algoFolderButton);
-
-		GridBagConstraints gbc_algoCombo = new GridBagConstraints();
-		gbc_algoCombo.anchor = GridBagConstraints.WEST;
-		gbc_algoCombo.insets = new Insets(0, 0, 0, 5);
-		gbc_algoCombo.gridx = 4;
-		gbc_algoCombo.gridy = 0;
-		menuPanel.add(algoCombo, gbc_algoCombo);
+		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("choose folder");
 
 		// Add Panel to SimulationMenu

+ 16 - 4
src/ui/view/TimePanel.java

@@ -19,7 +19,12 @@ import javax.swing.event.ChangeListener;
 import ui.controller.Control;
 import ui.model.Model;
 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.
+ * 
+ * @author Gruppe14
+ */
 public class TimePanel extends JPanel {
 
 	private Model model;
@@ -34,11 +39,13 @@ public class TimePanel extends JPanel {
 	private Timer timer;
 	private boolean running = false;
 
-	/**
-	 * 
-	 */
 	private static final long serialVersionUID = 1L;
 
+	/**
+	 * Constructor.
+	 * @param mod the Model
+	 * @param cont the Controller
+	 */
 	public TimePanel(Model mod, Control cont) {
 		super();
 		this.model = mod;
@@ -158,6 +165,11 @@ public class TimePanel extends JPanel {
 		this.add(timeSlider);
 	}
 	
+	/**
+	 * Retunrs the TimeSlider.
+	 * 
+	 * @return the TimeSlider
+	 */
 	public JSlider getTimeSlider(){
 		return timeSlider;
 	}

+ 74 - 41
src/ui/view/UnitGraph.java

@@ -26,10 +26,16 @@ import classes.HolonSwitch;
 
 import java.awt.Cursor;
 
+/**
+ * This Class represents a Graph where the User can model the behavior of
+ * elements and switches over time.
+ * 
+ * @author Gruppe14
+ */
 public class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, ComponentListener {
 
 	private static final long serialVersionUID = 1L;
-	private float MAXIMUM = 0;
+	private float maximum = 0;
 
 	// Information shown when a Point is Dragged
 	private String dragInformation = "";
@@ -66,6 +72,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	private double x = 0, y = 0;
 	private int x1, x2, y1, y2, ctrlx1, ctrly1, ctrlx2, ctrly2;
 
+	/**
+	 * Constructor.
+	 * 
+	 * @param model
+	 *            the Model
+	 * @param control
+	 *            the Controller
+	 */
 	public UnitGraph(final Model model, Control control) {
 		setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
 		this.controller = control;
@@ -80,9 +94,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Paints all Components on the Canvas
+	 * Paints all Components on the Canvas.
 	 * 
-	 * @param Graphics
+	 * @param g
+	 *            Graphics
 	 * 
 	 */
 	public void paintComponent(Graphics g) {
@@ -213,9 +228,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Wenn ein Punkt bei einem HolonElement gedragged wird
+	 * When a Point of a Holon Element is dragged.
 	 * 
 	 * @param e
+	 *            MouseEvent
 	 */
 	public void elementDragged(MouseEvent e) {
 		if (pointDrag && tempP != null) {
@@ -241,9 +257,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Wenn ein Punkt bei einem CpsSwitch gedragged wird
+	 * When a Point of a switch is dragged.
 	 * 
 	 * @param e
+	 *            MouseEvent
 	 */
 	public void switchDragged(MouseEvent e) {
 		if (pointDrag && tempP != null && tempP != pointList.getFirst() && tempP != pointList.getLast()) {
@@ -295,9 +312,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Wenn ein Punkt von einem Element gedrueckt wird
+	 * When a point of a Holon Element is pressed.
 	 * 
 	 * @param e
+	 *            MouseEvent
 	 */
 	public void elementPressed(MouseEvent e) {
 		boolean added = false;
@@ -349,9 +367,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Wenn ein Punkt von einem Switch gedr�ck wird
+	 * When a point of a Switch is pressed.
 	 * 
 	 * @param e
+	 *            MouseEvent
 	 */
 	public void switchPressed(MouseEvent e) {
 		boolean added = false;
@@ -431,10 +450,19 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 			pointDrag = false;
 			tempP = null;
 		}
+		/**
+		 * reset the dragInformation.
+		 */
 		dragInformation = "";
 		repaint();
 	}
 
+	/**
+	 * When the Component is Resized.
+	 * 
+	 * @param e
+	 *            ComponentEvent
+	 */
 	public void componentResized(ComponentEvent e) {
 		// Wenn ein anderes Element genommen wird
 		if (init) {
@@ -468,8 +496,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	public void componentShown(ComponentEvent e) {
 	}
 
-	/*
-	 * Empty the Graph
+	/**
+	 * Empty the Graph.
 	 */
 	public void empty() {
 		pointList = null;
@@ -481,8 +509,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		repaint();
 	}
 
-	/*
-	 * Resets the Points for the Element
+	/**
+	 * Resets the Points for the Element.
 	 */
 	public void reset() {
 		pointList.removeAll(pointList);
@@ -492,32 +520,32 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * converts the number to fit the canvas
+	 * converts the number to fit the canvas.
 	 * 
-	 * @param double
-	 *            d, the number to convert
+	 * @param d
+	 *            the number to convert
 	 * @return the converted number
 	 */
 	public double convertToCanvasY(float d) {
-		return (height - (d * (height / MAXIMUM)));
+		return (height - (d * (height / maximum)));
 	}
 
 	/**
-	 * converts the number to fit the value
+	 * converts the number to fit the value.
 	 * 
-	 * @param double
-	 *            d, the number to convert
+	 * @param d
+	 *            the number to convert
 	 * @return the converted number
 	 */
 	public float convertToValueY(double d) {
-		return (float) Math.round(((height - (height * (d / height))) / (height / MAXIMUM)) * 10) / 10;
+		return (float) Math.round(((height - (height * (d / height))) / (height / maximum)) * 10) / 10;
 	}
 
 	/**
-	 * Visualize the HolonElement on the Graph
+	 * Visualize the HolonElement on the Graph.
 	 * 
-	 * @param HolonElement
-	 *            ele, which should be visualized
+	 * @param selectedElement
+	 *            which should be visualized
 	 */
 	public void repaintWithNewElement(ArrayList<HolonElement> selectedElement) {
 		arrayOfFloats = selectedElement.get(selectedElement.size() - 1).getEnergyAt();
@@ -525,7 +553,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		pointList = selectedElement.get(selectedElement.size() - 1).getGraphPoints();
 		isSwitch = false;
 		isElement = true;
-		MAXIMUM = selectedElement.get(selectedElement.size() - 1).getEnergy();
+		maximum = selectedElement.get(selectedElement.size() - 1).getEnergy();
 		// First time clicked on the Element
 		if (pointList.isEmpty()) {
 			pointList.addFirst(new Point(0, 0));
@@ -535,10 +563,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Visualize the HolonElement on the Graph
+	 * Visualize the Switch on the Graph.
 	 * 
-	 * @param HolonElement
-	 *            ele, which should be visualized
+	 * @param s
+	 *            which should be visualized
 	 */
 	public void repaintWithNewSwitch(HolonSwitch s) {
 		arrayOfBooleans = s.getActiveAt();
@@ -554,12 +582,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Build a Curve for the Graph
+	 * Build a Curve for the Graph.
 	 * 
-	 * @param Point,Point
-	 *            ,startpoint p1 and endpoint p2
+	 * @param p1
+	 *            startpoint
+	 * @param p2
+	 *            endpoint
 	 * 
-	 * @return CubicCurve2D, c, the CubicCurve2D for the Graph
+	 * @return the CubicCurve2D for the Graph
 	 */
 	public CubicCurve2D buildCurve(Point p1, Point p2) {
 		x1 = (int) p1.getX();
@@ -585,11 +615,11 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Fills the Arrays with booleans
+	 * Fills the Arrays with booleans.
 	 */
 	public void fillArrayofBooleans() {
 		for (int i = 0; i < arrayOfBooleans.length; i++) {
-			int t = (int) getYValueAt_2((int) (i * width / (model.getIterations() - 1)));
+			int t = (int) getYValueAt2((int) (i * width / (model.getIterations() - 1)));
 			if (t == 0) {
 				arrayOfBooleans[i] = true;
 			} else {
@@ -600,23 +630,24 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
-	 * Fills the Arrays of each HolonElement
+	 * Fills the Arrays of each HolonElement.
 	 */
 	@SuppressWarnings("unchecked")
 	public void fillArrayofValue() {
 		for (HolonElement he : tempElements) {
-			MAXIMUM = he.getEnergy();
+			maximum = he.getEnergy();
 			he.setGraphPoints((LinkedList<Point>) pointList.clone());
 			for (int i = 0; i < arrayOfFloats.length; i++) {
-				he.getEnergyAt()[i] = convertToValueY(getYValueAt_2((int) (i * width / (model.getIterations() - 1))));
+				he.getEnergyAt()[i] = convertToValueY(getYValueAt2((int) (i * width / (model.getIterations() - 1))));
 			}
 			arrayOfFloats = he.getEnergyAt();
 		}
 	}
 
 	/**
+	 * Get the Y Value at the x Coordination.
 	 * 
-	 * @param xVal,
+	 * @param xVal
 	 *            the x value for the y value
 	 * @return y, the value at x
 	 */
@@ -635,12 +666,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
+	 * Get y value at the x Coordination via curves.
 	 * 
-	 * @param xVal,
+	 * @param xVal
 	 *            the x value for the y value
-	 * @return y, the value at x
+	 * @return y value at x
 	 */
-	public float getYValueAt_2(int xVal) {
+	public float getYValueAt2(int xVal) {
 		for (int i = 0; i < pointList.size() - 1; i++) {
 			// get the Points
 			if (xVal >= pointList.get(i).getX()) {
@@ -687,10 +719,11 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	}
 
 	/**
+	 * Get the Intersection Point of 2 Lines.
 	 * 
-	 * @param l1,
+	 * @param l1
 	 *            the first Line
-	 * @param l2,
+	 * @param l2
 	 *            the second Line
 	 * 
 	 * @return The Intersection Point