浏览代码

hat noch bugs

username 6 年之前
父节点
当前提交
f46351106f
共有 3 个文件被更改,包括 34 次插入9 次删除
  1. 32 8
      src/exampleAlgorithms/FlexExample.java
  2. 1 1
      src/ui/controller/Control.java
  3. 1 0
      src/ui/view/MyCanvas.java

+ 32 - 8
src/exampleAlgorithms/FlexExample.java

@@ -56,7 +56,9 @@ public class FlexExample implements Algorithm {
 		private boolean useGroupNode = false;
 		private DecoratedGroupNode dGroupNode = null;
 		private boolean cancel = false;
-
+		private boolean overAllTimeSteps = false;
+		
+		
 
 		//Parameter defined by Algo
 		private HashMap<Integer, AccessWrapper> access;
@@ -143,6 +145,14 @@ public class FlexExample implements Algorithm {
 			borderPanel.add(useGroupNodeCheckBox);
 			
 			
+			JCheckBox overAllTimeStepsCheckbox = new JCheckBox("overAllTimeSteps");
+			overAllTimeStepsCheckbox.setSelected(false);
+			overAllTimeStepsCheckbox.setBounds(20, 30, 250, 30);
+			overAllTimeStepsCheckbox.addActionListener(actionEvent -> {
+				overAllTimeSteps = overAllTimeStepsCheckbox.isSelected();
+			});
+			parameterPanel.add(overAllTimeStepsCheckbox);
+			
 			NumberFormat format = NumberFormat.getIntegerInstance();
 			format.setGroupingUsed(false);
 			format.setParseIntegerOnly(true);
@@ -177,7 +187,10 @@ public class FlexExample implements Algorithm {
 			buttonPanel.add(undoButton);
 			JButton runButton =  new JButton("Run");
 			runButton.addActionListener(actionEvent -> {
-				Runnable task = () -> run();
+				Runnable task = () -> {
+					if(this.overAllTimeSteps)runAll();
+					else run();
+				};
 				runThread = new Thread(task);
 				runThread.start();
 			});
@@ -195,19 +208,30 @@ public class FlexExample implements Algorithm {
 			}
 		}
 		
-		private void run() {
+		private void runAll() {
 			cancel = false;
 			disableGuiInput(true);
 			startTimer();
-			executeDemoAlgo();
-			if(cancel) {
-				resetLast();
-				disableGuiInput(false);
-				return;
+			control.resetSimulation();
+			for(int i = 0; i < 100; i++) {
+				control.setCurIteration(i);
+				executeDemoAlgo();
+				if(cancel) {
+					resetLast();
+					disableGuiInput(false);
+					return;
+				}				
 			}
 			printElapsedTime();
 			disableGuiInput(false);
 		}
+		private void run() {
+			disableGuiInput(true);
+			startTimer();
+			executeDemoAlgo();
+			printElapsedTime();
+			disableGuiInput(false);
+		}
 		
 		private void resetLast() {
 			if(!resetChain.isEmpty()) {

+ 1 - 1
src/ui/controller/Control.java

@@ -486,7 +486,7 @@ public class Control {
      */
     public void setCurIteration(int curit) {
         globalController.setCurIteration(curit);
-        getGui().getTimePanel().getTimeSlider().setValue(curit);
+        //getGui().getTimePanel().getTimeSlider().setValue(curit);
     }
 
     /**

+ 1 - 0
src/ui/view/MyCanvas.java

@@ -584,6 +584,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		
 		VisualRepresentationalState  visualState = controller.getSimManager().getActualVisualRepresentationalState();
 		//VisualState Representation:
+		if(visualState == null) System.out.println("AHHH"); 
 		for(ExitCable cable : visualState.getExitCableList()) {
 			paintExitCable(g2d, cable);
 		}