Browse Source

Properties update ready and without bugs

Edgardo Palza 8 years ago
parent
commit
ef360835ea
1 changed files with 26 additions and 27 deletions
  1. 26 27
      src/ui/view/GUI.java

+ 26 - 27
src/ui/view/GUI.java

@@ -48,6 +48,8 @@ import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeCellRenderer;
 
+import com.sun.javafx.geom.Edge;
+
 import Interfaces.CategoryListener;
 import classes.Category;
 import classes.CpsEdge;
@@ -228,15 +230,15 @@ public class GUI<E> implements CategoryListener {
 		menuBar.add(mnHelp);
 
 		mnHelp.add(aboutUs);
-		
+
 		menuBar.add(mnAlgorithm);
-		
+
 		mnAlgorithm.add(chckbxmntmUseAlgorithm);
-		
+
 		mnAlgorithm.add(splitPane_2);
-		
+
 		splitPane_2.setLeftComponent(lblSelect);
-		
+
 		splitPane_2.setRightComponent(comboBoxAlgo);
 
 		unitGraph.setBackground(Color.WHITE);
@@ -248,7 +250,7 @@ public class GUI<E> implements CategoryListener {
 
 		tabbedPane.addTab("Modeling", new ImageIcon(new ImageIcon(this.getClass().getResource("/Images/home.png"))
 				.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)), canvasSP, "Model a CPS");
-		
+
 		tabbedPane.addTab("New tab", null, label_1, null);
 
 		tabbedPane.addTab("Simulation",
@@ -374,12 +376,8 @@ public class GUI<E> implements CategoryListener {
 					} else {
 						temp = tableModelProperties.getValueAt(2, 1);
 						Float ftemp = Float.parseFloat(temp.toString());
-						System.out.println(ftemp);
 						model.getSelectedEdge().setCapacity(ftemp);
 					}
-					for (CpsEdge c : getActualCps().getConnections()) {
-						System.out.println(c.getA().getName() + " conected to " + c.getB().getName());
-					}
 				} catch (Exception e) {
 
 				}
@@ -601,30 +599,30 @@ public class GUI<E> implements CategoryListener {
 					}
 					tableModelProperties.setCellEditable(0, 1, true);
 					tableModelProperties.setCellEditable(2, 1, false);
-					ArrayList<CpsEdge> temp_array = temp.getConnectedTo();
+					ArrayList<CpsEdge> temp_array = temp.getConnections();
 					if (!temp_array.isEmpty()) {
 						boolean first = true;
 						for (CpsEdge temp2 : temp_array) {
 							if (first) {
 								first = false;
-								if (temp.getName().compareTo(temp2.getA().getCompareName()) == 0) {
+								if (temp.getID() != temp2.getA().getID()) {
 									Object[] tempConnection = { temp.getName() + " is connected to",
-											temp2.getB().getName() + " with ID: " + temp2.getB().getID() };
+											temp2.getA().getName() + " with ID: " + temp2.getA().getID() };
 									tableModelProperties.addRow(tempConnection);
 								} else {
 									Object[] tempConnection = { temp.getName() + " is connected to",
-											temp2.getA().getName() + " with ID: " + temp2.getA().getID() };
+											temp2.getB().getName() + " with ID: " + temp2.getB().getID() };
 									tableModelProperties.addRow(tempConnection);
 								}
-
 							} else {
-								if (temp.getName().compareTo(temp2.getA().getCompareName()) == 0) {
+								if (temp.getID() != temp2.getA().getID()) {
 									Object[] tempConnection = { "",
-											temp2.getB().getName() + " with ID: " + temp2.getB().getID() };
+											temp2.getA().getName() + " with ID: " + temp2.getA().getID() };
 									tableModelProperties.addRow(tempConnection);
+
 								} else {
 									Object[] tempConnection = { "",
-											temp2.getA().getName() + " with ID: " + temp2.getA().getID() };
+											temp2.getB().getName() + " with ID: " + temp2.getB().getID() };
 									tableModelProperties.addRow(tempConnection);
 								}
 
@@ -934,11 +932,10 @@ public class GUI<E> implements CategoryListener {
 		deleteRows();
 		if (canvas.dataSelected != null) {
 			fillElementTable(canvas.dataSelected);
-		}
-		/**
-		 * hinzugef�gt damit man auch nach dem objekt platziert wurde elemente
-		 * von Objekten in Kategorien ansehen kann
-		 */
+		} /**
+			 * hinzugef�gt damit man auch nach dem objekt platziert wurde
+			 * elemente von Objekten in Kategorien ansehen kann
+			 */
 		canvas.dataSelected = null;
 
 	}
@@ -963,13 +960,13 @@ public class GUI<E> implements CategoryListener {
 	 */
 	public void refreshTableProperties() {
 		CpsObject tempCps = getActualCps();
-		if (tempCps.getClass() == HolonObject.class && tempCps != null) {
+		if (tempCps != null && tempCps.getClass() == HolonObject.class) {
 			tableModelProperties.removeRow(2);
-			Object[] tempEnergy = { "Total Energy", ((HolonObject) canvas.tempCps).getCurrentEnergy() };
+			Object[] tempEnergy = { "Total Energy", ((HolonObject) tempCps).getCurrentEnergy() };
 			tableModelProperties.insertRow(2, tempEnergy);
 		}
 	}
-
+
 	private static void addPopup(Component component, final JPopupMenu popup) {
 		component.addMouseListener(new MouseAdapter() {
 			public void mousePressed(MouseEvent e) {
@@ -977,15 +974,17 @@ public class GUI<E> implements CategoryListener {
 					showMenu(e);
 				}
 			}
+
 			public void mouseReleased(MouseEvent e) {
 				if (e.isPopupTrigger()) {
 					showMenu(e);
 				}
 			}
+
 			private void showMenu(MouseEvent e) {
 				popup.show(e.getComponent(), e.getX(), e.getY());
 			}
 		});
 	}
-
+
 }