How can i dynamically compare and switch between two properties in JavaFX .bind call

Viewed 25

I want to dynamically bind to the property with the lesser out of two value, so i can "fit" the circle into the bbox. Ideally i hoped there is method like min or max for properties (hypothetical example below), but there is none as far as i looked. Can anyone suggest an alternative?

this.outline.radiusProperty().bind(this.heightProperty().divide(2.).min(this.widthProperty().divide(2.)));
1 Answers

The "high-level" Bindings API has a Bindings.min(...) method:

this.outline.radiusProperty().bind(Bindings.min(
    this.heightProperty().divide(2.), 
    this.widthProperty().divide(2.)
));
Related