Skip to content

Commit 03eacab

Browse files
committed
fix ui
1 parent 9fd7b63 commit 03eacab

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

src/ch/epfl/chacun/Base32.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package ch.epfl.chacun;
22

3+
import java.util.Objects;
4+
35
/**
46
* This is a utility class containing useful methods to work with Base32
57
*
@@ -38,6 +40,7 @@ private Base32() {
3840
* @return if all the characters of the given string belong to the charset of Base32
3941
*/
4042
public static boolean isValid(String encoded) {
43+
Objects.requireNonNull(encoded);
4144
return encoded.chars().allMatch(c -> ALPHABET.indexOf(c) != -1);
4245
}
4346

src/ch/epfl/chacun/gui/BoardUI.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,16 @@ private static Node getCancelledAnimalNode(
228228
Animal animal, ObservableValue<Set<Animal>> cancelledAnimalsO,
229229
double negatedTileRotation
230230
) {
231-
ImageView cancelledAnimalView = new ImageView();
232-
cancelledAnimalView.visibleProperty().bind(cancelledAnimalsO.map(
231+
ImageView imageView = new ImageView();
232+
imageView.visibleProperty().bind(cancelledAnimalsO.map(
233233
cancelledAnimals -> cancelledAnimals.contains(animal)
234234
));
235-
cancelledAnimalView.setId(STR."marker_\{animal.id()}");
236-
cancelledAnimalView.getStyleClass().add("marker");
237-
cancelledAnimalView.setFitHeight(ImageLoader.MARKER_FIT_SIZE);
238-
cancelledAnimalView.setFitWidth(ImageLoader.MARKER_FIT_SIZE);
239-
cancelledAnimalView.setRotate(negatedTileRotation);
240-
return cancelledAnimalView;
235+
imageView.setId(STR."marker_\{animal.id()}");
236+
imageView.getStyleClass().add("marker");
237+
imageView.setFitHeight(ImageLoader.MARKER_FIT_SIZE);
238+
imageView.setFitWidth(ImageLoader.MARKER_FIT_SIZE);
239+
imageView.setRotate(negatedTileRotation);
240+
return imageView;
241241
}
242242

243243
private static Node getOccupantNode(

src/ch/epfl/chacun/gui/DecksUI.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public static Node create(
5252

5353

5454
// ImageView of the next tile to place, which has to be shown in large size
55-
ImageView view = new ImageView();
55+
ImageView imageView = new ImageView();
5656
// we bind the graphical view of the tile to place to the tile itself
57-
view.imageProperty().bind(tileO.map(tile -> ImageLoader.largeImageForTile(tile.id())));
58-
view.setFitHeight(ImageLoader.LARGE_TILE_FIT_SIZE);
59-
view.setFitWidth(ImageLoader.LARGE_TILE_FIT_SIZE);
57+
imageView.imageProperty().bind(tileO.map(tile -> ImageLoader.largeImageForTile(tile.id())));
58+
imageView.setFitHeight(ImageLoader.LARGE_TILE_FIT_SIZE);
59+
imageView.setFitWidth(ImageLoader.LARGE_TILE_FIT_SIZE);
6060

6161
// Text, occupy tile (only visible if textToDisplay is not empty,
6262
// meaning that the player does not want to do some action)
@@ -67,7 +67,7 @@ public static Node create(
6767
text.setWrappingWidth(WRAPPING_WIDTH * ImageLoader.LARGE_TILE_FIT_SIZE);
6868

6969
// Here we handle the next tile to place
70-
StackPane stackPane = new StackPane(view, text);
70+
StackPane stackPane = new StackPane(imageView, text);
7171
stackPane.setId("next-tile");
7272
// if the player clicks on the text, it means that he does not want to place or retake an occupant
7373
stackPane.setOnMouseClicked(_ -> onOccupantClick.accept(null));
@@ -93,13 +93,13 @@ public static Node create(
9393
* @return a node representing the deck
9494
*/
9595
private static Node getDeckNode(Tile.Kind kind, ObservableValue<Integer> leftTiles) {
96-
ImageView image = new ImageView();
97-
image.setId(kind.toString());
98-
image.setFitHeight(ImageLoader.NORMAL_TILE_FIT_SIZE);
99-
image.setFitWidth(ImageLoader.NORMAL_TILE_FIT_SIZE);
96+
ImageView imageView = new ImageView();
97+
imageView.setId(kind.toString());
98+
imageView.setFitHeight(ImageLoader.NORMAL_TILE_FIT_SIZE);
99+
imageView.setFitWidth(ImageLoader.NORMAL_TILE_FIT_SIZE);
100100
Text text = new Text();
101101
text.textProperty().bind(leftTiles.map(String::valueOf));
102-
return new StackPane(image, text);
102+
return new StackPane(imageView, text);
103103
}
104104

105105
}

0 commit comments

Comments
 (0)