本文整理匯總了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);
}