Commit 112c3f8f authored by Stefan Michel's avatar Stefan Michel

- thread beendet nun richtig ( immernoch mit stop ), aber die button werden richtig disabled

parent 512137ae
......@@ -64,7 +64,7 @@ public class Main extends Application {
}
@Override
public void start(Stage primaryStage) throws Exception {
public void start(Stage primaryStage) {
Scene scene = new Scene(new MainViewCreationFX(terrain, terrainController, ioController, hamsterController, threadManager), 1000, 500);
primaryStage.setScene(scene);
primaryStage.setTitle(terrain.getName());
......
......@@ -13,13 +13,9 @@ import java.util.Optional;
public class SetFileNameDialogBox {
private boolean breiteIsValid = false;
private boolean hoeheIsValid = false;
private Terrain terrain;
private IOController ioController;
public SetFileNameDialogBox(Terrain terrain, IOController ioController) {
this.terrain = terrain;
this.ioController = ioController;
setFileNameDialogBox();
}
......
......@@ -8,6 +8,7 @@ import model.exceptions.WallException;
/**
* Created by Stefan Michel on 23.10.17.
*/
@SuppressWarnings("EmptyMethod")
public class Hamster extends Thread {
private Terrain terrain;
......@@ -61,10 +62,7 @@ public class Hamster extends Thread {
if (nextCol < 0 || nextRow < 0 || nextCol > terrain.getMaxCols() - 1 || nextRow > terrain.getMaxRows() - 1) {
return false;
}
if (terrain.getCornAmount(nextCol, nextRow) == -1) {
return false;
}
return true;
return terrain.getCornAmount(nextCol, nextRow) != -1;
}
@Invisible
......@@ -112,10 +110,10 @@ public class Hamster extends Thread {
}
public void stopHamster() {
super.stop();
running = false;
terrain.setChanged();
terrain.notifyObservers();
super.stop();
}
public boolean isRunning() {
......
......@@ -188,7 +188,7 @@ public class Terrain extends Observable {
super.notifyObservers();
if (hamster != null && hamster.isAlive()) {
try {
hamster.sleep((long) (-1 * speed + 1000));
Thread.sleep((long) (-1 * speed + 1000));
} catch (InterruptedException e) {
try {
hamster.wait();
......
......@@ -140,9 +140,7 @@ public class MainViewCreationFX extends VBox implements Observer {
menuItem.setOnAction(event -> {
try {
method.invoke(terrain.getHamster());
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
});
......@@ -397,16 +395,9 @@ public class MainViewCreationFX extends VBox implements Observer {
stopp.setDisable(true);
start.setOnAction(event -> {
threadManager.startThread();
});
pause.setOnAction(event -> {
threadManager.pauseThread();
});
stopp.setOnAction(event -> {
threadManager.stopThread();
});
start.setOnAction(event -> threadManager.startThread());
pause.setOnAction(event -> threadManager.pauseThread());
stopp.setOnAction(event -> threadManager.stopThread());
// Slider
slider = new Slider(0, 900, 450);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment