View Javadoc
1   package org.djunits.unit;
2   
3   import static org.djunits.unit.unitsystem.UnitSystem.SI_DERIVED;
4   
5   import org.djunits.unit.unitsystem.UnitSystem;
6   
7   /**
8    * Standard solid angle unit.
9    * <p>
10   * Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>.
12   * <p>
13   * $LastChangedDate: 2019-01-18 00:35:01 +0100 (Fri, 18 Jan 2019) $, @version $Revision: 324 $, by $Author: averbraeck $,
14   * initial version May 15, 2014 <br>
15   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
16   */
17  public class AngleSolidUnit extends LinearUnit<AngleSolidUnit>
18  {
19      /** */
20      private static final long serialVersionUID = 20140607L;
21  
22      /** The SI unit for solid angle is steradian. */
23      public static final AngleSolidUnit SI;
24  
25      /** steradian. */
26      public static final AngleSolidUnit STERADIAN;
27  
28      /** square degree. */
29      public static final AngleSolidUnit SQUARE_DEGREE;
30  
31      static
32      {
33          SI = new AngleSolidUnit("AngleSolidUnit.steradian", "AngleSolidUnit.sr", SI_DERIVED);
34          STERADIAN = SI;
35          SQUARE_DEGREE = new AngleSolidUnit("AngleSolidUnit.square_degree", "AngleSolidUnit.sq_deg", SI_DERIVED, STERADIAN,
36                  (Math.PI / 180.0) * (Math.PI / 180.0), true);
37      }
38  
39      /**
40       * Build a standard unit.
41       * @param nameKey String; the key to the locale file for the long name of the unit
42       * @param abbreviationKey String; the key to the locale file for the abbreviation of the unit
43       * @param unitSystem UnitSystem; the unit system, e.g. SI or Imperial
44       */
45      private AngleSolidUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
46      {
47          super(nameKey, abbreviationKey, unitSystem, true);
48      }
49  
50      /**
51       * Construct a derived unit as a conversion from another unit.
52       * @param nameOrNameKey String; if standardUnit: the key to the locale file for the long name of the unit, otherwise the
53       *            name itself
54       * @param abbreviationOrAbbreviationKey String; if standardUnit: the key to the locale file for the abbreviation of the
55       *            unit, otherwise the abbreviation itself
56       * @param unitSystem UnitSystem; the unit system, e.g. SI or Imperial
57       * @param referenceUnit AngleSolidUnit; the unit to convert to
58       * @param scaleFactorToReferenceUnit double; multiply a value in this unit by the factor to convert to the given reference
59       *            unit
60       * @param standardUnit boolean; indicates whether it is a standard unit with a definition in the locale, or a user-defined
61       *            unit
62       */
63      private AngleSolidUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
64              final AngleSolidUnit referenceUnit, final double scaleFactorToReferenceUnit, final boolean standardUnit)
65      {
66          super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit,
67                  standardUnit);
68      }
69  
70      /**
71       * Build a user-defined unit with a conversion factor to another unit.
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 referenceUnit AngleSolidUnit; the unit to convert to
76       * @param scaleFactorToReferenceUnit double; multiply a value in this unit by the factor to convert to the given reference
77       *            unit
78       */
79      public AngleSolidUnit(final String name, final String abbreviation, final UnitSystem unitSystem,
80              final AngleSolidUnit referenceUnit, final double scaleFactorToReferenceUnit)
81      {
82          this(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit, false);
83      }
84  
85      /** {@inheritDoc} */
86      @Override
87      public final AngleSolidUnit getStandardUnit()
88      {
89          return STERADIAN;
90      }
91  
92      /** {@inheritDoc} */
93      @Override
94      public final String getSICoefficientsString()
95      {
96          return "1";
97      }
98  
99  }