当前位置: 首页>>代码示例>>Java>>正文


Java Amount类代码示例

本文整理汇总了Java中org.jscience.physics.amount.Amount的典型用法代码示例。如果您正苦于以下问题:Java Amount类的具体用法?Java Amount怎么用?Java Amount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Amount类属于org.jscience.physics.amount包,在下文中一共展示了Amount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
@Override
public Double convert(Double value, MassUnit from, MassUnit to) {
    if (value == null)
        return null;

    if (from.equals(UNSUPPORTED) || to.equals(UNSUPPORTED))
        return null;

    Unit fUnit = get(from);
    Unit tUnit = get(to);

    if (fUnit == null || tUnit == null)
        return null;

    Amount<Mass> m = Amount.valueOf(value, fUnit);
    return m.doubleValue(tUnit);
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:18,代码来源:DefaultMassConverter.java

示例2: convert

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
@Override
public Double convert(Double value, DataAmountUnit from, DataAmountUnit to) {
    if (value == null)
        return null;

    if (from.equals(UNSUPPORTED) || to.equals(UNSUPPORTED))
        return null;

    Unit fUnit = get(from);
    Unit tUnit = get(to);

    if (fUnit == null || tUnit == null)
        return null;

    Amount<DataAmount> m = Amount.valueOf(value, fUnit);
    return m.doubleValue(tUnit);
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:18,代码来源:DefaultDataAmountConverter.java

示例3: convert

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
@Override
public Double convert(Double value, LengthUnit from, LengthUnit to) {
    if (value == null)
        return null;

    if (from.equals(UNSUPPORTED) || to.equals(UNSUPPORTED))
        return null;

    Unit fUnit = get(from);
    Unit tUnit = get(to);

    if (fUnit == null || tUnit == null)
        return null;

    Amount<Length> m = Amount.valueOf(value, fUnit);
    return m.doubleValue(tUnit);
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:18,代码来源:DefaultLengthConverter.java

示例4: doSave

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
/**
 * @throws IOException  
 */
@Override
protected void doSave(OutputStream outputStream, Map<?, ?> options) throws IOException {
	PrintWriter writer = new PrintWriter(outputStream);
	for (EObject o : getContents()) {
		AmountConstraint c = (AmountConstraint) o;
		String key = c.getKey();
		AmountExtent<?> extent = c.getExtent();
		Amount<?> min = extent.getMin();
		Amount<?> max = extent.getMax();
		boolean waived = c.isWaived();
		StringBuffer buffer = new StringBuffer(key)
			.append(",").append(JScienceFactory.eINSTANCE.convertToString(JSciencePackage.Literals.EAMOUNT, min))
			.append(",").append(JScienceFactory.eINSTANCE.convertToString(JSciencePackage.Literals.EAMOUNT, max))
			.append(",").append(waived);
		writer.println(buffer.toString());	
	}
	writer.close();
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:22,代码来源:AmountConstraintResource.java

示例5: testSetStartLaterEndComputingDuration

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
public void testSetStartLaterEndComputingDuration() {
	for (EPlanElement element : Util.createTestElements()) {
		TemporalMember member = element.getMember(TemporalMember.class);
		member.setCalculatedVariable(CalculatedVariable.DURATION);
		Date start = new Date();
		member.setStartTime(start);
		Date end = member.getEndTime();
		Amount<Duration> duration = AmountUtils.toAmount(3421, DateUtils.MILLISECONDS);
		Date end2 = DateUtils.add(end, duration);
		NotificationAdapter adapter = new NotificationAdapter(
				Util.setEnd(member, end, end2),
				Util.setDuration(member, DateUtils.ZERO_DURATION, duration)
			);
		member.eAdapters().add(adapter);
		member.setEndTime(end2);
		adapter.assertFinished();
		Util.check(member, start, duration, end2);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:20,代码来源:TestTemporalMember.java

示例6: testDistanceRequirementTextAnytimeBefore

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
/**
 * The [start,end] of activity 1 must occur at or earlier than 
 * the [start,end] of activity 2.
 */
public void testDistanceRequirementTextAnytimeBefore() {
	for (Timepoint timepointA : Timepoint.values()) {
		for (Timepoint timepointB : Timepoint.values()) {
			EPlanElement elementA = activity1;
			EPlanElement elementB = activity2;
			Amount<Duration> minDelta = ZERO;
			Amount<Duration> maxDelta = null;
			String text = constraintViolationPrinter.getDistanceRequirementText(
					ConstraintUtils.createConstraintPoint(elementA, timepointA), 
					ConstraintUtils.createConstraintPoint(elementB, timepointB), 
					minDelta, maxDelta, true);
			trace.debug("testDistanceRequirementTextAnytimeBefore() = " + text);
			String pattern = "";
			pattern += getTimepointPattern(timepointB, elementB);
			pattern += ".* should be no earlier than .*";
			pattern += getTimepointPattern(timepointA, elementA);
			pattern += ".*";
			boolean matches = text.matches(pattern);
			assertTrue("'" + text + "' doesn't match the pattern", matches);
			assertTrue(text.contains(identifiableRegistry.getUniqueId(elementA)));
			assertTrue(text.contains(identifiableRegistry.getUniqueId(elementB)));
		}
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:29,代码来源:TestConstraintViolationDistancePrinter.java

示例7: interpolate

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
@Override
public Amount<F> interpolate(Date point, SortedMap<Date, Amount<F>> pointValues) {
	// Searches exact.
	Amount<F> y = pointValues.get(point);
    if (y != null)
        return y;

    // Searches surrounding points/values.
    SortedMap<Date, Amount<F>> headMap = pointValues.headMap(point);
    Date x1 = headMap.lastKey();
    Amount<F> y1 = headMap.get(x1);
    SortedMap<Date, Amount<F>> tailMap = pointValues.tailMap(point);
    Date x2 = tailMap.firstKey();
    Amount<F> y2 = tailMap.get(x2);

    // Interpolates.
    final Date x = point;
	double pct = (x.getTime() - x1.getTime()) / (float) (x2.getTime() - x1.getTime());
	Amount<F> value = y2.minus(y1).times(pct).plus(y1);
    return value;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:22,代码来源:Linear.java

示例8: update

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
@Override
public boolean update() {
	Amount newValue = null;
	for (Dependency d : getPrevious()) {
		if (d instanceof ConditionDependency) {
			ConditionDependency condition = (ConditionDependency) d;
			DataPoint dataPoint = (DataPoint) condition.getValue();
			if (dataPoint != null) {
				Amount v = (Amount) dataPoint.getValue();
				if (v != null) {
					if (newValue == null) {
						newValue = v;
					} else {
						newValue = newValue.plus(v);
					}
				}
			}
		}
	}
	DataPoint<Amount> newDataPoint = JScienceFactory.eINSTANCE.createEDataPoint(conditions.getTime(), newValue); 
	if (!CommonUtils.equals(getValue(), newDataPoint)) {
		setValue(newDataPoint);
		return true;
	}
	return false;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:27,代码来源:SummingConditionDependency.java

示例9: convertToExponentialString

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
private <T extends Quantity> String convertToExponentialString(Amount<T> amount) {
	Unit unit = amount.getUnit();
	Unit baseUnit = unit.getStandardUnit();
	Unit currentUnit = baseUnit; 
	double currentAmount = amount.doubleValue(currentUnit);
	while (Math.abs(currentAmount) >= 1000) {
		currentUnit = SI.KILO(currentUnit);
		// If next is peta, roll over and play dead
		if (SI.PETA(baseUnit).equals(SI.KILO(currentUnit))) {
			break;
		}
		currentAmount = amount.doubleValue(currentUnit);
	}
	Number value = AmountUtils.getNumericValue(amount.to(currentUnit));
	return formatNumber(value) + " " + UNIT_FORMAT.format(currentUnit);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:EnsembleAmountFormat.java

示例10: testSetStartEarlierStartComputingDuration

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
public void testSetStartEarlierStartComputingDuration() {
	for (EPlanElement element : Util.createTestElements()) {
		TemporalMember member = element.getMember(TemporalMember.class);
		member.setCalculatedVariable(CalculatedVariable.DURATION);
		Date start = new Date();
		member.setStartTime(start);
		Amount<Duration> duration = AmountUtils.toAmount(145, DateUtils.MILLISECONDS);
		Date start2 = DateUtils.subtract(start, duration);
		NotificationAdapter adapter = new NotificationAdapter(
				Util.setStart(member, start, start2),
				Util.setDuration(member, DateUtils.ZERO_DURATION, duration)
			);
		member.eAdapters().add(adapter);
		member.setStartTime(start2);
		adapter.assertFinished();
		Util.check(member, start2, duration, start);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:TestTemporalMember.java

示例11: getText

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
@Override
public String getText(DataPoint facet) {
	EDataType dataType = profile.getDataType();
	Object value = facet.getValue();
	if (value == null) {
		return "";
	}
	if  (dataType.getInstanceClass() == Amount.class || value instanceof Amount) {
		return EnsembleAmountFormat.INSTANCE.formatAmount((Amount) value);
	}
	if (dataType.getInstanceClass() == Date.class) {
		return DATE_STRINGIFIER.getDisplayString((Date) value);
	}
	if (stringifier != null) {
		try {
			return stringifier.getDisplayString(value);
		} catch (Exception e) {
			LogUtil.errorOnce(e.getMessage());
		}
	}
	return value.toString();
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:23,代码来源:ProfileDataPointColumnProvider.java

示例12: testSimpleNumericProfileEffect

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
public void testSimpleNumericProfileEffect() throws Exception {
	final ProfileMember profileMember = activity.getMember(ProfileMember.class);
	assertNotNull(profileMember);
	assertNotNull(ResourceUtils.getProfile(plan, KEY_TEST_PROFILE));
	final ProfileEffect effect = createProfileEffect(DateUtils.ZERO_DURATION, "10", DateUtils.ZERO_DURATION, "-10");
	TransactionUtils.writing(plan, new Runnable() {
		@Override
		public void run() {
			profileMember.getEffects().add(effect);
		}
	});
	recomputePlan(plan);
	
	assertProfileValue(plan, KEY_TEST_PROFILE, ACTIVITY_START, Amount.valueOf(10, Unit.ONE));
	assertProfileValue(plan, KEY_TEST_PROFILE, ACTIVITY_END  , Amount.valueOf( 0, Unit.ONE));
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:TestProfileEffect.java

示例13: convertTimeDistanceToNetwork

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
public Time convertTimeDistanceToNetwork(Amount<Duration> duration) {
	long milliseconds = duration.longValue(SI.MILLI(SI.SECOND));
	// Convert milliseconds to seconds.
	long value = Math.round(milliseconds/((double)CONVERSION_CONSTANT));
	if (value < DistanceGraph.MIN_DISTANCE) {
		if ((milliseconds != Long.MIN_VALUE) && (value != DistanceGraph.NEG_INFINITY)) {
			trace.warn("value (" + value + ") too negative, becoming negative infinity (" + DistanceGraph.NEG_INFINITY + ")");
		}
		value = DistanceGraph.NEG_INFINITY;
	}
	if (value > DistanceGraph.MAX_DISTANCE) {
		if ((milliseconds != Long.MAX_VALUE) && (value != DistanceGraph.POS_INFINITY)) {
			trace.warn("value (" + value + ") too positive, becoming positive infinity (" + DistanceGraph.POS_INFINITY + ")");
		}
		value = DistanceGraph.POS_INFINITY;
	}
	Time distance = getTime(value);
	if (distance != value) {
		trace.warn("time distance " + value + " changed during conversion to time " + distance);
	}
	trace.debug("convertTimeDistanceToNetwork(" + milliseconds + "): " + distance);
	return distance;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:24,代码来源:TemporalNetworkModel.java

示例14: setEnd

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
@Override
public Map<EPlanElement, TemporalExtent> setEnd(EPlanElement element, Date end, TemporalExtentsCache initialState) {
	Amount<Duration> duration = initialState.getDuration(element);
	IPlanConstraintInfo info = getPlanConstraintInfo();
	ConsistencyProperties properties = info.getConstraintProperties(element);
	ConsistencyBounds bounds = properties.getBounds();
	List<PeriodicTemporalConstraint> constraints = ConstraintUtils.getPeriodicConstraints(element, false);
	end = constrainEnd(duration, end, constraints, bounds);
	Date start = initialState.getStart(element);
	if (start == null) {
		start = end;
	}
	Map<EPlanElement, TemporalExtent> changedTimes = new LinkedHashMap<EPlanElement, TemporalExtent>();
	affectElements(element, start, end, properties, initialState, changedTimes);
	performAnyRegisteredTweaks(changedTimes);
	return changedTimes;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:ConstrainedPlanModifier.java

示例15: testActivitySetEndToNull

import org.jscience.physics.amount.Amount; //导入依赖的package包/类
public void testActivitySetEndToNull() {
	for (CalculatedVariable variable : Arrays.asList(CalculatedVariable.DURATION, CalculatedVariable.START)) {
		for (EPlanElement element : Util.createDurativeElements()) {
			TemporalMember member = element.getMember(TemporalMember.class);
			member.setCalculatedVariable(variable);
			Date start = member.getStartTime();
			Amount<Duration> duration = member.getDuration();
			Date end = member.getEndTime();
			NotificationAdapter adapter = new NotificationAdapter(
					Util.setEnd(member, end, null),
					Util.setStart(member, start, null)
				);
			member.eAdapters().add(adapter);
			member.setEndTime(null);
			adapter.assertFinished();
			Util.check(member, null, duration, null);
		}
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:20,代码来源:TestTemporalMember.java


注:本文中的org.jscience.physics.amount.Amount类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。