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)
    Converts value, specified with unit, to its equivalent in this Unit.
    double getConversionToMeter()  
    java.lang.String getName()  
    java.lang.String getShortName()  

    Methods inherited from class mgui.util.Unit

    compareTo, toString

    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()
      Specified by:
      getName in class Unit
    • getShortName

      public java.lang.String getShortName()
      Specified by:
      getShortName in class Unit
    • getConversionToMeter

      public double getConversionToMeter()
    • convert

      public double convert​(Unit unit, double value) throws UnitConversionException
      Converts value, specified with unit, to its equivalent in this Unit.
      Specified by:
      convert in class Unit
      Parameters:
      unit - the unit in which value is currently specified
      value - the value to convert
      Returns:
      the equivalent of value in this unit
      Throws:
      UnitConversionException