本文整理汇总了Java中org.jscience.physics.amount.Amount.isLessThan方法的典型用法代码示例。如果您正苦于以下问题:Java Amount.isLessThan方法的具体用法?Java Amount.isLessThan怎么用?Java Amount.isLessThan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jscience.physics.amount.Amount
的用法示例。
在下文中一共展示了Amount.isLessThan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBoundRequirementTextStart
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public void testBoundRequirementTextStart() {
Date min = new Date();
Date max = DateUtils.add(min, Amount.valueOf(25000, DateUtils.MILLISECONDS));
Amount<Duration> earliest = ConstraintUtils.getPeriodicConstraintOffset(min);
Amount<Duration> latest = ConstraintUtils.getPeriodicConstraintOffset(max);
if (latest.isLessThan(earliest)) {
Amount<Duration> swap = earliest;
earliest = latest;
latest = swap;
}
PeriodicTemporalConstraint bound = createBound(Timepoint.START, earliest, latest);
String text = constraintViolationPrinter.getBoundRequirementText(bound);
trace.debug("testBoundRequirementTextStart() = " + text);
boolean matches = text.matches(".+should be between .+ and .+");
assertTrue("'" + text + "' doesn't match the pattern", matches);
}
示例2: testBoundRequirementTextEnd
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public void testBoundRequirementTextEnd() {
Date min = new Date();
Date max = DateUtils.add(min, Amount.valueOf(25000, DateUtils.MILLISECONDS));
Amount<Duration> earliest = ConstraintUtils.getPeriodicConstraintOffset(min);
Amount<Duration> latest = ConstraintUtils.getPeriodicConstraintOffset(max);
if (latest.isLessThan(earliest)) {
Amount<Duration> swap = earliest;
earliest = latest;
latest = swap;
}
PeriodicTemporalConstraint bound = createBound(Timepoint.END, earliest, latest);
String text = constraintViolationPrinter.getBoundRequirementText(bound);
trace.debug("testBoundRequirementTextEnd() = " + text);
boolean matches = text.matches(".+should be between .+ and .+");
assertTrue("'" + text + "' doesn't match the pattern", matches);
}
示例3: isViolated
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@Override
public boolean isViolated() {
ConstraintPoint point = getPoint();
Date date = point.getDate();
if (date == null) {
return false;
}
Amount<Duration> offset = ConstraintUtils.getPeriodicConstraintOffset(date);
Amount<Duration> earliest = getEarliest();
Amount<Duration> latest = getLatest();
if ((earliest != null) && offset.isLessThan(earliest)) {
if (!closeEnough(offset, earliest)) {
return true;
}
}
if ((latest != null) && offset.isGreaterThan(latest)) {
if (!closeEnough(offset, latest)) {
return true;
}
}
return false;
}
示例4: union
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public AmountExtent<T> union(AmountExtent<T> extent) {
if (extent == null) {
return this;
}
Amount<T> min = getMin();
Amount<T> max = getMax();
if (max == null || (extent.getMax() != null
&& max.getUnit().isCompatible(extent.getMax().getUnit())
&& max.isLessThan(extent.getMax()))) {
max = extent.getMax();
}
if (min == null || (extent.getMin() != null
&& min.getUnit().isCompatible(extent.getMin().getUnit())
&& min.isGreaterThan(extent.getMin()))) {
min = extent.getMin();
}
return new AmountExtent<T>(min, max);
}
示例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;
}
示例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;
}
示例7: getOffsetText
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* Returns the duration as a formated string
* @param offset - the duration
* @return
*/
public String getOffsetText(Amount<Duration> offset) {
if (offset.compareTo(ZERO) == 0) {
return "at the same time as";
}
long duration = offset.abs().longValue(SI.SECOND);
String string = DurationFormat.getEnglishDuration(duration);
string += " ";
if (offset.isLessThan(ZERO)) {
string += "after";
} else {
string += "before";
}
return string;
}
示例8: maybeUpdateParentDuration
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* If the parent uses child times, then update it in response to the supplied duration change, if necessary.
* This is only allowed if there is no start or end time on the parent.
*
* @param member
* @param oldDuration
* @param newDuration
* @param notifications
*/
public static void maybeUpdateParentDuration(TemporalMemberImpl member, Amount<Duration> oldDuration, Amount<Duration> newDuration, NotificationChain notifications) {
TemporalMemberImpl parent = getContainingParentTemporalMember(member);
if (parent != null) {
if (newDuration.isGreaterThan(oldDuration)) {
growDuration(parent, newDuration, notifications);
}
if (newDuration.isLessThan(oldDuration)) {
shrinkDuration(parent, oldDuration, newDuration, notifications);
}
}
}
示例9: shrinkDuration
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* This is called when a child has gotten shorter in duration. So, if the old duration was
* the sole cause for the length of the parent, the parent will be shortened and notifications
* will be posted.
*
* @param parent
* @param oldDuration
* @param newDuration
* @param notifications
*/
private static void shrinkDuration(TemporalMemberImpl parent, Amount<Duration> oldDuration, Amount<Duration> newDuration, NotificationChain notifications) {
Amount<Duration> duration = parent.getDuration();
if (!oldDuration.isLessThan(duration)) {
for (EPlanChild child : parent.getPlanElement().getChildren()) {
TemporalMember member = child.getMember(TemporalMember.class, true);
Amount<Duration> childDuration = member.getDuration();
if (childDuration.isGreaterThan(newDuration)) {
newDuration = childDuration;
}
}
parent.setDuration(newDuration, notifications);
}
}
示例10: isViolated
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@Override
public boolean isViolated() {
ConstraintPoint pointA = getPointA();
Date dateA = pointA.getDate();
if (dateA == null) {
return false;
}
ConstraintPoint pointB = getPointB();
Date dateB = pointB.getDate();
if (dateB == null) {
return false;
}
Amount<Duration> delta = DateUtils.subtract(dateB, dateA);
Amount<Duration> minimum = getMinimumBminusA();
Amount<Duration> maximum = getMaximumBminusA();
if ((minimum != null) && delta.isLessThan(minimum)) {
if (!closeEnough(delta, minimum)) {
return true;
}
}
if ((maximum != null) && delta.isGreaterThan(maximum)) {
if (!closeEnough(delta, maximum)) {
return true;
}
}
return false;
}
示例11: exceedsMaximumGap
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
private boolean exceedsMaximumGap(ProfileEqualityConstraint constraint, ProfileReferenceViolation violation) {
Amount<Duration> maxGap = constraint.getMaximumGap();
if (maxGap != null) {
Amount<Duration> violationDuration = violation.getDuration();
return maxGap.isLessThan(violationDuration);
}
return true;
}
示例12: createDurationCombo
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
private static Combo createDurationCombo(Composite parent, Amount<Duration> delta) {
Combo combo = new Combo(parent, SWT.READ_ONLY);
combo.add("before");
combo.add("after");
if (delta.isLessThan(ZERO)) {
combo.select(1);
} else {
combo.select(0);
}
return combo;
}
示例13: intersection
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public AmountExtent<T> intersection(AmountExtent<T> extent) {
Amount<T> min = getMin();
Amount<T> max = getMax();
if (max == null || (extent.getMax() != null && max.isGreaterThan(extent.getMax()))) max = extent.getMax();
if (min == null || (extent.getMin() != null && min.isLessThan(extent.getMin()))) min = extent.getMin();
return new AmountExtent<T>(min, max);
}
示例14: convertDurationToEuropa
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* Convert the given duration (could be null) to europa seconds.
* @param milliseconds
* @return
*/
public static Number convertDurationToEuropa(Amount<Duration> duration) {
if (duration == null) {
return 1;
}
if (duration.isLessThan(ZERO)) {
throw new IllegalArgumentException("duration must be non-negative");
}
Number result = convertTimeDistanceToEuropa(duration);
if (result.longValue() < 1) {
return 1;
}
return result;
}
示例15: updateSubactivityOffset
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
private void updateSubactivityOffset(String subactivityId, Date ownerStart, Date childStart) {
Vector<Object> parameters;
Amount<Duration> offset = DateUtils.subtract(childStart, ownerStart);
if (offset.isLessThan(ZERO)) {
offset = ZERO; // Europa doesn't like negative offsets. (who would?)
}
parameters = new Vector<Object>();
parameters.add(subactivityId);
parameters.add(EuropaConverter.convertTimeDistanceToEuropa(offset));
client.queueExecute(EuropaCommand.SET_SUBACTIVITY_OFFSET, parameters);
}