Ver código fonte

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

Kevin Trometer 7 anos atrás
pai
commit
3c954f31ae

+ 4 - 1
src/ui/controller/SimulationManager.java

@@ -595,7 +595,10 @@ public class SimulationManager {
 
 	public void setFlexiblePane(FlexiblePane fp) {
 		flexPane = fp;
-		
+	}
+	
+	public FlexiblePane getFlexiblePane(){
+		return flexPane;
 	}
 
 }

+ 9 - 7
src/ui/view/FlexiblePane.java

@@ -23,6 +23,12 @@ public class FlexiblePane extends JScrollPane {
 		flexPanel = new JPanel();
 		flexPanel.setLayout(new BoxLayout(flexPanel, BoxLayout.Y_AXIS));
 		setViewportView(flexPanel);
+		class ResizeListener extends ComponentAdapter{
+			public void componentResized(ComponentEvent e){
+				flexPanel.requestFocusInWindow();
+			}
+		}
+		this.addComponentListener(new ResizeListener());
 	}
 	
 	public void recalculate(){
@@ -66,13 +72,9 @@ public class FlexiblePane extends JScrollPane {
 			((FlexibleData)flexPanel.getComponent(0)).setCons(gridCons);
 			((FlexibleData)flexPanel.getComponent(0)).setProdConsVal(gridProd, gridCons);
 		}
-		
-		class ResizeListener extends ComponentAdapter{
-			public void componentResized(ComponentEvent e){
-				flexPanel.requestFocusInWindow();
-			}
-		}
-		this.addComponentListener(new ResizeListener());
+		flexPanel.revalidate();
+		flexPanel.repaint();
+		flexPanel.updateUI();
 	}
 	
 	public JPanel getPanel(){

+ 1 - 1
src/ui/view/GUI.java

@@ -655,7 +655,7 @@ public class GUI<E> implements CategoryListener {
 		mntmEditShowedInformation.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				try {
-					ShowedInformationPopUp dialog = new ShowedInformationPopUp(canvas, contentPane);
+					ShowedInformationPopUp dialog = new ShowedInformationPopUp(canvas, contentPane, controller);
 					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
 					dialog.setVisible(true);
 				} catch (Exception ex) {

+ 7 - 2
src/ui/view/ShowedInformationPopUp.java

@@ -10,6 +10,8 @@ import javax.swing.JDialog;
 import javax.swing.JPanel;
 import javax.swing.border.EmptyBorder;
 
+import ui.controller.Control;
+
 /**
  * This Class represents a Popup to edit the shown Information.
  * 
@@ -21,6 +23,7 @@ public class ShowedInformationPopUp extends JDialog {
 	private final JPanel contentPanel = new JPanel();
 	private final JButton btnOk = new JButton("OK");
 	private MyCanvas canvas;
+	private Control controller;
 	private JCheckBox objectEnergyCheckbox;
 	private JCheckBox connectionCheckbox;
 	private JCheckBox colorizedBorderCheckbox;
@@ -33,17 +36,18 @@ public class ShowedInformationPopUp extends JDialog {
 	 * @param canvas
 	 *            the Canvas
 	 */
-	public ShowedInformationPopUp(MyCanvas canvas, JPanel update) {
+	public ShowedInformationPopUp(MyCanvas canvas, JPanel update, Control cont) {
 		super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		this.setTitle(Languages.getLanguage()[31]);
-		setBounds(100, 100, 400, 254);
+		setBounds(100, 100, 400, 276);
 		getContentPane().setLayout(new BorderLayout());
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);
 		this.canvas = canvas;
 		this.toUpdate = update;
+		controller = cont;
 
 		objectEnergyCheckbox = new JCheckBox(Languages.getLanguage()[32]);
 		objectEnergyCheckbox.setBounds(19, 19, 300, 23);
@@ -59,6 +63,7 @@ public class ShowedInformationPopUp extends JDialog {
 			public void actionPerformed(ActionEvent arg0) {
 				setInformation(connectionCheckbox.isSelected(), objectEnergyCheckbox.isSelected(),
 						colorizedBorderCheckbox.isSelected(), nodeOfnodeConnectionCheckbox.isSelected());
+				controller.getSimManager().getFlexiblePane().recalculate();
 				dispose();
 			}
 		});

+ 26 - 0
src/ui/view/StatPanel2.java

@@ -61,6 +61,10 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 	public static final String AVG_WASTED_ENERGY_HOLONS = "Average wasted Energy";
 	public static final String NR_BROKEN_EDGES = "Amount of broken Edges";
 	public static final String PROD_CONS_RATIO = "Producer/Consumer Ratio";
+	public static final String AVG_CLOSED_SW_HOLON = "Average of closed Switches per Holon";
+	public static final String AVG_ACTIVE_ELEMENTS_HOLON = "Average of active Elements per Holon";
+	public static final String AVG_INACTIVE_ELEMENTS_HOLON = "Average of inactive Elements per Holon";
+	public static final String AVG_PRODUCTION_HOLON = "Average Production per Holon";
 	
 	public static final String TOT_PROD_OBJ = "total Production";
 	public static final String TOT_CONS_OBJ = "total Consumption";
@@ -127,6 +131,11 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 		holonHashtable.put(AVG_WASTED_ENERGY_HOLONS, new PropertyDataSet());
 		holonHashtable.put(NR_BROKEN_EDGES, new PropertyDataSet());
 		holonHashtable.put(PROD_CONS_RATIO, new PropertyDataSet());
+		holonHashtable.put(AVG_CLOSED_SW_HOLON, new PropertyDataSet());
+		holonHashtable.put(AVG_ACTIVE_ELEMENTS_HOLON, new PropertyDataSet());
+		holonHashtable.put(AVG_INACTIVE_ELEMENTS_HOLON, new PropertyDataSet());
+		holonHashtable.put(AVG_PRODUCTION_HOLON, new PropertyDataSet());
+
 		
 		//propValTable associates the Strings to the numbers
 		propValTable = new Hashtable<String, Integer>();
@@ -150,6 +159,15 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 		propValTable.put(AVG_WASTED_ENERGY_HOLONS, TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS);
 		propValTable.put(NR_BROKEN_EDGES, TrackedDataSet.AMOUNT_BROKEN_EDGES);
 		propValTable.put(PROD_CONS_RATIO, TrackedDataSet.RATIO_PRODUCERS_CONSUMERS);
+		propValTable.put(AVG_CLOSED_SW_HOLON, TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS);
+		propValTable.put(AVG_ACTIVE_ELEMENTS_HOLON, TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS);
+		propValTable.put(AVG_INACTIVE_ELEMENTS_HOLON, TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS);
+		propValTable.put(AVG_PRODUCTION_HOLON, TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS);
+
+
+		
+
+
 
 		JScrollPane graphScrollPane = new JScrollPane();
 		graphScrollPane.setBorder(null);
@@ -193,6 +211,14 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 		holonNode.add(new DefaultMutableTreeNode(AVG_WASTED_ENERGY_HOLONS));
 		holonNode.add(new DefaultMutableTreeNode(AVG_CONS_ENERGY_IN_HOLONS));
 		holonNode.add(new DefaultMutableTreeNode(AVG_PRODS_IN_HOLONS));
+		holonNode.add(new DefaultMutableTreeNode(AVG_CLOSED_SW_HOLON));
+		holonNode.add(new DefaultMutableTreeNode(AVG_ACTIVE_ELEMENTS_HOLON));
+		holonNode.add(new DefaultMutableTreeNode(AVG_INACTIVE_ELEMENTS_HOLON));
+		holonNode.add(new DefaultMutableTreeNode(AVG_PRODUCTION_HOLON));
+
+
+
+
 
 		objectsNode = new DefaultMutableTreeNode("Objects");
 		objectsNode.add(new DefaultMutableTreeNode("empty"));

+ 7 - 3
src/ui/view/UpperNodeCanvas.java

@@ -373,7 +373,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 								tabbedPane = (JTabbedPane) tempSplit.getLeftComponent();
 								tabbedPane2 = null;
 							}
-							//Look if the uppernode is open in a Tab
+							// Look if the uppernode is open in a Tab
 							for (int i = 4; i < tabbedPane.getTabCount(); i++) {
 								if (tabbedPane.getComponentAt(i) == null) {
 								} else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
@@ -388,8 +388,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 								if (tabbedPane2 != null
 										&& ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
 												.getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
-									((ButtonTabComponent) tabbedPane
-											.getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
+									((ButtonTabComponent) tabbedPane.getTabComponentAt(tabbedPane2.getSelectedIndex()))
+											.removeTabs();
 								}
 							} catch (Exception e2) {
 							}
@@ -715,6 +715,9 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 								g2.setColor(Color.RED);
 								g2.setStroke(new BasicStroke(2));
 							}
+							if (ed.getA().getId() == model.getSelectedObjectID()
+									|| ed.getB().getId() == model.getSelectedObjectID())
+								g2.setColor(Color.BLUE);
 						} else {
 							g2.setColor(Color.DARK_GRAY);
 							g2.setStroke(new BasicStroke(2));
@@ -853,6 +856,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 		dataSelected = null;
 		edgeHighlight = null;
 		controller.setSelecteEdge(null);
+		controller.setSelectedObjectID(-1);
 		// Object Selection
 
 		// Erase old data in the PropertyTable