is Nan Or Infinity JavaFX BooleanBinding - Java JavaFX

Java examples for JavaFX:Bindable Properties

Description

is Nan Or Infinity JavaFX BooleanBinding

Demo Code


//package com.java2s;
import javafx.beans.binding.BooleanBinding;

import javafx.beans.value.ObservableDoubleValue;

public class Main {
    public static BooleanBinding isNanOrInfinity(
            final ObservableDoubleValue observable) {
        return new BooleanBinding() {
            {//from  w  w w.j  a  va  2 s.c  om
                super.bind(observable);
            }

            @Override
            protected boolean computeValue() {
                double value = observable.get();
                return Double.isInfinite(value) || Double.isNaN(value);
            }
        };
    }
}

Related Tutorials