com.timjohnstondev.unitconverter.controller
Class ModelController

java.lang.Object
  extended by com.timjohnstondev.unitconverter.controller.ModelController

public class ModelController
extends Object

The controller in the MVC pattern for this application. Acts and the intermediary between the view components and the model components.


Constructor Summary
ModelController()
          Constructs and initializes a ModelController, pulling all of the model data into a PropertyList.
 
Method Summary
 String getConversion(String property, String from, String to)
          Returns the Conversion factor or formula for the given Property name for going from one set of units to another.
 List<String> getPropertyNames()
          Returns a list of all the Property names in the data source.
 List<String> getSymbols(String property)
          Returns a list of all the symbols for this Property in the data source.
 List<String> getSymbols(String property, String fromUnit)
          Returns a list, minus the symbol provided, of the symbols for this Property in the data source.
 String getUnitName(String property, String unitSymbol)
          Returns this symbol's name in unabbreviated words for this Property.
 String getUnitSeparator()
          Returns the unit separator symbol or the default (*) if the value has not been set
 void setPropertyOrderPreferences(JList list)
          Updates the preference that orders the Propertys in the application.
 void setUnitSeparator(String symbol)
          Updates the unit separator symbol
 boolean usesMoles(String propertyName)
          Returns true if this Property can do mole to mass and mass to mole unit conversions, else false
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelController

public ModelController()
Constructs and initializes a ModelController, pulling all of the model data into a PropertyList.

Method Detail

getConversion

public final String getConversion(String property,
                                  String from,
                                  String to)
Returns the Conversion factor or formula for the given Property name for going from one set of units to another.

Parameters:
property - the name of the Property that will be converted, such as temperature, pressure or length
from - the original units
to - the desired units
Returns:
the factor or formula to perform the conversion

getPropertyNames

public final List<String> getPropertyNames()
Returns a list of all the Property names in the data source. The order of the names is determined by the underlying PropertyList. This list order was initially based on the order the properties appear in the data source.

Returns:
a list of the Property names

getSymbols

public final List<String> getSymbols(String property)
Returns a list of all the symbols for this Property in the data source. The order of the symbols is determined by the underlying PropertyList. This list order was initially based on the order the symbols appear in the data source for this Property.

Parameters:
property - the name of the Property that is the basis for the units
Returns:
a list of the symbols

getSymbols

public final List<String> getSymbols(String property,
                                     String fromUnit)
Returns a list, minus the symbol provided, of the symbols for this Property in the data source. The order of the symbols is determined by the underlying Property. This list order was initially based on the order the symbols appear in the data source for this Property.

Parameters:
property - the name of the Property that is the basis for the units
fromUnit - the symbol to leave out of the list
Returns:
a list of the symbols

getUnitName

public final String getUnitName(String property,
                                String unitSymbol)
Returns this symbol's name in unabbreviated words for this Property.

Parameters:
property - the name of the Property that is the basis for this unit
unitSymbol - the symbol that represents the returned name
Returns:
the name for this symbol

getUnitSeparator

public final String getUnitSeparator()
Returns the unit separator symbol or the default (*) if the value has not been set

Returns:
the unit separator symbol or the default (*) if the value has not been set

setUnitSeparator

public final void setUnitSeparator(String symbol)
Updates the unit separator symbol

Parameters:
symbol - the new unit separator symbol

usesMoles

public final boolean usesMoles(String propertyName)
Returns true if this Property can do mole to mass and mass to mole unit conversions, else false

Parameters:
propertyName - name of the property
Returns:
true if this Property can do mole to mass and mass to mole unit conversions, else false

setPropertyOrderPreferences

public final void setPropertyOrderPreferences(JList list)
Updates the preference that orders the Propertys in the application.

Parameters:
list - Property list


Copyright © 2009 Tim Johnston Development, LLC. All Rights Reserved.