From 8e613844ae19a4dea2089ac34c1f0ae650eaeae7 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Sat, 13 Apr 2019 10:05:08 -0400 Subject: The dimension selector now loads dimensions from a file. The dimension selector does nothing, as its purpose is to filter a list which does not exist yet, but it does correctly load the options. --- src/org/unitConverter/unit/BaseUnit.java | 24 ++++++++++++++++++++++++ src/org/unitConverter/unit/LinearUnit.java | 10 ++++++++++ 2 files changed, 34 insertions(+) (limited to 'src/org/unitConverter/unit') diff --git a/src/org/unitConverter/unit/BaseUnit.java b/src/org/unitConverter/unit/BaseUnit.java index 643272f..8bac866 100755 --- a/src/org/unitConverter/unit/BaseUnit.java +++ b/src/org/unitConverter/unit/BaseUnit.java @@ -18,11 +18,35 @@ package org.unitConverter.unit; import java.util.Objects; +import org.unitConverter.dimension.StandardDimensions; import org.unitConverter.dimension.UnitDimension; /** * A unit that is the base for its dimension. It does not have to be for a base dimension, so units like the Newton and * Joule are still base units. + *

+ * {@code BaseUnit} does not have any public constructors or static factories. There are two ways to obtain + * {@code BaseUnit} instances. + *

    + *
  1. The class {@link SI} in this package has constants for all of the SI base units. You can use these constants and + * multiply or divide them to get other units. For example: + * + *
    + * BaseUnit JOULE = SI.KILOGRAM.times(SI.METRE.toExponent(2)).dividedBy(SI.SECOND.toExponent(2));
    + * 
    + * + *
  2. + *
  3. You can also query a unit system for a base unit using a unit dimension. The previously mentioned {@link SI} + * class can do this for SI and SI-derived units (including imperial and USC), but if you want to use another system, + * this is the way to do it. {@link StandardDimensions} contains common unit dimensions that you can use for this. Here + * is an example: + * + *
    + * BaseUnit JOULE = SI.SI.getBaseUnit(StandardDimensions.ENERGY);
    + * 
    + * + *
  4. + *
* * @author Adrien Hopkins * @since 2018-12-23 diff --git a/src/org/unitConverter/unit/LinearUnit.java b/src/org/unitConverter/unit/LinearUnit.java index c755f79..5b2680b 100644 --- a/src/org/unitConverter/unit/LinearUnit.java +++ b/src/org/unitConverter/unit/LinearUnit.java @@ -23,6 +23,16 @@ import org.unitConverter.math.DecimalComparison; /** * A unit that is equal to a certain number multiplied by its base. + *

+ * {@code LinearUnit} does not have any public constructors or static factories. In order to obtain a {@code LinearUnit} + * instance, multiply its base by the conversion factor. Example: + * + *

+ * LinearUnit foot = METRE.times(0.3048);
+ * 
+ * + * (where {@code METRE} is a {@code BaseUnit} instance) + *

* * @author Adrien Hopkins * @since 2018-12-22 -- cgit v1.2.3