JavaFX has properties you can bind to each other to keep them insync. Watch this video for a very minimal example which scales a text by dragging a slider.
Now let’s look at the Xtend code used to write this small sample
The important lines are:
// Bidirectional binding between sliders sl_1.valueProperty .. sl_2.valueProperty; // Unidirectional binding from slider to scaleX/Y l.scaleXProperty -> sl_2.valueProperty; l.scaleYProperty -> sl_2.valueProperty;
The trick here to make this code not as verbose as it’s java counterpart is that Xtend allows to overload operators (+, -, ->, .., …).
What I don’t fully understand is why I can’t define my operator overloading like this:
def static <T> operator_mappedTo(Property<T> x, ObservableValue<? extends T> y) {
x.bind(y);
}
which should work when looking at the inheritance hierarchy of DoubleProperty, maybe some Xtend guru can explain it to me

June 19, 2012 




Looks like it’s got something to do with the mappedTo operator. Other operators work fine with your parameterized code.