+
+ +

Class UnitConverterGUI.Presenter

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.unitConverter.converterGUI.UnitConverterGUI.Presenter
    • +
    +
  • +
+
+
    +
  • +
    +
    Enclosing class:
    +
    UnitConverterGUI
    +
    +
    +
    private static class UnitConverterGUI.Presenter
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeFieldDescription
      private UnitDatabasedatabase +
      The units known by the program.
      +
      private java.util.List<java.lang.String>dimensionNames +
      The names of all of the dimensions
      +
      private java.util.Comparator<java.lang.String>prefixNameComparator 
      private java.util.List<java.lang.String>prefixNames +
      The names of all of the prefixes
      +
      private intsignificantFigures 
      private java.util.List<java.lang.String>unitNames +
      The names of all of the units
      +
      private UnitConverterGUI.Viewview +
      The presenter's associated view.
      +
      +
    • +
    +
    + +
    + +
    + +
    +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      private static voidaddDefaults​(UnitDatabase database) +
      Adds default units and dimensions to a database.
      +
      voidconvertDimensionBased() +
      Converts in the dimension-based converter
      +
      voidconvertExpressions() +
      Runs whenever the convert button is pressed.
      +
      java.util.List<java.lang.String>dimensionNameList() 
      java.util.Comparator<java.lang.String>getPrefixNameComparator() 
      private java.lang.StringgetRoundedString​(double value) 
      java.util.Set<java.lang.String>prefixNameSet() 
      voidprefixSelected() +
      Runs whenever a prefix is selected in the viewer.
      +
      voidsetSignificantFigures​(int significantFigures) 
      booleanunitMatchesDimension​(java.lang.String unitName, + java.lang.String dimensionName) +
      Returns true if and only if the unit represented by unitName has the dimension represented by + dimensionName.
      +
      voidunitNameSelected() +
      Runs whenever a unit is selected in the viewer.
      +
      java.util.Set<java.lang.String>unitNameSet() 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Detail

      + + + + + + + +
        +
      • +

        database

        +
        private final UnitDatabase database
        +
        The units known by the program.
        +
      • +
      + + + +
        +
      • +

        unitNames

        +
        private final java.util.List<java.lang.String> unitNames
        +
        The names of all of the units
        +
      • +
      + + + +
        +
      • +

        prefixNames

        +
        private final java.util.List<java.lang.String> prefixNames
        +
        The names of all of the prefixes
        +
      • +
      + + + +
        +
      • +

        dimensionNames

        +
        private final java.util.List<java.lang.String> dimensionNames
        +
        The names of all of the dimensions
        +
      • +
      + + + +
        +
      • +

        prefixNameComparator

        +
        private final java.util.Comparator<java.lang.String> prefixNameComparator
        +
      • +
      + + + +
        +
      • +

        significantFigures

        +
        private int significantFigures
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Presenter

        +
        Presenter​(UnitConverterGUI.View view)
        +
        Creates the presenter.
        +
        +
        Parameters:
        +
        view - presenter's associated view
        +
        Since:
        +
        2018-12-27, v0.1.0
        +
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        addDefaults

        +
        private static void addDefaults​(UnitDatabase database)
        +
        Adds default units and dimensions to a database.
        +
        +
        Parameters:
        +
        database - database to add to
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        convertDimensionBased

        +
        public final void convertDimensionBased()
        +
        Converts in the dimension-based converter
        +
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        convertExpressions

        +
        public final void convertExpressions()
        +
        Runs whenever the convert button is pressed. + +

        + Reads and parses a unit expression from the from and to boxes, then converts from to to. Any + errors are shown in JOptionPanes. +

        +
        +
        Since:
        +
        2019-01-26, v0.1.0
        +
        +
      • +
      + + + +
        +
      • +

        dimensionNameList

        +
        public final java.util.List<java.lang.String> dimensionNameList()
        +
        +
        Returns:
        +
        a list of all of the unit dimensions
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        getPrefixNameComparator

        +
        public final java.util.Comparator<java.lang.String> getPrefixNameComparator()
        +
        +
        Returns:
        +
        a comparator to compare prefix names
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        getRoundedString

        +
        private final java.lang.String getRoundedString​(double value)
        +
        +
        Parameters:
        +
        value - value to round
        +
        Returns:
        +
        string of that value rounded to significantDigits significant digits.
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        prefixNameSet

        +
        public final java.util.Set<java.lang.String> prefixNameSet()
        +
        +
        Returns:
        +
        a set of all prefix names in the database
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        prefixSelected

        +
        public final void prefixSelected()
        +
        Runs whenever a prefix is selected in the viewer. +

        + Shows its information in the text box to the right. +

        +
        +
        Since:
        +
        2019-01-15, v0.1.0
        +
        +
      • +
      + + + +
        +
      • +

        setSignificantFigures

        +
        public final void setSignificantFigures​(int significantFigures)
        +
        +
        Parameters:
        +
        significantFigures - new value of significantFigures
        +
        Since:
        +
        2019-01-15, v0.1.0
        +
        +
      • +
      + + + +
        +
      • +

        unitMatchesDimension

        +
        public final boolean unitMatchesDimension​(java.lang.String unitName,
        +                                          java.lang.String dimensionName)
        +
        Returns true if and only if the unit represented by unitName has the dimension represented by + dimensionName.
        +
        +
        Parameters:
        +
        unitName - name of unit to test
        +
        dimensionName - name of dimension to test
        +
        Returns:
        +
        whether unit has dimenision
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        unitNameSelected

        +
        public final void unitNameSelected()
        +
        Runs whenever a unit is selected in the viewer. +

        + Shows its information in the text box to the right. +

        +
        +
        Since:
        +
        2019-01-15, v0.1.0
        +
        +
      • +
      + + + +
        +
      • +

        unitNameSet

        +
        public final java.util.Set<java.lang.String> unitNameSet()
        +
        +
        Returns:
        +
        a set of all of the unit names
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+