本文整理汇总了Java中org.jscience.physics.amount.Amount.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java Amount.compareTo方法的具体用法?Java Amount.compareTo怎么用?Java Amount.compareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jscience.physics.amount.Amount
的用法示例。
在下文中一共展示了Amount.compareTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createExactlyBeforeRow
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
private void createExactlyBeforeRow(Composite parent) {
Composite row = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.marginHeight = 0;
layout.marginWidth = 3;
row.setLayout(layout);
Label exactlyLabel = createLabel(row, "exactly");
exactlyLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
Amount<Duration> delta = DEFAULT_EXACTLY_DELTA_TIME;
if (oldConstraint != null) {
Amount<Duration> minimum = oldConstraint.getMinimumBminusA();
Amount<Duration> maximum = oldConstraint.getMaximumBminusA();
if ((minimum != null) && (maximum != null) && (minimum.compareTo(maximum) == 0)) {
delta = minimum;
}
}
exactlyTime = createDurationText(row, delta);
exactlyTime.getEditorControl().addModifyListener(new SelectButtonModifyListener(exactlyRadioButton));
exactlyCombo1 = createDurationCombo(row, delta);
exactlyCombo1.addModifyListener(new SelectButtonModifyListener(exactlyRadioButton));
}
示例2: createPeriodicTemporalConstraintOperation
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
private TemporalBoundEditOperation createPeriodicTemporalConstraintOperation(EPlanElement planElement, Amount<Duration> offset, IUndoContext undoContext) {
ConstraintsMember facet = planElement.getMember(ConstraintsMember.class, true);
Set<PeriodicTemporalConstraint> oldConstraints = getRelevantConstraints(facet);
PeriodicTemporalConstraint newConstraint = null;
for (PeriodicTemporalConstraint oldConstraint : oldConstraints) {
Amount<Duration> time = getRelevantPartOfConstraint(oldConstraint);
if (time.compareTo(offset) == 0) {
return null; // same as an existing pin
}
}
newConstraint = createPeriodicTemporalConstraint(planElement, offset);
TemporalBoundEditOperation operation = new TemporalBoundEditOperation(getEarliestOrLatestName(), planElement, oldConstraints, newConstraint);
if (undoContext != null) {
operation.addContext(undoContext);
}
operation.addContext(undoContext);
return operation;
}
示例3: compare
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@Override
public int compare(Amount<Duration> duration1, Amount<Duration> duration2) {
if (duration1 == duration2) {
return 0;
}
if (duration1 == null) {
return -1;
}
if (duration2 == null) {
return 1;
}
return duration1.compareTo(duration2);
}
示例4: isPinConstraint
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* Test a bound to see if it is a pin constraint
* @param bound
* @return true if the constraint is a pin constraint
*/
public static boolean isPinConstraint(PeriodicTemporalConstraint bound) {
if (bound.getPoint().getEndpoint() == Timepoint.START) {
Amount<Duration> earliest = bound.getEarliest();
Amount<Duration> latest = bound.getLatest();
return (earliest != null) && (latest != null) && (earliest.compareTo(latest) == 0);
}
return false;
}
示例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: getText
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* Returns the constraint as a form text string
* @param bound
* @param selected indicates if text should be formatted using getTextSelected
* @return the constraint as a form text string
*/
public String getText(PeriodicTemporalConstraint bound, boolean selected) {
// extract the fields
final EPlanElement element = bound.getPoint().getElement();
final Amount<Duration> earliest = bound.getEarliest();
final Amount<Duration> latest = bound.getLatest();
// construct the string
String string = (selected ? getTextSelected(element) : getText(element));
if ((earliest == null) && (latest == null)) {
string += " has a null constraint.";
return string;
}
string += " must ";
string += getHypertext(bound.getPoint(), false);
final String searliest = TIME_OF_DAY_STRINGIFIER.getDisplayString(earliest);
final String slatest = TIME_OF_DAY_STRINGIFIER.getDisplayString(latest);
if (earliest == null) {
string += " no later than "; // at or before
string += slatest;
} else if (latest == null) {
string += " no earlier than "; // at or after
string += searliest;
} else if (earliest.compareTo(latest) == 0) {
string += " at ";
string += searliest;
} else {
// both earliest and latest are not null
string += " between ";
string += searliest;
string += " and ";
string += slatest;
}
string += " on the day it is scheduled.";
return string;
}
示例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: compare
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@Override
public int compare(ComputableAmount value1, ComputableAmount value2) {
Integer null1 = compareNull(value1, value2);
if (null1 != null) return null1;
Amount amount1 = value1.getAmount();
Amount amount2 = value2.getAmount();
Integer null2 = compareNull(amount1, amount1);
if (null2 != null) return null1;
return amount1.compareTo(amount2);
}
示例9: createOptions
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
private void createOptions(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.marginWidth = 24;
composite.setLayout(gridLayout);
anyTimeBeforeRadioButton = new Button(composite, SWT.RADIO);
createAnyTimeBeforeRow(composite);
immediatelyBeforeRadioButton = new Button(composite, SWT.RADIO);
createImmediatelyBeforeRow(composite);
atleastRadioButton = new Button(composite, SWT.RADIO);
createAtleastBeforeRow(composite);
exactlyRadioButton = new Button(composite, SWT.RADIO);
createExactlyBeforeRow(composite);
betweenRadioButton = new Button(composite, SWT.RADIO);
createBetweenRow(composite);
if (oldConstraint == null) {
anyTimeBeforeRadioButton.setSelection(true);
} else {
Amount<Duration> minimum = oldConstraint.getMinimumBminusA();
Amount<Duration> maximum = oldConstraint.getMaximumBminusA();
if ((maximum == null) && (minimum != null) && (minimum.compareTo(ZERO) == 0)) {
anyTimeBeforeRadioButton.setSelection(true);
} else if ((minimum != null) && (minimum.compareTo(ZERO) == 0)
&& (maximum != null) && (maximum.compareTo(ZERO) == 0)) {
immediatelyBeforeRadioButton.setSelection(true);
} else if (maximum == null) {
atleastRadioButton.setSelection(true);
} else if (minimum == null) {
// weird
anyTimeBeforeRadioButton.setSelection(true);
} else if (minimum.compareTo(maximum) == 0) {
exactlyRadioButton.setSelection(true);
} else {
betweenRadioButton.setSelection(true);
}
}
}