本文整理汇总了Java中org.jscience.physics.amount.Amount.plus方法的典型用法代码示例。如果您正苦于以下问题:Java Amount.plus方法的具体用法?Java Amount.plus怎么用?Java Amount.plus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jscience.physics.amount.Amount
的用法示例。
在下文中一共展示了Amount.plus方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: update
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public boolean update() {
Amount amount = null;
for (Dependency previous : getPrevious()) {
Amount value = getValue(previous);
if (value != null) {
if (amount == null) {
amount = value;
} else {
amount = amount.plus(value);
}
}
}
DataPoint newValue = amount == null ? null : JSCIENCE_FACTORY.createEDataPoint(getDate(), amount);
DataPoint oldValue = (DataPoint) getValue();
if (!CommonUtils.equals(oldValue, newValue)) {
setValue(newValue);
return true;
}
return false;
}
示例3: testActivitySetEarlierStartComputingDuration
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public void testActivitySetEarlierStartComputingDuration() {
for (EPlanElement element : Util.createDurativeElements()) {
TemporalMember member = element.getMember(TemporalMember.class);
member.setCalculatedVariable(CalculatedVariable.DURATION);
Date start = member.getStartTime();
Date end = member.getEndTime();
Amount<Duration> shift = AmountUtils.toAmount(3924, DateUtils.MILLISECONDS);
Date start2 = DateUtils.subtract(start, shift);
Amount<Duration> duration2 = shift.plus(Util.TEST_DURATION);
NotificationAdapter adapter = new NotificationAdapter(
Util.setStart(member, start, start2),
Util.setDuration(member, Util.TEST_DURATION, duration2)
);
member.eAdapters().add(adapter);
member.setStartTime(start2);
adapter.assertFinished();
Util.check(member, start2, duration2, end);
}
}
示例4: testActivitySetLaterEndComputingDuration
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public void testActivitySetLaterEndComputingDuration() {
for (EPlanElement element : Util.createDurativeElements()) {
TemporalMember member = element.getMember(TemporalMember.class);
member.setCalculatedVariable(CalculatedVariable.DURATION);
Date start = member.getStartTime();
Date end = member.getEndTime();
Amount<Duration> shift = AmountUtils.toAmount(5924, DateUtils.MILLISECONDS);
Date end2 = DateUtils.add(end, shift);
Amount<Duration> duration2 = shift.plus(Util.TEST_DURATION);
NotificationAdapter adapter = new NotificationAdapter(
Util.setEnd(member, end, end2),
Util.setDuration(member, Util.TEST_DURATION, duration2)
);
member.eAdapters().add(adapter);
member.setEndTime(end2);
adapter.assertFinished();
Util.check(member, start, duration2, end2);
}
}
示例5: coalesceElements
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected Object coalesceElements(Collection elements) {
final EMap<ADEffectKey, ComputableAmount> effects = ActivityDictionaryFactory.eINSTANCE.createADEffectMember().getEffects();
for (Object element : elements) {
IObservableValue v = (IObservableValue) element;
final EMap elementEffects = (EMap) v.getValue();
Set entrySet = new HashSet(elementEffects.entrySet());
for (Object e : entrySet) {
Entry<ADEffectKey, ComputableAmount> entry = (Entry<ADEffectKey, ComputableAmount>) e;
ADEffectKey key = entry.getKey();
if (effects.containsKey(key)) {
Amount<?> currentValue = EMFUtils.copy(entry.getValue()).getAmount();
Amount<?> subTotal = EMFUtils.copy(effects.get(key)).getAmount();
subTotal = subTotal.plus(currentValue);
ComputableAmount totalCA = JScienceFactory.eINSTANCE.createComputableAmount(subTotal, ComputingState.COMPLETE);
effects.put(key, totalCA);
} else {
effects.put(EMFUtils.copy(key), EMFUtils.copy(entry.getValue()));
}
}
}
return effects;
}
示例6: coalesceElements
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@Override
protected Object coalesceElements(Collection elements) {
Amount total = null;
for (Object o : elements) {
IObservableValue v = (IObservableValue) o;
Object value = v.getValue();
Amount<?> current = null;
if (value instanceof ComputableAmount) {
current = ((ComputableAmount)value).getAmount();
} else if (value instanceof Amount) {
current = (Amount<?>) value;
} else {
continue;
}
if (current != null) {
if (total == null) {
total = current;
} else {
total = total.plus(current);
}
}
}
return total;
}
示例7: 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;
}
示例8: getFacet
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@Override
public Amount<Duration> getFacet(Object element) {
if (element instanceof List) {
Set<EActivity> activities = new LinkedHashSet<EActivity>();
Set<EPlanElement> parents = new LinkedHashSet<EPlanElement>();
for (Object object : (List) element) {
if (object instanceof EActivity) {
activities.add((EActivity)object);
} else if (object instanceof EPlanElement) {
parents.add((EPlanElement)object);
}
}
activities.addAll(EPlanUtils.computeContainedActivities(parents));
Amount<Duration> durationTotal = null;
for (EActivity activity : activities) {
Amount<Duration> duration = activity.getMember(TemporalMember.class).getDuration();
if (durationTotal == null) {
durationTotal = duration;
} else if (duration != null) {
durationTotal = durationTotal.plus(duration);
}
}
return durationTotal;
}
if (element instanceof EPlanChild) {
EPlanChild planElement = (EPlanChild)element;
if (planElement instanceof EActivity) {
return planElement.getMember(TemporalMember.class).getDuration();
}
return getFacet(EPlanUtils.getChildren(planElement));
}
return null;
}
示例9: getAsStartOffset
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public TemporalOffset getAsStartOffset(Amount<Duration> duration) {
if (timepoint == Timepoint.START) {
return new TemporalOffset(timepoint, offset);
}
return new TemporalOffset(Timepoint.START, duration.plus(offset));
}
示例10: assertEditingResult
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public void assertEditingResult(PeriodicTemporalConstraint constraint, Timepoint timepoint) throws ExecutionException {
TemporalBoundColumn column = new TemporalBoundColumn(TEST_PROVIDER, timepoint);
EActivity a = constructBoundedActivity(constraint);
ConstraintsMember originalFacet = column.getFacet(a);
String originalText = column.getText(originalFacet);
Amount<Duration> offset = ConstraintUtils.getPeriodicConstraintOffset(new Date(TIME));
Amount<Duration> oneHour = TimeOfDayUtils.getOffset(1, 0, 0);
offset = offset.plus(oneHour);
String laterDateString = new TimeOfDayFormat().format(offset);
column.modify(originalFacet, laterDateString, undoContext);
ConstraintsMember constraintsMember = a.getMember(ConstraintsMember.class, true);
Set<PeriodicTemporalConstraint> bounds = column.getTimepointPeriodicTemporalConstraints(constraintsMember);
assertEquals("Number mismatch in bounds count after editing", 1, bounds.size());
ConstraintsMember changedFacet = column.getFacet(a);
assertEquals("Column text not equal", laterDateString, column.getText(changedFacet));
IUndoableOperation op = OperationHistoryFactory.getOperationHistory().getUndoOperation(undoContext);
assertNotNull("Null operation found for "+constraint.getRationale(), op);
OperationHistoryFactory.getOperationHistory().undo(undoContext, null, null);
ConstraintsMember finalFacet = column.getFacet(a);
assertEquals("Error in undo operation", originalText, column.getText(finalFacet));
}