summaryrefslogtreecommitdiff
path: root/src/org/unitConverter/unit
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2019-04-13 10:05:08 -0400
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2019-04-13 10:05:08 -0400
commit8e613844ae19a4dea2089ac34c1f0ae650eaeae7 (patch)
tree43f3fcf2fc7fafb840156a6fe0a5596ba091a904 /src/org/unitConverter/unit
parentec036fdad931fbbd7dec28b864150f8668e91b41 (diff)
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.
Diffstat (limited to 'src/org/unitConverter/unit')
-rwxr-xr-xsrc/org/unitConverter/unit/BaseUnit.java24
-rw-r--r--src/org/unitConverter/unit/LinearUnit.java10
2 files changed, 34 insertions, 0 deletions
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.
+ * <p>
+ * {@code BaseUnit} does not have any public constructors or static factories. There are two ways to obtain
+ * {@code BaseUnit} instances.
+ * <ol>
+ * <li>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:
+ *
+ * <pre>
+ * BaseUnit JOULE = SI.KILOGRAM.times(SI.METRE.toExponent(2)).dividedBy(SI.SECOND.toExponent(2));
+ * </pre>
+ *
+ * </li>
+ * <li>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:
+ *
+ * <pre>
+ * BaseUnit JOULE = SI.SI.getBaseUnit(StandardDimensions.ENERGY);
+ * </pre>
+ *
+ * </li>
+ * </ol>
*
* @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.
+ * <p>
+ * {@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:
+ *
+ * <pre>
+ * LinearUnit foot = METRE.times(0.3048);
+ * </pre>
+ *
+ * (where {@code METRE} is a {@code BaseUnit} instance)
+ * </p>
*
* @author Adrien Hopkins
* @since 2018-12-22