本文整理汇总了Java中javafx.beans.binding.Bindings类的典型用法代码示例。如果您正苦于以下问题:Java Bindings类的具体用法?Java Bindings怎么用?Java Bindings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bindings类属于javafx.beans.binding包,在下文中一共展示了Bindings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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));
}
示例3: defineTableButtons
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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);
}
示例4: defineTableButtons
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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);
}
示例5: bind
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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());
}
示例6: HighlightCell
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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));
}
示例7: bind
import javafx.beans.binding.Bindings; //导入依赖的package包/类
/**
* 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());
}
示例8: unbind
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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());
}
示例9: bind
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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());
}
示例10: initialize
import javafx.beans.binding.Bindings; //导入依赖的package包/类
@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()));
}
示例11: ShopEntry
import javafx.beans.binding.Bindings; //导入依赖的package包/类
/**
* 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());
}
示例12: CSSTheme
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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));
}
示例13: createContextMenu
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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);
}
示例14: initRightClick
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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;
});
}
示例15: initRightClick
import javafx.beans.binding.Bindings; //导入依赖的package包/类
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;
});
}