Skip to content
Snippets Groups Projects
Commit d355d7b9 authored by Vilde Enger Gravdal's avatar Vilde Enger Gravdal
Browse files

final commit

parent 59843e4a
No related branches found
No related tags found
No related merge requests found
......@@ -66,12 +66,12 @@ public class ChaosCanvas {
*/
public void plotPoint(Vector2D point) {
// Mapping continuous to discrete, assuming x and y are normalized [0, 1]
int x = (int) ((point.getX0() + 2.65) / 5.3 * this.width); // Tilpass etter behov
int x = (int) ((point.getX0() + 2.65) / 5.3 * this.width);
int y = (int) ((1.0 - (point.getX1() / 10.0))
* this.height); // Flipp Y for grafisk representasjon
* this.height);
if (x >= 0 && x < width && y >= 0 && y < height) {
canvas[y][x] = 1; // Setter punktet som tegnet/valgt
canvas[y][x] = 1;
}
}
......
......@@ -35,6 +35,11 @@ public class JuliaTransform implements Transform2D {
}
/**
* Returns the values of the complex point used in the transformation.
*
* @return the values of the complex point
*/
@Override
public double[] getValues() {
return new double[]{
......
......@@ -45,7 +45,7 @@ public class FilePicker extends VBox {
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
fileMenu.show(fileButton, Side.BOTTOM, 0, 0); // Position the menu right below the button
fileMenu.show(fileButton, Side.BOTTOM, 0, 0);
});
drawingArea.setStyle("-fx-border-color: black; -fx-border-width: 1px;");
......@@ -70,7 +70,6 @@ public class FilePicker extends VBox {
if (!file.getName().equals(".DS_Store")) {
MenuItem item = new MenuItem(file.getName());
item.setOnAction(e -> {
// Handle file selection here
System.out.println("Selected file: " + file.getName());
ChaosGameDescription fileHandler = null;
......@@ -80,17 +79,16 @@ public class FilePicker extends VBox {
throw new RuntimeException(ex);
}
int canvasWidth = 100; // Width of the canvas
int canvasHeight = 150; // Height of the canvas
int canvasWidth = 100;
int canvasHeight = 150;
ChaosCanvas chaosCanvas = new ChaosCanvas(canvasWidth, canvasHeight);
ChaosGame game = new ChaosGame(chaosCanvas, fileHandler);
game.runSteps(10000000);
drawingArea.getChildren().clear(); // Clear the drawing area before drawing
drawingArea.getChildren().clear();
// Pass the drawing area to the drawTransformation method
Drawing.drawTransformation(drawingArea, chaosCanvas);
chaosCanvas.printCanvas();
});
......
......@@ -54,13 +54,13 @@ public class Main extends Application {
// Create Canvas
Canvas javafxCanvas = new Canvas(canvasWidth, canvasHeight);
Pane canvasPane = new Pane(javafxCanvas); // Create a Pane to contain the Canvas
Pane canvasPane = new Pane(javafxCanvas);
// Draw lines using data from file
Drawing.drawTransformation(canvasPane, canvas); // Pass the Pane to the Drawing method
Drawing.drawTransformation(canvasPane, canvas);
// Add Canvas to layout
HBox root = new HBox(canvasPane); // Use the Pane instead of the Canvas
HBox root = new HBox(canvasPane);
// Set up scene and show the stage
Scene scene = new Scene(root);
......
......@@ -23,7 +23,7 @@ public class DrawingView {
this.model = model;
drawingArea = new Pane();
drawingArea.setStyle(
"-fx-background-color: white; -fx-border-color: black; -fx-border-width: 1px;"); // Set background and border
"-fx-background-color: white; -fx-border-color: black; -fx-border-width: 1px;");
drawingArea.setPrefSize(600, 500); // Set preferred size
container.getChildren().add(drawingArea);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment