From 4be4ffd57a80808a331796a4a05540adad1668ff Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 1 Aug 2017 10:47:31 -0700 Subject: [PATCH] Add comments to the JavaFX codebase --- .../nwapw/abacus/fx/AbacusApplication.java | 4 ++ .../org/nwapw/abacus/fx/AbacusController.java | 17 +++++++ .../org/nwapw/abacus/fx/CopyableCell.java | 9 ++++ .../org/nwapw/abacus/fx/HistoryModel.java | 45 +++++++++++++++++++ 4 files changed, 75 insertions(+) diff --git a/src/main/java/org/nwapw/abacus/fx/AbacusApplication.java b/src/main/java/org/nwapw/abacus/fx/AbacusApplication.java index 3f86fdd..82d31fb 100644 --- a/src/main/java/org/nwapw/abacus/fx/AbacusApplication.java +++ b/src/main/java/org/nwapw/abacus/fx/AbacusApplication.java @@ -6,6 +6,10 @@ import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; +/** + * The main application class for JavaFX responsible for loading + * and displaying the fxml file. + */ public class AbacusApplication extends Application { @Override diff --git a/src/main/java/org/nwapw/abacus/fx/AbacusController.java b/src/main/java/org/nwapw/abacus/fx/AbacusController.java index 7c9d539..3939e0f 100644 --- a/src/main/java/org/nwapw/abacus/fx/AbacusController.java +++ b/src/main/java/org/nwapw/abacus/fx/AbacusController.java @@ -11,9 +11,19 @@ import org.nwapw.abacus.number.NumberInterface; import org.nwapw.abacus.tree.TreeNode; +/** + * The controller for the abacus FX UI, responsible + * for all the user interaction. + */ public class AbacusController { + /** + * Constant string that is displayed if the text could not be lexed or parsed. + */ private static final String ERR_SYNTAX = "Syntax Error"; + /** + * Constant string that is displayed if the tree could not be reduced. + */ private static final String ERR_EVAL = "Evaluation Error"; @FXML @@ -31,8 +41,15 @@ public class AbacusController { @FXML private Button inputButton; + /** + * The list of history entries, created by the users. + */ private ObservableList historyData; + /** + * The abacus instance used for calculations and all + * other main processing code. + */ private Abacus abacus; @FXML diff --git a/src/main/java/org/nwapw/abacus/fx/CopyableCell.java b/src/main/java/org/nwapw/abacus/fx/CopyableCell.java index 7755704..f7c4cb9 100644 --- a/src/main/java/org/nwapw/abacus/fx/CopyableCell.java +++ b/src/main/java/org/nwapw/abacus/fx/CopyableCell.java @@ -6,8 +6,17 @@ import javafx.scene.input.MouseEvent; import java.awt.*; import java.awt.datatransfer.StringSelection; +/** + * A cell that copies its value to the clipboard + * when double clicked. + * @param The type of the table view generic type. + * @param The type of the value contained in the cell. + */ public class CopyableCell extends TableCell { + /** + * Creates a new copyable cell. + */ public CopyableCell(){ addEventFilter(MouseEvent.MOUSE_CLICKED, event -> { if(event.getClickCount() == 2){ diff --git a/src/main/java/org/nwapw/abacus/fx/HistoryModel.java b/src/main/java/org/nwapw/abacus/fx/HistoryModel.java index 2a267b5..9a7ba2b 100644 --- a/src/main/java/org/nwapw/abacus/fx/HistoryModel.java +++ b/src/main/java/org/nwapw/abacus/fx/HistoryModel.java @@ -3,12 +3,33 @@ package org.nwapw.abacus.fx; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; +/** + * The data model used for storing history entries. + */ public class HistoryModel { + /** + * The property used for displaying the column + * for the user input. + */ private final StringProperty input; + /** + * The property used for displaying the column + * that contains the parsed input. + */ private final StringProperty parsed; + /** + * The property used for displaying the column + * that contains the program output. + */ private final StringProperty output; + /** + * Creates a new history model with the given variables. + * @param input the user input + * @param parsed the parsed input + * @param output the program output. + */ public HistoryModel(String input, String parsed, String output){ this.input = new SimpleStringProperty(); this.parsed = new SimpleStringProperty(); @@ -18,23 +39,47 @@ public class HistoryModel { this.output.setValue(output); } + /** + * Gets the input property. + * @return the input property. + */ public StringProperty inputProperty() { return input; } + /** + * Gets the input. + * @return the input. + */ public String getInput() { return input.get(); } + /** + * Gets the parsed input property. + * @return the parsed input property. + */ public StringProperty parsedProperty() { return parsed; } + /** + * Gets the parsed input. + * @return the parsed input. + */ public String getParsed() { return parsed.get(); } + /** + * Gets the output property. + * @return the output property. + */ public StringProperty outputProperty() { return output; } + /** + * Gets the program output. + * @return the output. + */ public String getOutput() { return output.get(); }