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


Java Bindings.createDoubleBinding方法代码示例

本文整理汇总了Java中javafx.beans.binding.Bindings.createDoubleBinding方法的典型用法代码示例。如果您正苦于以下问题:Java Bindings.createDoubleBinding方法的具体用法?Java Bindings.createDoubleBinding怎么用?Java Bindings.createDoubleBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.beans.binding.Bindings的用法示例。


在下文中一共展示了Bindings.createDoubleBinding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initProgressBinding

import javafx.beans.binding.Bindings; //导入方法依赖的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));
}
 
开发者ID:cmlanche,项目名称:easyMvvmFx,代码行数:22,代码来源:CompositeCommand.java

示例2: getDouble

import javafx.beans.binding.Bindings; //导入方法依赖的package包/类
private NumberBinding getDouble(AnimatableField field, NodeModel node, KeyValueModel keyValue, KeyFrameModel keyFrame) {
    DoubleBinding currentValue = ModelFunctions.toDoubleBinding(keyValue.valueProperty());
    KeyFrameModel earlier = getEarlierKeyFrameWithNonNullValue(field, node, keyFrame);
    KeyFrameModel later = getLaterKeyFrameWithNonNullValue(field, node, keyFrame);

    if (earlier != null) {
        DoubleProperty earlierTime = earlier.absoluteTimeProperty();
        double earlierValue = (Double) earlier.getKeyValues().get(node).get(field).getValue();

        if (later != null) {
            DoubleProperty laterTime = later.absoluteTimeProperty();
            double laterValue = (Double) later.getKeyValues().get(node).get(field).getValue();

            DoubleBinding interpolated = Bindings.createDoubleBinding(() -> {
                double timeFraction = (keyFrame.getAbsoluteTime() - earlierTime.get()) / (laterTime.get() - earlierTime.get());
                double interpolatorFactor = later.getKeyValues().get(node).get(field).getInterpolator().curve(timeFraction);
                return (double) Math.round(earlierValue + (laterValue - earlierValue) * interpolatorFactor);
            }, earlierTime, laterTime, keyFrame.absoluteTimeProperty());

            return Bindings.when(keyValue.valueProperty().isNotNull()).then(currentValue).otherwise(interpolated);
        } else {
            return Bindings.when(keyValue.valueProperty().isNotNull()).then(currentValue).otherwise(earlierValue);
        }
    } else {
        return currentValue;
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:28,代码来源:TimelineSceneSynchronizer.java

示例3: currentTimeInSeconds

import javafx.beans.binding.Bindings; //导入方法依赖的package包/类
private DoubleBinding currentTimeInSeconds() {
    return Bindings.createDoubleBinding(() -> timeline.getCurrentTime().toSeconds(), timeline.currentTimeProperty());
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:4,代码来源:PlayerHandler.java

示例4: toDoubleBinding

import javafx.beans.binding.Bindings; //导入方法依赖的package包/类
public static DoubleBinding toDoubleBinding(ObjectProperty<Object> property) {
    return Bindings.createDoubleBinding(() -> (property.get() instanceof Double ? (Double) property.get() : 0), property);
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:4,代码来源:ModelFunctions.java


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