本文整理汇总了Java中javafx.beans.binding.DoubleExpression.add方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleExpression.add方法的具体用法?Java DoubleExpression.add怎么用?Java DoubleExpression.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.beans.binding.DoubleExpression
的用法示例。
在下文中一共展示了DoubleExpression.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initProgressBinding
import javafx.beans.binding.DoubleExpression; //导入方法依赖的package包/类
private void initProgressBinding() {
DoubleExpression tmp = constantOf(0);
for (Command command : registeredCommands) {
final ReadOnlyDoubleProperty progressProperty = command.progressProperty();
/**
* When the progress of a command is "undefined", the progress property has a value of -1.
* But in our use case we like to have a value of 0 in this case.
* Therefore we create a custom binding here.
*/
final DoubleBinding normalizedProgress = Bindings
.createDoubleBinding(() -> (progressProperty.get() == -1) ? 0.0 : progressProperty.get(),
progressProperty);
tmp = tmp.add(normalizedProgress);
}
int divisor = registeredCommands.isEmpty() ? 1 : registeredCommands.size();
progress.bind(Bindings.divide(tmp, divisor));
}
示例2: RadialMenuSectionDynamic
import javafx.beans.binding.DoubleExpression; //导入方法依赖的package包/类
public RadialMenuSectionDynamic(Params params, RadialPane radialPane, RadialMenuSectionDynamic parentSection, DoubleExpression streakAngleDeg) {
this.params = params;
this.radialPane = radialPane;
this.parentSection = parentSection;
this.radialPane.addRadialSection(this);
if (streakAngleDeg != null) {
this.streakAngleDeg.bind(streakAngleDeg);
} else {
this.streakAngleDeg.bind(params.angleFromDegProperty()
.add(params.angleToDegProperty().subtract(params.angleFromDegProperty()).multiply(0.5d)));
}
itemsCount = new SimpleListProperty<>(items).sizeProperty();
final DoubleExpression itemRadiusHalf = params.buttonSizeProperty().multiply(0.5);
if (parentSection != null) {
innerRadius.bind(parentSection.outerRadiusProperty().add(itemRadiusHalf.multiply(params.spacingFactorProperty().multiply(2))));
} else {
innerRadius.bind(params.minRadiusProperty());
}
final DoubleExpression angleDeg = params.angleToDegProperty().subtract(params.angleFromDegProperty());
final DoubleExpression angleRad = new FunctionDoubleBinding(Math::toRadians, angleDeg);
final DoubleExpression availablePerimeter = angleRad.multiply(innerRadius.add(itemRadiusHalf));
final DoubleExpression gapSize = params.buttonSizeProperty().multiply(params.gapFactorProperty());
final DoubleExpression allItemsSize = params.buttonSizeProperty().multiply(itemsCount.subtract(1));
final DoubleExpression totalSize = allItemsSize.add(gapSize.multiply(itemsCount.subtract(1)));
final NumberBinding candidateNominalRadius = new When(availablePerimeter.greaterThan(totalSize))
.then(innerRadius.add(itemRadiusHalf))
.otherwise(totalSize.divide(angleRad));
final DoubleExpression candidateAngularTotalSizeDeg = new FunctionDoubleBinding(Math::toDegrees, totalSize.divide(candidateNominalRadius));
final DoubleExpression candidateAngularItemSizeDeg = candidateAngularTotalSizeDeg.divide(itemsCount);
final DoubleExpression angularTotalSizeWithOverlapDeg = candidateAngularTotalSizeDeg.add(candidateAngularItemSizeDeg);
nominalRadius.bind(candidateNominalRadius.add(new When(angularTotalSizeWithOverlapDeg.greaterThan(TWO_PI))
.then(totalSize.divide(angularTotalSizeWithOverlapDeg.subtract(TWO_PI)))
.otherwise(0)));
angularTotalSizeDeg = new FunctionDoubleBinding(Math::toDegrees, totalSize.divide(nominalRadius));
// TODO: Make sure, that outerRadius is reasonably small to prevent "large texture" errors
outerRadius.bind(nominalRadius.add(itemRadiusHalf.add(params.buttonWidthOffsetProperty())));
params.centerOffsetProperty().add(outerRadius);
fromAngleDeg.bind(this.streakAngleDeg.subtract(angularTotalSizeDeg.multiply(0.5)));
toAngleDeg.bind(this.streakAngleDeg.add(angularTotalSizeDeg.multiply(0.5)));
correctedStreakAngleDeg.bind(this.streakAngleDeg.add(new When(fromAngleDeg.lessThan(params.angleFromDegProperty()))
.then(params.angleFromDegProperty().subtract(fromAngleDeg))
.otherwise(new When(toAngleDeg.greaterThan(params.angleToDegProperty()))
.then(params.angleToDegProperty().subtract(toAngleDeg))
.otherwise(0))));
toAngleDeg.bind(fromAngleDeg.add(angularTotalSizeDeg));
angularItemSizeDeg.bind(angularTotalSizeDeg.divide(itemsCount));
final Circle perimeter = setupPerimeter(params);
radialPane.getChildren().add(perimeter);
params.centerOffsetProperty().addListener(observable -> radialPane.layout());
totalSize.addListener((sender, oldV, newV) -> System.out.println(this + " [" + itemsCount.intValue() + "] totalSize: " + newV));
nominalRadius.addListener((sender, oldV, newV)-> System.out.println(this + " [" + itemsCount.intValue() + "] nominalRadius: " + newV));
angularTotalSizeDeg.addListener((sender, oldV, newV)-> System.out.println(this + " [" + itemsCount.intValue() + "] ang. size (deg): " + newV));
}