use of javafx.beans.value.WritableDoubleValue in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXDoubleUnidirectional.
@Test
public void testJavaFXDoubleUnidirectional() {
Property<Double> doubleDolphinProperty = new MockedProperty<>();
Property<Number> numberDolphinProperty = new MockedProperty<>();
DoubleProperty doubleJavaFXProperty = new SimpleDoubleProperty();
WritableDoubleValue writableDoubleValue = new SimpleDoubleProperty();
doubleDolphinProperty.set(47.0);
assertNotEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
Binding binding = FXBinder.bind(doubleJavaFXProperty).to(doubleDolphinProperty);
assertEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
doubleDolphinProperty.set(100.0);
assertEquals(doubleJavaFXProperty.doubleValue(), 100.0, EPSILON);
doubleDolphinProperty.set(null);
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
binding.unbind();
doubleDolphinProperty.set(100.0);
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
numberDolphinProperty.set(12.0);
binding = FXBinder.bind(doubleJavaFXProperty).to(numberDolphinProperty);
assertEquals(doubleJavaFXProperty.doubleValue(), 12.0, EPSILON);
numberDolphinProperty.set(null);
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
binding.unbind();
numberDolphinProperty.set(100.0);
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
doubleDolphinProperty.set(47.0);
binding = FXBinder.bind(writableDoubleValue).to(doubleDolphinProperty);
assertEquals(writableDoubleValue.get(), 47.0, EPSILON);
doubleDolphinProperty.set(100.0);
assertEquals(writableDoubleValue.get(), 100.0, EPSILON);
doubleDolphinProperty.set(null);
assertEquals(writableDoubleValue.get(), 0.0, EPSILON);
binding.unbind();
doubleDolphinProperty.set(100.0);
assertEquals(writableDoubleValue.get(), 0.0, EPSILON);
}
use of javafx.beans.value.WritableDoubleValue in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXDoubleUnidirectionalWithConverter.
@Test
public void testJavaFXDoubleUnidirectionalWithConverter() {
Property<String> stringDolphinProperty = new MockedProperty<>();
DoubleProperty doubleJavaFXProperty = new SimpleDoubleProperty();
WritableDoubleValue writableDoubleValue = new SimpleDoubleProperty();
Converter<String, Double> stringDoubleConverter = s -> s == null ? null : Double.parseDouble(s);
stringDolphinProperty.set("47.0");
assertNotEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
Binding binding = FXBinder.bind(doubleJavaFXProperty).to(stringDolphinProperty, stringDoubleConverter);
assertEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
stringDolphinProperty.set("100.0");
assertEquals(doubleJavaFXProperty.doubleValue(), 100.0, EPSILON);
stringDolphinProperty.set(null);
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
binding.unbind();
stringDolphinProperty.set("100.0");
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
stringDolphinProperty.set("12.0");
binding = FXBinder.bind(doubleJavaFXProperty).to(stringDolphinProperty, stringDoubleConverter);
assertEquals(doubleJavaFXProperty.doubleValue(), 12.0, EPSILON);
stringDolphinProperty.set(null);
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
binding.unbind();
stringDolphinProperty.set("100.0");
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
stringDolphinProperty.set("47.0");
binding = FXBinder.bind(writableDoubleValue).to(stringDolphinProperty, stringDoubleConverter);
assertEquals(writableDoubleValue.get(), 47.0, EPSILON);
stringDolphinProperty.set("100.0");
assertEquals(writableDoubleValue.get(), 100.0, EPSILON);
stringDolphinProperty.set(null);
assertEquals(writableDoubleValue.get(), 0.0, EPSILON);
binding.unbind();
stringDolphinProperty.set("100.0");
assertEquals(writableDoubleValue.get(), 0.0, EPSILON);
}
Aggregations