From 8cc60583134a4d01e9967424e5a51332de6cc38b Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Tue, 19 Apr 2022 16:35:43 -0500 Subject: Finalized version 0.4.0-alpha.1 --- src/main/java/sevenUnitsGUI/Main.java | 34 +++++++++++++ src/main/java/sevenUnitsGUI/Presenter.java | 2 +- src/main/java/sevenUnitsGUI/TabbedView.java | 76 ++--------------------------- src/main/java/sevenUnitsGUI/View.java | 8 +++ src/main/java/sevenUnitsGUI/ViewBot.java | 3 +- 5 files changed, 48 insertions(+), 75 deletions(-) create mode 100644 src/main/java/sevenUnitsGUI/Main.java (limited to 'src/main/java/sevenUnitsGUI') 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 . + */ +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 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 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 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 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 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 @@ -29,6 +29,14 @@ import sevenUnits.utils.NameSymbol; * @since 2021-12-15 */ 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. -- cgit v1.2.3