Browse Source

Add comments for some methods in the class GUI. Fix a bug of the Deletebtn for HolonElements by user-defined Objects

Edgardo Palza 7 years ago
parent
commit
1ee24a0676

+ 7 - 6
src/ui/controller/Control.java

@@ -171,8 +171,8 @@ public class Control {
 		objectController.addNewElementIntoCategoryObject(catName, objName, eleName, amount, energy);
 	}
 
-	public void deleteElementCanvas(int id, String element) {
-		objectController.deleteElementInCanvas(id, element);
+	public void deleteElementCanvas(int id, int elementId) {
+		objectController.deleteElementInCanvas(id, elementId);
 	}
 
 	public void deleteElementCanvas(HolonObject obj, HolonElement ele) {
@@ -213,11 +213,12 @@ public class Control {
 	public void initListener(CategoryListener catLis) {
 		categoryController.addCategoryListener(catLis);
 	}
-	
-	public void calculateStateForCurrentTimeStep(){
+
+	public void calculateStateForCurrentTimeStep() {
 		simulationManager.reset();
 		simulationManager.calculateStateForTimeStep(MODEL.getCurIteration());
 	}
+
 	public void calculateStateForTimeStep(int x) {
 		simulationManager.reset();
 		simulationManager.calculateStateForTimeStep(x);
@@ -271,8 +272,8 @@ public class Control {
 	public Model getModel() {
 		return MODEL;
 	}
-	
-	public SimulationManager getSimManager(){
+
+	public SimulationManager getSimManager() {
 		return simulationManager;
 	}
 

+ 9 - 4
src/ui/controller/MultiPurposeController.java

@@ -86,16 +86,21 @@ public class MultiPurposeController {
 			return object.getElements().get(idx);
 	}
 
+	public HolonElement searchEleById(HolonObject object, int idEle) {
+		return object.searchElementById(idEle);
+	}
+
 	public CpsEdge searchEdge(int a, int b) {
 
 		CpsObject A = searchByID(a);
 		CpsObject B = searchByID(b);
 
 		for (CpsEdge edge : MODEL.getEdgesOnCanvas()) {
-//			if (edge.getA().getObjName().equals(A.getObjName()) && (edge.getB().getObjName().equals(B.getObjName()))
-//					|| edge.getB().getObjName().equals(A.getObjName())
-//							&& (edge.getA().getObjName().equals(B.getObjName())))
-			if( (edge.getA().equals(A) && edge.getB().equals(B)) || (edge.getB().equals(A)) && edge.getA().equals(B))
+			// if (edge.getA().getObjName().equals(A.getObjName()) &&
+			// (edge.getB().getObjName().equals(B.getObjName()))
+			// || edge.getB().getObjName().equals(A.getObjName())
+			// && (edge.getA().getObjName().equals(B.getObjName())))
+			if ((edge.getA().equals(A) && edge.getB().equals(B)) || (edge.getB().equals(A)) && edge.getA().equals(B))
 				return edge;
 		}
 		return null;

+ 8 - 6
src/ui/controller/ObjectController.java

@@ -102,7 +102,7 @@ public class ObjectController {
 	 * @param ele
 	 */
 	public void deleteElement(HolonObject obj, HolonElement ele) {
-
+		System.out.println(ele.getEleName() + " and " + obj.getEleIdx());
 		mpC.decIdx(ele.getEleName(), obj.getEleIdx());
 		obj.getEleIdx().remove(ele.getEleName());
 		obj.getElements().remove(ele);
@@ -133,10 +133,11 @@ public class ObjectController {
 	 * @param ele
 	 * @param amount
 	 */
-	public void deleteElementInCanvas(int ID, String ele) {
+	public void deleteElementInCanvas(int ID, int eleId) {
 		HolonObject object = (HolonObject) mpC.searchByID(ID);
-		HolonElement element = mpC.searchEle(object, ele);
-
+		HolonElement element = mpC.searchEleById(object, eleId);
+		// mpC.searchEle(object, ele);
+		System.out.println(object.getName() + " and " + element.getEleName());
 		deleteElement(object, element);
 	}
 
@@ -164,11 +165,12 @@ public class ObjectController {
 	public void setSelectedObjectID(int id) {
 		MODEL.setSelectedObjectID(id);
 	}
-	
+
 	/**
 	 * sets clipBoardObjects
 	 * 
-	 * @param ArrayList of CpsObjects
+	 * @param ArrayList
+	 *            of CpsObjects
 	 */
 	public void setClipboardObjects(ArrayList<CpsObject> list) {
 		MODEL.setClipboradObjects(list);

+ 91 - 74
src/ui/view/GUI.java

@@ -124,7 +124,9 @@ public class GUI<E> implements CategoryListener {
 	// In this section are all the Holonelements that correspond to the clicked
 	// HolonObject with consumption/production, name and amount.
 
+	// Table for HolonElements --> all cells are editable
 	private JTable tableHolonElement = new JTable();
+	// Model for single or multi selection
 	private PropertyTable tableModelHolonElementMulti = new PropertyTable();
 	private PropertyTable tableModelHolonElementSingle = new PropertyTable();
 	private final JPanel scrollElements = new JPanel();
@@ -132,7 +134,8 @@ public class GUI<E> implements CategoryListener {
 
 	// In this section are all the properties that correspond to the clicked
 	// HolonObject, such as connections, name, Type, etc.
-
+	// 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 JPanel graphLabel = new JPanel();
 	private DefaulTable tableModelProperties;
@@ -140,7 +143,6 @@ public class GUI<E> implements CategoryListener {
 
 	// In this section is the graph for the selected HolonElement of the clicked
 	// HolonObject
-
 	private JTable tableGraph = new JTable();
 	private DefaultTableModel tableModelGraph = new DefaultTableModel();
 	private final JScrollPane scrollGraph = new JScrollPane();
@@ -174,7 +176,6 @@ public class GUI<E> implements CategoryListener {
 	private String actualObjectClicked;
 	private Image img = null;
 	private CpsObject tempCps = null;
-	private HolonElement tempElement = null;
 	private int yValueElements = 0;
 
 	private MyCanvas canvas;
@@ -187,8 +188,10 @@ public class GUI<E> implements CategoryListener {
 	private final JMenu mnAlgorithm = new JMenu("Algorithm");
 	private final JCheckBoxMenuItem chckbxmntmUseAlgorithm = new JCheckBoxMenuItem("Use Algorithm");
 	private final JComboBox comboBoxAlgo = new JComboBox();
+	// Coord for all Cells with text
 	private int yTHIS;
 	private int xTHIS;
+	// Coord for all Cells with boolean values (checkbox)
 	private int yBTHIS;
 	private int xBTHIS;
 	private CpsObject temp = null;
@@ -531,12 +534,13 @@ public class GUI<E> implements CategoryListener {
 		 * RIGHT CONTAINER (INFORMATION)
 		 **********************/
 		// Set up of the HolonElements section
-		Object[] columnNamesMulti = { "Object", "ID", "Device", "Energy", "Quantity", "Activated" };
+		// Two different Models: Multi for multi-selection mode and Single for
+		// single-selection mode (CPS-Object)
+		Object[] columnNamesMulti = { "Object", "Nr.", "Device", "Energy", "Quantity", "Activated" };
 		tableModelHolonElementMulti.setColumnIdentifiers(columnNamesMulti);
-		Object[] columnNamesSingle = { "ID", "Device", "Energy", "Quantity", "Activated" };
+		Object[] columnNamesSingle = { "Nr.", "Device", "Energy", "Quantity", "Activated" };
 		tableModelHolonElementSingle.setColumnIdentifiers(columnNamesSingle);
 		tableHolonElement.setBorder(null);
-
 		tableHolonElement.setFillsViewportHeight(true);
 		tableHolonElement.setCellSelectionEnabled(true);
 		tableHolonElement.setColumnSelectionAllowed(true);
@@ -552,7 +556,7 @@ public class GUI<E> implements CategoryListener {
 
 		// Set up of the Properties section
 		Object[] colNames = { "Field", "Information" };
-		tableModelProperties = new DefaulTable(100, colNames.length);
+		tableModelProperties = new DefaulTable(1000, colNames.length);
 		tableModelProperties.setColumnIdentifiers(colNames);
 		tableProperties.setModel(tableModelProperties);
 		tableProperties.setFillsViewportHeight(true);
@@ -561,8 +565,6 @@ public class GUI<E> implements CategoryListener {
 		scrollProperties.setViewportView(tableProperties);
 
 		// Set up of the Graph section
-		Object[] tempText = { "Here comes the graph for each clicked HolonElement" };
-		tableModelGraph.setColumnIdentifiers(tempText);
 		tableGraph.setModel(tableModelGraph);
 		tableGraph.setFillsViewportHeight(true);
 		tableGraph.setCellSelectionEnabled(true);
@@ -604,46 +606,53 @@ public class GUI<E> implements CategoryListener {
 			}
 		});
 		/*
-		 * Delete the choosen HolonElement of the selected HolonObject
+		 * Delete the chosen HolonElement of the selected HolonObject,
+		 * Multi-Selection for CpsObjects as well as for HolonElements possible
 		 */
 		btnDelHolEL.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {
+				// For Single Selection of CpsObject
 				if (model.getSelectedCpsObjects().size() == 1) {
 					if (getActualCps().getClass() == HolonObject.class) {
 						HolonObject obj = (HolonObject) getActualCps();
 						for (HolonElement e : selectedElements) {
-							controller.deleteElementCanvas(obj.getID(), e.getEleName());
+							controller.deleteElementCanvas(obj.getID(), e.getId());
 							refreshTableHolonElement();
 							refreshTableProperties();
 							controller.calculateStateForTimeStep(model.getCurIteration());
 							// Names displayed in graph are not updated
 						}
+						selectedElements.clear();
 					}
+					// For MultiSelection of CpsObject
 				} else if (model.getSelectedCpsObjects().size() > 1) {
 					for (Integer i : eleToDelete.keySet()) {
 						for (HolonElement e : eleToDelete.get(i)) {
-							controller.deleteElementCanvas(i, e.getEleName());
+							controller.deleteElementCanvas(i, e.getId());
 						}
 					}
 					refreshTableHolonElement();
 					refreshTableProperties();
 				}
-				holonEleNamesDisplayed = "None ";
 			}
 		});
 		/*
-		 * Communication between HolonElement Table and displayed Graph
+		 * Communication between HolonElement Table and displayed Graph and
+		 * Properties, as well as selection of differet HolonElements
 		 */
 		tableHolonElement.addMouseListener(new MouseAdapter() {
 			public void mousePressed(MouseEvent e) {
 				HolonObject obj = (HolonObject) getActualCps();
 				yValueElements = e.getY();
 				HolonElement ele = null;
+				// Search for current clicked HolonElement
 				if (model.getSelectedCpsObjects().size() == 1) {
 					ele = getActualHolonElement(obj, yValueElements, 0);
 				} else {
 					ele = getActualHolonElement(null, yValueElements, 0);
 				}
+				// Multi-Selection of HolonElements through control button +
+				// mouse click
 				if (e.isControlDown() && ele != null) {
 					if (!selectedElements.contains(ele)) {
 						selectedElements.add(ele);
@@ -655,34 +664,29 @@ public class GUI<E> implements CategoryListener {
 						unitGraph.repaintWithNewElement(selectedElements);
 					}
 					getActualHolonElement(null, yValueElements, 2);
-				} else if (ele != null) {
+				} // if no control-button pressed but a HolonElement choose
+				else if (ele != null) {
 					selectedElements.clear();
 					selectedElements.add(ele);
 					getActualHolonElement(null, yValueElements, 1);
 					holonEleNamesDisplayed = ele.getEleName() + " ";
 					unitGraph.repaintWithNewElement(selectedElements);
-				} else {
+				} // If any empty space is clicked
+				else {
 					elementGraph.setText("None ");
 					unitGraph.empty();
 				}
-				// if any HolonElement is double-clicked --> Edit instance of
-				// selected HolonElement
+				// if any HolonElement is double-clicked --> Edit-Mode started
+				// for selected HolonElement
 				if (e.getClickCount() == 2) {
 					yTHIS = e.getY();
 					xTHIS = e.getX();
 				}
+				// for single click and empty slot
 				if (e.getClickCount() == 1 && ele == null) {
 					selectedElements.clear();
 					holonEleNamesDisplayed = "None ";
 				}
-				// for (int i = 0; i < selectedElements.size(); i++) {
-				// if (i == 0) {
-				// System.out.println("Selected Items: " +
-				// selectedElements.get(i).getEleName());
-				// } else {
-				// System.out.println(selectedElements.get(i).getEleName());
-				// }
-				// }
 				elementGraph.setText(holonEleNamesDisplayed);
 				yBTHIS = e.getY();
 				xBTHIS = e.getX();
@@ -691,8 +695,7 @@ public class GUI<E> implements CategoryListener {
 		});
 
 		/*
-		 * If the HolonElement Table enters to editing instance, than is the
-		 * propertyChangeListener triggered
+		 * Triggered every time a change is made
 		 */
 		tableHolonElement.addPropertyChangeListener(new PropertyChangeListener() {
 			@Override
@@ -702,11 +705,12 @@ public class GUI<E> implements CategoryListener {
 					int yBMouse = yBTHIS;
 					int selectedValueY = (int) Math.floor(yMouse / 16);
 					int selectedValueBY = (int) Math.floor(yBMouse / 16);
+					// for multi-selection mode
 					if (model.getSelectedCpsObjects().size() > 1) {
-						// Multiple Selection
 						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) {
 								HolonElement eleBTemp = getActualHolonElement(null, yBMouse, 0);
 								String newBStuff = tableModelHolonElementMulti
@@ -714,25 +718,32 @@ public class GUI<E> implements CategoryListener {
 								Boolean bTemp = Boolean.parseBoolean(newBStuff);
 								eleBTemp.setActive(bTemp);
 							} else {
+								// Update of HolonElement
 								HolonElement eleTemp = getActualHolonElement(null, yMouse, 0);
 								String newStuff = tableModelHolonElementMulti.getValueAt(selectedValueY, selectedValueX)
 										.toString();
+								// Name update
 								if (selectedValueX == 2) {
 									eleTemp.setEleName(newStuff);
-								} else if (selectedValueX == 3) {
+								}
+								// Energy Update
+								else if (selectedValueX == 3) {
 									Float ftemp = Float.parseFloat(newStuff);
 									eleTemp.setEnergy(ftemp);
-								} else if (selectedValueX == 4) {
+								}
+								// Amount of Elements update
+								else if (selectedValueX == 4) {
 									Integer iTemp = Integer.parseInt(newStuff);
 									eleTemp.setAmount(iTemp);
 								}
 							}
 						}
-					} else if (model.getSelectedCpsObjects().size() == 1) {
-						// Single Selection
+					} // 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));
 						if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
+							// For last column (boolean with a checkbox)
 							if (selectedValueBX == 4) {
 								HolonElement eleBTemp = getActualHolonElement((HolonObject) getActualCps(), yBMouse, 0);
 								String newBStuff = tableModelHolonElementSingle
@@ -740,15 +751,19 @@ public class GUI<E> implements CategoryListener {
 								Boolean bTemp = Boolean.parseBoolean(newBStuff);
 								eleBTemp.setActive(bTemp);
 							} else {
+								// Update of HolonElement
 								HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse, 0);
 								String newStuff = tableModelHolonElementSingle
 										.getValueAt(selectedValueY, selectedValueX).toString();
+								// Name update
 								if (selectedValueX == 1) {
 									eleTemp.setEleName(newStuff);
-								} else if (selectedValueX == 2) {
+								} // Energy Update
+								else if (selectedValueX == 2) {
 									Float ftemp = Float.parseFloat(newStuff);
 									eleTemp.setEnergy(ftemp);
-								} else if (selectedValueX == 3) {
+								} // Amount of Elements update
+								else if (selectedValueX == 3) {
 									Integer iTemp = Integer.parseInt(newStuff);
 									eleTemp.setAmount(iTemp);
 								}
@@ -768,9 +783,7 @@ public class GUI<E> implements CategoryListener {
 		 * HolonElement Properties Actions
 		 **********************/
 		/*
-		 * If any value at the Properties Table enters to editing instance, than
-		 * is PropertyChangeListener triggered (For HolonObject, the only value
-		 * to be edited is the name and for CpsEdge the Max.flow)
+		 * Update any change in the Property table
 		 */
 		tableProperties.addPropertyChangeListener(new PropertyChangeListener() {
 
@@ -1000,7 +1013,6 @@ public class GUI<E> implements CategoryListener {
 						controller.addCategory(catName);
 					}
 					break;
-
 				case "Object":
 					if (selectedNode == null) {
 						JOptionPane.showMessageDialog(new JFrame(),
@@ -1037,7 +1049,8 @@ public class GUI<E> implements CategoryListener {
 		/**
 		 * Update of every interaction between the user and the canvas (only on
 		 * the canvas). Basically the update of all the information concerning
-		 * the clicked HolonObject
+		 * the clicked HolonObject. For multi-selection, the propertyTable would
+		 * be disabled
 		 */
 		canvas.addMouseListener(new MouseAdapter() {
 
@@ -1045,19 +1058,13 @@ public class GUI<E> implements CategoryListener {
 			public void mousePressed(MouseEvent e) {
 				selectedElements.clear();
 				holonEleNamesDisplayed = "None ";
-
+				// If any empty space is clicked
 				if (temp == null || temp.getID() != model.getSelectedObjectID()) {
 					unitGraph.empty();
 					elementGraph.setText("None ");
 				}
 				temp = getActualCps();
-				// Update of the Information about the HolonElements - only for
-				// if (temp instanceof HolonObject) {
-				// refreshTableHolonElement();
-				// }
-				// Update of the Information about the Properties - only for
-				// CpsObjects
-				// Erase old data
+				// Erase old data in the PropertyTable
 				if (tableModelProperties.getRowCount() > 0) {
 					for (int i = tableModelProperties.getRowCount() - 1; i > -1; i--) {
 						tableModelProperties.removeRow(i);
@@ -1070,35 +1077,23 @@ public class GUI<E> implements CategoryListener {
 						controller.addSelectedObject(temp);
 					}
 				}
-				// } else if (e.isShiftDown() && model.getSelectedEdge() !=
-				// null) {
-				// selectedObjects.add(model.getSelectedEdge());
-				// }
-				// boolean nothingImportant = true;
-				// for (CpsObject c : model.getSelectedCpsObjects()) {
-				// if (nothingImportant) {
-				// System.out.println("Elements: " + c.getName() + " and ID: " +
-				// c.getID());
-				// nothingImportant = false;
-				// } else {
-				// System.out.println(c.getName() + " and ID: " + c.getID());
-				// }
-				// }
-				// Write new data
+				// Write new data in the PropertyTable
 				if (temp != null) {
+					// Name of the CpsObject
 					Object[] tempName = { "Name", temp.getName() };
 					tableModelProperties.addRow(tempName);
+					// Id of the CpsObject
 					Object[] tempId = { "ID", temp.getID() };
 					tableModelProperties.addRow(tempId);
+					// For HolonObjects the Total Energy (production or
+					// consumption) is calculated
 					if (temp instanceof HolonObject) {
 						refreshTableHolonElement();
 						Object[] tempEnergy = { "Total Energy", ((HolonObject) temp).getCurrentEnergy() };
 						tableModelProperties.addRow(tempEnergy);
-						// } else if (temp instanceof HolonTransformer) {
-						// deleteRows();
-						// Object[] tempRatioPerc = { "Ratio Type", true };
-						// tableModelProperties.addRow(tempRatioPerc);
-					} else if (temp instanceof HolonSwitch) {
+					} // For HolonSwitches is showed the actual status (active
+						// or inactive)
+					else if (temp instanceof HolonSwitch) {
 						deleteRows(tableModelHolonElementSingle);
 						deleteRows(tableModelHolonElementMulti);
 						Object[] tempActive = { "Active", ((HolonSwitch) temp).getActiveAt()[model.getCurIteration()] };
@@ -1109,10 +1104,12 @@ public class GUI<E> implements CategoryListener {
 						deleteRows(tableModelHolonElementSingle);
 						deleteRows(tableModelHolonElementMulti);
 					}
+					// For Objects the only editable cell is the name
 					tableModelProperties.setCellEditable(0, 1, true);
 					tableModelProperties.setCellEditable(2, 1, false);
 					tableModelProperties.setCellEditable(3, 1, false);
 					ArrayList<CpsEdge> temp_array = temp.getConnections();
+					// If the clicked object has connections
 					if (!temp_array.isEmpty()) {
 						boolean first = true;
 						for (CpsEdge temp2 : temp_array) {
@@ -1140,23 +1137,31 @@ public class GUI<E> implements CategoryListener {
 							}
 						}
 					}
-				} else if (model.getSelectedEdge() != null) {
+				} // If the clicked Object is an edge
+				else if (model.getSelectedEdge() != null) {
+					// Name displayed
 					Object[] tempName = { "Name", "Edge: " + model.getSelectedEdge().getA().getName() + " to "
 							+ model.getSelectedEdge().getB().getName() };
 					tableModelProperties.addRow(tempName);
+					// Current Flow displayed
 					Object[] tempFlow = { "Current flow", model.getSelectedEdge().getFlow() };
 					tableModelProperties.addRow(tempFlow);
+					// Max Capacity displayed
 					Object[] tempCapacity = { "Max. Capacity", model.getSelectedEdge().getCapacity() };
 					tableModelProperties.addRow(tempCapacity);
+					// Status displayed
 					Object[] tempStatus = { "Status", model.getSelectedEdge().getStateEdge() };
 					tableModelProperties.addRow(tempStatus);
+					// For edges, the only possible editable cell is the max
+					// flow
 					tableModelProperties.setCellEditable(0, 1, false);
 					tableModelProperties.setCellEditable(2, 1, true);
 					tableModelProperties.setCellEditable(3, 1, true);
 				} else if (getActualCps() == null) {
 					deleteRows(tableModelHolonElementSingle);
 					deleteRows(tableModelHolonElementMulti);
-				}
+				} // Update of the HolonElementTable (Single- or
+					// Multi-Selection)
 				if (model.getSelectedCpsObjects().size() > 1) {
 					tableHolonElement.setModel(tableModelHolonElementMulti);
 				} else if (model.getSelectedCpsObjects().size() == 1) {
@@ -1545,7 +1550,8 @@ public class GUI<E> implements CategoryListener {
 	 * Search for actual selected HolonElement
 	 * 
 	 * @param obj
-	 *            selected HolonObject
+	 *            selected HolonObject, if obj==null means multi-selection
+	 *            active
 	 * @param yValue
 	 *            Y-Coord in the HolonElementsTable
 	 * @param toMultiHash
@@ -1556,15 +1562,19 @@ public class GUI<E> implements CategoryListener {
 	public HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash) {
 		final int yTemp = (int) Math.floor(yValue / 16);
 		int rowsTotal = 0;
+		// Filter for search --> single and multi selection
 		if (obj == null) {
 			rowsTotal = tableModelHolonElementMulti.getRowCount();
 		} else {
 			rowsTotal = tableModelHolonElementSingle.getRowCount();
 		}
+		// search for the clicked HolonObject and HolonElement --> in the
+		// HolonElementTable
 		HolonObject obtTemp = null;
 		HolonElement toReturnEle = null;
 		int id = 0;
 		if (rowsTotal != 0 && rowsTotal > yTemp) {
+			// Multi-Selection search
 			if (obj == null) {
 				String tempStringObj = tableModelHolonElementMulti.getValueAt(yTemp, 0).toString();
 				int idTempObj = Integer.parseInt(tempStringObj.split(", ")[1]);
@@ -1576,7 +1586,6 @@ public class GUI<E> implements CategoryListener {
 					if (!eleTemp.contains(obtTemp.searchElementById(id))) {
 						eleTemp.add(obtTemp.searchElementById(id));
 						eleToDelete.replace(idTempObj, eleTemp);
-
 					}
 				} else if (toMultiHash == 2) {
 					eleTemp.add(obtTemp.searchElementById(id));
@@ -1588,20 +1597,28 @@ public class GUI<E> implements CategoryListener {
 				} else if (toMultiHash == 0) {
 					toReturnEle = obtTemp.searchElementById(id);
 				}
-			} else {
+			} // Single-Selection search
+			else {
 				eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
 				id = Integer.parseInt(tableModelHolonElementSingle.getValueAt(yTemp, 0).toString());
 				toReturnEle = obj.searchElementById(id);
 			}
 			model.setSelectedHolonElement(toReturnEle);
 			return toReturnEle;
-		} else {
+		} // If no HolonObject selected
+		else {
 			eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
 			model.setSelectedHolonElement(null);
 			return null;
 		}
 	}
 
+	/**
+	 * Search for clicked HolonObject through the mouse's y-Coord
+	 * 
+	 * @param yValue
+	 * @return clicked HolonObject
+	 */
 	public HolonObject getHolonObj(int yValue) {
 		final int yTemp = (int) Math.floor(yValue / 16);
 		HolonObject obtTemp = null;