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-2018 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.kelvin", "AbsoluteTemperatureUnit.K", OTHER, 1.0, 0.0, true,
45                  TemperatureUnit.KELVIN);
46          KELVIN = BASE;
47          DEGREE_CELSIUS = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.degree_Celsius", "AbsoluteTemperatureUnit.dgC",
48                  SI_DERIVED, 1.0, 273.15, true, TemperatureUnit.DEGREE_CELSIUS);
49          DEGREE_FAHRENHEIT = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.degree_Fahrenheit",
50                  "AbsoluteTemperatureUnit.dgF", IMPERIAL, 5.0 / 9.0, 459.67, true, TemperatureUnit.DEGREE_FAHRENHEIT);
51          DEGREE_RANKINE = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.degree_Rankine", "AbsoluteTemperatureUnit.dgR",
52                  OTHER, 5.0 / 9.0, 0.0, true, TemperatureUnit.DEGREE_RANKINE);
53          DEGREE_REAUMUR = new AbsoluteTemperatureUnit("AbsoluteTemperatureUnit.degree_Reaumur", "AbsoluteTemperatureUnit.dgRe",
54                  OTHER, 4.0 / 5.0, 273.15, true, TemperatureUnit.DEGREE_REAUMUR);
55      }
56  
57      /**
58       * Build a AbsoluteTemperatureUnit with a conversion factor and offset to Kelvin.
59       * @param nameOrNameKey if standardUnit: the key to the locale file for the long name of the unit, otherwise the name itself
60       * @param abbreviationOrAbbreviationKey if standardUnit: the key to the locale file for the abbreviation of the unit,
61       *            otherwise the abbreviation itself
62       * @param unitSystem the unit system, e.g. SI or Imperial
63       * @param conversionFactorToStandardUnit multiply by this number to convert to the standard unit
64       * @param offsetToStandardUnit the offsetToKelvin to add to convert to the standard (e.g., SI) unit
65       * @param standardUnit indicates whether it is a standard unit with a definition in the locale, or a user-defined unit
66       * @param relativeUnit the corresponding relative unit belonging to this absolute unit
67       */
68      private AbsoluteTemperatureUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey,
69              final UnitSystem unitSystem, final double conversionFactorToStandardUnit, final double offsetToStandardUnit,
70              final boolean standardUnit, final TemperatureUnit relativeUnit)
71      {
72          super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, conversionFactorToStandardUnit, offsetToStandardUnit,
73                  standardUnit, relativeUnit);
74      }
75  
76      /**
77       * Build a user-defined AbsoluteTemperatureUnit with a conversion factor and offset to Kelvin.
78       * @param name the long name of the unit
79       * @param abbreviation the abbreviation of the unit
80       * @param unitSystem the unit system, e.g. SI or Imperial
81       * @param conversionFactorToStandardUnit multiply by this number to convert to the standard unit
82       * @param offsetToKelvin the offsetToKelvin to add to convert to the standard (e.g., SI) unit
83       * @param relativeUnit the corresponding relative unit belonging to this absolute unit
84       */
85      public AbsoluteTemperatureUnit(final String name, final String abbreviation, final UnitSystem unitSystem,
86              final double conversionFactorToStandardUnit, final double offsetToKelvin, final TemperatureUnit relativeUnit)
87      {
88          this(name, abbreviation, unitSystem, conversionFactorToStandardUnit, offsetToKelvin, false, relativeUnit);
89      }
90  
91      /** {@inheritDoc} */
92      @Override
93      public final AbsoluteTemperatureUnit getStandardUnit()
94      {
95          return KELVIN;
96      }
97  
98      /** {@inheritDoc} */
99      @Override
100     public final String getSICoefficientsString()
101     {
102         return "K";
103     }
104 
105 }