当前位置: 首页>>代码示例>>Java>>正文


Java DoubleExpression.addListener方法代码示例

本文整理汇总了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;
}
 
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:10,代码来源:TransparentBinding.java

示例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;
}
 
开发者ID:jackmoxley,项目名称:Moxy-Parser,代码行数:12,代码来源:BidirectionalDifferenceBinding.java

示例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));
    }
 
开发者ID:dejv78,项目名称:jfx.radialmenu,代码行数:75,代码来源:RadialMenuSectionDynamic.java


注:本文中的javafx.beans.binding.DoubleExpression.addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。