Skip to content
Snippets Groups Projects
Commit e48ef630 authored by Magnus Eik's avatar Magnus Eik
Browse files

Add dummy radio buttons for fractal to ChaosGameGUIView.

parent 534eb91f
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@ import edu.ntnu.stud.chaosgame.model.generators.ChaosGameDescriptionFactory;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.Scene;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.RadioButton;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelWriter;
......@@ -34,6 +36,7 @@ public class ChaosGameGUIView {
private final Timeline timeline;
public ChaosGameGUIView(Stage primaryStage) throws IOException {
this.timeline = new Timeline(new KeyFrame(Duration.seconds(0.05), event -> this.drawChaosGame()));
......@@ -50,6 +53,14 @@ public class ChaosGameGUIView {
VBox sideMenu = new VBox();
//TEMPORARY CODE to test Chaos Games in GUI
ChaosGameDescriptionFactory factory = new ChaosGameDescriptionFactory();
ChaosGameDescription description = factory.getDescriptions().get(1);
ChaosCanvas canvas = new ChaosCanvas(1000, 1000, description.getMinCoords(), description.getMaxCoords());
game = new ChaosGame(description, canvas);
Button startButton = new Button("Start");
startButton.setOnAction(event -> timeline.play());
Button stopButton = new Button("Stop");
......@@ -62,6 +73,7 @@ public class ChaosGameGUIView {
WritableImage newWritableImage = new WritableImage(width, height);
setPixelWriter(newWritableImage.getPixelWriter());
setImageViewFromImage(newWritableImage);
canvas.clearCanvas();
});
Button clearButton = new Button("Clear");
......@@ -70,8 +82,21 @@ public class ChaosGameGUIView {
getImageView().setImage(null);
setCurrentLine(0);
});
// Radio buttons for choosing fractal type
ToggleGroup group = new ToggleGroup();
RadioButton sierpinskiRadioButton = new RadioButton("Sierpinski");
sierpinskiRadioButton.setToggleGroup(group);
sierpinskiRadioButton.setSelected(true);
RadioButton barnsleyRadioButton = new RadioButton("Barnsley");
barnsleyRadioButton.setToggleGroup(group);
RadioButton juliaRadioButton = new RadioButton("Julia");
juliaRadioButton.setToggleGroup(group);
sideMenu.getChildren().addAll(startButton,stopButton,newButton,clearButton);
sideMenu.getChildren().addAll(sierpinskiRadioButton, barnsleyRadioButton, juliaRadioButton);
BorderPane borderPane = new BorderPane();
borderPane.setCenter(imageView);
......@@ -83,20 +108,16 @@ public class ChaosGameGUIView {
primaryStage.setScene(scene);
primaryStage.show();
//TEMPORARY CODE to test Chaos Games in GUI
ChaosGameDescriptionFactory factory = new ChaosGameDescriptionFactory();
ChaosGameDescription description = factory.getDescriptions().get(0);
ChaosCanvas canvas = new ChaosCanvas(1000, 1000, description.getMinCoords(), description.getMaxCoords());
game = new ChaosGame(description, canvas);
}
public void drawChaosGame(){
ChaosCanvas canvas = game.getCanvas();
game.runSteps(100000);
game.runSteps(10);
// Test implementation for drawing fractals
int[][] betaArray = canvas.getCanvasArray();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment