Android Open Source - AstroPhysCalc Mass Unit






From Project

Back to project page AstroPhysCalc.

License

The source code is released under:

Apache License

If you think the Android project AstroPhysCalc listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.astrophyscalc;
/*from  w ww .ja  v  a2  s  .c o m*/
public enum MassUnit implements Unit {

  M_E("Me", 9.10938188E-31d),
  M_P("Mp", 1.67262158E-27d),
  NG("ng", 1E-9d),
  MG("mg", 1E-6d),
  G("g", 1E-3d),
  KG("kg", 1d),
  T("tons", 1000d),
  M_EARTH("Earths", 5.97219E24d),
  M_JUP("Jupiters", 1.89813E27d),
  M_SUN("Suns", 1.989E30d);

  private final String name;
  private final double ratioToBase;
  private final static MassUnit base = KG;

  MassUnit(final String name, final double ratioToBase) {
    this.name = name;
    this.ratioToBase = ratioToBase;
  }

  public static MassUnit getUnit(final String name) {
    MassUnit[] units = MassUnit.values();
    for (MassUnit unit : units) {
      if (unit.getName().equals(name)) {
        return unit;
      }
    }
    return null;
  }

  @Override
  public double inBaseUnits() {
    return ratioToBase;
  }

  @Override
  public Unit getBase() {
    return base;
  }

  @Override
  public String getName() {
    return name;
  }

  @Override
  public boolean isSameBaseAs(Unit unit) {
    return unit instanceof MassUnit;
  }

}




Java Source Code List

org.astrophyscalc.AstroPhysCalcActivity.java
org.astrophyscalc.CalcPage.java
org.astrophyscalc.CalcRow.java
org.astrophyscalc.Calculator.java
org.astrophyscalc.Constants.java
org.astrophyscalc.DimensionTest.java
org.astrophyscalc.Dimension.java
org.astrophyscalc.FractionTest.java
org.astrophyscalc.Fraction.java
org.astrophyscalc.LengthUnit.java
org.astrophyscalc.MassUnit.java
org.astrophyscalc.TimeUnitTest.java
org.astrophyscalc.TimeUnit.java
org.astrophyscalc.UnitAndDimTest.java
org.astrophyscalc.UnitAndDim.java
org.astrophyscalc.UnitExpressionTest.java
org.astrophyscalc.UnitExpression.java
org.astrophyscalc.UnitSelectionRule.java
org.astrophyscalc.UnitSelector.java
org.astrophyscalc.UnitSpinnerItem.java
org.astrophyscalc.UnitUtilTest.java
org.astrophyscalc.UnitUtil.java
org.astrophyscalc.Unit.java
org.astrophyscalc.ValueAndUnitsTest.java
org.astrophyscalc.ValueAndUnits.java