Java 类javafx.beans.binding.Bindings 实例源码

项目:easyMvvmFx    文件:CompositeCommand.java   
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));
}
项目:ModLoaderInstaller    文件:MainPanel.java   
@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));
}
项目:atbash-octopus    文件:JWKView.java   
private void defineTableButtons() {
    Button addButton = new Button("Add", addIconView);
    addButton.setOnAction(actionEvent -> new NewJWKView(primaryStage, rootPane, jwkSetData).initialize());

    Button removeButton = new Button("Remove", removeIconView);
    removeButton.setOnAction(actionEvent -> onRemove(tableView));
    removeButton.disableProperty().bind(Bindings.isEmpty(tableView.getSelectionModel().getSelectedItems()));

    Button importButton = new Button("Import", importIconView);
    importButton.setOnAction(actionEvent -> onImport());

    buttonRow = new HBox(30);  // Buttons
    buttonRow.setPadding(new Insets(10, 10, 10, 10));
    buttonRow.getChildren().addAll(addButton, removeButton, importButton);

}
项目:atbash-octopus    文件:ImportJWKView.java   
private void defineTableButtons() {
    Button cancelButton = new Button("Cancel");
    cancelButton.setOnAction(actionEvent -> new JWKView(primaryStage, rootPane, jwkSetData).initialize());

    Button importPublicButton = new Button("Import public");
    importPublicButton.setOnAction(actionEvent -> importPublicKey());

    importPublicButton.disableProperty().bind(Bindings.createBooleanBinding(this::isImportPublicButtonDisabled, tableView.getSelectionModel().getSelectedItems()));

    Button importButton = new Button("Import");
    importButton.setOnAction(actionEvent -> importKey());
    importButton.disableProperty().bind(Bindings.isEmpty(tableView.getSelectionModel().getSelectedItems()));

    buttonRow = new HBox(30);  // Buttons
    buttonRow.setPadding(new Insets(10, 10, 10, 10));
    buttonRow.getChildren().addAll(cancelButton, importPublicButton, importButton);

}
项目:ABC-List    文件:LinkMappingService.java   
public void bind(TestdataLinkMappingPresenter presenter) {
    this.presenter = presenter;

    saveMaxEntities = presenter.getSaveMaxEntities();

    entityProperty.unbind();
    entityProperty.setValue(0);
    entityProperty.bind(super.progressProperty());

    this.presenter.getProgressBarPercentInformation().textProperty().bind(
            Bindings.createStringBinding(() -> {
                int process = (int) (entityProperty.getValue() * 100.0d);
                if (process <= 0) {
                    process = 0;
                } else {
                    ++process;
                }

                return process + "%"; // NOI18N
            },
            entityProperty));

    this.presenter.progressPropertyFromEntityDream().unbind();
    this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty());
}
项目:tenhou-visualizer    文件:HighlightCell.java   
public HighlightCell(StringProperty textToHighlight) {
    super();

    this.backgroundProperty().bind(Bindings.when(Bindings.and(Bindings.isNotNull(textToHighlight), Bindings.equal(itemProperty(), textToHighlight)))
            .then(HIGHLIGHT_BACKGROUND)
            .otherwise(Background.EMPTY));
}
项目:CalendarFX    文件:DayViewBase.java   
/**
 * Invokes {@link DateControl#bind(DateControl, boolean)} and adds some more
 * bindings between this control and the given control.
 *
 * @param otherControl the control that will be bound to this control
 * @param bindDate     if true will also bind the date property
 */
public final void bind(DayViewBase otherControl, boolean bindDate) {
    super.bind(otherControl, bindDate);

    Bindings.bindBidirectional(
            otherControl.earlyLateHoursStrategyProperty(),
            earlyLateHoursStrategy);
    Bindings.bindBidirectional(otherControl.hoursLayoutStrategyProperty(),
            hoursLayoutStrategyProperty());
    Bindings.bindBidirectional(otherControl.hourHeightProperty(),
            hourHeightProperty());
    Bindings.bindBidirectional(otherControl.hourHeightCompressedProperty(),
            hourHeightCompressedProperty());
    Bindings.bindBidirectional(otherControl.visibleHoursProperty(),
            visibleHoursProperty());
    Bindings.bindBidirectional(otherControl.enableCurrentTimeMarkerProperty(),
            enableCurrentTimeMarkerProperty());
    Bindings.bindBidirectional(otherControl.trimTimeBoundsProperty(),
            trimTimeBoundsProperty());
}
项目:CalendarFX    文件:DayViewBase.java   
public final void unbind(DayViewBase otherControl) {
    super.unbind(otherControl);

    Bindings.unbindBidirectional(
            otherControl.earlyLateHoursStrategyProperty(),
            earlyLateHoursStrategy);
    Bindings.unbindBidirectional(otherControl.hoursLayoutStrategyProperty(),
            hoursLayoutStrategyProperty());
    Bindings.unbindBidirectional(otherControl.hourHeightProperty(),
            hourHeightProperty());
    Bindings.unbindBidirectional(
            otherControl.hourHeightCompressedProperty(),
            hourHeightCompressedProperty());
    Bindings.unbindBidirectional(otherControl.visibleHoursProperty(),
            visibleHoursProperty());
    Bindings.unbindBidirectional(otherControl.enableCurrentTimeMarkerProperty(),
            enableCurrentTimeMarkerProperty());
    Bindings.unbindBidirectional(otherControl.trimTimeBoundsProperty(),
            trimTimeBoundsProperty());
}
项目:ABC-List    文件:ExerciseTermService.java   
public void bind(TestdataExerciseTermPresenter presenter) {
    this.presenter = presenter;

    saveMaxEntities = presenter.getSaveMaxEntities();

    entityProperty.unbind();
    entityProperty.setValue(0);
    entityProperty.bind(super.progressProperty());

    this.presenter.getProgressBarPercentInformation().textProperty().bind(
            Bindings.createStringBinding(() -> {
                int process = (int) (entityProperty.getValue() * 100.0d);
                if (process <= 0) {
                    process = 0;
                } else {
                    ++process;
                }

                return process + "%"; // NOI18N
            },
            entityProperty));

    this.presenter.progressPropertyFromEntityDream().unbind();
    this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty());
}
项目:drd    文件:ItemWeaponMeleController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    this.title = resources.getString(R.Translate.ITEM_TYPE_WEAPON_MELE);
    this.imageChooserTitle = resources.getString(R.Translate.ITEM_IMAGE_CHOOSE_DIALOG);

    txtName.textProperty().bindBidirectional(model.name);
    txtDescription.textProperty().bindBidirectional(model.description);

    cmbWeaponType.setItems(FXCollections.observableArrayList(MeleWeaponType.values()));
    cmbWeaponType.valueProperty().bindBidirectional(model.weaponType);
    cmbWeaponType.converterProperty().setValue(StringConvertors.forMeleWeaponType(translator));
    cmbWeaponClass.setItems(FXCollections.observableArrayList(MeleWeaponClass.values()));
    cmbWeaponClass.valueProperty().bindBidirectional(model.weaponClass);
    cmbWeaponClass.converterProperty()
        .setValue(StringConvertors.forMeleWeaponClass(translator));

    FormUtils.initTextFormater(txtStrength, model.strength);
    FormUtils.initTextFormater(txtRampancy, model.rampancy);
    FormUtils.initTextFormater(txtDefenceNumber, model.defence);
    FormUtils.initTextFormater(txtWeight, model.weight);

    lblPrice.textProperty().bind(model.price.text);
    imageView.imageProperty().bindBidirectional(model.image);

    btnFinish.disableProperty().bind(Bindings.or(model.name.isEmpty(), model.imageRaw.isNull()));
}
项目:drd    文件:ShopEntry.java   
/**
 * Vytvoří novou abstrakní nákupní položku
 */
public ShopEntry(ItemBase itemBase) {
    ammount.minValueProperty().bind(Bindings
        .when(inShoppingCart)
        .then(1)
        .otherwise(0));

    imageRaw.addListener((observable, oldValue, newValue) -> {
        final ByteArrayInputStream inputStream = new ByteArrayInputStream(newValue);
        image.set(new Image(inputStream));
    });

    this.itemBase = itemBase;
    this.id.bind(itemBase.idProperty());
    this.name.bind(itemBase.nameProperty());
    this.description.bind(itemBase.descriptionProperty());
    this.price = itemBase.getPrice();
    this.weight.bind(itemBase.weightProperty());
    this.author.bind(itemBase.authorProperty());
    this.downloaded.bindBidirectional(itemBase.downloadedProperty());
    this.uploaded.bindBidirectional(itemBase.uploadedProperty());
    this.imageRaw.bind(itemBase.imageProperty());
}
项目:fxexperience2    文件:CSSTheme.java   
public CSSTheme() {

        css.bind(Bindings.createStringBinding(() -> String.format(
                ".root { %n  "
               + "-fx-base: %s;%n  "
               + "-fx-background: %s;%n  "
               + "-fx-accent: %s;%n  "
               + "-fx-default-button: %s;%n  "
               + "-fx-focus-color: %s;%n  "
               + "-fx-faint-focus-color: %s;%n}",
                ColorEncoder.encodeColor((Color) base.get()),
                ColorEncoder.encodeColor((Color) background.get()),
                ColorEncoder.encodeColor((Color) accent.get()),
                ColorEncoder.encodeColor((Color) defaultButton.get()),
                ColorEncoder.encodeColor((Color) focusColor.get()),
                ColorEncoder.encodeColor((Color) faintFocusColor.get())),
                base, background, accent, defaultButton, focusColor, faintFocusColor));
    }
项目:stvs    文件:SpecificationTableController.java   
private ContextMenu createContextMenu() {
    MenuItem insertRow = new MenuItem("Insert Row");
    MenuItem columnResize = new MenuItem("Resize columns");
    MenuItem deleteRow = new MenuItem("Delete Row");
    MenuItem comment = new MenuItem("Comment ...");

    insertRow.setAccelerator(new KeyCodeCombination(KeyCode.INSERT));
    insertRow.setOnAction(event -> insertRow());

    deleteRow.setAccelerator(new KeyCodeCombination(KeyCode.DELETE));
    deleteRow.setOnAction(event -> deleteRow());

    MenuItem addNewColumn = new MenuItem("New Column...");
    addNewColumn.setOnAction(event -> addNewColumn());

    comment.setOnAction(event -> addRowComment(event));
    comment.setAccelerator(KeyCodeCombination.keyCombination("Ctrl+k"));
    insertRow.disableProperty().bind(Bindings.not(tableView.editableProperty()));
    deleteRow.disableProperty().bind(Bindings.not(tableView.editableProperty()));
    addNewColumn.disableProperty().bind(Bindings.not(tableView.editableProperty()));
    columnResize.setAccelerator(KeyCodeCombination.keyCombination("Ctrl+R"));
    columnResize.setOnAction(event -> resizeColumns());

    return new ContextMenu(insertRow, deleteRow, addNewColumn, comment, columnResize);
}
项目:recruitervision    文件:CvFilesWindowController.java   
private void initRightClick() {
    fileTable.setRowFactory(param -> {
        final TableRow<File> row = new TableRow<>();
        final ContextMenu rowMenu = new ContextMenu();

        MenuItem addNewFile = new MenuItem("Add File");
        addNewFile.setOnAction(event -> addCvFile());

        MenuItem removeFile = new MenuItem("Remove file");
        removeFile.setOnAction(event -> removeCvFile());

        rowMenu.getItems().addAll(removeFile, addNewFile);
        row.contextMenuProperty()
                .bind(Bindings
                        .when(Bindings.isNotNull(row.itemProperty()))
                        .then(rowMenu)
                        .otherwise((ContextMenu) null));
        return row;
    });
}
项目:recruitervision    文件:ParsedFilesController.java   
private void initRightClick() {
    millingTable.setRowFactory(param -> {
        final TableRow<Filed> row = new TableRow<>();
        final ContextMenu rowMenu = new ContextMenu();

        MenuItem showExtracted = new MenuItem("Show extracted");
        showExtracted.setOnAction(event -> showExtracted());

        MenuItem showParsed = new MenuItem("Show parsed");
        showParsed.setOnAction(event -> showParsed());

        row.setOnMouseClicked(event -> {
            if (event.getClickCount() == 2 && (!row.isEmpty())) {
                screensManager.showParsedFileData(row.getItem());
            }
        });

        rowMenu.getItems().addAll(showParsed, showExtracted);
        row.contextMenuProperty()
                .bind(Bindings
                        .when(Bindings.isNotNull(row.itemProperty()))
                        .then(rowMenu)
                        .otherwise((ContextMenu) null));
        return row;
    });
}
项目:vars-annotation    文件:FilterableTreeItem.java   
public FilterableTreeItem(T value) {
    super(value);
    this.sourceList = FXCollections.observableArrayList();
    this.filteredList = new FilteredList<>(this.sourceList);
    this.filteredList.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        return child -> {
            // Set the predicate of child items to force filtering
            if (child instanceof FilterableTreeItem) {
                FilterableTreeItem<T> filterableChild = (FilterableTreeItem<T>) child;
                filterableChild.setPredicate(this.predicate.get());
            }
            // If there is no predicate, keep this tree item
            if (this.predicate.get() == null)
                return true;
            // If there are children, keep this tree item
            if (child.getChildren().size() > 0)
                return true;
            // Otherwise ask the TreeItemPredicate
            return this.predicate.get().test(this, child.getValue());
        };
    }, this.predicate));
    setHiddenFieldChildren(this.filteredList);
}
项目:vars-annotation    文件:FilterableTreeItemDemo.java   
private Node createAddItemPane() {
    HBox box = new HBox(6);
    TextField firstname = new TextField();
    firstname.setPromptText("Enter first name ...");
    TextField lastname = new TextField();
    lastname.setPromptText("Enter last name ...");

    Button addBtn = new Button("Add new actor to \"Folder 1\"");
    addBtn.setOnAction(event -> {
        FilterableTreeItem<Actor> treeItem = new FilterableTreeItem<>(new Actor(firstname.getText(), lastname.getText()));
        folder1.getInternalChildren().add(treeItem);
    });
    addBtn.disableProperty().bind(Bindings.isEmpty(lastname.textProperty()));

    box.getChildren().addAll(firstname, lastname, addBtn);
    TitledPane pane = new TitledPane("Add new element", box);
    pane.setCollapsible(false);
    return pane;
}
项目:vars-annotation    文件:FilterableTreeItemDemo.java   
private Node createFilteredTree() {
    FilterableTreeItem<Actor> root = getTreeModel();
    root.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        if (filterField.getText() == null || filterField.getText().isEmpty())
            return null;
        return TreeItemPredicate.create(actor -> actor.toString().contains(filterField.getText()));
    }, filterField.textProperty()));

    TreeView<Actor> treeView = new TreeView<>(root);
    treeView.setShowRoot(false);

    TitledPane pane = new TitledPane("Filtered TreeView", treeView);
    pane.setCollapsible(false);
    pane.setMaxHeight(Double.MAX_VALUE);
    return pane;
}
项目:hygene    文件:MainController.java   
@Override
public void initialize(final URL location, final ResourceBundle resources) {
    try {
        Hygene.getInstance().getPrimaryStage().setMinHeight(650.0);
        Hygene.getInstance().getPrimaryStage().setMinWidth(920.0);
    } catch (final UIInitialisationException e) {
        LOGGER.error("Hygene instance not initialised.", e);
    }

    mainBorderPane.getLeft().visibleProperty().bind(graphStore.getGfaFileProperty().isNotNull());
    mainBorderPane.getRight().visibleProperty().bind(graphStore.getGfaFileProperty().isNotNull());

    leftPane.visibleProperty().bind(toggleLeftPane.selectedProperty()
            .and(graphStore.getGfaFileProperty().isNotNull()));
    leftPane.managedProperty().bind(toggleLeftPane.selectedProperty()
            .and(graphStore.getGfaFileProperty().isNotNull()));
    toggleLeftPane.textProperty().bind(Bindings.when(toggleLeftPane.selectedProperty())
            .then("<")
            .otherwise(">"));

    rightPane.visibleProperty().bind(toggleRightPane.selectedProperty()
            .and(graphStore.getGfaFileProperty().isNotNull()));
    rightPane.managedProperty().bind(toggleRightPane.selectedProperty()
            .and(graphStore.getGfaFileProperty().isNotNull()));
    toggleRightPane.textProperty().bind(Bindings.when(toggleRightPane.selectedProperty())
            .then(">")
            .otherwise("<"));

    graphVisualizer.getSelectedSegmentProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            toggleLeftPane.setSelected(true);
            nodeProperties.setExpanded(true);
        }
    });
}
项目:marathonv5    文件:GroupInputStage.java   
private Node createButtonBar() {
    ButtonBarX buttonBar = new ButtonBarX();
    okButton = FXUIUtils.createButton("ok", "Create " + type.fileType().toLowerCase() + " file", false, "OK");
    okButton.setOnAction(e -> onOK());
    okButton.disableProperty().bind(Bindings.isEmpty(name.textProperty()));
    Button cancelButton = FXUIUtils.createButton("cancel", "Cancel the " + type.fileType().toLowerCase() + " file creation",
            true, "Cancel");
    cancelButton.setOnAction(e -> dispose());
    buttonBar.getButtons().addAll(okButton, cancelButton);
    return buttonBar;
}
项目:CSS-Editor-FX    文件:MainFrameController.java   
private void init() {
  // name
  name.bind(Bindings.when(file.isNull())
      .then(Bindings.createStringBinding(() -> "new" + order.get(), order))
      .otherwise(toStringBinding(map(file, f -> f.getName()))));

  // graphics
  tab.setGraphic(icon);
  icon.setStyleClass("tab-icon");
  icon.setIcon(FontAwesomeIcon.SAVE);
  // Hold the object in cache to avoid gc
  StringBinding state = CacheUtil.cache(this, "state",
      () -> Bindings.when(Bindings.equal(toObjectBinding(currentTabEntity()), this))
          .then(Bindings.when(manager.modifiedProperty())
              .then("selected-modified")
              .otherwise("selected"))
          .otherwise(Bindings.when(manager.modifiedProperty())
              .then("modified")
              .otherwise("")));
  state.addListener((ob, o, n) -> {
    uncatch(() -> icon.pseudoClassStateChanged(PseudoClass.getPseudoClass(o), false));
    uncatch(() -> icon.pseudoClassStateChanged(PseudoClass.getPseudoClass(n), true));
  });

  // recent
  file.addListener((ob, o, n) -> todoAll(
      () -> ifThat(n != null).todo(() -> recentSupport.setLastFile(n)),
      () -> ifThat(o == null && n != null).todo(() -> releaseName())
      ));
}
项目:HotaruFX    文件:EditorController.java   
private void initUndoRedo() {
    undoButton.disableProperty().bind(
            Bindings.not(editor.undoAvailableProperty()));
    redoButton.disableProperty().bind(
            Bindings.not(editor.redoAvailableProperty()));
    undoButton.setOnAction(editorAction(editor::undo));
    redoButton.setOnAction(editorAction(editor::redo));
}
项目:can4eve    文件:TestAppGUI.java   
@Test
public void testBinding() {
  SimpleLongProperty lp = new SimpleLongProperty();
  lp.setValue(4711);
  keepBinding = Bindings.createLongBinding(() -> callMe(lp.get()), lp);
  lp.addListener((obs, oldValue, newValue) -> callMe(newValue));
  lp.setValue(1);
  assertEquals(2, calledEffect);
  assertEquals(2, keepBinding.get());
}
项目:GameAuthoringEnvironment    文件:PlayerSideBarCell.java   
/**
 * Binds the list cell to change background when you can place the cell
 *
 * @param box
 */
private void setBackgroundBinding () {
    BooleanProperty canPlace = getProfilable().getCost().canPlace();
    backgroundProperty().bind(Bindings.when(canPlace)
            .then(PLACEABLE_BACKGROUND)
            .otherwise(UNPLACEABLE_BACKGROUND));

}
项目:easyMvvmFx    文件:ObservableRules.java   
public static ObservableBooleanValue notEmpty(ObservableValue<String> source) {
    return Bindings.createBooleanBinding(() -> {
        final String s = source.getValue();

        return s != null && !s.trim().isEmpty();
    }, source);
}
项目:easyMvvmFx    文件:DelegateCommand.java   
/**
 * Creates a command with a condition about the executability by using the 'executableObservable' parameter. Pass a
 * <code>true</code> to the #inBackground parameter to run the {@link Command} in a background thread.
 * 
 * <b>IF YOU USE THE BACKGROUND THREAD: </b> don't forget to return to the UI-thread by using
 * {@link Platform#runLater(Runnable)}, otherwise you get an Exception.
 *
 * @param actionSupplier
 *            a function that returns a new Action which should be executed
 * @param executableObservable
 *            which defines whether the {@link Command} can execute
 * @param inBackground
 *            defines whether the execution {@link #execute()} is performed in a background thread or not
 */
public DelegateCommand(final Supplier<Action> actionSupplier, ObservableValue<Boolean> executableObservable,
        boolean inBackground) {
    this.actionSupplier = actionSupplier;
    this.inBackground = inBackground;
    if (executableObservable != null) {
        executable.bind(Bindings.createBooleanBinding(() -> {
            final boolean isRunning = runningProperty().get();
            final boolean isExecutable = executableObservable.getValue();

            return !isRunning && isExecutable;
        }, runningProperty(), executableObservable));
    }

}
项目:amelia    文件:TodoListCell.java   
@Override
public void updateItem(T item, boolean empty){
    if(empty){
    }else{
        ca.setContent(item);
        setText(ca.getAdaptedContent().toString());
        backgroundProperty().bind(Bindings.when(this.visibleProperty())
        .then(new Background(new BackgroundFill(Color.valueOf(ca.getColor()), new CornerRadii(2d), Insets.EMPTY)))
        .otherwise(new Background(new BackgroundFill(Color.TRANSPARENT, new CornerRadii(2d), Insets.EMPTY))));
        setPrefHeight(this.getFont().getSize() * Constants.TODO_TICKET_CELL_HEIGHT);
    }
}
项目:amelia    文件:MainViewController.java   
@Override 
public void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);
        if (empty) {
            setText(null);
            setGraphic(null);
        } else {
            Image out = IDH.getImagesMap().get(item.toString());

            if(out != null){
                im.setImage(out);
                im.setSmooth(true);
                im.setPreserveRatio(true);
                setGraphic(im);
                this.setOnMouseClicked(evt ->{
                       SELECTED = VIEWER_PANEL.getSelectionModel().getSelectedIndex();
                       setInfoViewData(CDH.getData().get(item.toString().split(":")[0]));
                });

                setPrefHeight(155);
                setPrefWidth(VIEWER_PANEL.getPrefWidth() - 5);
                backgroundProperty().bind(Bindings.when(this.selectedProperty())
                .then(new Background(new BackgroundFill(Color.valueOf("#1E90FF"), new CornerRadii(2d), Insets.EMPTY)))
                .otherwise(new Background(new BackgroundFill(Color.valueOf("#FFFFFF"), new CornerRadii(2d), Insets.EMPTY))));
                setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
            }
        }
}
项目:ABC-List    文件:LinkService.java   
public void bind(TestdataLinkPresenter presenter) {
    this.presenter = presenter;

    saveMaxEntities = presenter.getSaveMaxEntities();
    timePeriod = presenter.getTimePeriod();

    String startTime = DateConverter.getDefault().convertLongToDateTime(now, DateConverter.PATTERN__DATE);
    int year = Integer.parseInt(startTime.substring(6)) - timePeriod;
    startTime = startTime.substring(0, 6) + year;

    final long convertedStartTime = DateConverter.getDefault().convertDateTimeToLong(startTime, DateConverter.PATTERN__DATE);
    convertedTimePeriod = now - convertedStartTime;

    entityProperty.unbind();
    entityProperty.setValue(0);
    entityProperty.bind(super.progressProperty());

    this.presenter.getProgressBarPercentInformation().textProperty().bind(
            Bindings.createStringBinding(() -> {
                int process = (int) (entityProperty.getValue() * 100.0d);
                if (process <= 0) {
                    process = 0;
                } else {
                    ++process;
                }

                return process + "%"; // NOI18N
            },
            entityProperty));

    this.presenter.progressPropertyFromEntityDream().unbind();
    this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty());
}
项目:nitrite-database    文件:RootController.java   
void setRootLayout(BorderPane rootLayout) {
    this.rootLayout = rootLayout;
    brightness.valueProperty().addListener((observable, oldValue, newValue) -> {
        Double value = (Double) newValue;
        value = value * 2.55;
        StringExpression styleString = Bindings.format("-fx-base:rgb(%1$.0f , %1$.0f, %1$.0f)", value);
        this.rootLayout.styleProperty().bind(styleString);
    });
    brightness.setMin(0);
    brightness.setMax(100);
    brightness.setValue(30.8);
}
项目:qgu    文件:TaskTableView.java   
/*********************************************
 *                                           *
 * CONTEXT MENU FACTORY                      *
 *                                           *
 *********************************************/
private TableRow<ObservableGanttTask> tableRowFactory(TableView<ObservableGanttTask> table) {
    final TableRow<ObservableGanttTask> row = new TableRow<>();

    row.contextMenuProperty().bind(
            Bindings.when(Bindings.isNull(row.itemProperty()))
                .then((ContextMenu)null)
                .otherwise(Bindings.when(row.indexProperty().isEqualTo(0))
                        .then(makeFirstTaskContextMenu())
                        .otherwise(makeRegularTaskContextMenu(row))));
    return row;
}
项目:wall-t    文件:ConfigurationView.java   
private HBox connexionStatusInformation( ) {
    final HBox container = new HBox( );
    container.setAlignment( Pos.CENTER );
    container.setSpacing( 10 );

    final ProgressIndicator indicator = new ProgressIndicator( );
    indicator.setPrefSize( 20, 20 );
    indicator.visibleProperty( ).bind( _model.loadingProperty( ) );

    final Label connectionInformation = new Label( );
    connectionInformation.setTextAlignment( TextAlignment.CENTER );
    connectionInformation.setWrapText( true );
    connectionInformation.textProperty( ).bind( _model.loadingInformationProperty( ) );
    connectionInformation.visibleProperty( ).bind( _model.loadingInformationProperty( ).isEmpty( ).not( ) );
    connectionInformation.textFillProperty( ).bind( Bindings.<Paint>createObjectBinding( ( ) -> {
        if ( _model.loadingProperty( ).get( ) )
            return Paint.valueOf( "black" );
        return _model.isLoadingFailure( ) ? Paint.valueOf( "red" ) : Paint.valueOf( "green" );
    }, _model.loadingFailureProperty( ), _model.loadingProperty( ) ) );

    connectionInformation.minHeightProperty( ).bind( createIntegerBinding( ( ) -> {
        if ( _model.loadingInformationProperty( ).isEmpty( ).get( ) ) {
            return 0;
        } else {
            return 50;
        }
    }, _model.loadingInformationProperty( ) ) );
    connectionInformation.maxHeightProperty( ).bind( connectionInformation.minHeightProperty( ) );

    container.getChildren( ).addAll( indicator, connectionInformation );
    return container;
}
项目:LivroJavaComoProgramar10Edicao    文件:VideoPlayerController.java   
public void initialize() 
{
   // get URL of the video file
   URL url = VideoPlayerController.class.getResource("sts117.mp4");

   // create a Media object for the specified URL
   Media media = new Media(url.toExternalForm());

   // create a MediaPlayer to control Media playback
   mediaPlayer = new MediaPlayer(media);

   // specify which MediaPlayer to display in the MediaView
   mediaView.setMediaPlayer(mediaPlayer); 

   // set handler to be called when the video completes playing
   mediaPlayer.setOnEndOfMedia(() -> {
      playing = false;
      playPauseButton.setText("Play");
   });

   // set handler that displays an ExceptionDialog if an error occurs
   mediaPlayer.setOnError(() -> {
      ExceptionDialog dialog = 
         new ExceptionDialog(mediaPlayer.getError());
       dialog.showAndWait();
   });

   // bind the MediaView's width/height to the scene's width/height
   DoubleProperty width = mediaView.fitWidthProperty();
   DoubleProperty height = mediaView.fitHeightProperty();
   width.bind(Bindings.selectDouble(
      mediaView.sceneProperty(), "width"));
   height.bind(Bindings.selectDouble(
      mediaView.sceneProperty(), "height")); 
}
项目:javafx-qiniu-tinypng-client    文件:ObservableRules.java   
public static ObservableBooleanValue notEmpty(ObservableValue<String> source) {
    return Bindings.createBooleanBinding(() -> {
        final String s = source.getValue();

        return s != null && !s.trim().isEmpty();
    }, source);
}
项目:javafx-qiniu-tinypng-client    文件:DelegateCommand.java   
/**
 * Creates a command with a condition about the executability by using the 'executableObservable' parameter. Pass a
 * <code>true</code> to the #inBackground parameter to run the {@link Command} in a background thread.
 * 
 * <b>IF YOU USE THE BACKGROUND THREAD: </b> don't forget to return to the UI-thread by using
 * {@link Platform#runLater(Runnable)}, otherwise you get an Exception.
 *
 * @param actionSupplier
 *            a function that returns a new Action which should be executed
 * @param executableObservable
 *            which defines whether the {@link Command} can execute
 * @param inBackground
 *            defines whether the execution {@link #execute()} is performed in a background thread or not
 */
public DelegateCommand(final Supplier<Action> actionSupplier, ObservableValue<Boolean> executableObservable,
        boolean inBackground) {
    this.actionSupplier = actionSupplier;
    this.inBackground = inBackground;
    if (executableObservable != null) {
        executable.bind(Bindings.createBooleanBinding(() -> {
            final boolean isRunning = runningProperty().get();
            final boolean isExecutable = executableObservable.getValue();

            return !isRunning && isExecutable;
        }, runningProperty(), executableObservable));
    }

}
项目:ABC-List    文件:ExerciseService.java   
public void bind(TestdataExercisePresenter presenter) {
    this.presenter = presenter;

    saveMaxEntities = presenter.getSaveMaxEntities();
    timePeriod = presenter.getTimePeriod();

    String startTime = DateConverter.getDefault().convertLongToDateTime(now, DateConverter.PATTERN__DATE);
    int year = Integer.parseInt(startTime.substring(6)) - timePeriod;
    startTime = startTime.substring(0, 6) + year;

    final long convertedStartTime = DateConverter.getDefault().convertDateTimeToLong(startTime, DateConverter.PATTERN__DATE);
    convertedTimePeriod = now - convertedStartTime;

    entityProperty.unbind();
    entityProperty.setValue(0);
    entityProperty.bind(super.progressProperty());

    this.presenter.getProgressBarPercentInformation().textProperty().bind(
            Bindings.createStringBinding(() -> {
                int process = (int) (entityProperty.getValue() * 100.0d);
                if (process <= 0) {
                    process = 0;
                } else {
                    ++process;
                }

                return process + "%"; // NOI18N
            },
            entityProperty));

    this.presenter.progressPropertyFromEntityDream().unbind();
    this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty());
}
项目:shuffleboard    文件:EditableLabel.java   
/**
 * A text label that you can double click to edit.
 */
public EditableLabel() {
  setMaxWidth(USE_PREF_SIZE);

  Label label = new Label();
  label.textProperty().bind(text);
  label.visibleProperty().bind(Bindings.not(editing));
  getChildren().add(label);

  TextField editField = new AutoSizedTextField();
  editField.visibleProperty().bind(editing);
  editField.textProperty().bindBidirectional(text);
  getChildren().add(editField);

  setOnMouseClicked(mouseEvent -> {
    if (mouseEvent.getClickCount() == 2) {
      editing.set(true);
    }
  });

  editField.setOnAction(__ae -> editing.set(false));

  editField.focusedProperty().addListener((__, wasFocused, isFocused) -> {
    if (!isFocused) {
      editing.set(false);
    }
  });

  editing.addListener((__, wasEditing, isEditing) -> {
    if (isEditing) {
      editField.requestFocus();
    }
  });
}
项目:ABC-List    文件:TopicService.java   
public void bind(TestdataTopicPresenter presenter) {
    this.presenter = presenter;

    saveMaxEntities = presenter.getSaveMaxEntities();
    timePeriod = presenter.getTimePeriod();

    String startTime = DateConverter.getDefault().convertLongToDateTime(now, DateConverter.PATTERN__DATE);
    int year = Integer.parseInt(startTime.substring(6)) - timePeriod;
    startTime = startTime.substring(0, 6) + year;

    final long convertedStartTime = DateConverter.getDefault().convertDateTimeToLong(startTime, DateConverter.PATTERN__DATE);
    convertedTimePeriod = now - convertedStartTime;

    entityProperty.unbind();
    entityProperty.setValue(0);
    entityProperty.bind(super.progressProperty());

    this.presenter.getProgressBarPercentInformation().textProperty().bind(
            Bindings.createStringBinding(() -> {
                int process = (int) (entityProperty.getValue() * 100.0d);
                if (process <= 0) {
                    process = 0;
                } else {
                    ++process;
                }

                return process + "%"; // NOI18N
            },
            entityProperty));

    this.presenter.progressPropertyFromEntityDream().unbind();
    this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty());
}
项目:shuffleboard    文件:BooleanBoxWidget.java   
@FXML
private void initialize() {
  root.backgroundProperty().bind(
      Bindings.createObjectBinding(
          () -> createSolidColorBackground(getColor()),
          dataProperty(), trueColor, falseColor));
  exportProperties(trueColor, falseColor);
}
项目:CalendarFX    文件:HelloAllDayView.java   
@Override
protected DateControl createControl() {
    CalendarSource calendarSource = new CalendarSource();
    calendarSource.getCalendars().add(new HelloCalendar());

    allDayView = new AllDayView();
    allDayView.prefWidthProperty().bind(Bindings.multiply(150, allDayView.numberOfDaysProperty()));
    allDayView.setMaxWidth(Double.MAX_VALUE);
    allDayView.getCalendarSources().add(calendarSource);

    return allDayView;
}