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


Java Amount.approximates方法代码示例

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


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

示例1: equals

import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected final boolean equals(Amount newValue, Amount oldValue) {
	if (newValue == oldValue) {
   		return true;
   	}
       if (newValue == null) {
           return false;
       }
       if (oldValue == null) {
       	return false;
       }
	Double oldDouble = oldValue.getEstimatedValue();
	Double newDouble = newValue.getEstimatedValue();
	if (oldDouble.isNaN() && newDouble.isNaN()) {
		return true;
	}
       return newValue.approximates(oldValue);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:PlanElementDependency.java

示例2: equals

import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
 * This utility method will return true in the case where two things have the same dimension and are both zero, regardless of
 * the unit of each amount.
 * 
 * NOTE: does not currently work for non-zero based dimensions such
 * as temperature, where zero Celsius and zero Kelvin are different.
 * 
 * @param <Q>
 * @param q1
 * @param q2
 * @return boolean
 */
public static <Q extends Quantity> boolean equals(Amount<Q> q1, Amount<Q> q2) {
	if (q1 == null) {
		return (q2 == null);
	}
	if (q1.isExact() && q2.isExact()) {
		if (q1.getExactValue() == 0 && (q2.getExactValue() == 0)) {
			Dimension q1dimension = q1.getUnit().getDimension();
			Dimension q2dimension = q2.getUnit().getDimension();
			return q1dimension.equals(q2dimension);
		}
		Amount q3 = q1.to(q2.getUnit());
		return q3.approximates(q2);
	}
	return q1.equals(q2);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:28,代码来源:AmountUtils.java

示例3: hasUpdatedDuration

import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public static boolean hasUpdatedDuration(TemporalActivityDependency dependency) {
	DependencyMaintenanceSystem dms = dependency.getDependencyMaintenanceSystem();
	EActivity eActivity = dependency.getActivity();
	Dependency durationDependency = dms.getDurationDependency(eActivity);
	if (durationDependency == null) {
		return true;
	}
	
	Amount cachedDuration = (Amount) durationDependency.getValue();
	Amount<Duration> currentDuration = eActivity.getMember(TemporalMember.class).getDuration();
	return currentDuration != null 
			&& cachedDuration != null 
			&& currentDuration.approximates(cachedDuration);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:15,代码来源:ResourceUtils.java

示例4: update

import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public boolean update() {
	Amount amount = null;
	for (Dependency previous : getPrevious()) {
		Amount value = null;
		if (previous instanceof ActivityTemporalExplicitEffectDependency) {
			value = ((ActivityTemporalExplicitEffectDependency)previous).getExplicitDelta();
		} else if (previous instanceof TemporalActivityDependency) {
			DataPoint<Amount> dataPoint = (DataPoint<Amount>) previous.getValue();
			value = dataPoint == null ? null : dataPoint.getValue();
		}
		if (value != null) {
			if (amount == null) {
				amount = value;
			} else {
				amount = amount.plus(value);
			}
		}
	}
	Amount oldValue = (Amount) getValue();
	if ((oldValue == null && amount != null)
			|| (oldValue != null && amount == null)
			|| (oldValue == null || !oldValue.approximates(amount))) {
		setValue(amount);
		return true;
	}
	return false;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:30,代码来源:EffectDependency.java

示例5: getDistanceViolationText

import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
String getDistanceViolationText(ConstraintPoint pointA, ConstraintPoint pointB, Amount<Duration> minDelta, Amount<Duration> maxDelta) {
	Amount<Duration> delta = computeDelta(pointA, pointB);
	String result = "";
	if (minDelta != null && minDelta.approximates(ZERO) && maxDelta != null && maxDelta.approximates(ZERO) && delta.compareTo(ZERO) != 0) {
		result = "The " + getHypertext(pointA);
		result += " and the " + getHypertext(pointB);
		result += " are different.";
	} else if (maxDelta != null && maxDelta.approximates(ZERO)) {
		// A's timepoint must occur before B's timepoint
		result = "The " + getHypertext(pointA);
		result += " is after the " + getHypertext(pointB);
		result += ".";
	} else if (minDelta != null && delta.isLessThan(minDelta.abs())) {
		result = "The " + getHypertext(pointA);
		result += " and the " + getHypertext(pointB);
		result += " are ";
		result += DurationFormat.getEnglishDuration(minDelta.abs().minus(delta).longValue(SI.SECOND));
		result += " too close together.";
	} else if (maxDelta != null && delta.isGreaterThan(maxDelta.abs())) {
		result = "The " + getHypertext(pointA);
		result += " and the " + getHypertext(pointB);
		result += " are ";
		result += DurationFormat.getEnglishDuration(delta.minus(maxDelta.abs()).longValue(SI.SECOND));
		result += " too far apart.";
	}
	return result;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:28,代码来源:ConstraintViolationPrinter.java

示例6: getDistanceRequirementText

import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
protected String getDistanceRequirementText(ConstraintPoint pointA, ConstraintPoint pointB, Amount<Duration> minDelta, Amount<Duration> maxDelta, boolean usePronoun) {
	String result = "";
	if (minDelta != null && minDelta.approximates(ZERO) && maxDelta != null && maxDelta.approximates(ZERO)) {
		result = getTwoNodeText(pointA, pointB, usePronoun, result);
		result += " should be the same.";
	} else if (minDelta != null && minDelta.approximates(ZERO)) {
		result += "The " + getHypertext(pointB);
		result += " should be no earlier than ";
		result += "the " + getHypertext(pointA);
		result += ".";
	} else if (maxDelta != null && maxDelta.approximates(ZERO)) {
		result += "The " + getHypertext(pointB);
		result += " should be no later than ";
		result += "the " + getHypertext(pointA);
		result += ".";
	} else {
		Amount<Duration> delta = computeDelta(pointA, pointB);
		result = getTwoNodeText(pointA, pointB, usePronoun, result);
		result += " should be separated by";
		if (minDelta != null && (maxDelta==null || minDelta.approximates(maxDelta))) {
			result += " exactly " + DurationFormat.getEnglishDuration(minDelta.longValue(SI.SECOND));
		} else if (minDelta != null && delta.isLessThan(minDelta)) {
			result += " at least " + DurationFormat.getEnglishDuration(minDelta.longValue(SI.SECOND));
		} else if (maxDelta != null && delta.isGreaterThan(maxDelta)) {
			result += " at most " + DurationFormat.getEnglishDuration(maxDelta.longValue(SI.SECOND));
		}
		result += ".";
	}
	return result;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:31,代码来源:ConstraintViolationPrinter.java

示例7: createBinding

import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void createBinding(DetailProviderParameter parameter) {
	//
	// unwrap the parameter
	DataBindingContext dbc = parameter.getDataBindingContext();
	IItemPropertyDescriptor pd = parameter.getPropertyDescriptor();
	Composite parent = parameter.getParent();
	MultiEObject target = (MultiEObject) parameter.getTarget();
	FormToolkit toolkit = parameter.getDetailFormToolkit();
	List list = new ArrayList(target.getEObjects());
	//
	// Create the label and text controls
	String displayName = pd.getDisplayName(target);
	Label label = toolkit.createLabel(parent, displayName, SWT.NONE);
	Text text = toolkit.createText(parent, "", SWT.READ_ONLY);
	text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	
	//
	// Bind them all
	if (GAP.equals(displayName)) {
		Amount zero = Amount.valueOf(0, SI.SECOND);
		GapObservable observable = new GapObservable(list);
		Amount amount = (Amount)observable.getValue();
		if (amount != null 
				&& !amount.approximates(zero) 
				&& amount.isLessThan(zero)) {
			label.setText("Overlap");
		}
		createBinding(dbc, text, observable);
	} else if (START_OFFSET.equals(displayName)) {
		createBinding(dbc, text, new DeltaTimeObservable(list, TemporalPackage.Literals.TEMPORAL_MEMBER__START_TIME));
	} else if (END_OFFSET.equals(displayName)) {
		createBinding(dbc, text, new DeltaTimeObservable(list, TemporalPackage.Literals.TEMPORAL_MEMBER__END_TIME));
	} else if (EARLIEST_START_TIME.equals(displayName)) {
		createBinding(dbc, text, new EarliestDateObservable(list, TemporalPackage.Literals.TEMPORAL_MEMBER__START_TIME));
	} else if (LATEST_END_TIME.equals(displayName)) {
		createBinding(dbc, text, new LatestDateObservable(list, TemporalPackage.Literals.TEMPORAL_MEMBER__END_TIME));
	} else if (SPAN.equals(displayName)) {	
		createBinding(dbc, text, new SpanObservable(list));
	} else if (DURATION_SUM.equals(displayName)) {
		createBinding(dbc, text, new SummingAmountObservableValue(list, TemporalMember.class, TemporalPackage.Literals.TEMPORAL_MEMBER__DURATION));
	}
	super.createBinding(parameter);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:46,代码来源:TemporalPropertyDescriptorContributor.java


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