summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnitsGUI/Presenter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/sevenUnitsGUI/Presenter.java')
-rw-r--r--src/main/java/sevenUnitsGUI/Presenter.java60
1 files changed, 53 insertions, 7 deletions
diff --git a/src/main/java/sevenUnitsGUI/Presenter.java b/src/main/java/sevenUnitsGUI/Presenter.java
index 9f8fe69..b38f90b 100644
--- a/src/main/java/sevenUnitsGUI/Presenter.java
+++ b/src/main/java/sevenUnitsGUI/Presenter.java
@@ -91,7 +91,7 @@ public final class Presenter {
* @return text in About file
* @since 2022-02-19
*/
- static final String getAboutText() {
+ public static final String getAboutText() {
return Presenter.getLinesFromResource("/about.txt").stream()
.map(Presenter::withoutComments).collect(Collectors.joining("\n"))
.replaceAll("\\[VERSION\\]", ProgramInfo.VERSION.toString());
@@ -155,7 +155,7 @@ public final class Presenter {
/**
* The rule used for parsing input numbers. Any number-string inputted into
- * this program will be parsed using this method.
+ * this program will be parsed using this method. <b>Not implemented yet.</b>
*/
private Function<String, UncertainDouble> numberParsingRule;
@@ -381,6 +381,25 @@ public final class Presenter {
}
/**
+ * @return the rule that is used by this presenter to convert numbers into
+ * strings
+ * @since 2022-04-10
+ */
+ public Function<UncertainDouble, String> getNumberDisplayRule() {
+ return this.numberDisplayRule;
+ }
+
+ /**
+ * @return the rule that is used by this presenter to convert strings into
+ * numbers
+ * @since 2022-04-10
+ */
+ @SuppressWarnings("unused") // not implemented yet
+ private Function<String, UncertainDouble> getNumberParsingRule() {
+ return this.numberParsingRule;
+ }
+
+ /**
* @return true iff the One-Way Conversion feature is available (views that
* show units as a list will have metric units removed from the From
* unit list and imperial/USC units removed from the To unit list)
@@ -392,11 +411,12 @@ public final class Presenter {
}
/**
- * Loads settings from the user's settings file and applies them to the view.
+ * Loads settings from the user's settings file and applies them to the
+ * presenter.
*
* @since 2021-12-15
*/
- public void loadSettings() {}
+ private void loadSettings() {}
/**
* Completes creation of the presenter. This part of the initialization
@@ -416,12 +436,32 @@ public final class Presenter {
void prefixSelected() {}
/**
- * Gets user settings from the view then saves them to the user's settings
- * file.
+ * Saves the presenter's settings to the user settings file.
*
* @since 2021-12-15
*/
- public void saveSettings() {}
+ private void saveSettings() {}
+
+ /**
+ * @param numberDisplayRule the new rule that will be used by this presenter
+ * to convert numbers into strings
+ * @since 2022-04-10
+ */
+ public void setNumberDisplayRule(
+ Function<UncertainDouble, String> numberDisplayRule) {
+ this.numberDisplayRule = numberDisplayRule;
+ }
+
+ /**
+ * @param numberParsingRule the new rule that will be used by this presenter
+ * to convert strings into numbers
+ * @since 2022-04-10
+ */
+ @SuppressWarnings("unused") // not implemented yet
+ private void setNumberParsingRule(
+ Function<String, UncertainDouble> numberParsingRule) {
+ this.numberParsingRule = numberParsingRule;
+ }
/**
* @param oneWayConversionEnabled whether not one-way conversion should be
@@ -443,6 +483,12 @@ public final class Presenter {
this.updateView();
}
+ /**
+ * Runs whenever a unit name is selected in the unit viewer. Gets the
+ * description of a unit and displays it.
+ *
+ * @since 2022-04-10
+ */
void unitNameSelected() {}
/**