Package mgui.util
Class ScaledUnit
java.lang.Object
mgui.util.Unit
mgui.util.ScaledUnit
- All Implemented Interfaces:
java.lang.Comparable<Unit>
- Direct Known Subclasses:
SpatialUnit
public class ScaledUnit extends Unit
Specifies a simple unit, scaled by a constant factor with respect to a base unit. All subclasses must
implement the
convert method from the Unit interface.
SpatialUnit specifies no setter functions; the unit should be set from the constructor
and not changed.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Field Summary
Fields Modifier and Type Field Description protected doubleconversion_factorprotected java.lang.Stringnameprotected java.lang.Stringshort_name -
Constructor Summary
Constructors Constructor Description ScaledUnit(java.lang.String long_name, java.lang.String short_name, double factor) -
Method Summary
Modifier and Type Method Description doubleconvert(Unit unit, double value)Convertsvalue, specified withunit, to its equivalent in thisUnit.doublegetConversionToMeter()java.lang.StringgetName()java.lang.StringgetShortName()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
name
protected java.lang.String name -
short_name
protected java.lang.String short_name -
conversion_factor
protected double conversion_factor
-
-
Constructor Details
-
ScaledUnit
public ScaledUnit(java.lang.String long_name, java.lang.String short_name, double factor)
-
-
Method Details
-
getName
public java.lang.String getName() -
getShortName
public java.lang.String getShortName()- Specified by:
getShortNamein classUnit
-
getConversionToMeter
public double getConversionToMeter() -
convert
Convertsvalue, specified withunit, to its equivalent in thisUnit.- Specified by:
convertin classUnit- Parameters:
unit- the unit in whichvalueis currently specifiedvalue- the value to convert- Returns:
- the equivalent of
valuein this unit - Throws:
UnitConversionException
-