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 double
conversion_factor
protected java.lang.String
name
protected java.lang.String
short_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 double
convert(Unit unit, double value)
Convertsvalue
, specified withunit
, to its equivalent in thisUnit
.double
getConversionToMeter()
java.lang.String
getName()
java.lang.String
getShortName()
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:
getShortName
in classUnit
-
getConversionToMeter
public double getConversionToMeter() -
convert
Convertsvalue
, specified withunit
, to its equivalent in thisUnit
.- Specified by:
convert
in classUnit
- Parameters:
unit
- the unit in whichvalue
is currently specifiedvalue
- the value to convert- Returns:
- the equivalent of
value
in this unit - Throws:
UnitConversionException
-