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