Skip to content

Commit

Permalink
Add styling for GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene3231 committed Sep 2, 2020
1 parent 27a9e3d commit 886d584
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 38 deletions.
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
}

test {
systemProperty "file.encoding", "utf-8"
useJUnitPlatform()

testLogging {
Expand All @@ -43,9 +44,16 @@ test {
}

application {
applicationDefaultJvmArgs = ["-Dfile.encoding=utf-8"]
mainClassName = "duke.Duke"
}

compileJava.options.encoding = 'UTF-8'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

shadowJar {
archiveBaseName = "duke"
archiveClassifier = null
Expand All @@ -56,5 +64,6 @@ checkstyle {
}

run{
systemProperty "file.encoding", "utf-8"
standardInput = System.in
}
Empty file removed data/save.txt
Empty file.
3 changes: 2 additions & 1 deletion src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public static void main(String[] args) {
* Starts the chatbot.
*/
public static void initialize() {
Storage storage = new Storage("./data");
String home = System.getProperty("user.dir");
Storage storage = new Storage( home + "/data");
if (Storage.hasLoadingError) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/DukeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public DukeException(String message) {
*/
public static void tryAgain() {
System.out.println();
System.out.println("Please try again: ");
System.out.println("Please try again.");
}
}
4 changes: 4 additions & 0 deletions src/main/java/duke/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

Expand All @@ -25,6 +26,9 @@ public void start(Stage stage) {
fxmlLoader.<MainWindow>getController().setDuke(duke);
fxmlLoader.<MainWindow>getController().showGreeting();
stage.show();
stage.setTitle("Duke");
stage.getIcons().add(new Image(Main.class.getResourceAsStream("/images/icon.png")));
// Shooting Stars icon by Icons8 from https://icons8.com/icon/81220/shooting-stars
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/duke/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public class MainWindow extends AnchorPane {
private Duke duke;

private Image userImage = new Image(this.getClass().getResourceAsStream("/images/User.png"));
// Standing Man icon by Icons8 from https://icons8.com/icon/8NzonSPORfzB/man-in-a-tuxedo

private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/Duke.png"));
// Man In A Tuxedo icon by Icons8 from https://icons8.com/icon/21832/standing-man

@FXML
public void initialize() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ public static Task parseNewTaskCommand(String input, Task.TaskType tasktype) thr
return parseTaskWithTime(input, tasktype, "/by");
} catch (IndexOutOfBoundsException e) {
throw new DukeException("\u2639 Oops wrong format, use add deadline format: "
+ "deadline [task] /by [time (can be 'YYYY-MM-DD HHMM')] !");
+ "deadline [task] /by [time (can be 'YYYY-MM-DD HHMM')]");
}
} else if (tasktype == Task.TaskType.EVENT) {
try {
return parseTaskWithTime(input, tasktype, "/at");
} catch (IndexOutOfBoundsException e) {
throw new DukeException("\u2639 Oops wrong format, use add event format: "
+ "event [task] /at [time] !");
+ "event [task] /at [time]");
}
} else {
return new Task("this task should not be created");
Expand Down
22 changes: 3 additions & 19 deletions src/main/java/duke/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,12 @@ public void run() {
* Draws the top border of the chatbot's response.
*/
public static void drawTopBorder() {
System.out.println("___________________________________");
}

/**
* Draws the bottom border of the chatbot's response.
*/
public static void drawBottomBorder() {
System.out.println("___________________________________");

}

/**
Expand Down Expand Up @@ -125,25 +122,12 @@ public static void greet() {

public static String getGreeting() {
setLogo();
String greeting = " Hey! I'm Duke the chatbot!";
String doForYou = " What can I do for you?";
String greeting = "Hey! I'm Duke the chatbot!";
String doForYou = "What can I do for you?";
return logo + "\n" + greeting + "\n" + doForYou;
}

public static void setLogo() {
logo = "\n" +
" ___ ___ \n" +
" ( ) ( ) \n" +
" .-.| | ___ ___ | | ___ .--. \n" +
" / \\ | ( )( ) | | ( ) / \\ \n" +
"| .-. | | | | | | | ' / | .-. ; \n" +
"| | | | | | | | | |,' / | | | | \n" +
"| | | | | | | | | . '. | |/ | \n" +
"| | | | | | | | | | `. \\ | ' _.' \n" +
"| ' | | | | ; ' | | \\ \\ | .'.-. \n" +
"' `-' / ' `-' / | | \\ . ' `-' / \n" +
" `.__,' '.__.' (___ ) (___) `.__.' \n" +
" \n" +
" \n";
logo = "DUKE!";
}
}
6 changes: 3 additions & 3 deletions src/main/java/duke/data/save.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
6
5
todo assignment
todo resume
todo project
event meeting /at 1pm
todo settle problem
deadline send email /by 10 Oct 2020, 09:00 PM
todo readings
0 1 3 4
2 changes: 1 addition & 1 deletion src/main/java/duke/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public String getDescription() {
public String getStatusIcon() {
return (this.status == TaskStatus.DONE
// return tick or X symbols
? "\u2713"
? "\u2714"
: "\u2718");
}

Expand Down
Binary file modified src/main/resources/images/Duke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/images/User.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>

<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<fx:root alignment="TOP_RIGHT" prefHeight="129.0" prefWidth="517.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label minHeight="-Infinity" fx:id="dialog" text="Label" wrapText="true" />
<Label fx:id="dialog" alignment="CENTER" minHeight="-Infinity" style="-fx-background-color: #faf884; -fx-background-radius: 30; -fx-label-padding: 15;" text="Label" wrapText="true" />
<ImageView fx:id="displayPicture" fitHeight="99.0" fitWidth="99.0" pickOnBounds="true" preserveRatio="true" />
</children>
<padding>
<Insets bottom="15.0" left="5.0" right="5.0" top="15.0" />
</padding>
</fx:root>
</fx:root>
31 changes: 23 additions & 8 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="duke.MainWindow">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="835.0" prefWidth="602.0" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1" fx:controller="duke.MainWindow">
<children>
<TextField fx:id="userInput" layoutY="558.0" onAction="#handleUserInput" prefHeight="41.0" prefWidth="324.0" AnchorPane.bottomAnchor="1.0" />
<Button fx:id="sendButton" layoutX="324.0" layoutY="558.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="41.0" prefWidth="76.0" text="Enter" />
<ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" hvalue="1.0" prefHeight="557.0" prefWidth="400.0" vvalue="1.0">
<content>
<VBox fx:id="dialogContainer" prefHeight="552.0" prefWidth="388.0" />
</content>
<TextField fx:id="userInput" layoutX="13.0" layoutY="777.0" onAction="#handleUserInput" prefHeight="50.0" prefWidth="459.0" promptText="talk to Duke..." style="-fx-background-color: #D4F1F4; -fx-prompt-text-fill: grey; -fx-background-radius: 15;" AnchorPane.bottomAnchor="8.0">
<font>
<Font name="Segoe UI Italic" size="16.0" />
</font>
<effect>
<DropShadow spread="0.34" />
</effect></TextField>
<ScrollPane fx:id="scrollPane" focusTraversable="false" hbarPolicy="NEVER" hvalue="1.0" prefHeight="766.0" prefWidth="602.0" vvalue="1.0">
<content>
<VBox fx:id="dialogContainer" blendMode="DARKEN" prefHeight="766.0" prefWidth="584.0" style="-fx-background-color: #D4F1F4;" />
</content>
</ScrollPane>
<Button fx:id="sendButton" contentDisplay="CENTER" layoutX="487.0" layoutY="776.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="50.0" prefWidth="107.0" style="-fx-background-color: #75E6DA; -fx-background-radius: 15;" text="Enter" textFill="#5b5b5b">
<font>
<Font name="Segoe UI Bold" size="18.0" />
</font>
<effect>
<DropShadow />
</effect>
</Button>
</children>
</AnchorPane>
</AnchorPane>

0 comments on commit 886d584

Please sign in to comment.