Package org.unitConverter.converterGUI
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 Type Field Description private UnitDatabase
database
The units known by the program.private java.util.List<java.lang.String>
dimensionNames
The names of all of the dimensionsprivate java.util.Comparator<java.lang.String>
prefixNameComparator
private java.util.List<java.lang.String>
prefixNames
The names of all of the prefixesprivate int
significantFigures
private java.util.List<java.lang.String>
unitNames
The names of all of the unitsprivate UnitConverterGUI.View
view
The presenter's associated view.
-
Constructor Summary
Constructors Constructor Description Presenter(UnitConverterGUI.View view)
Creates the presenter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
addDefaults(UnitDatabase database)
Adds default units and dimensions to a database.void
convertDimensionBased()
Converts in the dimension-based convertervoid
convertExpressions()
Runs whenever the convert button is pressed.java.util.List<java.lang.String>
dimensionNameList()
java.util.Comparator<java.lang.String>
getPrefixNameComparator()
private java.lang.String
getRoundedString(double value)
java.util.Set<java.lang.String>
prefixNameSet()
void
prefixSelected()
Runs whenever a prefix is selected in the viewer.void
setSignificantFigures(int significantFigures)
boolean
unitMatchesDimension(java.lang.String unitName, java.lang.String dimensionName)
Returns true if and only if the unit represented byunitName
has the dimension represented bydimensionName
.void
unitNameSelected()
Runs whenever a unit is selected in the viewer.java.util.Set<java.lang.String>
unitNameSet()
-
-
-
Field Detail
-
view
private final UnitConverterGUI.View view
The presenter's associated view.
-
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
toto
. 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 byunitName
has the dimension represented bydimensionName
.- Parameters:
unitName
- name of unit to testdimensionName
- 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
-
-