add calculating methods to bind
    Tomas Mikula 
    tomas.mikula at gmail.com
       
    Wed May 21 19:34:06 UTC 2014
    
    
  
Hi Tom,
it seems to me that in your custom DoubleBinding implementation
`other` is not its dependency, thus it does not react to it's
invalidations.
Tomas
On Wed, May 21, 2014 at 9:25 PM, Tom Eugelink <tbee at tbee.org> wrote:
> 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