View Javadoc
1   package org.djunits.unit;
2   
3   import static org.djunits.unit.unitsystem.UnitSystem.IMPERIAL;
4   import static org.djunits.unit.unitsystem.UnitSystem.OTHER;
5   import static org.djunits.unit.unitsystem.UnitSystem.SI_DERIVED;
6   
7   import org.djunits.unit.unitsystem.UnitSystem;
8   
9   /**
10   * AbsoluteTemperature units.
11   * <p>
12   * Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>.
14   * <p>
15   * $LastChangedDate: 2017-01-30 14:23:11 +0100 (Mon, 30 Jan 2017) $, @version $Revision: 234 $, by $Author: averbraeck $,
16   * initial version Jun 5, 2014 <br>
17   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
18   */
19  public class AbsoluteTemperatureUnit extends AbsoluteLinearUnit<AbsoluteTemperatureUnit, TemperatureUnit>
20  {
21      /** */
22      private static final long serialVersionUID = 20140605L;
23  
24      /** The BASE unit for temperature is Kelvin. */
25      public static final AbsoluteTemperatureUnit BASE;
26  
27      /** Kelvin. */
28      public static final AbsoluteTemperatureUnit KELVIN;
29  
30      /** Degree Celsius. */
31      public static final AbsoluteTemperatureUnit DEGREE_CELSIUS;
32  
33      /** Degree Fahrenheit. */
34      public static final AbsoluteTemperatureUnit DEGREE_FAHRENHEIT;
35  
36      /** Degree Rankine. */
37      public static final AbsoluteTemperatureUnit DEGREE_RANKINE;
38  
39      /** Degree Reaumur. */
40      public static final AbsoluteTemperatureUnit DEGREE_REAUMUR;
41  
42      static
43      {
44          BASE = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.K", OTHER, 1.0, 0.0, TemperatureUnit.KELVIN);
45          KELVIN = BASE;
46          DEGREE_CELSIUS = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.dgC", SI_DERIVED, 1.0, 273.15,
47                  TemperatureUnit.DEGREE_CELSIUS);
48          DEGREE_FAHRENHEIT = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.dgF", IMPERIAL, 5.0 / 9.0, 459.67,
49                  TemperatureUnit.DEGREE_FAHRENHEIT);
50          DEGREE_RANKINE = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.dgR", OTHER, 5.0 / 9.0, 0.0,
51                  TemperatureUnit.DEGREE_RANKINE);
52          DEGREE_REAUMUR = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.dgRe", OTHER, 4.0 / 5.0, 273.15,
53                  TemperatureUnit.DEGREE_REAUMUR);
54      }
55  
56      /**
57       * Build a AbsoluteTemperatureUnit with a conversion factor and offset to Kelvin.
58       * @param abbreviationKey String; the key to the locale file for the abbreviation of the unit
59       * @param unitSystem UnitSystem; the unit system, e.g. SI or Imperial
60       * @param conversionFactorToStandardUnit double; multiply by this number to convert to the standard unit
61       * @param offsetToStandardUnit double; the offsetToKelvin to add to convert to the standard (e.g., SI) unit
62       * @param relativeUnit TemperatureUnit; the corresponding relative unit belonging to this absolute unit
63       */
64      private AbsoluteTemperatureUnit(final String abbreviationKey, final UnitSystem unitSystem,
65              final double conversionFactorToStandardUnit, final double offsetToStandardUnit, final TemperatureUnit relativeUnit)
66      {
67          super(abbreviationKey, unitSystem, conversionFactorToStandardUnit, offsetToStandardUnit, relativeUnit);
68      }
69  
70      /**
71       * Build a user-defined AbsoluteTemperatureUnit with a conversion factor and offset to Kelvin.
72       * @param name String; the long name of the unit
73       * @param abbreviation String; the abbreviation of the unit
74       * @param unitSystem UnitSystem; the unit system, e.g. SI or Imperial
75       * @param conversionFactorToStandardUnit double; multiply by this number to convert to the standard unit
76       * @param offsetToKelvin double; the offsetToKelvin to add to convert to the standard (e.g., SI) unit
77       * @param relativeUnit TemperatureUnit; the corresponding relative unit belonging to this absolute unit
78       */
79      public AbsoluteTemperatureUnit(final String name, final String abbreviation, final UnitSystem unitSystem,
80              final double conversionFactorToStandardUnit, final double offsetToKelvin, final TemperatureUnit relativeUnit)
81      {
82          super(name, abbreviation, unitSystem, conversionFactorToStandardUnit, offsetToKelvin, relativeUnit);
83      }
84  
85      /** {@inheritDoc} */
86      @Override
87      public final AbsoluteTemperatureUnit getStandardUnit()
88      {
89          return KELVIN;
90      }
91  
92      /** {@inheritDoc} */
93      @Override
94      public final String getSICoefficientsString()
95      {
96          return "K";
97      }
98  
99  }