use of javafx.beans.binding.StringBinding in project fxexperience2 by EricCanull.
the class PopupEditor method initializePopup.
private void initializePopup(Object startColor) {
setText(getPreviewString(startColor));
color.set((Color) startColor);
this.textProperty().bind(new StringBinding() {
{
bind(color);
}
@Override
protected String computeValue() {
return getWebColor();
}
});
this.showingProperty().addListener((ov, previousVal, newVal) -> {
if (newVal) {
if (!initialized) {
paintPicker = new PaintPicker(Mode.COLOR);
editorHost.getChildren().add(getPopupContentNode());
paintPicker.paintProperty().addListener(paintChangeListener);
}
paintPicker.setPaintProperty(color.get());
}
});
rectangle.fillProperty().bind(new ObjectBinding<Paint>() {
{
bind(color);
}
@Override
protected Paint computeValue() {
return getColor();
}
});
}
use of javafx.beans.binding.StringBinding in project fxexperience2 by EricCanull.
the class DerivationController method initialize.
@Override
public void initialize(URL url, ResourceBundle rb) {
gridPane.getChildren().addAll(baseColorPicker, desiredColorPicker);
GridPane.setConstraints(baseColorPicker, 1, 1);
baseColorPicker.setPrefWidth(120);
baseColorPicker.setMaxWidth(120);
GridPane.setConstraints(desiredColorPicker, 1, 6);
desiredColorPicker.setPrefWidth(120);
desiredColorPicker.setMaxWidth(120);
// FORWARD
forwardDerivationLabel.textProperty().bind(new StringBinding() {
{
bind(derivationSlider.valueProperty());
}
@Override
protected String computeValue() {
return String.format("%3.1f%%", derivationSlider.getValue());
}
});
Region derivedResultColor = new Region();
derivedResultColor.setPrefSize(50, 20);
derivedResultLabel.setGraphic(derivedResultColor);
derivedResultColor.styleProperty().bind(new StringBinding() {
{
bind(derivationSlider.valueProperty(), baseColorPicker.colorProperty());
}
@Override
protected String computeValue() {
return "-fx-border-color: black; -fx-background-color: derive(" + baseColorPicker.getWebColor() + ", " + derivationSlider.getValue() + "%);";
}
});
derivedResultLabel.textProperty().bind(new StringBinding() {
{
bind(derivationSlider.valueProperty(), baseColorPicker.colorProperty());
}
@Override
protected String computeValue() {
Color base = baseColorPicker.getColor();
double derivation = derivationSlider.getValue();
Color result = ColorEncoder.deriveColor(base, derivation / 100);
return getColorString(result);
}
});
// BACKWARD
reverseResultColor = new Region();
reverseResultColor.setPrefSize(50, 20);
reverseResultLabel.setGraphic(reverseResultColor);
ChangeListener<Color> updateReverse = (ObservableValue<? extends Color> ov, Color t, Color desiredColor) -> {
updateReverse();
};
baseColorPicker.colorProperty().addListener(updateReverse);
desiredColorPicker.colorProperty().addListener(updateReverse);
}
use of javafx.beans.binding.StringBinding in project fxexperience2 by EricCanull.
the class SplinePanelController method initialize.
/**
* Initializes the controller class.
* @param url
* @param rb
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
SplineEditor = new SplineEditor();
GridPane.setConstraints(SplineEditor, 0, 0, 1, 10, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
gridPane.add(SplineEditor, 0, 0);
codeTextField.textProperty().bind(new StringBinding() {
{
bind(SplineEditor.controlPoint1xProperty(), SplineEditor.controlPoint1yProperty(), SplineEditor.controlPoint2xProperty(), SplineEditor.controlPoint2yProperty());
}
@Override
protected String computeValue() {
return String.format("Interpolator.SPLINE(%.4f, %.4f, %.4f, %.4f);", SplineEditor.getControlPoint1x(), SplineEditor.getControlPoint1y(), SplineEditor.getControlPoint2x(), SplineEditor.getControlPoint2y());
}
});
// create anaimation updater
ChangeListener<Number> animUpdater = (ObservableValue<? extends Number> ov, Number t, Number t1) -> {
updateAnimation();
};
SplineEditor.controlPoint1xProperty().addListener(animUpdater);
SplineEditor.controlPoint1yProperty().addListener(animUpdater);
SplineEditor.controlPoint2xProperty().addListener(animUpdater);
SplineEditor.controlPoint2yProperty().addListener(animUpdater);
startAnimations();
}
use of javafx.beans.binding.StringBinding in project VocabHunter by VocabHunter.
the class ProgressController method bindValueLabel.
private void bindValueLabel(final Label valueLabel, final ObservableNumberValue property) {
StringBinding binding = Bindings.createStringBinding(() -> formatWords(property), property);
valueLabel.textProperty().bind(binding);
}
use of javafx.beans.binding.StringBinding in project VocabHunter by VocabHunter.
the class AbstractFilterModel method bindValues.
protected void bindValues() {
ObservableNumberValue count = countValue();
StringBinding countText = Bindings.createStringBinding(() -> formatTotalWords(count), count);
StringBinding filenameText = Bindings.createStringBinding(() -> filename(file.get()), file);
error.bind(Bindings.equal(count, 0));
countDescription.bind(Bindings.when(error).then(ERROR).otherwise(countText));
filename.bind(filenameText);
}
Aggregations