From 49d2c5d7ab920cc5aa2f5dff4a1fab9bfedc4a5d Mon Sep 17 00:00:00 2001 From: Eddy Date: Thu, 23 Mar 2023 14:54:45 +0100 Subject: [PATCH 01/13] WIP:piece graphics --- Piece/src/application/Piece.java | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Piece/src/application/Piece.java diff --git a/Piece/src/application/Piece.java b/Piece/src/application/Piece.java new file mode 100644 index 0000000..19e24b7 --- /dev/null +++ b/Piece/src/application/Piece.java @@ -0,0 +1,35 @@ +package application; +import javafx.application.Application; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.paint.Color; +import javafx.scene.shape.Polygon; +import javafx.stage.Stage; +public class Piece extends Application{ + + public void start(Stage primaryStage) throws Exception { + + Polygon piece1 = new Polygon(); + piece1.getPoints().addAll(new Double [] { + 0.0,0.0, + 200.0,0.0, + 200.0,200.0, + 100.0,200.0, + 100.0,100.0, + 0.0,100.0}); + + piece1.setFill(Color.LIMEGREEN); + piece1.setStroke(Color.BLACK); + + Group root = new Group(); + root.getChildren().addAll(piece1); + Scene scene = new Scene(root,490,450,Color.WHEAT); + primaryStage.setScene(scene); + primaryStage.setTitle("piece 1"); + primaryStage.show(); + } + + public static void main(String[] args) { + launch(args); + } +} \ No newline at end of file -- 2.46.0 From 5911d88918244f0eac1c2c42b6505120eb255c6b Mon Sep 17 00:00:00 2001 From: Eddy Date: Sat, 25 Mar 2023 18:22:47 +0100 Subject: [PATCH 02/13] progress with the rotation system but still not finished , it works tho --- Piece/src/application/Piece.java | 62 +++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/Piece/src/application/Piece.java b/Piece/src/application/Piece.java index 19e24b7..65a5c86 100644 --- a/Piece/src/application/Piece.java +++ b/Piece/src/application/Piece.java @@ -1,10 +1,17 @@ package application; import javafx.application.Application; +import javafx.event.Event; +import javafx.event.EventHandler; import javafx.scene.Group; -import javafx.scene.Scene; +import javafx.scene.Scene; +import javafx.scene.input.KeyEvent; +import javafx.scene.input.KeyCode; import javafx.scene.paint.Color; -import javafx.scene.shape.Polygon; +import javafx.scene.shape.Polygon; +import javafx.scene.transform.Rotate; +import javafx.animation.RotateTransition; import javafx.stage.Stage; +import javafx.util.Duration; public class Piece extends Application{ public void start(Stage primaryStage) throws Exception { @@ -17,16 +24,55 @@ public class Piece extends Application{ 100.0,200.0, 100.0,100.0, 0.0,100.0}); + + Group root = new Group(); + root.getChildren().addAll(piece1); + Scene scene = new Scene(root,490,450,Color.WHEAT); + primaryStage.setScene(scene); + primaryStage.setTitle("piece 1"); + primaryStage.show(); + + piece1.setFill(Color.LIMEGREEN); piece1.setStroke(Color.BLACK); + piece1.setStrokeWidth(3); + + + //Instantiating RotateTransition class to create the animation (rotation to the right) + RotateTransition rotaterght = new RotateTransition(); + //setting attributes for the RotateTransition + rotaterght.setByAngle(90); + rotaterght.autoReverseProperty(); + rotaterght.setDuration(Duration.millis(1000)); + rotaterght.setNode(piece1); + rotaterght.setAxis(Rotate.Z_AXIS); + + //Instantiating RotateTransition class to create the animation (rotation to the left) + RotateTransition rotatelft = new RotateTransition(); + //setting attributes for the RotateTransition + rotatelft.setByAngle(-90); + rotatelft.autoReverseProperty(); + rotatelft.setDuration(Duration.millis(1000)); + rotatelft.setNode(piece1); + rotatelft.setAxis(Rotate.Z_AXIS); + + + + scene.setOnKeyPressed(new EventHandler() { + + public void handle(KeyEvent event) {// 'event' means corresponds to clicking on the clipboard + switch (event.getCode()) {// 'getCode' gets the code of the key pressed on the clipboard + case RIGHT: rotaterght.play(); break; + case LEFT: rotatelft.play(); break; + default: System.out.println("this case hasn't been taken in charge yet"); + + } + } + }); + + - Group root = new Group(); - root.getChildren().addAll(piece1); - Scene scene = new Scene(root,490,450,Color.WHEAT); - primaryStage.setScene(scene); - primaryStage.setTitle("piece 1"); - primaryStage.show(); } public static void main(String[] args) { -- 2.46.0 From 895b20b680209177e15d7b478abdf11cec916ebf Mon Sep 17 00:00:00 2001 From: Eddy Date: Mon, 27 Mar 2023 01:14:05 +0200 Subject: [PATCH 03/13] new progress , succeded in moving the node with the mouse still not finished tho --- Piece/src/application/Piece.java | 60 +++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/Piece/src/application/Piece.java b/Piece/src/application/Piece.java index 65a5c86..acd3836 100644 --- a/Piece/src/application/Piece.java +++ b/Piece/src/application/Piece.java @@ -1,11 +1,14 @@ package application; import javafx.application.Application; +import javafx.scene.Node; import javafx.event.Event; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; +import javafx.scene.Cursor; import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyCode; +import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import javafx.scene.transform.Rotate; @@ -14,6 +17,8 @@ import javafx.stage.Stage; import javafx.util.Duration; public class Piece extends Application{ + double x; + double y; public void start(Stage primaryStage) throws Exception { Polygon piece1 = new Polygon(); @@ -57,6 +62,42 @@ public class Piece extends Application{ rotatelft.setNode(piece1); rotatelft.setAxis(Rotate.Z_AXIS); + /* */ + + piece1.setOnMousePressed(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + // record a delta distance for the drag and drop operation. + x = piece1.getLayoutX() - mouseEvent.getSceneX(); + y = piece1.getLayoutY() - mouseEvent.getSceneY(); + piece1.setCursor(Cursor.CLOSED_HAND); + piece1.setFill(Color.AZURE); + } + }); + + piece1.setOnMouseReleased(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + piece1.setCursor(Cursor.HAND); + piece1.setFill(Color.LIMEGREEN); + } + }); + + piece1.setOnMouseDragged(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + piece1.setLayoutX(mouseEvent.getSceneX() + x); + piece1.setLayoutY(mouseEvent.getSceneY() + y); + } + }); + + piece1.setOnMouseEntered(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + piece1.setCursor(Cursor.HAND); + } + }); + + + + + scene.setOnKeyPressed(new EventHandler() { @@ -72,9 +113,26 @@ public class Piece extends Application{ }); - } + /*public void pressed(MouseEvent event, Polygon piece1) { + piece1.setFill(Color.AZURE); + int x = piece1.getLayoutX() - MouseEvent.getSceneX(); + int y = piece1.getLayoutY() - MouseEvent.getSceneY(); + piece1.setCursor(Cursor.MOVE); + } + + public void dragged(MouseEvent event, Polygon piece1) { + piece1.setLayoutX(event.getSceneX()+ x); + piece1.setLayoutY(event.getSceneY()+ y); + piece1.draw(); + } + + public void released(MouseEvent event, Polygon piece1) { + piece1.setCursor(Cursor.HAND); + } + */ + public static void main(String[] args) { launch(args); } -- 2.46.0 From bb5e2ff4012cc6427a52e745659cf4f205ad5de0 Mon Sep 17 00:00:00 2001 From: Eddy Date: Mon, 27 Mar 2023 01:19:34 +0200 Subject: [PATCH 04/13] new progress , succeded in moving the node with the mouse still not finished tho --- Piece/src/application/Piece.java | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/Piece/src/application/Piece.java b/Piece/src/application/Piece.java index acd3836..357320f 100644 --- a/Piece/src/application/Piece.java +++ b/Piece/src/application/Piece.java @@ -56,17 +56,16 @@ public class Piece extends Application{ //Instantiating RotateTransition class to create the animation (rotation to the left) RotateTransition rotatelft = new RotateTransition(); //setting attributes for the RotateTransition - rotatelft.setByAngle(-90); + rotatelft.setByAngle(-90);// minus to rotate to the left rotatelft.autoReverseProperty(); rotatelft.setDuration(Duration.millis(1000)); rotatelft.setNode(piece1); rotatelft.setAxis(Rotate.Z_AXIS); - /* */ - - piece1.setOnMousePressed(new EventHandler() { + //Mouse events handling + piece1.setOnMousePressed(new EventHandler() { @Override public void handle(MouseEvent mouseEvent) { - // record a delta distance for the drag and drop operation. + // record a (x,y) distance for the drag and drop operation. x = piece1.getLayoutX() - mouseEvent.getSceneX(); y = piece1.getLayoutY() - mouseEvent.getSceneY(); piece1.setCursor(Cursor.CLOSED_HAND); @@ -96,9 +95,6 @@ public class Piece extends Application{ - - - scene.setOnKeyPressed(new EventHandler() { @@ -115,23 +111,6 @@ public class Piece extends Application{ } - /*public void pressed(MouseEvent event, Polygon piece1) { - piece1.setFill(Color.AZURE); - int x = piece1.getLayoutX() - MouseEvent.getSceneX(); - int y = piece1.getLayoutY() - MouseEvent.getSceneY(); - piece1.setCursor(Cursor.MOVE); - } - - public void dragged(MouseEvent event, Polygon piece1) { - piece1.setLayoutX(event.getSceneX()+ x); - piece1.setLayoutY(event.getSceneY()+ y); - piece1.draw(); - } - - public void released(MouseEvent event, Polygon piece1) { - piece1.setCursor(Cursor.HAND); - } - */ public static void main(String[] args) { launch(args); -- 2.46.0 From a99a53868b7f0469c5eb1ae249fad37edc5155e8 Mon Sep 17 00:00:00 2001 From: Eddy Date: Thu, 30 Mar 2023 11:47:23 +0200 Subject: [PATCH 05/13] progress --- Piece/src/application/Piece.java | 244 ++++++++++++++++++++++--------- 1 file changed, 176 insertions(+), 68 deletions(-) diff --git a/Piece/src/application/Piece.java b/Piece/src/application/Piece.java index 357320f..c5eadb8 100644 --- a/Piece/src/application/Piece.java +++ b/Piece/src/application/Piece.java @@ -3,6 +3,7 @@ import javafx.application.Application; import javafx.scene.Node; import javafx.event.Event; import javafx.event.EventHandler; +import javafx.scene.layout.Pane; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.Cursor; @@ -12,6 +13,7 @@ import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import javafx.scene.transform.Rotate; +import javafx.scene.transform.Scale; import javafx.animation.RotateTransition; import javafx.stage.Stage; import javafx.util.Duration; @@ -19,9 +21,21 @@ public class Piece extends Application{ double x; double y; + + + public void start(Stage primaryStage) throws Exception { Polygon piece1 = new Polygon(); + Polygon piece2 = new Polygon(); + Polygon piece3 = new Polygon(); + Polygon piece4 = new Polygon(); + Polygon piece5 = new Polygon(); + Polygon piece6 = new Polygon(); + Polygon piece7 = new Polygon(); + + + piece1.getPoints().addAll(new Double [] { 0.0,0.0, 200.0,0.0, @@ -29,90 +43,184 @@ public class Piece extends Application{ 100.0,200.0, 100.0,100.0, 0.0,100.0}); + + piece2.getPoints().addAll(new Double [] { + 100.0,0.0, + 200.0,0.0, + 200.0,300.0, + 100.0,300.0, + }); + + piece3.getPoints().addAll(new Double [] { + 0.0,0.0, + 200.0,0.0, + 200.0,200.0, + 0.0,200.0, + }); + + piece4.getPoints().addAll(new Double [] { + 0.0,0.0, + 200.0,0.0, + 200.0,300.0, + 0.0,300.0, + + }); + + piece5.getPoints().addAll(new Double [] { + 0.0,0.0, + 100.0,0.0, + 100.0,100.0, + 0.0,100.0, + }); + + piece6.getPoints().addAll(new Double [] { + 0.0,0.0, + 200.0,0.0, + 200.0,300.0, + 100.0,300.0, + 100.0,100.0, + 0.0,100.0}); + + piece7.getPoints().addAll(new Double [] { + 100.0,0.0, + 200.0,0.0, + 200.0,200.0, + 100.0,200.0, + }); - Group root = new Group(); - root.getChildren().addAll(piece1); - Scene scene = new Scene(root,490,450,Color.WHEAT); - primaryStage.setScene(scene); - primaryStage.setTitle("piece 1"); - primaryStage.show(); + /*for(int i ; i makeDraggable((Polygon) n)); + root.getChildren().forEach(n -> rotation((Polygon) n, scene)); + primaryStage.setScene(scene); + primaryStage.setTitle("piece 1"); + + primaryStage.show(); piece1.setFill(Color.LIMEGREEN); piece1.setStroke(Color.BLACK); piece1.setStrokeWidth(3); + + piece2.setFill(Color.LIMEGREEN); + piece2.setStroke(Color.BLACK); + piece2.setStrokeWidth(3); + + piece3.setFill(Color.LIMEGREEN); + piece3.setStroke(Color.BLACK); + piece3.setStrokeWidth(3); + + piece4.setFill(Color.LIMEGREEN); + piece4.setStroke(Color.BLACK); + piece4.setStrokeWidth(3); + + piece5.setFill(Color.LIMEGREEN); + piece5.setStroke(Color.BLACK); + piece5.setStrokeWidth(3); + + piece6.setFill(Color.LIMEGREEN); + piece6.setStroke(Color.BLACK); + piece6.setStrokeWidth(3); + + piece7.setFill(Color.LIMEGREEN); + piece7.setStroke(Color.BLACK); + piece7.setStrokeWidth(3); - - //Instantiating RotateTransition class to create the animation (rotation to the right) - RotateTransition rotaterght = new RotateTransition(); - //setting attributes for the RotateTransition - rotaterght.setByAngle(90); - rotaterght.autoReverseProperty(); - rotaterght.setDuration(Duration.millis(1000)); - rotaterght.setNode(piece1); - rotaterght.setAxis(Rotate.Z_AXIS); - - //Instantiating RotateTransition class to create the animation (rotation to the left) - RotateTransition rotatelft = new RotateTransition(); - //setting attributes for the RotateTransition - rotatelft.setByAngle(-90);// minus to rotate to the left - rotatelft.autoReverseProperty(); - rotatelft.setDuration(Duration.millis(1000)); - rotatelft.setNode(piece1); - rotatelft.setAxis(Rotate.Z_AXIS); - - //Mouse events handling - piece1.setOnMousePressed(new EventHandler() { - @Override public void handle(MouseEvent mouseEvent) { - // record a (x,y) distance for the drag and drop operation. - x = piece1.getLayoutX() - mouseEvent.getSceneX(); - y = piece1.getLayoutY() - mouseEvent.getSceneY(); - piece1.setCursor(Cursor.CLOSED_HAND); - piece1.setFill(Color.AZURE); - } - }); - - piece1.setOnMouseReleased(new EventHandler() { - @Override public void handle(MouseEvent mouseEvent) { - piece1.setCursor(Cursor.HAND); - piece1.setFill(Color.LIMEGREEN); - } - }); - - piece1.setOnMouseDragged(new EventHandler() { - @Override public void handle(MouseEvent mouseEvent) { - piece1.setLayoutX(mouseEvent.getSceneX() + x); - piece1.setLayoutY(mouseEvent.getSceneY() + y); - } - }); - - piece1.setOnMouseEntered(new EventHandler() { - @Override public void handle(MouseEvent mouseEvent) { - piece1.setCursor(Cursor.HAND); - } - }); - - - - scene.setOnKeyPressed(new EventHandler() { - + } + //double click delayed bug to fix + public static void rotaterght (Node node) { + RotateTransition rotaterght = new RotateTransition(); + //setting attributes for the RotateTransition + rotaterght.setByAngle(90); + rotaterght.autoReverseProperty(); + rotaterght.setDuration(Duration.millis(1000)); + rotaterght.setNode(node); + rotaterght.setAxis(Rotate.Z_AXIS); + rotaterght.play();} + + public static void rotatelft (Node node) { + //Instantiating RotateTransition class to create the animation (rotation to the left) + RotateTransition rotatelft = new RotateTransition(); + //setting attributes for the RotateTransition + rotatelft.setByAngle(-90);// minus to rotate to the left + rotatelft.autoReverseProperty(); + rotatelft.setDuration(Duration.millis(1000)); + rotatelft.setNode(node); + rotatelft.setAxis(Rotate.Z_AXIS); + rotatelft.play();} + + public void rotation (Polygon node, Scene scene) { + scene.setOnKeyPressed(new EventHandler() { public void handle(KeyEvent event) {// 'event' means corresponds to clicking on the clipboard switch (event.getCode()) {// 'getCode' gets the code of the key pressed on the clipboard - case RIGHT: rotaterght.play(); break; - case LEFT: rotatelft.play(); break; + case RIGHT: rotaterght(node); break; + //args to set + case LEFT: rotatelft(node); break; default: System.out.println("this case hasn't been taken in charge yet"); } } - }); + }); + } + + + + public void makeDraggable(Polygon node) { + node.setOnMousePressed(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + // record a (x,y) distance for the drag and drop operation. + x = node.getLayoutX() - mouseEvent.getSceneX(); + y = node.getLayoutY() - mouseEvent.getSceneY(); + node.requestFocus(); + node.setFocusTraversable(true); + node.focusedProperty(); + node.focusVisibleProperty(); + /*node.setFocused(true);*/ + node.setCursor(Cursor.CLOSED_HAND); + node.setFill(Color.AZURE); + } + }); - - } - + node.setOnMouseReleased(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + node.setCursor(Cursor.HAND); + node.setFill(Color.LIMEGREEN); + } + }); + + node.setOnMouseDragged(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + node.setLayoutX(mouseEvent.getSceneX() + x); + node.setLayoutY(mouseEvent.getSceneY() + y); + } + }); + + node.setOnMouseEntered(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + node.setCursor(Cursor.HAND); + } + }); + + } + public static void main(String[] args) { launch(args); - } -} \ No newline at end of file + } +} -- 2.46.0 From 5bfb2aba9ba8c3d3fc11b5e17c7ce89652793433 Mon Sep 17 00:00:00 2001 From: Eddy Date: Thu, 30 Mar 2023 11:51:47 +0200 Subject: [PATCH 06/13] progress --- Piece/src/application/Piece.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Piece/src/application/Piece.java b/Piece/src/application/Piece.java index c5eadb8..e632b4c 100644 --- a/Piece/src/application/Piece.java +++ b/Piece/src/application/Piece.java @@ -23,7 +23,6 @@ public class Piece extends Application{ double y; - public void start(Stage primaryStage) throws Exception { Polygon piece1 = new Polygon(); @@ -144,6 +143,7 @@ public class Piece extends Application{ } //double click delayed bug to fix + //ftm just the last piece implemented can be rotated public static void rotaterght (Node node) { RotateTransition rotaterght = new RotateTransition(); //setting attributes for the RotateTransition @@ -155,9 +155,9 @@ public class Piece extends Application{ rotaterght.play();} public static void rotatelft (Node node) { - //Instantiating RotateTransition class to create the animation (rotation to the left) + RotateTransition rotatelft = new RotateTransition(); - //setting attributes for the RotateTransition + rotatelft.setByAngle(-90);// minus to rotate to the left rotatelft.autoReverseProperty(); rotatelft.setDuration(Duration.millis(1000)); -- 2.46.0 From 90f25b1c26194e449ff8d4fedec250eaa5f4acfa Mon Sep 17 00:00:00 2001 From: BrokenBrad Date: Thu, 30 Mar 2023 23:58:06 +0200 Subject: [PATCH 07/13] Ajouter 'app/src/main/java/school_project/Piece.java' --- app/src/main/java/school_project/Piece.java | 226 ++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 app/src/main/java/school_project/Piece.java diff --git a/app/src/main/java/school_project/Piece.java b/app/src/main/java/school_project/Piece.java new file mode 100644 index 0000000..e632b4c --- /dev/null +++ b/app/src/main/java/school_project/Piece.java @@ -0,0 +1,226 @@ +package application; +import javafx.application.Application; +import javafx.scene.Node; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.scene.layout.Pane; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.Cursor; +import javafx.scene.input.KeyEvent; +import javafx.scene.input.KeyCode; +import javafx.scene.input.MouseEvent; +import javafx.scene.paint.Color; +import javafx.scene.shape.Polygon; +import javafx.scene.transform.Rotate; +import javafx.scene.transform.Scale; +import javafx.animation.RotateTransition; +import javafx.stage.Stage; +import javafx.util.Duration; +public class Piece extends Application{ + + double x; + double y; + + + public void start(Stage primaryStage) throws Exception { + + Polygon piece1 = new Polygon(); + Polygon piece2 = new Polygon(); + Polygon piece3 = new Polygon(); + Polygon piece4 = new Polygon(); + Polygon piece5 = new Polygon(); + Polygon piece6 = new Polygon(); + Polygon piece7 = new Polygon(); + + + + piece1.getPoints().addAll(new Double [] { + 0.0,0.0, + 200.0,0.0, + 200.0,200.0, + 100.0,200.0, + 100.0,100.0, + 0.0,100.0}); + + piece2.getPoints().addAll(new Double [] { + 100.0,0.0, + 200.0,0.0, + 200.0,300.0, + 100.0,300.0, + }); + + piece3.getPoints().addAll(new Double [] { + 0.0,0.0, + 200.0,0.0, + 200.0,200.0, + 0.0,200.0, + }); + + piece4.getPoints().addAll(new Double [] { + 0.0,0.0, + 200.0,0.0, + 200.0,300.0, + 0.0,300.0, + + }); + + piece5.getPoints().addAll(new Double [] { + 0.0,0.0, + 100.0,0.0, + 100.0,100.0, + 0.0,100.0, + }); + + piece6.getPoints().addAll(new Double [] { + 0.0,0.0, + 200.0,0.0, + 200.0,300.0, + 100.0,300.0, + 100.0,100.0, + 0.0,100.0}); + + piece7.getPoints().addAll(new Double [] { + 100.0,0.0, + 200.0,0.0, + 200.0,200.0, + 100.0,200.0, + }); + + /*for(int i ; i makeDraggable((Polygon) n)); + root.getChildren().forEach(n -> rotation((Polygon) n, scene)); + primaryStage.setScene(scene); + primaryStage.setTitle("piece 1"); + + primaryStage.show(); + + + + piece1.setFill(Color.LIMEGREEN); + piece1.setStroke(Color.BLACK); + piece1.setStrokeWidth(3); + + piece2.setFill(Color.LIMEGREEN); + piece2.setStroke(Color.BLACK); + piece2.setStrokeWidth(3); + + piece3.setFill(Color.LIMEGREEN); + piece3.setStroke(Color.BLACK); + piece3.setStrokeWidth(3); + + piece4.setFill(Color.LIMEGREEN); + piece4.setStroke(Color.BLACK); + piece4.setStrokeWidth(3); + + piece5.setFill(Color.LIMEGREEN); + piece5.setStroke(Color.BLACK); + piece5.setStrokeWidth(3); + + piece6.setFill(Color.LIMEGREEN); + piece6.setStroke(Color.BLACK); + piece6.setStrokeWidth(3); + + piece7.setFill(Color.LIMEGREEN); + piece7.setStroke(Color.BLACK); + piece7.setStrokeWidth(3); + + + } + //double click delayed bug to fix + //ftm just the last piece implemented can be rotated + public static void rotaterght (Node node) { + RotateTransition rotaterght = new RotateTransition(); + //setting attributes for the RotateTransition + rotaterght.setByAngle(90); + rotaterght.autoReverseProperty(); + rotaterght.setDuration(Duration.millis(1000)); + rotaterght.setNode(node); + rotaterght.setAxis(Rotate.Z_AXIS); + rotaterght.play();} + + public static void rotatelft (Node node) { + + RotateTransition rotatelft = new RotateTransition(); + + rotatelft.setByAngle(-90);// minus to rotate to the left + rotatelft.autoReverseProperty(); + rotatelft.setDuration(Duration.millis(1000)); + rotatelft.setNode(node); + rotatelft.setAxis(Rotate.Z_AXIS); + rotatelft.play();} + + public void rotation (Polygon node, Scene scene) { + scene.setOnKeyPressed(new EventHandler() { + public void handle(KeyEvent event) {// 'event' means corresponds to clicking on the clipboard + switch (event.getCode()) {// 'getCode' gets the code of the key pressed on the clipboard + case RIGHT: rotaterght(node); break; + //args to set + case LEFT: rotatelft(node); break; + default: System.out.println("this case hasn't been taken in charge yet"); + + } + } + }); + } + + + + public void makeDraggable(Polygon node) { + node.setOnMousePressed(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + // record a (x,y) distance for the drag and drop operation. + x = node.getLayoutX() - mouseEvent.getSceneX(); + y = node.getLayoutY() - mouseEvent.getSceneY(); + node.requestFocus(); + node.setFocusTraversable(true); + node.focusedProperty(); + node.focusVisibleProperty(); + /*node.setFocused(true);*/ + node.setCursor(Cursor.CLOSED_HAND); + node.setFill(Color.AZURE); + } + }); + + node.setOnMouseReleased(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + node.setCursor(Cursor.HAND); + node.setFill(Color.LIMEGREEN); + } + }); + + node.setOnMouseDragged(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + node.setLayoutX(mouseEvent.getSceneX() + x); + node.setLayoutY(mouseEvent.getSceneY() + y); + } + }); + + node.setOnMouseEntered(new EventHandler() { + @Override public void handle(MouseEvent mouseEvent) { + node.setCursor(Cursor.HAND); + } + }); + + } + + + public static void main(String[] args) { + launch(args); + } +} -- 2.46.0 From 70fef807d5cfd394ad33fa3772fb7dba42d5e598 Mon Sep 17 00:00:00 2001 From: BrokenBrad Date: Thu, 30 Mar 2023 23:58:42 +0200 Subject: [PATCH 08/13] Supprimer 'app/src/main/java/school_project/Controller.java' --- .../main/java/school_project/Controller.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 app/src/main/java/school_project/Controller.java diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java deleted file mode 100644 index c979cac..0000000 --- a/app/src/main/java/school_project/Controller.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This Java source file was generated by the Gradle 'init' task. - */ -package school_project; - -import javafx.application.Application; -import javafx.scene.Group; -import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.stage.Stage; - -public class Controller extends Application { - - @Override - public void start(Stage primaryStage) throws Exception { - primaryStage.setTitle("test"); - Button btn = new Button("test"); - btn.setOnAction(event -> System.out.println("hey")); - - Group root = new Group(); - root.getChildren().add(btn); - - Scene scene = new Scene(root, 300,300); - primaryStage.setScene(scene); - - primaryStage.show(); - } - - public static void main(String[] args) { - launch(); - } -} -- 2.46.0 From fbbda476b47da73b3e35a482e64cec7454b20421 Mon Sep 17 00:00:00 2001 From: BrokenBrad Date: Thu, 30 Mar 2023 23:59:21 +0200 Subject: [PATCH 09/13] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'app/src/main?= =?UTF-8?q?/java/school=5Fproject/Controller.java'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/school_project/{Piece.java => Controller.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/src/main/java/school_project/{Piece.java => Controller.java} (100%) diff --git a/app/src/main/java/school_project/Piece.java b/app/src/main/java/school_project/Controller.java similarity index 100% rename from app/src/main/java/school_project/Piece.java rename to app/src/main/java/school_project/Controller.java -- 2.46.0 From d4f254139c7102a227fb5ba08712eb91fcf838fe Mon Sep 17 00:00:00 2001 From: BrokenBrad Date: Fri, 31 Mar 2023 00:20:47 +0200 Subject: [PATCH 10/13] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'app/src/main?= =?UTF-8?q?/java/school=5Fproject/Controller.java'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/school_project/Controller.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index e632b4c..42ad843 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -1,4 +1,4 @@ -package application; +package school_project; import javafx.application.Application; import javafx.scene.Node; import javafx.event.Event; -- 2.46.0 From 78e50549d007d9462feb15eb6f96d23d19339882 Mon Sep 17 00:00:00 2001 From: BrokenBrad Date: Tue, 4 Apr 2023 15:20:40 +0200 Subject: [PATCH 11/13] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'app/src/main?= =?UTF-8?q?/java/school=5Fproject/Controller.java'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/school_project/Controller.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index 42ad843..15cf89f 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -17,7 +17,7 @@ import javafx.scene.transform.Scale; import javafx.animation.RotateTransition; import javafx.stage.Stage; import javafx.util.Duration; -public class Piece extends Application{ +public class Piece extends school_project{ double x; double y; -- 2.46.0 From a6fc46a0eab81a82e89af5940ed1b97e95de14dc Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Thu, 6 Apr 2023 18:15:33 +0200 Subject: [PATCH 12/13] Fixing Branch --- app/src/main/java/school_project/Controller.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index 15cf89f..ac18101 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -8,16 +8,14 @@ import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.Cursor; import javafx.scene.input.KeyEvent; -import javafx.scene.input.KeyCode; import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import javafx.scene.transform.Rotate; -import javafx.scene.transform.Scale; import javafx.animation.RotateTransition; import javafx.stage.Stage; import javafx.util.Duration; -public class Piece extends school_project{ +public class Controller extends Application{ double x; double y; -- 2.46.0 From 37cc19f49a893ffc0f7c582a294298b60b75b178 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Thu, 6 Apr 2023 18:25:04 +0200 Subject: [PATCH 13/13] fixup! Fixing Branch --- Piece/src/application/Piece.java | 226 ------------------ .../main/java/school_project/Controller.java | 4 +- 2 files changed, 1 insertion(+), 229 deletions(-) delete mode 100644 Piece/src/application/Piece.java diff --git a/Piece/src/application/Piece.java b/Piece/src/application/Piece.java deleted file mode 100644 index e632b4c..0000000 --- a/Piece/src/application/Piece.java +++ /dev/null @@ -1,226 +0,0 @@ -package application; -import javafx.application.Application; -import javafx.scene.Node; -import javafx.event.Event; -import javafx.event.EventHandler; -import javafx.scene.layout.Pane; -import javafx.scene.Group; -import javafx.scene.Scene; -import javafx.scene.Cursor; -import javafx.scene.input.KeyEvent; -import javafx.scene.input.KeyCode; -import javafx.scene.input.MouseEvent; -import javafx.scene.paint.Color; -import javafx.scene.shape.Polygon; -import javafx.scene.transform.Rotate; -import javafx.scene.transform.Scale; -import javafx.animation.RotateTransition; -import javafx.stage.Stage; -import javafx.util.Duration; -public class Piece extends Application{ - - double x; - double y; - - - public void start(Stage primaryStage) throws Exception { - - Polygon piece1 = new Polygon(); - Polygon piece2 = new Polygon(); - Polygon piece3 = new Polygon(); - Polygon piece4 = new Polygon(); - Polygon piece5 = new Polygon(); - Polygon piece6 = new Polygon(); - Polygon piece7 = new Polygon(); - - - - piece1.getPoints().addAll(new Double [] { - 0.0,0.0, - 200.0,0.0, - 200.0,200.0, - 100.0,200.0, - 100.0,100.0, - 0.0,100.0}); - - piece2.getPoints().addAll(new Double [] { - 100.0,0.0, - 200.0,0.0, - 200.0,300.0, - 100.0,300.0, - }); - - piece3.getPoints().addAll(new Double [] { - 0.0,0.0, - 200.0,0.0, - 200.0,200.0, - 0.0,200.0, - }); - - piece4.getPoints().addAll(new Double [] { - 0.0,0.0, - 200.0,0.0, - 200.0,300.0, - 0.0,300.0, - - }); - - piece5.getPoints().addAll(new Double [] { - 0.0,0.0, - 100.0,0.0, - 100.0,100.0, - 0.0,100.0, - }); - - piece6.getPoints().addAll(new Double [] { - 0.0,0.0, - 200.0,0.0, - 200.0,300.0, - 100.0,300.0, - 100.0,100.0, - 0.0,100.0}); - - piece7.getPoints().addAll(new Double [] { - 100.0,0.0, - 200.0,0.0, - 200.0,200.0, - 100.0,200.0, - }); - - /*for(int i ; i makeDraggable((Polygon) n)); - root.getChildren().forEach(n -> rotation((Polygon) n, scene)); - primaryStage.setScene(scene); - primaryStage.setTitle("piece 1"); - - primaryStage.show(); - - - - piece1.setFill(Color.LIMEGREEN); - piece1.setStroke(Color.BLACK); - piece1.setStrokeWidth(3); - - piece2.setFill(Color.LIMEGREEN); - piece2.setStroke(Color.BLACK); - piece2.setStrokeWidth(3); - - piece3.setFill(Color.LIMEGREEN); - piece3.setStroke(Color.BLACK); - piece3.setStrokeWidth(3); - - piece4.setFill(Color.LIMEGREEN); - piece4.setStroke(Color.BLACK); - piece4.setStrokeWidth(3); - - piece5.setFill(Color.LIMEGREEN); - piece5.setStroke(Color.BLACK); - piece5.setStrokeWidth(3); - - piece6.setFill(Color.LIMEGREEN); - piece6.setStroke(Color.BLACK); - piece6.setStrokeWidth(3); - - piece7.setFill(Color.LIMEGREEN); - piece7.setStroke(Color.BLACK); - piece7.setStrokeWidth(3); - - - } - //double click delayed bug to fix - //ftm just the last piece implemented can be rotated - public static void rotaterght (Node node) { - RotateTransition rotaterght = new RotateTransition(); - //setting attributes for the RotateTransition - rotaterght.setByAngle(90); - rotaterght.autoReverseProperty(); - rotaterght.setDuration(Duration.millis(1000)); - rotaterght.setNode(node); - rotaterght.setAxis(Rotate.Z_AXIS); - rotaterght.play();} - - public static void rotatelft (Node node) { - - RotateTransition rotatelft = new RotateTransition(); - - rotatelft.setByAngle(-90);// minus to rotate to the left - rotatelft.autoReverseProperty(); - rotatelft.setDuration(Duration.millis(1000)); - rotatelft.setNode(node); - rotatelft.setAxis(Rotate.Z_AXIS); - rotatelft.play();} - - public void rotation (Polygon node, Scene scene) { - scene.setOnKeyPressed(new EventHandler() { - public void handle(KeyEvent event) {// 'event' means corresponds to clicking on the clipboard - switch (event.getCode()) {// 'getCode' gets the code of the key pressed on the clipboard - case RIGHT: rotaterght(node); break; - //args to set - case LEFT: rotatelft(node); break; - default: System.out.println("this case hasn't been taken in charge yet"); - - } - } - }); - } - - - - public void makeDraggable(Polygon node) { - node.setOnMousePressed(new EventHandler() { - @Override public void handle(MouseEvent mouseEvent) { - // record a (x,y) distance for the drag and drop operation. - x = node.getLayoutX() - mouseEvent.getSceneX(); - y = node.getLayoutY() - mouseEvent.getSceneY(); - node.requestFocus(); - node.setFocusTraversable(true); - node.focusedProperty(); - node.focusVisibleProperty(); - /*node.setFocused(true);*/ - node.setCursor(Cursor.CLOSED_HAND); - node.setFill(Color.AZURE); - } - }); - - node.setOnMouseReleased(new EventHandler() { - @Override public void handle(MouseEvent mouseEvent) { - node.setCursor(Cursor.HAND); - node.setFill(Color.LIMEGREEN); - } - }); - - node.setOnMouseDragged(new EventHandler() { - @Override public void handle(MouseEvent mouseEvent) { - node.setLayoutX(mouseEvent.getSceneX() + x); - node.setLayoutY(mouseEvent.getSceneY() + y); - } - }); - - node.setOnMouseEntered(new EventHandler() { - @Override public void handle(MouseEvent mouseEvent) { - node.setCursor(Cursor.HAND); - } - }); - - } - - - public static void main(String[] args) { - launch(args); - } -} diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index ac18101..2241a89 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -1,10 +1,8 @@ package school_project; import javafx.application.Application; import javafx.scene.Node; -import javafx.event.Event; import javafx.event.EventHandler; -import javafx.scene.layout.Pane; -import javafx.scene.Group; +import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.Cursor; import javafx.scene.input.KeyEvent; -- 2.46.0