Browse Source

little fixes

dominik.rieder 8 years ago
parent
commit
d844dfa68a

+ 13 - 3
src/ui/controller/SimulationManager.java

@@ -46,7 +46,7 @@ public class SimulationManager {
 					for(int i = 0; i < hl.getConnections().size(); i++){
 						CpsEdge edge = hl.getConnectedTo().get(i);
 						if(edge.getState() && edge.getFlow() > 0){
-							// 0 = no energy, 1 = not supplied, 2 = supplied
+							// 0 = no energy, 1 = not supplied, 2 = supplied, 3 = producer, 4 = partially supplied
 							if((production + consumption) >= 0){
 								hl.setState(2);
 							}
@@ -70,12 +70,22 @@ public class SimulationManager {
 	
 	public void setFlow(subNet sN){
 		for(HolonObject hl: sN.getObjects()){
-			if(hl.getCurrentEnergyAtTimeStep(timeStep) > 0){
-				fillConnectionsFor(hl, new ArrayList<Integer>(), new ArrayList<CpsEdge>(), hl.getCurrentEnergyAtTimeStep(timeStep));
+			float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
+			if(energy > 0){
+				//fillConnectionsFor(hl, new ArrayList<Integer>(), new ArrayList<CpsEdge>(), hl.getCurrentEnergyAtTimeStep(timeStep));
+				for(CpsEdge e : sN.getEdges()){
+					e.setFlow(e.getFlow() + energy);
+				}
 			}
 		}
 	}
 	
+	public void fillConnectionsFor(subNet sN, float energy){
+		for(CpsEdge e : sN.getEdges()){
+			e.setFlow(e.getFlow() + energy);
+		}
+	}
+	
 	public void fillConnectionsFor(CpsObject cps, ArrayList<Integer> visitedObj, ArrayList<CpsEdge> visitedEdges ,float energy ){
 		visitedObj.add(cps.getID());
 		for(CpsEdge e: cps.getConnections()){

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

@@ -102,7 +102,6 @@ public class GUI<E> implements CategoryListener {
 	private final ArrayList<HolonElement> selectedElements = new ArrayList<HolonElement>();
 	private String holonEleNamesDisplayed = "None ";
 	HashMap<Integer, ArrayList<HolonElement>> eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
-
 	private final JTree tree = new JTree();
 	private final JEditorPane dtrpnHereWillBe = new JEditorPane();
 	/******************************************
@@ -1515,6 +1514,7 @@ public class GUI<E> implements CategoryListener {
 					if (!eleTemp.contains(obtTemp.searchElement(eleTempName))) {
 						eleTemp.add(obtTemp.searchElement(eleTempName));
 						eleToDelete.replace(idTemp, eleTemp);
+				
 					}
 				} else if (toMultiHash == 2) {
 					eleTemp.add(obtTemp.searchElement(eleTempName));

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

@@ -79,10 +79,10 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	// contains the value of the Capacity for new created Edges
 	private float edgeCapacity;
 
-	public MyCanvas(Model model, Control control) {
+	public MyCanvas(Model mod, Control control) {
 		this.add(objectTT);
 		this.controller = control;
-		this.model = model;
+		this.model = mod;
 		
 		showedInformation[0] = true;
 		showedInformation[1] = false;

+ 11 - 7
src/ui/view/searchPopUp.java

@@ -30,8 +30,12 @@ public class searchPopUp extends JDialog {
 	private JTextField findTextField;
 	private Control controller;
 	private MyCanvas canvas;
+	private JRadioButton rdbtnForward;
+	private JRadioButton rdbtnBackward;
+	private JRadioButton rdbtnAll;
+	private JRadioButton rdbtnSingle;
 
-	searchPopUp(Control controller, MyCanvas canvas) {
+	searchPopUp(Control contr, MyCanvas can) {
 		super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		this.setTitle("Search for Objects");
@@ -41,8 +45,8 @@ public class searchPopUp extends JDialog {
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);
 
-		this.controller = controller;
-		this.canvas = canvas;
+		this.controller = contr;
+		this.canvas = can;
 
 		JLabel lblFind = new JLabel("Find:");
 		lblFind.setFont(new Font("Tahoma", Font.PLAIN, 13));
@@ -71,13 +75,13 @@ public class searchPopUp extends JDialog {
 		lblNewLabel.setBounds(10, 90, 82, 14);
 		contentPanel.add(lblNewLabel);
 
-		JRadioButton rdbtnForward = new JRadioButton("Forward");
+		rdbtnForward = new JRadioButton("Forward");
 		rdbtnForward.setFont(new Font("Tahoma", Font.PLAIN, 13));
 		rdbtnForward.setBounds(10, 111, 109, 23);
 		contentPanel.add(rdbtnForward);
 		rdbtnForward.setSelected(true);
 
-		JRadioButton rdbtnBackward = new JRadioButton("Backward");
+		rdbtnBackward = new JRadioButton("Backward");
 		rdbtnBackward.setFont(new Font("Tahoma", Font.PLAIN, 13));
 		rdbtnBackward.setBounds(10, 137, 109, 23);
 		contentPanel.add(rdbtnBackward);
@@ -87,13 +91,13 @@ public class searchPopUp extends JDialog {
 		lblScope.setBounds(122, 90, 46, 14);
 		contentPanel.add(lblScope);
 
-		JRadioButton rdbtnAll = new JRadioButton("All");
+		rdbtnAll = new JRadioButton("All");
 		rdbtnAll.setFont(new Font("Tahoma", Font.PLAIN, 13));
 		rdbtnAll.setBounds(121, 112, 109, 23);
 		contentPanel.add(rdbtnAll);
 		rdbtnAll.setSelected(true);
 
-		JRadioButton rdbtnSingle = new JRadioButton("Single");
+		rdbtnSingle = new JRadioButton("Single");
 		rdbtnSingle.setFont(new Font("Tahoma", Font.PLAIN, 13));
 		rdbtnSingle.setBounds(121, 138, 109, 23);
 		contentPanel.add(rdbtnSingle);