javafx.beans.binding.StringBinding Java Examples
The following examples show how to use
javafx.beans.binding.StringBinding.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DemoUtil.java From RadialFx with GNU Lesser General Public License v3.0 | 6 votes |
public void addBooleanControl(final String title, final BooleanProperty boolProp) { final CheckBox check = new CheckBox(); check.setSelected(boolProp.get()); boolProp.bind(check.selectedProperty()); final VBox box = new VBox(); final Text titleText = new Text(title); titleText.textProperty().bind(new StringBinding() { { super.bind(check.selectedProperty()); } @Override protected String computeValue() { return title + " : " + String.valueOf(check.selectedProperty().get()); } }); box.getChildren().addAll(titleText, check); getChildren().add(box); }
Example #2
Source File: DemoUtil.java From RadialFx with GNU Lesser General Public License v3.0 | 6 votes |
public void addColorControl(final String title, final ObjectProperty<Paint> paintProperty) { final ColorPicker colorPicker = ColorPickerBuilder.create() .value((Color) paintProperty.get()).build(); paintProperty.bind(colorPicker.valueProperty()); final VBox box = new VBox(); final Text titleText = new Text(title); titleText.textProperty().bind(new StringBinding() { { super.bind(colorPicker.valueProperty()); } @Override protected String computeValue() { return title + " : " + colorPicker.getValue().toString(); } }); box.getChildren().addAll(titleText, colorPicker); getChildren().add(box); }
Example #3
Source File: MemoryViewerTableModel.java From Noexes with GNU General Public License v3.0 | 6 votes |
private StringBinding createBinding(int i) { SimpleLongProperty prop; switch(i / 4){ case 0: prop = value1; break; case 1: prop = value2; break; case 2: prop = value3; break; case 3: prop = value4; break; default: throw new IllegalArgumentException(String.valueOf(i)); } int rem = i % 4; return Bindings.createStringBinding(() -> { int j = (prop.intValue() >> (24 - rem * 8)) & 0xFF; return new String(new byte[]{formatChar(j)}, StandardCharsets.UTF_8); }, prop); }
Example #4
Source File: DemoUtil.java From RadialFx with GNU Lesser General Public License v3.0 | 6 votes |
private Slider addSliderControl(final String title, final DoubleProperty prop) { final Slider slider = new Slider(); slider.setValue(prop.get()); prop.bind(slider.valueProperty()); final VBox box = new VBox(); final Text titleText = new Text(title); titleText.textProperty().bind(new StringBinding() { { super.bind(slider.valueProperty()); } @Override protected String computeValue() { return title + " : " + twoDForm.format(slider.getValue()); } }); box.getChildren().addAll(titleText, slider); getChildren().add(box); return slider; }
Example #5
Source File: BatchRunnerResult.java From curly with Apache License 2.0 | 6 votes |
public BatchRunnerResult() { reportRow().add(new ReadOnlyStringWrapper("Batch run")); StringBinding successOrNot = Bindings.when(completelySuccessful()) .then(ApplicationState.getMessage(COMPLETED_SUCCESSFUL)) .otherwise(ApplicationState.getMessage(COMPLETED_UNSUCCESSFUL)); StringBinding successMessageBinding = Bindings.when(completed()) .then(successOrNot).otherwise(ApplicationState.getMessage(INCOMPLETE)); reportRow().add(successMessageBinding); reportRow().add(percentCompleteString().concat(" complete")); reportRow().add(percentSuccessString().concat(" success")); reportRow().add(getDuration()); allBindings.add(successOrNot); allBindings.add(successMessageBinding); }
Example #6
Source File: Segment.java From pikatimer with GNU General Public License v3.0 | 6 votes |
private void updateDistanceStringProperty(){ if (getEndSplit() != null && getStartSplit() != null) { distanceStringProperty.unbind(); distanceStringProperty.bind(new StringBinding(){ { super.bind(getEndSplit().splitDistanceProperty(),getStartSplit().splitDistanceProperty()); } @Override protected String computeValue() { return getEndSplit().getSplitDistance().subtract(getStartSplit().getSplitDistance()).abs().toPlainString().concat(" " + getEndSplit().getSplitDistanceUnits().toShortString()); } }); //distanceStringProperty.setValue(getEndSplit().getSplitDistance().subtract(getStartSplit().getSplitDistance()).abs().toPlainString().concat(" " + getEndSplit().getSplitDistanceUnits().toShortString())); } else { distanceStringProperty.unbind(); distanceStringProperty.setValue("0"); } }
Example #7
Source File: GenericBackendDialogN5.java From paintera with GNU General Public License v2.0 | 5 votes |
private Node initializeNode( final Node rootNode, final String datasetPromptText, final Node browseNode) { final MenuButton datasetDropDown = new MenuButton(); final StringBinding datasetDropDownText = Bindings.createStringBinding(() -> dataset.get() == null || dataset.get().length() == 0 ? datasetPromptText : datasetPromptText + ": " + dataset.get(), dataset); final ObjectBinding<Tooltip> datasetDropDownTooltip = Bindings.createObjectBinding(() -> Optional.ofNullable(dataset.get()).map(Tooltip::new).orElse(null), dataset); datasetDropDown.tooltipProperty().bind(datasetDropDownTooltip); datasetDropDown.disableProperty().bind(this.isN5Valid.not()); datasetDropDown.textProperty().bind(datasetDropDownText); datasetChoices.addListener((ListChangeListener<String>) change -> { final MatchSelection matcher = MatchSelection.fuzzySorted(datasetChoices, s -> { dataset.set(s); datasetDropDown.hide(); }); LOG.debug("Updating dataset dropdown to fuzzy matcher with choices: {}", datasetChoices); final CustomMenuItem menuItem = new CustomMenuItem(matcher, false); // clear style to avoid weird blue highlight menuItem.getStyleClass().clear(); datasetDropDown.getItems().setAll(menuItem); datasetDropDown.setOnAction(e -> {datasetDropDown.show(); matcher.requestFocus();}); }); final GridPane grid = new GridPane(); grid.add(rootNode, 0, 0); grid.add(datasetDropDown, 0, 1); GridPane.setHgrow(rootNode, Priority.ALWAYS); GridPane.setHgrow(datasetDropDown, Priority.ALWAYS); grid.add(browseNode, 1, 0); return grid; }
Example #8
Source File: AboutPanelSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates the {@link Hyperlink} leading to the git revision on github * * @return The {@link Hyperlink} leading to the git revision on github */ private Hyperlink createGitRevisionHyperlink() { final StringBinding revisionText = Bindings.createStringBinding( () -> Optional.ofNullable(getControl().getBuildInformation()) .map(ApplicationBuildInformation::getApplicationGitRevision).orElse(null), getControl().buildInformationProperty()); final BooleanBinding disableProperty = Bindings.when(Bindings .and(Bindings.isNotNull(revisionText), Bindings.notEqual(revisionText, "unknown"))) .then(false).otherwise(true); final Hyperlink gitRevisionHyperlink = new Hyperlink(); gitRevisionHyperlink.textProperty().bind(revisionText); // if the git revision equals "unknown" disable the hyperlink gitRevisionHyperlink.disableProperty().bind(disableProperty); gitRevisionHyperlink.visitedProperty().bind(disableProperty); gitRevisionHyperlink.underlineProperty().bind(disableProperty); // if the git revision has been clicked on open the corresponding commit page on github gitRevisionHyperlink.setOnAction(event -> { try { final URI uri = new URI("https://github.com/PhoenicisOrg/phoenicis/commit/" + getControl().getBuildInformation().getApplicationGitRevision()); getControl().getOpener().open(uri); } catch (URISyntaxException e) { LOGGER.error("Could not open GitHub URL.", e); } }); return gitRevisionHyperlink; }
Example #9
Source File: ThemeManager.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * Constructor * * @param currentTheme The current theme */ public ThemeManager(ObjectProperty<Theme> currentTheme) { super(); this.currentTheme = currentTheme; this.defaultCategoryIconsStylesheets = FXCollections.observableArrayList(); this.defaultLibraryCategoryIconsStylesheets = FXCollections.observableArrayList(); this.defaultEngineIconsStylesheets = FXCollections.observableArrayList(); // the base stylesheets final ObservableList<String> baseStylesheets = FXCollections .observableList(getStylesheets(Themes.STANDARD)); // the currently selected stylesheets (empty if the the selected theme is the standard theme) final ObservableList<String> currentStylesheets = CollectionBindings .mapToList(currentTheme, this::getNonStandardStylesheets); this.stylesheets = ConcatenatedList.create( defaultCategoryIconsStylesheets, defaultLibraryCategoryIconsStylesheets, defaultEngineIconsStylesheets, baseStylesheets, currentStylesheets); final ObjectBinding<Optional<URI>> currentWebEngineUri = ObjectBindings.map(currentTheme, theme -> theme.getResourceUri("description.css")); final StringBinding currentWebEngineStylesheet = StringBindings.map(currentWebEngineUri, uri -> uri.map(URI::toString).orElse(null)); this.webEngineStylesheet = Bindings .when(Bindings.isNull(currentWebEngineStylesheet)) .then(Themes.STANDARD.getResourceUri("description.css").map(URI::toString) .orElseThrow( () -> new IllegalStateException("Standard theme contains no \"description.css\" file"))) .otherwise(currentWebEngineStylesheet); }
Example #10
Source File: AbstractFilterModel.java From VocabHunter with Apache License 2.0 | 5 votes |
protected void bindValues() { ObservableNumberValue count = wordCountProperty(); StringBinding filenameText = Bindings.createStringBinding(() -> filename(file.get()), file); error.bind(Bindings.equal(count, 0)); filename.bind(filenameText); }
Example #11
Source File: WordNoteHandler.java From VocabHunter with Apache License 2.0 | 5 votes |
private void bindProperties(final TextArea textAreaNotePreview, final SessionModel sessionModel) { SimpleObjectProperty<WordModel> currentWordProperty = sessionModel.currentWordProperty(); StringBinding noteBinding = selectString(currentWordProperty, "note"); textAreaNotePreview.textProperty().bind(noteBinding); textAreaNotePreview.visibleProperty().bind(noteBinding.isNotEmpty()); }
Example #12
Source File: Clock.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public StringBinding getElapsedStringBinding(LocalDateTime start) { return Bindings.createStringBinding(() -> units.stream() .filter(u -> start.plus(1, u).isBefore(time.get())) // ignore units where less than 1 unit has elapsed .sorted(Comparator.reverseOrder()) // sort with biggest first .findFirst() // get the first (biggest) unit .map(u -> String.format("%d %s ago", u.between(start, time.get()), u)) // format as string .orElse("Just now") // default if elapsed time is less than smallest unit , time); }
Example #13
Source File: Participant.java From pikatimer with GNU General Public License v3.0 | 5 votes |
public Participant() { fullNameProperty.bind(new StringBinding(){ {super.bind(firstNameProperty,middleNameProperty, lastNameProperty);} @Override protected String computeValue() { return (firstNameProperty.getValueSafe() + " " + middleNameProperty.getValueSafe() + " " + lastNameProperty.getValueSafe()).replaceAll("( )+", " "); } }); //Convenience properties for the getDNF and getDQ status checks dnfProperty.bind(new BooleanBinding(){ {super.bind(statusProperty);} @Override protected boolean computeValue() { if (statusProperty.getValue().equals(Status.DNF)) return true; return false; } }); dqProperty.bind(new BooleanBinding(){ {super.bind(statusProperty);} @Override protected boolean computeValue() { if (statusProperty.getValue().equals(Status.DQ)) return true; return false; } }); waves.addListener(new ListChangeListener<Wave>() { @Override public void onChanged(Change<? extends Wave> c) { Platform.runLater(() -> wavesChangedCounterProperty.setValue(wavesChangedCounterProperty.get()+1)); } }); status = Status.GOOD; statusProperty.set(status); }
Example #14
Source File: StringBindingSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public StringBindingSample() { final SimpleDateFormat format = new SimpleDateFormat("mm/dd/yyyy"); final TextField dateField = new TextField(); dateField.setPromptText("Enter a birth date"); dateField.setMaxHeight(TextField.USE_PREF_SIZE); dateField.setMaxWidth(TextField.USE_PREF_SIZE); Label label = new Label(); label.textProperty().bind(new StringBinding() { { bind(dateField.textProperty()); } @Override protected String computeValue() { try { Date date = format.parse(dateField.getText()); Calendar c = Calendar.getInstance(); c.setTime(date); Date today = new Date(); Calendar c2 = Calendar.getInstance(); c2.setTime(today); if (c.get(Calendar.DAY_OF_YEAR) == c2.get(Calendar.DAY_OF_YEAR) - 1 && c.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) { return "You were born yesterday"; } else { return "You were born " + format.format(date); } } catch (Exception e) { return "Please enter a valid birth date (mm/dd/yyyy)"; } } }); VBox vBox = new VBox(7); vBox.setPadding(new Insets(12)); vBox.getChildren().addAll(label, dateField); getChildren().add(vBox); }
Example #15
Source File: StringBindingSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public StringBindingSample() { final SimpleDateFormat format = new SimpleDateFormat("mm/dd/yyyy"); final TextField dateField = new TextField(); dateField.setPromptText("Enter a birth date"); dateField.setMaxHeight(TextField.USE_PREF_SIZE); dateField.setMaxWidth(TextField.USE_PREF_SIZE); Label label = new Label(); label.textProperty().bind(new StringBinding() { { bind(dateField.textProperty()); } @Override protected String computeValue() { try { Date date = format.parse(dateField.getText()); Calendar c = Calendar.getInstance(); c.setTime(date); Date today = new Date(); Calendar c2 = Calendar.getInstance(); c2.setTime(today); if (c.get(Calendar.DAY_OF_YEAR) == c2.get(Calendar.DAY_OF_YEAR) - 1 && c.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) { return "You were born yesterday"; } else { return "You were born " + format.format(date); } } catch (Exception e) { return "Please enter a valid birth date (mm/dd/yyyy)"; } } }); VBox vBox = new VBox(7); vBox.setPadding(new Insets(12)); vBox.getChildren().addAll(label, dateField); getChildren().add(vBox); }
Example #16
Source File: AsteroidsMainMenu.java From FXGLGames with MIT License | 4 votes |
@Override protected Button createActionButton(StringBinding stringBinding, Runnable runnable) { return new Button(); }
Example #17
Source File: DemoUtil.java From RadialFx with GNU Lesser General Public License v3.0 | 4 votes |
public void addGraphicControl(final String title, final ObjectProperty<Node> graphicProperty) { final Node circle = CircleBuilder.create().radius(4).fill(Color.ORANGE).build(); final Node square = RectangleBuilder.create().width(8).height(8).build(); final Node text = TextBuilder.create().text("test").build(); final ComboBox<Node> choices = new ComboBox<Node>(FXCollections.observableArrayList(circle, square, text)); choices.setCellFactory(new Callback<ListView<Node>, ListCell<Node>>() { @Override public ListCell<Node> call(final ListView<Node> param) { final ListCell<Node> cell = new ListCell<Node>() { @Override public void updateItem(final Node item, final boolean empty) { super.updateItem(item, empty); if (item != null) { setText(item.getClass().getSimpleName()); } else { setText(null); } } }; return cell; } }); choices.getSelectionModel().select(0); graphicProperty.bind(choices.valueProperty()); final VBox box = new VBox(); final Text titleText = new Text(title); titleText.textProperty().bind(new StringBinding() { { super.bind(choices.selectionModelProperty()); } @Override protected String computeValue() { return title + " : " + String.valueOf(choices.selectionModelProperty().get().getSelectedItem().getClass().getSimpleName()); } }); box.getChildren().addAll(titleText, choices); getChildren().add(box); }
Example #18
Source File: GenericBackendDialogN5.java From paintera with GNU General Public License v2.0 | 4 votes |
public StringBinding errorMessage() { return errorMessage; }
Example #19
Source File: GoogleCloud.java From paintera with GNU General Public License v2.0 | 4 votes |
public GenericBackendDialogN5 backendDialog(ExecutorService propagationExecutor) { final Label storageLabel = new Label(); final Label bucketLabel = new Label(); final StringBinding storageAsString = Bindings.createStringBinding( () -> Optional.ofNullable(storage.getValue()).map(Storage::toString).orElse(""), storage ); final StringBinding bucketAsString = Bindings.createStringBinding( () -> Optional.ofNullable(bucket.getValue()).map(Bucket::getName).orElse(""), bucket ); storageLabel.textProperty().bind(storageAsString); bucketLabel.textProperty().bind(bucketAsString); final GridPane grid = new GridPane(); grid.add(storageLabel, 1, 0); grid.add(bucketLabel, 1, 1); grid.add(new Label("storage"), 0, 0); grid.add(new Label("bucket"), 0, 1); grid.setHgap(10); final Consumer<Event> onClick = event -> { { final GoogleCloudBrowseHandler handler = new GoogleCloudBrowseHandler(); final Optional<Pair<Storage, Bucket>> res = handler.select(grid.getScene()); LOG.debug("Got result from handler: {}", res); if (res.isPresent()) { LOG.debug("Got result from handler: {} {}", res.get().getA(), res.get().getB()); storageAndBucket.storage.set(res.get().getA()); storageAndBucket.bucket.set(res.get().getB()); } } }; final Button browseButton = new Button("Browse"); browseButton.setOnAction(onClick::accept); return new GenericBackendDialogN5(grid, browseButton, "google", writerSupplier, propagationExecutor); }
Example #20
Source File: MemoryViewerTableModel.java From Noexes with GNU General Public License v3.0 | 4 votes |
public StringBinding asciiBinding(int i){ return asciiBindings[i]; }
Example #21
Source File: RunnerResult.java From curly with Apache License 2.0 | 4 votes |
public StringBinding percentCompleteString() { return percentCompleteBinding; }
Example #22
Source File: RunnerResult.java From curly with Apache License 2.0 | 4 votes |
public StringBinding percentSuccessString() { return percentSuccessBinding; }
Example #23
Source File: ObservableEntityProperty.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 4 votes |
public StringBinding valueProperty() { return value; }
Example #24
Source File: ObservableEntityProperty.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 4 votes |
public StringBinding nameProperty() { return name; }
Example #25
Source File: ObservableEntityProperty.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 4 votes |
public StringBinding indexProperty() { return index; }
Example #26
Source File: ThemeManager.java From phoenicis with GNU Lesser General Public License v3.0 | 4 votes |
public StringBinding webEngineStylesheetProperty() { return this.webEngineStylesheet; }
Example #27
Source File: JFXSlider.java From JFoenix with Apache License 2.0 | 4 votes |
/** * @return the current slider value factory */ public final Callback<JFXSlider, StringBinding> getValueFactory() { return valueFactory == null ? null : valueFactory.get(); }
Example #28
Source File: JFXSlider.java From JFoenix with Apache License 2.0 | 4 votes |
public final ObjectProperty<Callback<JFXSlider, StringBinding>> valueFactoryProperty() { if (valueFactory == null) { valueFactory = new SimpleObjectProperty<>(this, "valueFactory"); } return valueFactory; }
Example #29
Source File: AsteroidsMainMenu.java From FXGLGames with MIT License | 4 votes |
@Override protected Button createActionButton(StringBinding stringBinding, Runnable runnable) { return new Button(); }
Example #30
Source File: Clock.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public StringBinding getTimeStringBinding() { return getTimeStringBinding(DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM)); }