-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 245013d
Showing
31 changed files
with
882 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# IDEA files | ||
/.idea/ | ||
/out/ | ||
/*.iml | ||
|
||
# Gradle build files | ||
/.gradle/ | ||
/build/ | ||
src/main/resources/docs/ | ||
|
||
# MacOS custom attributes files created by Finder | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Contributors | ||
|
||
Display | Name | Github Profile | Homepage | ||
---|:---:|:---:|:---: | ||
![](https://avatars1.githubusercontent.com/u/22460123) | Jeffry Lum | [Github](https://github.com/j-lum/) | [Homepage](https://se.kasugano.moe) | ||
|
||
# I would like to join this list. How can I help the project | ||
|
||
For more information, please refer to our [contributor's guide](https://oss-generic.github.io/process/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Duke | ||
|
||
Duke is a Personal Assistant Chatbot that helps a person to keep track of various things. | ||
|
||
# Tutorials | ||
|
||
Increments | Tutorial Name | ||
---|--- | ||
A-Gradle | [Gradle Tutorial 1 : Introduction to Gradle](tutorials/gradle-tutorial-1-introduction-to-gradle.md) | ||
Level-10 | [JavaFX Tutorial 1: Introduction to JavaFX](tutorials/ui-tutorial-1-introduction-to-javafx.md) | ||
Level-10 | [JavaFX Tutorial 2: Creating a GUI for Duke](tutorials/ui-tutorial-2-creating-a-gui-for-duke.md) | ||
Level-10 | [JavaFX Tutorial 3: Interacting with the user](tutorials/ui-tutorial-3-interacting-with-the-user.md) | ||
Level-10 | [JavaFX Tutorial 4: Introduction to FXML](tutorials/ui-tutorial-4-introduction-to-fxml.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# User Guide | ||
|
||
## Features | ||
|
||
### Feature 1 | ||
Description of feature. | ||
|
||
## Usage | ||
|
||
### `Keyword` - Describe action | ||
|
||
Describe action and its outcome. | ||
|
||
Example of usage: | ||
|
||
`keyword (optional arguments)` | ||
|
||
Expected outcome: | ||
|
||
`outcome` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@startuml | ||
hide members | ||
hide circle | ||
skinparam shadowing false | ||
skinparam ClassFontSize 16 | ||
skinparam ClassFontName Arial | ||
|
||
class Stage | ||
class AnchorPane | ||
class ScrollPane | ||
class VBox | ||
class ImageView | ||
class Label | ||
|
||
AnchorPane -up-> Stage | ||
ScrollPane -up-> AnchorPane | ||
|
||
TextField -up-> AnchorPane | ||
Button -up-> AnchorPane | ||
|
||
VBox -up-> ScrollPane | ||
ImageView -up-> VBox | ||
Label -up-> VBox | ||
@enduml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@startuml | ||
hide members | ||
hide circle | ||
skinparam shadowing false | ||
skinparam ClassFontSize 16 | ||
skinparam ClassFontName Arial | ||
|
||
Class Stage | ||
Class Scene | ||
Class "Root Node" as RN | ||
Class Node | ||
Class "Node" as Node1 | ||
Class "Node" as Node2 | ||
Class "Node" as Node3 | ||
|
||
Scene -up-> Stage : > must have one | ||
RN -up-> Scene : > must have one | ||
Node -up-> RN : > can have zero or more | ||
Node1 -up-> Node | ||
Node2 -up-> Node | ||
Node3 -up-> Node | ||
@enduml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# Gradle Tutorial 1 - Setting up Gradle | ||
|
||
Gradle is a _build automation tool_ used to automate build processes. | ||
There are many ways of integrating Gradle into a project. | ||
In this guide, we will be using the _Gradle wrapper_. | ||
|
||
## Primer to Gradle | ||
|
||
As a developer, you write a build file that describes the project. | ||
|
||
A build file mainly consists of _plugins_, _tasks_ and _properties_. | ||
|
||
Plugins extend the functionality of Gradle. The `java` plugin adds support for `Java` projects. | ||
|
||
Tasks are reusable blocks of logic. | ||
For example, the task `clean` simply deletes the project build directory. | ||
Tasks can be composed of other tasks or be dependent on another task. | ||
You might be surprised to find that a simple `check` will invoke another eight tasks at the very least! | ||
|
||
Properties change the behavior of tasks. | ||
For instance, `mainClassName` of the `application` plugin is a compulsory property which tells Gradle which class is the entrypoint to your application. | ||
As Gradle favors `convention over configuration`, there is not much to you need to configure if you follow the recommended directory structure. | ||
|
||
## Getting started | ||
|
||
1. Merge [this branch](https://github.com/se-edu/duke/tree/gradle). This will add the Gradle wrapper to your project. | ||
|
||
2. Navigate to the root directory of your project and type `gradlew run`. | ||
|
||
For users of IntelliJ IDEA, you can import the Gradle project by `Help > Find Action > Import Gradle Project`. | ||
|
||
![Import Gradle](assets/ImportGradle.png) | ||
|
||
After this, IntelliJ IDEA will identify your project as a Gradle project and you will gain access to the `Gradle Toolbar`. | ||
Through the toolbar, you run Gradle tasks and view your project's dependencies. | ||
|
||
## Using Gradle | ||
|
||
Simply type `gradlew {taskName}` into the terminal and Gradle will run the task! | ||
For example, you can type `gradlew tasks` and Gradle will show you a list of tasks available for your project. | ||
Some plugins may add more helpful tasks so be sure to check the documentation! | ||
|
||
If you're using IntelliJ IDEA, you can click on the Gradle icon in the Gradle toolbar and create a new run configuration. | ||
|
||
![Gradle icon](assets/GradleIcon.png) | ||
|
||
Having a run configuration will save you a few keypresses in the long run. | ||
|
||
## Adding plugins | ||
|
||
Gradle plugins are reusable units of build logic. | ||
Most common build tasks are provided as core plugins by Gradle. | ||
Given below are instructions on how to use some useful plugins: | ||
|
||
### Checkstyle | ||
To add support for _Checkstyle_, a tool to check if your code complies with coding standards. | ||
Since Checkstyle is a core plugin, simply add the line `id 'checkstyle` into the `plugins` block. | ||
|
||
Your build file should look something like this now | ||
|
||
```groovy | ||
plugins { | ||
id 'java' | ||
id 'application' | ||
id 'checkstyle' | ||
} | ||
// ... code omitted for brevity ... | ||
``` | ||
|
||
Checkstyle expects configuration files to for checkstyle to be in `./config/checkstyle/` by convention. | ||
You can find the configuration files used in later projects [here](https://github.com/se-edu/addressbook-level3/tree/master/config/checkstyle). | ||
|
||
The plugin adds a few _tasks_ to your project. | ||
Run `gradlew checkstyleMain checkstyleTest` to verify that you have set up Checkstyle properly. | ||
|
||
To find out the full list of tasks available to you, you can run `gradlew tasks --all`. | ||
|
||
### Shadow | ||
|
||
Shadow is a plugin that helps you package your application into an executable jar file. | ||
Add the following line to your Gradle build file: | ||
|
||
```groovy | ||
plugin { | ||
//... | ||
id 'com.github.johnrengelman.shadow' version '5.1.0' | ||
//... | ||
} | ||
``` | ||
|
||
The plugin can be configured by setting some properties. | ||
Let's try to produce a jar file with the name in format of `{baseName}-{version}.jar`. | ||
|
||
Add the following block to your build file: | ||
|
||
```groovy | ||
//Publishes an executable jar to ./build/libs/ | ||
shadowJar { | ||
archiveBaseName = "duke" | ||
archiveVersion = "0.1.3" | ||
archiveClassifier = null | ||
archiveAppendix = null | ||
} | ||
``` | ||
|
||
Now you can run the task `shadowJar` with the command `gradlew shadowJar`. | ||
Are you able to execute your jar file with `java -jar {jarName}`? | ||
|
||
## Adding dependencies | ||
|
||
### JUnit 5 | ||
|
||
JUnit is a testing framework for Java. | ||
It allows developers to write tests and run them. | ||
|
||
Add the following dependency to your build file: | ||
|
||
```groovy | ||
dependencies { | ||
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0' | ||
} | ||
``` | ||
|
||
Then, configure Gradle to use JUnit by adding the following block to your build file: | ||
|
||
```groovy | ||
test { | ||
useJUnitPlatform() | ||
} | ||
``` | ||
By convention, tests belong in `src/test` folder. | ||
Create a new `test` folder in under `src`. | ||
|
||
``` | ||
src | ||
├─main | ||
│ ├─java | ||
│ │ └─seedu | ||
│ │ └─duke | ||
│ └─resources | ||
│ └─view | ||
└─test | ||
└─java | ||
└─seedu | ||
└─duke | ||
``` | ||
|
||
If you have imported your Gradle project into IntelliJ IDEA, you will notice that IDEA is able to mark the test | ||
directory as the Test root (colored in green by default) automatically. | ||
|
||
You can now write a test and run it with `gradlew test`. | ||
|
||
## Further reading | ||
|
||
Now that you have a general idea of how to accomplish basic tasks with Gradle, here's a list of material you can read | ||
to further your understanding. | ||
|
||
- [Official Gradle Documentation](https://docs.gradle.org/current/userguide/userguide.html) | ||
- [Google's checkstyle file](https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml) | ||
- [Shadow](https://imperceptiblethoughts.com/shadow/introduction/) | ||
- [Official JUnit Documentation](https://junit.org/junit5/docs/current/user-guide/#writing-tests) | ||
- [AddressBook Level-4's build file](https://github.com/se-edu/addressbook-level4/blob/master/build.gradle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# JavaFX Tutorial 1 – Hello World | ||
|
||
# Setting up | ||
Follow the guide in the README. | ||
|
||
|
||
# Basics of JavaFX: | ||
|
||
## An analogy | ||
In JavaFX, you are a director and each application is a play. | ||
First you provision the props that you will feature in your play. | ||
These can be hand props for your actors to interact with or even set dressings just to liven up the background. | ||
You then decide where to layout the props for every scene. | ||
With a proper script in hand, you can finally approach a theatre and request for a stage. | ||
There on, it’s just a matter of pulling the curtains on your masterpiece. | ||
|
||
## JavaFX lifecycle of an application | ||
Instead of creating props, you create `Nodes` instead. | ||
`Nodes` are the fundamental building blocks of a JavaFX application. | ||
You create `Nodes` and place them onto a `Scene`. | ||
A scene can be thought of as a graph, each `Scene` must have a root `Node` and each `Node` can have zero or more children. | ||
|
||
![Hierarchy of Objects in JavaFX](assets/JavaFxHierarchy.png) | ||
|
||
Don’t worry too much about this for now, you’ll see exactly how to work with the scene graph in a later tutorial. | ||
Then, you set your `Scene` on a `Stage` provided by JavaFX. | ||
When you call `Stage#show()` method, JavaFX renders a window with your `Stage` on it. | ||
|
||
# Writing your first program | ||
As customary, let’s start off with a simple “Hello World” program. | ||
Create a new `HelloWorld.java` class in the `duke.seedu` package. | ||
Have the class extend `javafx.application.Application`. | ||
This requires you to override the `Application#start()` method and provide a concrete implementation. | ||
Notice that the method signature for `Application#start()` has a parameter `Stage`. | ||
This is the _primary stage_ that JavaFX provides. | ||
|
||
```java | ||
public class HelloWorld extends Application { | ||
|
||
public static void main(String[] args) { | ||
launch(); | ||
} | ||
|
||
@Override | ||
public void start(Stage stage) { | ||
// Our code goes here | ||
} | ||
} | ||
``` | ||
|
||
Let’s create a `Label` to contain the text that we want to show. | ||
We then create the `Scene` and set its content. | ||
Finally, we can set the stage and show it. | ||
|
||
```java | ||
public class HelloWorld extends Application { | ||
|
||
public static void main(String[] args) { | ||
launch(); | ||
} | ||
|
||
@Override | ||
public void start(Stage stage) { | ||
Label helloWorld = new Label("Hello World!"); // Creating a new Label control | ||
Scene scene = new Scene(helloWorld); // Setting the scene to be our Label | ||
|
||
stage.setScene(scene); // Setting the stage to show our screen | ||
stage.show(); // Render the stage. | ||
} | ||
} | ||
``` | ||
|
||
Run the program and you should see something like this: | ||
|
||
![Hello World](assets/HelloWorld.png) | ||
|
||
Congratulations! You have created your first GUI application! | ||
|
||
# Exercises | ||
1. We mentioned that `Node`s are the fundamental building blocks of JavaFX and used a `Label` as our root node in the HelloWorld application. | ||
|
||
1. What are some of the other types of `Node`s? | ||
1. How does JavaFX group them? | ||
|
||
1. `Node`s can be interacted with like Plain Old Java Objects (POJO). | ||
|
||
1. What properties of a `Label` can you change programmatically? | ||
1. Try changing the `Label` to have a font of Arial at size 50. | ||
|
||
1. You’ve learnt that a `Stage` can be thought of as a window. | ||
|
||
1. Can you have more than one `Stage` an application? | ||
1. Try creating another stage and showing it! What happens? | ||
|
Oops, something went wrong.