當前位置: 首頁>>代碼示例>>Java>>正文


Java Bindings.createObjectBinding方法代碼示例

本文整理匯總了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));
}
 
開發者ID:zeobviouslyfakeacc,項目名稱:ModLoaderInstaller,代碼行數:36,代碼來源:MainPanel.java

示例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());
}
 
開發者ID:hendrikebbers,項目名稱:ExtremeGuiMakeover,代碼行數:8,代碼來源:Movie.java

示例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());
}
 
開發者ID:hendrikebbers,項目名稱:ExtremeGuiMakeover,代碼行數:8,代碼來源:Movie.java

示例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);


    }
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:28,代碼來源:BindingDemo.java

示例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;
    }
}
 
開發者ID:rmfisher,項目名稱:fx-animation-editor,代碼行數:28,代碼來源:TimelineSceneSynchronizer.java

示例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);
}
 
開發者ID:rmfisher,項目名稱:fx-animation-editor,代碼行數:4,代碼來源:ModelFunctions.java

示例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);

    }
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:15,代碼來源:DateTimePickerController.java


注:本文中的javafx.beans.binding.Bindings.createObjectBinding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。