本文整理匯總了Java中javafx.beans.binding.Bindings.createObjectBinding方法的典型用法代碼示例。如果您正苦於以下問題:Java Bindings.createObjectBinding方法的具體用法?Java Bindings.createObjectBinding怎麽用?Java Bindings.createObjectBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.beans.binding.Bindings
的用法示例。
在下文中一共展示了Bindings.createObjectBinding方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initialize
import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
@FXML
private void initialize() {
// Replace constants in instructions label
instructionsLabel.setText(instructionsLabel.getText()
.replace("${version}", TLD_VERSION)
.replace("${exe_path}", OPERATING_SYSTEM.getExampleExecutablePath())
.replace("${dll_name}", DLL_NAME));
// Selected file depends on the path in the text field
// Not bound the "traditional" way as that caused duplicate calls to createPathFromText
fileTextField.setOnKeyReleased(ke -> selectedFile.setValue(createPathFromText(fileTextField.getText())));
// Only able to change file path when not currently patching
fileTextField.disableProperty().bind(working);
// File status depends on selected file
fileStatusBinding = Bindings.createObjectBinding(this::calculateHashes, selectedFile);
fileStatusProperty.bind(fileStatusBinding);
// File status label responds to selected file status
fileStatusLabel.textProperty().bind(Bindings.createStringBinding(
() -> fileStatusProperty.getValue().getDisplayName(), fileStatusProperty));
fileStatusLabel.textFillProperty().bind(Bindings.createObjectBinding(
() -> fileStatusProperty.getValue().getDisplayColor(), fileStatusProperty));
// File select button should be focused (runLater -> when Scene graph is established)
Platform.runLater(() -> fileSelectButton.requestFocus());
// Patch button should only be enabled if file is valid and not currently patching
patchButton.disableProperty().bind(
Bindings.createBooleanBinding(() -> !fileStatusProperty.getValue().isValid(), fileStatusProperty)
.or(working));
patchButton.textProperty().bind(Bindings.createStringBinding(
() -> fileStatusProperty.getValue().getButtonText(), fileStatusProperty));
}
示例2: createPosterImageBinding
import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public final Binding<Image> createPosterImageBinding() {
return Bindings.createObjectBinding(() -> {
return Optional.ofNullable(getPosterFileName()).
map(s -> new Image(Database.class.getResource(s).toExternalForm())).
orElse(null);
}, posterFileNameProperty());
}
示例3: createBackgroundImageBinding
import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public final Binding<Image> createBackgroundImageBinding() {
return Bindings.createObjectBinding(() -> {
return Optional.ofNullable(getBackgroundFileName()).
map(s -> new Image(Database.class.getResource(s).toExternalForm())).
orElse(null);
}, backgroundFileNameProperty());
}
示例4: main
import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public static void main(String[] args) {
ObjectProperty<LocalDateTime> dp = new SimpleObjectProperty<>(LocalDateTime.now());
ObjectProperty<Instant> ip = new SimpleObjectProperty<>();
Binding<Instant> ib = Bindings.createObjectBinding(
() -> dp.get().toInstant(OffsetDateTime.now().getOffset()),
dp);
ip.bind(ib);
// Binding<LocalDateTime> db = Bindings.createObjectBinding(
// () -> ip.get().atZone(ZoneId.systemDefault()).toLocalDateTime(),
// ip);
// dp.bind(db);
dp.addListener((obs, ov, nv) -> System.out.println(dp.get()));
ip.addListener((obs, ov, nv) -> System.out.println(ip.get()));
dp.setValue(LocalDateTime.of(2000, 9, 22, 9, 16, 0));
dp.setValue(LocalDateTime.of(1968, 12, 25, 8, 0, 0));
dp.setValue(LocalDateTime.of(2002, 7, 27, 3, 30, 0));
//
// ip.setValue(Instant.EPOCH);
// ip.setValue(Instant.MAX);
// ip.setValue(Instant.MIN);
}
示例5: getColor
import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
private ObjectBinding<Paint> getColor(AnimatableField field, NodeModel node, KeyValueModel keyValue, KeyFrameModel keyFrame) {
ObjectBinding<Paint> currentValue = ModelFunctions.toPaintBinding(keyValue.valueProperty(), Color.TRANSPARENT);
KeyFrameModel earlier = getEarlierKeyFrameWithNonNullValue(field, node, keyFrame);
KeyFrameModel later = getLaterKeyFrameWithNonNullValue(field, node, keyFrame);
if (earlier != null) {
DoubleProperty earlierTime = earlier.absoluteTimeProperty();
Color earlierValue = (Color) earlier.getKeyValues().get(node).get(field).getValue();
if (later != null) {
DoubleProperty laterTime = later.absoluteTimeProperty();
Color laterValue = (Color) later.getKeyValues().get(node).get(field).getValue();
ObjectBinding<Paint> interpolated = Bindings.createObjectBinding(() -> {
double timeFraction = (keyFrame.getAbsoluteTime() - earlierTime.get()) / (laterTime.get() - earlierTime.get());
double interpolatorFactor = later.getKeyValues().get(node).get(field).getInterpolator().curve(timeFraction);
return earlierValue.interpolate(laterValue, 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;
}
}
示例6: toPaintBinding
import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public static ObjectBinding<Paint> toPaintBinding(ObjectProperty<Object> property, Paint fallback) {
return Bindings.createObjectBinding(() -> (property.get() instanceof Paint ? (Paint) property.get() : fallback), property);
}
示例7: DateTimePickerController
import javafx.beans.binding.Bindings; //導入方法依賴的package包/類
public DateTimePickerController() {
root = new HBox(datePicker, timePicker);
ObjectBinding<Instant> dateBinding = Bindings.createObjectBinding(
this::getTimestamp, datePicker.valueProperty());
ObjectBinding<Instant> timeBinding = Bindings.createObjectBinding(
this::getTimestamp, timePicker.valueProperty());
timestampProperty.bind(dateBinding);
timestampProperty.bind(timeBinding);
}