Example usage for javafx.beans.property SimpleDoubleProperty SimpleDoubleProperty

List of usage examples for javafx.beans.property SimpleDoubleProperty SimpleDoubleProperty

Introduction

In this page you can find the example usage for javafx.beans.property SimpleDoubleProperty SimpleDoubleProperty.

Prototype

public SimpleDoubleProperty(double initialValue) 

Source Link

Document

The constructor of DoubleProperty

Usage

From source file:Main.java

public static void main(String[] args) {
    final DoubleProperty radius = new SimpleDoubleProperty(2);

    DoubleBinding volumeOfSphere = new DoubleBinding() {
        {//from  w  w w  .  ja va  2 s .  co  m
            super.bind(radius);
        }

        @Override
        protected double computeValue() {
            return radius.get() + 4;
        }
    };

    System.out.println(radius.get());
    System.out.println(volumeOfSphere.get());

    radius.set(50);
    System.out.println(radius.get());
    System.out.println(volumeOfSphere.get());
}

From source file:Main.java

public static void main(String[] args) {
    final DoubleProperty a = new SimpleDoubleProperty(0);
    final DoubleProperty b = new SimpleDoubleProperty(0);
    final DoubleProperty c = new SimpleDoubleProperty(0);

    DoubleBinding area = new DoubleBinding() {
        {//  w  ww. j  ava2  s.  c  om
            super.bind(a, b, c);
        }

        @Override
        protected double computeValue() {
            double a0 = a.get();
            double b0 = b.get();
            double c0 = c.get();

            return a0 * b0 * c0;

        }
    };

    a.set(2);
    b.set(2);
    c.set(2);
    System.out.println(area.get());
}

From source file:Main.java

public static void main(String[] args) {
    DoubleProperty a = new SimpleDoubleProperty(0);
    DoubleProperty b = new SimpleDoubleProperty(0);

    DoubleBinding s = a.add(b).divide(2.0D);

    final DoubleBinding aBinding = new When(a.add(b).greaterThan(b).and(a.add(a).greaterThan(b)))
            .then(s.multiply(s.subtract(a)).multiply(s.subtract(b))).otherwise(0.0D);

    a.set(3);//w w w  .  j a  v  a 2s.  co  m
    b.set(4);
    System.out.println(a.get());
    System.out.println(b.get());
    System.out.println(aBinding.get());

    a.set(2);
    b.set(2);
    System.out.println(a.get());
    System.out.println(b.get());
    System.out.println(aBinding.get());

}

From source file:Main.java

@Override
public void start(Stage stage) throws Exception {
    ImageView imageView = new ImageView();
    ScrollPane scrollPane = new ScrollPane();
    DoubleProperty zoomProperty = new SimpleDoubleProperty(200);

    zoomProperty.addListener(new InvalidationListener() {
        @Override/*from ww w  .j a  v a 2s  . c o  m*/
        public void invalidated(Observable arg0) {
            imageView.setFitWidth(zoomProperty.get() * 2);
            imageView.setFitHeight(zoomProperty.get() * 3);
        }
    });
    scrollPane.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() {
        @Override
        public void handle(ScrollEvent event) {
            if (event.getDeltaY() > 0) {
                zoomProperty.set(zoomProperty.get() * 1.2);
            } else if (event.getDeltaY() < 0) {
                zoomProperty.set(zoomProperty.get() / 1.1);
            }
        }
    });
    imageView.setImage(new Image("http://yourImageURL"));
    imageView.preserveRatioProperty().set(true);
    scrollPane.setContent(imageView);
    stage.setScene(new Scene(scrollPane, 400, 300));
    stage.show();
}

From source file:eu.ggnet.dwoss.report.entity.ReportLine.java

public DoubleProperty priceProperty() {
    if (priceProperty == null) {
        priceProperty = new SimpleDoubleProperty(price);
        priceProperty.addListener(new ChangeListener<Number>() {

            @Override/*from  w w w .ja v a 2s  .  c o m*/
            public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) {
                price = newValue.doubleValue();
            }
        });
    }
    return priceProperty;
}

From source file:eu.ggnet.dwoss.report.entity.ReportLine.java

public DoubleProperty afterTaxPriceProperty() {
    if (afterTaxPriceProperty == null) {
        afterTaxPriceProperty = new SimpleDoubleProperty(afterTaxPrice);
        afterTaxPriceProperty.addListener(new ChangeListener<Number>() {

            @Override/*from ww  w.ja  va 2  s  .c o  m*/
            public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) {
                afterTaxPrice = newValue.doubleValue();
            }
        });
    }
    return afterTaxPriceProperty;
}

From source file:eu.ggnet.dwoss.report.entity.ReportLine.java

public DoubleProperty manufacturerCostPriceProperty() {
    if (manufacturerCostPriceProperty == null) {
        manufacturerCostPriceProperty = new SimpleDoubleProperty(manufacturerCostPrice);
        manufacturerCostPriceProperty.addListener((ov, o, n) -> manufacturerCostPrice = n.doubleValue());
    }/*from ww w  . j a v a 2  s  .co  m*/
    return manufacturerCostPriceProperty;
}

From source file:eu.ggnet.dwoss.report.entity.ReportLine.java

public DoubleProperty marginPercentageProperty() {
    if (marginPercentageProperty == null) {
        marginPercentageProperty = new SimpleDoubleProperty(marginPercentage);
        marginPercentageProperty.addListener(new ChangeListener<Number>() {

            @Override//  www  .  ja  v  a  2s .com
            public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) {
                marginPercentage = newValue.doubleValue();
            }
        });
    }
    return marginPercentageProperty;
}

From source file:eu.ggnet.dwoss.report.entity.ReportLine.java

public DoubleProperty purchasePriceProperty() {
    if (purchasePriceProperty == null) {
        purchasePriceProperty = new SimpleDoubleProperty(purchasePrice);
        purchasePriceProperty.addListener(new ChangeListener<Number>() {

            @Override//from   w ww .  j a v a2 s . c om
            public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) {
                purchasePrice = newValue.doubleValue();
            }
        });
    }
    return purchasePriceProperty;
}

From source file:eu.ggnet.dwoss.report.entity.ReportLine.java

public DoubleProperty contractorReferencePriceProperty() {
    if (contractorReferencePriceProperty == null) {
        contractorReferencePriceProperty = new SimpleDoubleProperty(contractorReferencePrice);
        contractorReferencePriceProperty.addListener(new ChangeListener<Number>() {

            @Override//from  w w  w .  j  a va  2  s.com
            public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) {
                contractorReferencePrice = newValue.doubleValue();
            }
        });
    }
    return contractorReferencePriceProperty;
}