Package mgui.util

Class Unit

java.lang.Object
mgui.util.Unit
All Implemented Interfaces:
java.lang.Comparable<Unit>
Direct Known Subclasses:
ScaledUnit

public abstract class Unit
extends java.lang.Object
implements java.lang.Comparable<Unit>
Specifies an abstract unit, with a conversion factor to some base unit.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Constructor Summary

    Constructors
    Constructor Description
    Unit()  
  • Method Summary

    Modifier and Type Method Description
    int compareTo​(Unit unit)  
    abstract double convert​(Unit unit, double value)
    Converts value, specified with unit, to its equivalent in this Unit.
    abstract java.lang.String getName()  
    abstract java.lang.String getShortName()  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Unit

      public Unit()
  • Method Details

    • getName

      public abstract java.lang.String getName()
    • getShortName

      public abstract java.lang.String getShortName()
    • convert

      public abstract double convert​(Unit unit, double value) throws UnitConversionException
      Converts value, specified with unit, to its equivalent in this 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
    • compareTo

      public int compareTo​(Unit unit)
      Specified by:
      compareTo in interface java.lang.Comparable<Unit>
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object