Tabnine Logo
Dimension.getBaseDimensions
Code IndexAdd Tabnine to your IDE (free)

How to use
getBaseDimensions
method
in
javax.measure.Dimension

Best Java code snippets using javax.measure.Dimension.getBaseDimensions (Showing top 12 results out of 315)

origin: apache/sis

/**
 * Returns {@code true} if the given dimension has no components.
 */
static boolean isDimensionless(final Dimension dim) {
  if (dim instanceof UnitDimension) {
    return ((UnitDimension) dim).isDimensionless();
  } else if (dim != null) {
    // Fallback for foreigner implementations.
    final Map<? extends Dimension, Integer> bases = dim.getBaseDimensions();
    if (bases != null) return bases.isEmpty();
  }
  return false;       // Unit is a base unit (not a product of existing units).
}
origin: org.apache.sis.core/sis-utility

/**
 * Returns the base dimensions and their exponents whose product make the given dimension.
 * If the given dimension is a base dimension, then this method returns {@code this} raised
 * to power 1. This method never returns {@code null}.
 */
@SuppressWarnings("ReturnOfCollectionOrArrayField")     // Safe because the map is unmodifiable.
private static Map<? extends Dimension, Fraction> getBaseDimensions(final Dimension dimension) {
  if (dimension instanceof UnitDimension) {
    return ((UnitDimension) dimension).components;
  }
  /*
   * Fallback for non-SIS implementations. The cast from <? extends Dimension> to <Dimension>
   * is safe if we use the 'components' map as a read-only map (no put operation allowed).
   */
  @SuppressWarnings("unchecked")
  Map<Dimension,Integer> components = (Map<Dimension,Integer>) dimension.getBaseDimensions();
  if (components == null) {
    return Collections.singletonMap(dimension, new Fraction(1,1));
  }
  return ObjectConverters.derivedValues(components, Dimension.class, FractionConverter.FromInteger.INSTANCE);
}
origin: tec.units/indriya

/**
 * Returns the fundamental dimension for the one specified. If the specified dimension is a dimensional product, the dimensional product of its
 * fundamental dimensions is returned. Physical quantities are considered commensurate only if their fundamental dimensions are equals using the
 * current physics model.
 *
 * @param dimension
 *          the dimension for which the fundamental dimension is returned.
 * @return <code>this</code> or a rational product of fundamental dimension.
 */
public Dimension getFundamentalDimension(Dimension dimension) {
 Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions();
 if (dimensions == null)
  return dimension; // Fundamental dimension.
 // Dimensional Product.
 Dimension fundamentalProduct = QuantityDimension.NONE;
 for (Map.Entry<? extends Dimension, Integer> e : dimensions.entrySet()) {
  fundamentalProduct = fundamentalProduct.multiply(this.getFundamentalDimension(e.getKey())).pow(e.getValue());
 }
 return fundamentalProduct;
}
origin: apache/sis

/**
 * Returns the base dimensions and their exponents whose product make the given dimension.
 * If the given dimension is a base dimension, then this method returns {@code this} raised
 * to power 1. This method never returns {@code null}.
 */
@SuppressWarnings("ReturnOfCollectionOrArrayField")     // Safe because the map is unmodifiable.
private static Map<? extends Dimension, Fraction> getBaseDimensions(final Dimension dimension) {
  if (dimension instanceof UnitDimension) {
    return ((UnitDimension) dimension).components;
  }
  /*
   * Fallback for non-SIS implementations. The cast from <? extends Dimension> to <Dimension>
   * is safe if we use the 'components' map as a read-only map (no put operation allowed).
   */
  @SuppressWarnings("unchecked")
  Map<Dimension,Integer> components = (Map<Dimension,Integer>) dimension.getBaseDimensions();
  if (components == null) {
    return Collections.singletonMap(dimension, new Fraction(1,1));
  }
  return ObjectConverters.derivedValues(components, Dimension.class, FractionConverter.FromInteger.INSTANCE);
}
origin: tec.uom/uom-se

/**
 * Returns the fundamental dimension for the one specified. If the specified dimension is a dimensional product, the dimensional product of its
 * fundamental dimensions is returned. Physical quantities are considered commensurate only if their fundamental dimensions are equals using the
 * current physics model.
 *
 * @param dimension
 *          the dimension for which the fundamental dimension is returned.
 * @return <code>this</code> or a rational product of fundamental dimension.
 */
public Dimension getFundamentalDimension(Dimension dimension) {
 Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions();
 if (dimensions == null)
  return dimension; // Fundamental dimension.
 // Dimensional Product.
 Dimension fundamentalProduct = QuantityDimension.NONE;
 for (Map.Entry<? extends Dimension, Integer> e : dimensions.entrySet()) {
  fundamentalProduct = fundamentalProduct.multiply(this.getFundamentalDimension(e.getKey())).pow(e.getValue());
 }
 return fundamentalProduct;
}
origin: tec.units/unit-ri

/**
 * Returns the fundamental dimension for the one specified. If the specified dimension is a dimensional product, the dimensional product of its
 * fundamental dimensions is returned. Physical quantities are considered commensurate only if their fundamental dimensions are equals using the
 * current physics model.
 *
 * @param dimension
 *          the dimension for which the fundamental dimension is returned.
 * @return <code>this</code> or a rational product of fundamental dimension.
 */
public Dimension getFundamentalDimension(Dimension dimension) {
 Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions();
 if (dimensions == null)
  return dimension; // Fundamental dimension.
 // Dimensional Product.
 Dimension fundamentalProduct = QuantityDimension.NONE;
 for (Map.Entry<? extends Dimension, Integer> e : dimensions.entrySet()) {
  fundamentalProduct = fundamentalProduct.multiply(this.getFundamentalDimension(e.getKey())).pow(e.getValue());
 }
 return fundamentalProduct;
}
origin: tec.uom/uom-se

Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions();
if (dimensions == null)
 return AbstractConverter.IDENTITY; // Fundamental dimension.
origin: tec.units/indriya

Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions();
if (dimensions == null)
 return AbstractConverter.IDENTITY; // Fundamental dimension.
origin: tec.units/unit-ri

Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions();
if (dimensions == null)
 return AbstractConverter.IDENTITY; // Fundamental dimension.
origin: apache/sis

/**
 * Tests {@link UnitDimension#getBaseDimensions()}. This method indirectly tests the results
 * of {@link UnitDimension#multiply(Dimension)}, {@link UnitDimension#divide(Dimension)} and
 * {@link UnitDimension#pow(int)} since this test uses constants that were created with above
 * operations.
 */
@Test
public void testGetBaseDimensions() {
  assertNull("LENGTH",        LENGTH       .getBaseDimensions());     // Null value as per JSR-363 specification.
  assertNull("TIME",          TIME         .getBaseDimensions());
  assertTrue("DIMENSIONLESS", DIMENSIONLESS.getBaseDimensions().isEmpty());
  assertMapEquals(Collections.singletonMap(LENGTH, 3), VOLUME.getBaseDimensions());
  final Map<Dimension,Integer> expected = new HashMap<>(4);
  assertNull(expected.put(MASS,    1));
  assertNull(expected.put(LENGTH,  1));
  assertNull(expected.put(TIME,   -2));
  assertMapEquals(expected, FORCE.getBaseDimensions());
}
origin: apache/sis

/**
 * Tests a dimension with rational power. This tests use the specific detectivity, which dimension is T^2.5 / (M⋅L).
 */
@Test
@DependsOnMethod({"testMultiply", "testDivide", "testPow", "testRoot"})
public void testRationalPower() {
  final Dimension dim = specificDetectivity();
  final Map<Dimension,Fraction> expected = new HashMap<>(4);
  assertNull(expected.put(TIME,   new Fraction( 5, 2)));
  assertNull(expected.put(MASS,   new Fraction(-1, 1)));
  assertNull(expected.put(LENGTH, new Fraction(-1, 1)));
  assertMapEquals(expected, ((UnitDimension) dim).components);
  try {
    dim.getBaseDimensions().toString();
    fail("Mapping from Fraction to Integer should not be allowed.");
  } catch (UnconvertibleObjectException e) {
    final String message = e.getMessage();
    assertTrue(message, message.contains("Integer"));
  }
  // 'toString()' formatting tested in UnitFormatTest.testRationalPower().
}
origin: apache/sis

/**
 * Tests {@link UnitDimension#multiply(Dimension)}.
 */
@Test
@DependsOnMethod("testEqualsAndHashCode")
public void testMultiply() {
  assertSame(LENGTH, LENGTH.multiply(DIMENSIONLESS));
  assertSame(AREA,   LENGTH.multiply(LENGTH));
  assertSame(VOLUME, LENGTH.multiply(AREA));
  assertSame(VOLUME, AREA  .multiply(LENGTH));
  final Map<Dimension,Integer> expected = new HashMap<>(4);
  assertNull(expected.put(LENGTH, 1));
  assertNull(expected.put(TIME,   1));
  assertMapEquals(expected, LENGTH.multiply(TIME).getBaseDimensions());
}
javax.measureDimensiongetBaseDimensions

Popular methods of Dimension

  • multiply
  • pow
  • root
  • divide

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • onRequestPermissionsResult (Fragment)
  • addToBackStack (FragmentTransaction)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now