summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnitsGUI
diff options
context:
space:
mode:
authorAdrien Hopkins <ahopk127@my.yorku.ca>2022-04-19 16:35:43 -0500
committerAdrien Hopkins <ahopk127@my.yorku.ca>2022-04-19 16:35:43 -0500
commit8cc60583134a4d01e9967424e5a51332de6cc38b (patch)
treeaf3bb8662dd4203fcfbd071f005e0619096f61ee /src/main/java/sevenUnitsGUI
parent0aacba9fc8a9140fdf331172ad66afe280d09b5e (diff)
Finalized version 0.4.0-alpha.1
Diffstat (limited to 'src/main/java/sevenUnitsGUI')
-rw-r--r--src/main/java/sevenUnitsGUI/Main.java34
-rw-r--r--src/main/java/sevenUnitsGUI/Presenter.java2
-rw-r--r--src/main/java/sevenUnitsGUI/TabbedView.java76
-rw-r--r--src/main/java/sevenUnitsGUI/View.java8
-rw-r--r--src/main/java/sevenUnitsGUI/ViewBot.java3
5 files changed, 48 insertions, 75 deletions
diff --git a/src/main/java/sevenUnitsGUI/Main.java b/src/main/java/sevenUnitsGUI/Main.java
new file mode 100644
index 0000000..b5a896f
--- /dev/null
+++ b/src/main/java/sevenUnitsGUI/Main.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2022 Adrien Hopkins
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+package sevenUnitsGUI;
+
+/**
+ * The main code for the 7Units GUI
+ *
+ * @since 2022-04-19
+ */
+public final class Main {
+
+ /**
+ * @param args
+ * @since 2022-04-19
+ */
+ public static void main(String[] args) {
+ View.createTabbedView();
+ }
+
+}
diff --git a/src/main/java/sevenUnitsGUI/Presenter.java b/src/main/java/sevenUnitsGUI/Presenter.java
index fd050b7..4feea44 100644
--- a/src/main/java/sevenUnitsGUI/Presenter.java
+++ b/src/main/java/sevenUnitsGUI/Presenter.java
@@ -567,7 +567,7 @@ public final class Presenter {
* @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)
- *
+ *
* @since 2022-03-30
*/
public boolean oneWayConversionEnabled() {
diff --git a/src/main/java/sevenUnitsGUI/TabbedView.java b/src/main/java/sevenUnitsGUI/TabbedView.java
index c8e69ee..be80ccb 100644
--- a/src/main/java/sevenUnitsGUI/TabbedView.java
+++ b/src/main/java/sevenUnitsGUI/TabbedView.java
@@ -124,87 +124,17 @@ final class TabbedView implements ExpressionConversionView, UnitConversionView {
* Rounds to a fixed number of significant digits. Precision is used,
* representing the number of significant digits to round to.
*/
- SIGNIFICANT_DIGITS(true) {
- @Override
- public Function<UncertainDouble, String> getRuleFromPrecision(
- int precision) {
- return StandardDisplayRules.fixedPrecision(precision);
- }
- },
+ SIGNIFICANT_DIGITS,
/**
* Rounds to a fixed number of decimal places. Precision is used,
* representing the number of decimal places to round to.
*/
- DECIMAL_PLACES(true) {
- @Override
- public Function<UncertainDouble, String> getRuleFromPrecision(
- int precision) {
- return StandardDisplayRules.fixedDecimals(precision);
- }
- },
+ DECIMAL_PLACES,
/**
* Rounds according to UncertainDouble's toString method. The specified
* precision is ignored.
*/
- UNCERTAINTY(false) {
- @Override
- public Function<UncertainDouble, String> getRuleFromPrecision(
- int precision) {
- return StandardDisplayRules.uncertaintyBased();
- }
- };
-
- /**
- * If true, this type of rounding rule requires you to specify a
- * precision.
- */
- private final boolean requiresPrecision;
-
- /**
- * @param canCustomizePrecision
- * @since 2022-04-18
- */
- private StandardRoundingType(boolean requiresPrecision) {
- this.requiresPrecision = requiresPrecision;
- }
-
- /**
- * Gets a rounding rule of this type.
- *
- * @param precision the rounding type's precision. If
- * {@link #requiresPrecision} is false, this field will
- * be ignored.
- * @return rounding rule
- * @since 2022-04-18
- */
- public abstract Function<UncertainDouble, String> getRuleFromPrecision(
- int precision);
-
- /**
- * Tries to get this rule without specifying precision.
- *
- * @throws UnsupportedOperationException if this rule requires specifying
- * precision
- * @since 2022-04-18
- */
- public final Function<UncertainDouble, String> getRuleWithoutPrecision() {
- if (this.requiresPrecision())
- throw new UnsupportedOperationException("Rounding type " + this
- + " requires you to specify precision.");
- else
- // random number to mess with anyone who lies about whether or not
- // precision is required
- return this.getRuleFromPrecision(-623546735);
- }
-
- /**
- * @return whether or not this rounding type requires you to specify an
- * integer precision
- * @since 2022-04-18
- */
- public boolean requiresPrecision() {
- return this.requiresPrecision;
- }
+ UNCERTAINTY;
}
/**
diff --git a/src/main/java/sevenUnitsGUI/View.java b/src/main/java/sevenUnitsGUI/View.java
index 011e87f..b2d2b94 100644
--- a/src/main/java/sevenUnitsGUI/View.java
+++ b/src/main/java/sevenUnitsGUI/View.java
@@ -30,6 +30,14 @@ import sevenUnits.utils.NameSymbol;
*/
public interface View {
/**
+ * @return a new tabbed view
+ * @since 2022-04-19
+ */
+ static View createTabbedView() {
+ return new TabbedView();
+ }
+
+ /**
* @return the presenter associated with this view
* @since 2022-04-19
*/
diff --git a/src/main/java/sevenUnitsGUI/ViewBot.java b/src/main/java/sevenUnitsGUI/ViewBot.java
index 9253ae5..a3ba7a2 100644
--- a/src/main/java/sevenUnitsGUI/ViewBot.java
+++ b/src/main/java/sevenUnitsGUI/ViewBot.java
@@ -34,7 +34,8 @@ import sevenUnits.utils.Nameable;
* @author Adrien Hopkins
* @since 2022-01-29
*/
-final class ViewBot implements UnitConversionView, ExpressionConversionView {
+public final class ViewBot
+ implements UnitConversionView, ExpressionConversionView {
/**
* A record of the parameters given to
* {@link View#showPrefix(NameSymbol, String)}, for testing.