added background and few design adjustments
parent
2e34cb91b4
commit
6ca85066db
|
@ -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<Image> listTileImage = Rack.getRackTileImage();
|
||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
Map<Rectangle, Tile> assocRectangleTile = new HashMap<Rectangle, Tile>();
|
||||
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<MouseEvent>() {
|
||||
|
||||
@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<MouseEvent>() {
|
||||
|
||||
@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<NUMBER_OF_BOX_ON_ONE_LINE; i++) {
|
||||
for(int j=0; j<NUMBER_OF_BOX_ON_ONE_LINE; j++) {
|
||||
int a = i;
|
||||
int b = j;
|
||||
|
||||
|
@ -212,7 +225,6 @@ public class LaticeApplicationWindow extends Application {
|
|||
if (arg0.getDragboard().hasString()){
|
||||
Dragboard dragboard = arg0.getDragboard();
|
||||
|
||||
System.out.println("got files :" + dragboard.getFiles());
|
||||
r[a][b].setFill(new ImagePattern(listTileImage.get(getIndexTileClicked())));
|
||||
}
|
||||
arg0.consume();
|
||||
|
@ -245,7 +257,6 @@ public class LaticeApplicationWindow extends Application {
|
|||
System.out.println("entered");
|
||||
Dragboard dragboard = arg0.getDragboard();
|
||||
|
||||
System.out.println("got files :" + dragboard.getFiles());
|
||||
r[a][b].setFill(new ImagePattern(listTileImage.get(getIndexTileClicked())));
|
||||
arg0.setDropCompleted(true);
|
||||
assocRectangleTile.put(r[a][b], listRackTile.get(getIndexTileClicked()));
|
||||
|
@ -262,7 +273,8 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
setRootLayout(root);
|
||||
setRootLayout(stackPane);
|
||||
stackPane.getChildren().add(root);
|
||||
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.setTitle("Latice");
|
||||
|
@ -270,10 +282,10 @@ public class LaticeApplicationWindow extends Application {
|
|||
primaryStage.show();
|
||||
|
||||
}
|
||||
public static void setRootLayout(BorderPane root) {
|
||||
public static void setRootLayout(StackPane root) {
|
||||
rootLayout = root;
|
||||
}
|
||||
public static BorderPane getRootLayout() {
|
||||
public static StackPane getRootLayout() {
|
||||
return rootLayout;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import javafx.fxml.FXML;
|
|||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.stage.Stage;
|
||||
import latice.application.LaticeApplicationWindow;
|
||||
|
@ -23,7 +23,7 @@ public class MainScreenController extends LaticeApplicationWindow{
|
|||
public void playButtonClicked(MouseEvent event) {
|
||||
System.out.println("playButtonClicked");
|
||||
Stage stage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
|
||||
BorderPane root = getRootLayout();
|
||||
StackPane root = getRootLayout();
|
||||
Scene scene = new Scene(root, 1280, 720);
|
||||
stage.setScene(scene);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class Rack {
|
|||
|
||||
|
||||
|
||||
public HBox createImageTileOfRack() {
|
||||
public HBox createTileImage() {
|
||||
Image image;
|
||||
ImageView imageView;
|
||||
Tile tile;
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
Loading…
Reference in New Issue