本文整理汇总了Java中javafx.beans.binding.DoubleExpression.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleExpression.addListener方法的具体用法?Java DoubleExpression.addListener怎么用?Java DoubleExpression.addListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.beans.binding.DoubleExpression
的用法示例。
在下文中一共展示了DoubleExpression.addListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import javafx.beans.binding.DoubleExpression; //导入方法依赖的package包/类
public static TransparentBinding bind(DoubleProperty property1,
DoubleExpression property2) {
checkParameters(property1, property2);
final TransparentBinding binding = new TransparentBinding(property1,
property2);
property1.setValue(property2.getValue());
property2.addListener(binding);
return binding;
}
示例2: bind
import javafx.beans.binding.DoubleExpression; //导入方法依赖的package包/类
public static BidirectionalDifferenceBinding bind(DoubleProperty property1,
DoubleProperty property2, DoubleExpression difference) {
checkParameters(property1, property2, difference);
final BidirectionalDifferenceBinding binding = new BidirectionalDifferenceBinding(
property1, property2, difference);
property2.setValue(property1.getValue() - difference.getValue());
property1.addListener(binding);
property2.addListener(binding);
difference.addListener(binding);
return binding;
}
示例3: 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));
}