本文整理汇总了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));
}
示例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;
}
}
示例3: currentTimeInSeconds
import javafx.beans.binding.Bindings; //导入方法依赖的package包/类
private DoubleBinding currentTimeInSeconds() {
return Bindings.createDoubleBinding(() -> timeline.getCurrentTime().toSeconds(), timeline.currentTimeProperty());
}
示例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);
}