Ver Fonte

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

Jessey Widhalm há 8 anos atrás
pai
commit
f3867770b5

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

@@ -39,17 +39,15 @@ public class SimulationManager {
 				for(int i = 0; i < hl.getConnections().size(); i++){
 					CpsEdge edge = hl.getConnectedTo().get(i);
 					if(edge.getState()){
-						System.out.println(hl.getCurrentEnergyAtTimeStep(x));
-						System.out.println(edge.getFlow());
-						if((hl.getCurrentEnergyAtTimeStep(x) + edge.getFlow()) >= 0 ){
+						if((production + consumption) >= 0 ){
 							hl.setSupplied(true);
 						}else{
 							hl.setSupplied(false);
 						}
 						break;
 					}
+					hl.setSupplied(false);
 				}
-				System.out.println(hl.getName() + "is supplied:" + hl.getSupplied());
 			}
 		}
 		canvas.repaint();

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

@@ -461,6 +461,8 @@ public class GUI<E> implements CategoryListener {
 						}
 						refreshTableProperties();
 						tableModelHolonElement.fireTableDataChanged();
+						controller.calculateStateForTimeStep(model.getCurIteration());
+						unitGraph.repaint();
 					}
 				} catch (Exception e) {
 

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

@@ -183,7 +183,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 					if (((HolonObject) cps).getSupplied()) {
 						g2.setColor(Color.GREEN);
 					} else {
-						g2.setColor(Color.YELLOW);
+						g2.setColor(Color.ORANGE);
 					}
 					g2.fillRect(cps.getPosition().x - (controller.getScale() / 20),
 							cps.getPosition().y - (controller.getScale() / 20),
@@ -283,7 +283,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			x = e.getX();
 			y = e.getY();
 			dragging = false;
-			tempCps.setPosition(e.getX() - controller.getScaleDiv2(), e.getY() - controller.getScaleDiv2());
 		}
 
 		// Rightclick List
@@ -297,6 +296,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		}
 
 		doMark = false;
+		controller.calculateStateForTimeStep(model.getCurIteration());
 		repaint();
 	}
 
@@ -413,7 +413,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				}
 				if (newEdge) {
 					e = new CpsEdge(cps, tempCps);
-					controller.calculateStateForTimeStep(model.getCurIteration());
 					controller.AddEdgeOnCanvas(e);
 				}
 			}