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-2018 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: 2018-01-28 03:17:44 +0100 (Sun, 28 Jan 2018) $, @version $Revision: 256 $, 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 the key to the locale file for the long name of the unit 42 * @param abbreviationKey the key to the locale file for the abbreviation of the unit 43 * @param 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 if standardUnit: the key to the locale file for the long name of the unit, otherwise the name itself 53 * @param abbreviationOrAbbreviationKey if standardUnit: the key to the locale file for the abbreviation of the unit, 54 * otherwise the abbreviation itself 55 * @param unitSystem the unit system, e.g. SI or Imperial 56 * @param referenceUnit the unit to convert to 57 * @param scaleFactorToReferenceUnit multiply a value in this unit by the factor to convert to the given reference unit 58 * @param standardUnit indicates whether it is a standard unit with a definition in the locale, or a user-defined unit 59 */ 60 private AngleSolidUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem, 61 final AngleSolidUnit referenceUnit, final double scaleFactorToReferenceUnit, final boolean standardUnit) 62 { 63 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit, 64 standardUnit); 65 } 66 67 /** 68 * Build a user-defined unit with a conversion factor to another unit. 69 * @param name the long name of the unit 70 * @param abbreviation the abbreviation of the unit 71 * @param unitSystem the unit system, e.g. SI or Imperial 72 * @param referenceUnit the unit to convert to 73 * @param scaleFactorToReferenceUnit multiply a value in this unit by the factor to convert to the given reference unit 74 */ 75 public AngleSolidUnit(final String name, final String abbreviation, final UnitSystem unitSystem, 76 final AngleSolidUnit referenceUnit, final double scaleFactorToReferenceUnit) 77 { 78 this(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit, false); 79 } 80 81 /** {@inheritDoc} */ 82 @Override 83 public final AngleSolidUnit getStandardUnit() 84 { 85 return STERADIAN; 86 } 87 88 /** {@inheritDoc} */ 89 @Override 90 public final String getSICoefficientsString() 91 { 92 return "1"; 93 } 94 95 }