aboutsummaryrefslogtreecommitdiff
path: root/src/com.example.portfolio2/com/example/portfolio2/HelloApplication.java
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-04-28 19:16:17 +0200
committerJonas Smedegaard <dr@jones.dk>2025-04-28 19:16:17 +0200
commit34e38a3e79a21f78ec18d228a881505131af49f0 (patch)
tree951f4735b00ff39827a0eeb2da03eb2ad8a564b4 /src/com.example.portfolio2/com/example/portfolio2/HelloApplication.java
parentb3627749041ce2ace1fc34d7b1c225feb46ae9bf (diff)
add and improve javadoc
Diffstat (limited to 'src/com.example.portfolio2/com/example/portfolio2/HelloApplication.java')
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/HelloApplication.java61
1 files changed, 40 insertions, 21 deletions
diff --git a/src/com.example.portfolio2/com/example/portfolio2/HelloApplication.java b/src/com.example.portfolio2/com/example/portfolio2/HelloApplication.java
index 1fa5a62..3b754d4 100644
--- a/src/com.example.portfolio2/com/example/portfolio2/HelloApplication.java
+++ b/src/com.example.portfolio2/com/example/portfolio2/HelloApplication.java
@@ -17,13 +17,20 @@ import javafx.stage.Stage;
import java.io.IOException;
import java.util.List;
+/// Bachelorizer - bachelor programme registrar
public class HelloApplication extends Application {
- // Initializing model, controller and database objects
+ /// Default constructor
+ // (declared explicitly only to silence javadoc)
+ public HelloApplication(){}
+
+ /// Application model
private Model model = new Model();
+ /// Application controller
private Controller con = new Controller(model,this);
+ /// database singleton
MyDB myDB = new MyDB();
/* Below is the original implementation of the UI elements with
@@ -59,10 +66,10 @@ public class HelloApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
- // Clears old insertions into the participation table
+ // clear old insertions into participation table
con.initialize();
- // Defines a list of columns based on their names.
+ // define list of columns based on their names
List<ActivityColumn> columns = List.of(
new ActivityColumn("Program"),
new ActivityColumn("Subject 1"),
@@ -70,10 +77,10 @@ public class HelloApplication extends Application {
new ActivityColumn("Elective")
);
- // Defines a list of subject modules
+ // define list of subject modules
List<String> subjectModules = List.of("Computer Science", "Informatik", "Astrology");
- // Loop for defining button funtionality for each activity column
+ // define button functionality for each activity column
for (ActivityColumn col : columns) {
col.nameLabel.setStyle("-fx-font-size: 18px; -fx-padding: 10px;"); // Styling
col.ectsLabel.setStyle("-fx-font-size: 18px; -fx-padding: 10px");
@@ -81,13 +88,13 @@ public class HelloApplication extends Application {
col.activitySelect.setPrefSize(250, 35);
col.area.setPrefWidth(250);
- // All boxes share the same activity logic
+ // all boxes share same activity logic
col.activitySelect.setOnAction(event -> {
con.onActivitySelected(col.categoryCombo, col.activitySelect, col.area);
con.updateEcts(col.ectsLabel, col.categoryCombo);
});
- // Switch statement handles different category boxes
+ // handle each category box
switch (col.name) {
case "Program" -> {
col.categoryCombo.getItems().addAll("HumTek", "NatBach");
@@ -95,7 +102,7 @@ public class HelloApplication extends Application {
con.onComboSelected(col.categoryCombo, col.activitySelect, col.area);
});
}
- // We considered using the list for filling the box but couldn't figure it out
+ // TODO: use the list for filling the box
case "Subject 1" -> {
col.categoryCombo.getItems().addAll("Computer Science", "Informatik", "Astrology");
col.categoryCombo.setOnAction(event -> {
@@ -105,8 +112,7 @@ public class HelloApplication extends Application {
}
case "Subject 2" -> {
col.categoryCombo.getItems().addAll("Computer Science", "Informatik", "Astrology");
- // We figured we have to specify
- // the second column like this but reckon there's a better way.
+ // TODO: figure out a better way...
col.categoryCombo.setOnAction(event -> {
con.onSubjectModuleSelected(col.categoryCombo, columns.get(1).categoryCombo, subjectModules);
con.onComboSelected(col.categoryCombo, col.activitySelect, col.area);
@@ -114,14 +120,15 @@ public class HelloApplication extends Application {
}
case "Elective" -> {
- // Hide useless box
+ // hide useless box
col.categoryCombo.setVisible(false);
+
con.fillElective(col.activitySelect);
}
}
}
- // Define an HBox based on the columns and define the scene based on it.
+ // define HBox and scene for columns
HBox root = new HBox(columns.get(0).asVBox(), columns.get(1).asVBox(), columns.get(2).asVBox(), columns.get(3).asVBox());
Scene scene = new Scene(root, 1000, 500);
stage.setTitle("Course Selector RUC: Ultimate Deluxe Edition");
@@ -129,21 +136,37 @@ public class HelloApplication extends Application {
stage.show();
}
+ /// JVM entry point
+ ///
+ /// @param args command-line arguments
public static void main(String[] args) {
launch();
}
- // Class for each column of activities
+ /// column of activities
private class ActivityColumn {
- // Each column contains these elements
+ /// identifier stored in the text felt
String name;
+
+ /// display text
Label nameLabel;
+
+ /// dropdown list for categories
ComboBox<String> categoryCombo;
+
+ /// dropdown list for activities
ComboBox<String> activitySelect;
+
+ /// descriptionof chosen activities
TextArea area;
+
+ /// text to display ECTS points
Label ectsLabel;
+ /// column of activities
+ ///
+ /// @param name identifier
ActivityColumn(String name) {
this.name = name;
nameLabel = new Label(name);
@@ -151,15 +174,11 @@ public class HelloApplication extends Application {
activitySelect = new ComboBox<>();
area = new TextArea();
ectsLabel = new Label();
- // new column, "this.name" to define and saved in the text felt,
- // new "nameLabel" to show visual text.
- // CategoryCombo creat a dropdown list
- // activitySelect creat one more dropdown list with Combobox, possible to choose activity.
- // area = new TextArea helps create a text felt to describe the chosen activity
- // ectsLabel = new Label shows text for ects points
-
}
+ /// activity columne as VBox
+ ///
+ /// @return column of activities as VBox
VBox asVBox() {
return new VBox(nameLabel, categoryCombo, activitySelect, area, ectsLabel);
}