Loading .idea/misc.xml +1 −2 Original line number Diff line number Diff line Loading @@ -7,9 +7,8 @@ <option value="$PROJECT_DIR$/pom.xml" /> </list> </option> <option name="workspaceImportForciblyTurnedOn" value="true" /> </component> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="22" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="22" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/out" /> </component> </project> No newline at end of file src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +19 −14 Original line number Diff line number Diff line Loading @@ -8,12 +8,11 @@ import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.geometry.Bounds; import javafx.geometry.Point3D; import javafx.geometry.Pos; import javafx.scene.*; import javafx.scene.control.Label; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.layout.StackPane; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Box; Loading Loading @@ -224,22 +223,28 @@ public class GraphicsAndWindowsTest extends Application { //Lays out the children in Z order with the last member being front most //Effectively allows you to layer multiple elements //We are layering our 3D scene with a 2D label on top of it StackPane Layers = new StackPane(); Layers.getChildren().addAll(subScene3D, fpsLabel, scoreLabel); StackPane.setAlignment(fpsLabel, Pos.BOTTOM_RIGHT); //Places FPS in bottom right StackPane.setAlignment(scoreLabel, Pos.TOP_LEFT); //Places FPS in bottom right // Use Pane instead of StackPane Pane layers = new Pane(); // This replaces StackPane for direct control layers.setPrefSize(1500, 800); // Set the preferred size to match the scene layers.getChildren().add(subScene3D); // Add the 3D subscene layers.getChildren().addAll(fpsLabel, scoreLabel); // Add labels fpsLabel.setLayoutX(1350); // Position the FPS label at the bottom-right corner fpsLabel.setLayoutY(780); scoreLabel.setLayoutX(20); // Position the score label at the top-left corner scoreLabel.setLayoutY(20); Scene scene = new Scene(Layers, 1500, 800); Scene scene = new Scene(layers, 1500, 800); /* Mouse event for setting anchors */ ourWindow.setOnMousePressed(mouseEvent -> { layers.setOnMousePressed(mouseEvent -> { anchorX = mouseEvent.getX(); anchorY = mouseEvent.getY(); //System.out.println("Mouse pressed at: " + anchorX + ", " + anchorY); System.out.println("Mouse pressed at: " + anchorX + ", " + anchorY); slingLine.setStroke(Color.RED); slingLine.setStrokeWidth(2); Loading @@ -247,14 +252,14 @@ public class GraphicsAndWindowsTest extends Application { slingLine.setStartY(anchorY); slingLine.setEndX(anchorX); slingLine.setEndY(anchorY); group3D.getChildren().add(slingLine); layers.getChildren().add(slingLine); }); /* Mouse event for drawing line as the mouse is dragged through the window. */ ourWindow.setOnMouseDragged(mouseEvent -> { layers.setOnMouseDragged(mouseEvent -> { double dragX = mouseEvent.getX(); double dragY = mouseEvent.getY(); //System.out.println("Mouse dragged to: " + dragX + ", " + dragY); Loading @@ -268,10 +273,10 @@ public class GraphicsAndWindowsTest extends Application { Mouse event to launch object and delete the slingLine drawn on window. */ ourWindow.setOnMouseReleased(mouseEvent -> { layers.setOnMouseReleased(mouseEvent -> { releaseX = mouseEvent.getX(); releaseY = mouseEvent.getY(); //System.out.println("Mouse released at: " + releaseX + ", " + releaseY); System.out.println("Mouse released at: " + releaseX + ", " + releaseY); for (MovingObject o : objects ) { double x = releaseX -anchorX; Loading @@ -282,7 +287,7 @@ public class GraphicsAndWindowsTest extends Application { } // Remove the sling visualization line group3D.getChildren().remove(slingLine); layers.getChildren().remove(slingLine); }); Loading target/classes/org/example/newmat/GraphicsAndWindowsTest$1.class (5.67 KiB) File changed.No diff preview for this file type. View original file View changed file target/classes/org/example/newmat/GraphicsAndWindowsTest$2.class (830 B) File changed.No diff preview for this file type. View original file View changed file target/classes/org/example/newmat/GraphicsAndWindowsTest.class +491 B (11.3 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
.idea/misc.xml +1 −2 Original line number Diff line number Diff line Loading @@ -7,9 +7,8 @@ <option value="$PROJECT_DIR$/pom.xml" /> </list> </option> <option name="workspaceImportForciblyTurnedOn" value="true" /> </component> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="22" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="22" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/out" /> </component> </project> No newline at end of file
src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +19 −14 Original line number Diff line number Diff line Loading @@ -8,12 +8,11 @@ import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.geometry.Bounds; import javafx.geometry.Point3D; import javafx.geometry.Pos; import javafx.scene.*; import javafx.scene.control.Label; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.layout.StackPane; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Box; Loading Loading @@ -224,22 +223,28 @@ public class GraphicsAndWindowsTest extends Application { //Lays out the children in Z order with the last member being front most //Effectively allows you to layer multiple elements //We are layering our 3D scene with a 2D label on top of it StackPane Layers = new StackPane(); Layers.getChildren().addAll(subScene3D, fpsLabel, scoreLabel); StackPane.setAlignment(fpsLabel, Pos.BOTTOM_RIGHT); //Places FPS in bottom right StackPane.setAlignment(scoreLabel, Pos.TOP_LEFT); //Places FPS in bottom right // Use Pane instead of StackPane Pane layers = new Pane(); // This replaces StackPane for direct control layers.setPrefSize(1500, 800); // Set the preferred size to match the scene layers.getChildren().add(subScene3D); // Add the 3D subscene layers.getChildren().addAll(fpsLabel, scoreLabel); // Add labels fpsLabel.setLayoutX(1350); // Position the FPS label at the bottom-right corner fpsLabel.setLayoutY(780); scoreLabel.setLayoutX(20); // Position the score label at the top-left corner scoreLabel.setLayoutY(20); Scene scene = new Scene(Layers, 1500, 800); Scene scene = new Scene(layers, 1500, 800); /* Mouse event for setting anchors */ ourWindow.setOnMousePressed(mouseEvent -> { layers.setOnMousePressed(mouseEvent -> { anchorX = mouseEvent.getX(); anchorY = mouseEvent.getY(); //System.out.println("Mouse pressed at: " + anchorX + ", " + anchorY); System.out.println("Mouse pressed at: " + anchorX + ", " + anchorY); slingLine.setStroke(Color.RED); slingLine.setStrokeWidth(2); Loading @@ -247,14 +252,14 @@ public class GraphicsAndWindowsTest extends Application { slingLine.setStartY(anchorY); slingLine.setEndX(anchorX); slingLine.setEndY(anchorY); group3D.getChildren().add(slingLine); layers.getChildren().add(slingLine); }); /* Mouse event for drawing line as the mouse is dragged through the window. */ ourWindow.setOnMouseDragged(mouseEvent -> { layers.setOnMouseDragged(mouseEvent -> { double dragX = mouseEvent.getX(); double dragY = mouseEvent.getY(); //System.out.println("Mouse dragged to: " + dragX + ", " + dragY); Loading @@ -268,10 +273,10 @@ public class GraphicsAndWindowsTest extends Application { Mouse event to launch object and delete the slingLine drawn on window. */ ourWindow.setOnMouseReleased(mouseEvent -> { layers.setOnMouseReleased(mouseEvent -> { releaseX = mouseEvent.getX(); releaseY = mouseEvent.getY(); //System.out.println("Mouse released at: " + releaseX + ", " + releaseY); System.out.println("Mouse released at: " + releaseX + ", " + releaseY); for (MovingObject o : objects ) { double x = releaseX -anchorX; Loading @@ -282,7 +287,7 @@ public class GraphicsAndWindowsTest extends Application { } // Remove the sling visualization line group3D.getChildren().remove(slingLine); layers.getChildren().remove(slingLine); }); Loading
target/classes/org/example/newmat/GraphicsAndWindowsTest$1.class (5.67 KiB) File changed.No diff preview for this file type. View original file View changed file
target/classes/org/example/newmat/GraphicsAndWindowsTest$2.class (830 B) File changed.No diff preview for this file type. View original file View changed file
target/classes/org/example/newmat/GraphicsAndWindowsTest.class +491 B (11.3 KiB) File changed.No diff preview for this file type. View original file View changed file