Skip to content

Commit

Permalink
Fixed Checkstyle for Ui
Browse files Browse the repository at this point in the history
  • Loading branch information
RusdiHaizim committed Oct 15, 2019
1 parent ec9d009 commit 0c02a64
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
14 changes: 12 additions & 2 deletions src/main/java/javacake/AvatarScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ public class AvatarScreen extends VBox {
public enum AvatarMode {
HAPPY, SAD, POUT
}

private Image avatarHappy1 = new Image(this.getClass().getResourceAsStream("/images/avatar/hapop.png"));
private Image avatarHappy2 = new Image(this.getClass().getResourceAsStream("/images/avatar/hapclos.png"));
List<Image> images = new ArrayList<>();
private int imageIndex = 0 ;
private int imageIndex = 0;

/**
* Constructor for setting Avatar's face.
* @param type Type of face Avatar makes
*/
public AvatarScreen(AvatarMode type) {
images.add(avatarHappy1);
images.add(avatarHappy2);
Expand All @@ -41,12 +46,17 @@ public AvatarScreen(AvatarMode type) {

//avatarImage.setImage(images.get(0));
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), ev -> {
avatarImage.setImage(images.get(imageIndex++%2));
avatarImage.setImage(images.get(imageIndex++ % 2));
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
}

/**
* Method to set Avatar.
* @param type Type of face Avatar makes
* @return AvatarScreen object
*/
public static AvatarScreen setAvatar(AvatarMode type) {
return new AvatarScreen(type);
}
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/javacake/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ public class DialogBox extends HBox {

private Image hilda1 = new Image(this.getClass().getResourceAsStream("/images/hilda_1.png"));
private Image hilda2 = new Image(this.getClass().getResourceAsStream("/images/hilda_2.png"));
List<Image> images = new ArrayList<>();
private int imageIndex = 0 ;

private DialogBox(String text, Image img) {
images.add(hilda1);
images.add(hilda2);

try {
FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml"));
fxmlLoader.setController(this);
Expand All @@ -57,12 +52,6 @@ private DialogBox(String text, Image img) {

dialog.setText(text);
displayPicture.setImage(img);

// Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), ev -> {
// displayPicture.setImage(images.get(imageIndex++%2));
// }));
// timeline.setCycleCount(Animation.INDEFINITE);
// timeline.play();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/javacake/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ private void handleUserInput() {
String input = userInput.getText();
userInput.clear();
System.out.println(input);
// dialogContainer.getChildren().add(
// DialogBox.getUserDialog(input, userImage));
// dialogContainer.getChildren().add(
// DialogBox.getUserDialog(input, userImage));
String response = "";
if (isStarting && duke.isFirstTimeUser) {
duke.userName = input;
Expand Down Expand Up @@ -129,7 +129,7 @@ private void handleUserInput() {
}
if (response.contains("Bye.")) {
PauseTransition pause = new PauseTransition(Duration.seconds(2));
pause.setOnFinished(e->primaryStage.hide());
pause.setOnFinished(e -> primaryStage.hide());
pause.play();
}
} catch (DukeException e) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/javacake/TopBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class TopBar extends HBox {
@FXML
private ImageView cakeRight;

/**
* Constructor for title bar.
*/
public TopBar() {
try {
FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/TopBar.fxml"));
Expand All @@ -27,6 +30,10 @@ public TopBar() {
}
}

/**
* Method to set TopBar.
* @return TopBar object
*/
public static TopBar setTitle() {
return new TopBar();
}
Expand Down

0 comments on commit 0c02a64

Please sign in to comment.