add calculating methods to bind

Tom Eugelink tbee at tbee.org
Wed May 21 19:25:37 UTC 2014


I came up with this:

startXProperty().bind( *snap(*heightProperty().multiply(0.2)) )


And then:

     private DoubleBinding snap(final ObservableNumberValue other, final Observable... dependencies) {
         return new DoubleBinding() {
             {
                 super.bind(dependencies);
             }

             @Override
             public void dispose() {
                 super.unbind(dependencies);
             }

             @Override
             protected double computeValue() {
                 return NodeUtil.snap(other.doubleValue());
             }

             @Override
             public ObservableList<?> getDependencies() {
                 return new ImmutableObservableList<Observable>(dependencies);
             }
         };
     }

But that always returns 0... I feel this should have worked.

Tom


More information about the openjfx-dev mailing list