diff --git a/src/main/java/latice/application/LaticeApplicationWindow.java b/src/main/java/latice/application/LaticeApplicationWindow.java index 6ce8baa..6a8f2dd 100644 --- a/src/main/java/latice/application/LaticeApplicationWindow.java +++ b/src/main/java/latice/application/LaticeApplicationWindow.java @@ -31,6 +31,7 @@ import javafx.scene.layout.BackgroundSize; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; +import javafx.scene.layout.StackPane; import javafx.scene.paint.ImagePattern; import javafx.scene.shape.Rectangle; import javafx.scene.text.Font; @@ -45,9 +46,21 @@ import latice.model.Tile; public class LaticeApplicationWindow extends Application { + private static final int NUMBER_OF_BOX_ON_ONE_LINE = 9; + + private static final int RECTANGLE_HEIGHT = 50; + + private static final int RECTANGLE_WIDTH = 50; + + private static final int Y_CENTER = 37; + + private static final int X_CENTER = 355; + + private static final int BOX_WIDTH = 52; + javafx.scene.paint.Color realColor = new javafx.scene.paint.Color(0, 0, 0, 0); - Image image = new Image("laticePlateau.png"); + Image image = new Image("backgroundLatice.png"); ImageView imageView = new ImageView(image); Tile blueBird = new Tile(Color.NAVYBLUE, Shape.BIRD); @@ -58,7 +71,7 @@ public class LaticeApplicationWindow extends Application { ArrayList listTileImage = Rack.getRackTileImage(); ArrayList listOfTile = new ArrayList(); Map assocRectangleTile = new HashMap(); - static BorderPane rootLayout; + static StackPane rootLayout; public static int indexTileClicked; @@ -79,6 +92,9 @@ public class LaticeApplicationWindow extends Application { Parent loader = FXMLLoader.load(getClass().getResource("../view/MainScreen.fxml")); Scene menu = new Scene(loader, 1280, 720); MainScreenController MSC = new MainScreenController(); + + //StackPane for background image + BorderPane root onto it + StackPane stackPane = new StackPane(); //root layout BorderPane root = new BorderPane(); @@ -93,17 +109,17 @@ public class LaticeApplicationWindow extends Application { BackgroundImage myBG= new BackgroundImage(image, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, BackgroundSize.DEFAULT); - pane.setBackground(new Background(myBG)); - + stackPane.setBackground(new Background(myBG)); + //Creating rectangle for tiles placement Rectangle[][] r = new Rectangle[9][9]; int counterI = 0; int counterJ = 0; - for (int i=1; i<10 ; i++) { - for (int j=1; j < 10 ; j++) { + for (int i=1; i<=NUMBER_OF_BOX_ON_ONE_LINE ; i++) { + for (int j=1; j <= NUMBER_OF_BOX_ON_ONE_LINE ; j++) { - r[counterI][counterJ] = new Rectangle(i*52+307,j*52+3,50,50); + r[counterI][counterJ] = new Rectangle(i*BOX_WIDTH+X_CENTER,j*BOX_WIDTH+Y_CENTER,RECTANGLE_WIDTH,RECTANGLE_HEIGHT); r[counterI][counterJ].setFill(realColor.TRANSPARENT); pane.getChildren().add(r[counterI][counterJ]); System.out.println(r[counterI][counterJ]); @@ -148,32 +164,29 @@ public class LaticeApplicationWindow extends Application { //deck.displayListTile(); + //Confirm Button + Image checkMark = new Image("checkMark.png"); + ImageView checkMarkView = new ImageView(checkMark); + Button confirmButton = new Button("Confirm", checkMarkView); + + confirmButton.setOnMouseClicked(new EventHandler() { + + @Override + public void handle(MouseEvent arg0) { + // TODO on mouse clicked on confirm + + } + + }); + //With Image Rack rack2 = new Rack(deck); - HBox rackImage = rack2.createImageTileOfRack(); - + HBox rackImage = rack2.createTileImage(); + rackImage.getChildren().add(confirmButton); + rackImage.setMargin(rackImage.getChildren().get(4), new Insets(0,150,0,0)); root.setBottom(rackImage); - //Confirm Button - Image checkMark = new Image("checkMark.png"); - ImageView checkMarkView = new ImageView(checkMark); - Button confirmButton = new Button("Confirm", checkMarkView); - root.setAlignment(confirmButton, Pos.BOTTOM_LEFT); - confirmButton.setOnMouseClicked(new EventHandler() { - - @Override - public void handle(MouseEvent arg0) { - // TODO on mouse clicked on confirm - - } - - }); - - - root.setRight(confirmButton); - - //------------------------------------------------------------------------ @@ -200,8 +213,8 @@ public class LaticeApplicationWindow extends Application { ImagePattern imagePattern = new ImagePattern(listTileImage.get(getIndexTileClicked())); //Setting drag & drop on rectangles - for(int i=0; i<9; i++) { - for(int j=0; j<9; j++) { + for(int i=0; i