Package javax.measure.converter

Examples of javax.measure.converter.UnitConverter.convert()


        } else if (unit != null) {
            final UnitConverter converter = unit.getConverterToAny(targetUnit);
            if (!converter.equals(UnitConverter.IDENTITY)) {
                boolean minInc = isMinIncluded;
                boolean maxInc = isMaxIncluded;
                double minimum = converter.convert(getMinDouble());
                double maximum = converter.convert(getMaxDouble());
                if (minimum > maximum) {
                    final double  td = minimum; minimum = maximum; maximum = td;
                    final boolean tb = minInc;  minInc  = maxInc;  maxInc  = tb;
                }
View Full Code Here


            final UnitConverter converter = unit.getConverterToAny(targetUnit);
            if (!converter.equals(UnitConverter.IDENTITY)) {
                boolean minInc = isMinIncluded;
                boolean maxInc = isMaxIncluded;
                double minimum = converter.convert(getMinDouble());
                double maximum = converter.convert(getMaxDouble());
                if (minimum > maximum) {
                    final double  td = minimum; minimum = maximum; maximum = td;
                    final boolean tb = minInc;  minInc  = maxInc;  maxInc  = tb;
                }
                if (Numbers.isInteger(type)) {
View Full Code Here

      if (travelDistance >= stepLength) {
        loc = path.remove();
        travelledNodes.add(loc);

        final long timeSpent = DoubleMath.roundToLong(
            toExternalTimeConv.convert(stepLength / speed),
            RoundingMode.HALF_DOWN);
        time.consume(timeSpent);
        traveled += stepLength;
      } else {
        final Point diff = Point.diff(path.peek(), loc);
View Full Code Here

        tempPos = path.remove();
        if (!(tempPos instanceof Loc)) {
          travelledNodes.add(tempPos);
        }
        final long timeSpent = DoubleMath.roundToLong(
            toExternalTimeConv.convert(connLength / speed),
            RoundingMode.HALF_DOWN);
        time.consume(timeSpent);
        traveled += connLength;

        if (tempPos instanceof Loc) {
View Full Code Here

  @Test
  public void maxSpeedTest() {
    final UnitConverter speedConverter = NonSI.KILOMETERS_PER_HOUR
        .getConverterTo(AbstractRoadModel.INTERNAL_SPEED_UNIT);

    final double s = speedConverter.convert(speed);

    final SpeedyRoadUser agent = new SpeedyRoadUser(speed);
    assertEquals(s, model.getMaxSpeed(agent, A, B), DELTA);
    assertEquals(speed > 2.5 ? speedConverter.convert(2.5) : s,
        model.getMaxSpeed(agent, B, C), DELTA);
View Full Code Here

    final double s = speedConverter.convert(speed);

    final SpeedyRoadUser agent = new SpeedyRoadUser(speed);
    assertEquals(s, model.getMaxSpeed(agent, A, B), DELTA);
    assertEquals(speed > 2.5 ? speedConverter.convert(2.5) : s,
        model.getMaxSpeed(agent, B, C), DELTA);
    assertEquals(s, model.getMaxSpeed(agent, C, B), DELTA);
    assertEquals(s, model.getMaxSpeed(agent, B, D), DELTA);
    assertEquals(s, model.getMaxSpeed(agent, C, D), DELTA);
    assertEquals(speedConverter.convert(1), model.getMaxSpeed(agent, D, C),
View Full Code Here

    assertEquals(speed > 2.5 ? speedConverter.convert(2.5) : s,
        model.getMaxSpeed(agent, B, C), DELTA);
    assertEquals(s, model.getMaxSpeed(agent, C, B), DELTA);
    assertEquals(s, model.getMaxSpeed(agent, B, D), DELTA);
    assertEquals(s, model.getMaxSpeed(agent, C, D), DELTA);
    assertEquals(speedConverter.convert(1), model.getMaxSpeed(agent, D, C),
        DELTA);
    assertEquals(s, model.getMaxSpeed(agent, D, E), DELTA);
  }

  @Test
View Full Code Here

    g.addConnection(A, B, new LengthData(3));

    final UnitConverter conv = NonSI.KILOMETERS_PER_HOUR
        .getConverterTo(AbstractRoadModel.INTERNAL_SPEED_UNIT);

    assertEquals(conv.convert(10),
        rm.getMaxSpeed(new SpeedyRoadUser(10), A, B), EPSILON);

    ((Graph<MultiAttributeData>) graph).addConnection(SE, SW,
        new MultiAttributeData(3, 5d));
    assertEquals(conv.convert(5),
View Full Code Here

    assertEquals(conv.convert(10),
        rm.getMaxSpeed(new SpeedyRoadUser(10), A, B), EPSILON);

    ((Graph<MultiAttributeData>) graph).addConnection(SE, SW,
        new MultiAttributeData(3, 5d));
    assertEquals(conv.convert(5),
        model.getMaxSpeed(new SpeedyRoadUser(10), SE, SW), EPSILON);

    ((Graph<MultiAttributeData>) graph).addConnection(NE, SE,
        new MultiAttributeData(3, Double.NaN));
    assertEquals(conv.convert(10),
View Full Code Here

    assertEquals(conv.convert(5),
        model.getMaxSpeed(new SpeedyRoadUser(10), SE, SW), EPSILON);

    ((Graph<MultiAttributeData>) graph).addConnection(NE, SE,
        new MultiAttributeData(3, Double.NaN));
    assertEquals(conv.convert(10),
        model.getMaxSpeed(new SpeedyRoadUser(10), NE, SE), EPSILON);
  }

  @SuppressWarnings("null")
  @Test(expected = IllegalArgumentException.class)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.