Added Rack view in JavaFX

master
Cemal Odabasioglu 2022-04-24 15:12:45 +02:00
parent cff5a97d93
commit b056b09aac
2 changed files with 54 additions and 10 deletions

View File

@ -1,6 +1,7 @@
package latice.application; package latice.application;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import javafx.application.Application; import javafx.application.Application;
import javafx.geometry.Insets; import javafx.geometry.Insets;
@ -15,6 +16,8 @@ import javafx.scene.text.Font;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.stage.Stage; import javafx.stage.Stage;
import latice.model.Color; import latice.model.Color;
import latice.model.Deck;
import latice.model.Rack;
import latice.model.Shape; import latice.model.Shape;
import latice.model.Tile; import latice.model.Tile;
@ -23,6 +26,8 @@ public class LaticeApplicationWindow extends Application{
Image image = new Image("C:/Users/cemal/saebut1/latice/src/main/resources/laticePlateau.png"); Image image = new Image("C:/Users/cemal/saebut1/latice/src/main/resources/laticePlateau.png");
ImageView imageView = new ImageView(image); ImageView imageView = new ImageView(image);
Tile blueBird = new Tile(Color.BLUE, Shape.BIRD); Tile blueBird = new Tile(Color.BLUE, Shape.BIRD);
Tile greenLeaf = new Tile(Color.GREEN, Shape.LEAF); Tile greenLeaf = new Tile(Color.GREEN, Shape.LEAF);
Tile redFlower = new Tile(Color.RED, Shape.FLOWER); Tile redFlower = new Tile(Color.RED, Shape.FLOWER);
@ -45,21 +50,51 @@ public class LaticeApplicationWindow extends Application{
root.setCenter(imageView); root.setCenter(imageView);
//Rack //Rack
HBox rack = new HBox(); HBox rackBox = new HBox();
rackBox.setSpacing(10);
rackBox.setPadding(new Insets(15,20, 10,10));
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
System.out.println("Hello Latice !");
for (Color color : Color.values()) {
for (Shape shape : Shape.values()) {
Tile tile = new Tile(color, shape);
listOfTile.add(tile);
}
}
System.out.println("-----------------");
System.out.println("Notre Deck :");
Deck deck = new Deck(listOfTile);
System.out.println("-----------------");
Rack rack = new Rack(deck);
System.out.println("-----------------");
//deck.displayListTile();
ArrayList<Tile> listRackTile = Rack.getListRackTile();
rack.setSpacing(10);
rack.setPadding(new Insets(15,20, 10,10));
Text rackTile1 = new Text(); Text rackTile1 = new Text();
rackTile1.setText(blueBird.getShape().toString() + blueBird.getColor()); rackTile1.setText(listRackTile.get(0).getShape().toString() + listRackTile.get(0).getColor().toString());
Text rackTile2 = new Text(); Text rackTile2 = new Text();
rackTile2.setText(greenLeaf.getShape().toString() + greenLeaf.getColor()); rackTile2.setText(listRackTile.get(1).getShape().toString() + listRackTile.get(1).getColor().toString());
Text rackTile3 = new Text(); Text rackTile3 = new Text();
rackTile3.setText(redFlower.getShape().toString() + redFlower.getColor()); rackTile3.setText(listRackTile.get(2).getShape().toString() + listRackTile.get(2).getColor().toString());
Text rackTile4 = new Text();
rackTile4.setText(listRackTile.get(3).getShape().toString() + listRackTile.get(3).getColor().toString());
Text rackTile5 = new Text();
rackTile5.setText(listRackTile.get(4).getShape().toString() + listRackTile.get(4).getColor().toString());
rack.getChildren().addAll(rackTile1, rackTile2, rackTile3); rackBox.getChildren().addAll(rackTile1, rackTile2, rackTile3, rackTile4, rackTile5);
rack.setAlignment(Pos.CENTER); rackBox.setAlignment(Pos.CENTER);
root.setBottom(rack); root.setBottom(rackBox);
Scene scene = new Scene(root, 1280, 720); Scene scene = new Scene(root, 1280, 720);

View File

@ -3,7 +3,7 @@ package latice.model;
import java.util.ArrayList; import java.util.ArrayList;
public class Rack { public class Rack {
private ArrayList<Tile> listRackTile = new ArrayList<Tile>(); private static ArrayList<Tile> listRackTile = new ArrayList<Tile>();
public Rack(Deck deck) { public Rack(Deck deck) {
System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs"); System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs");
@ -20,6 +20,15 @@ public class Rack {
System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs"); System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs");
} }
public static ArrayList<Tile> getListRackTile() {
return listRackTile;
}
public void setListRackTile(ArrayList<Tile> listRackTile) {
this.listRackTile = listRackTile;
}
// TODO add method(s) javafx // TODO add method(s) javafx