Java Code Examples for org.reactfx.value.Var#mapBidirectional()

The following examples show how to use org.reactfx.value.Var#mapBidirectional() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LanguageVersionRangeSlider.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Var<LanguageVersion> minVersionProperty() {
    return Var.mapBidirectional(
        lowValueProperty(),
        num -> fromIndex(num.intValue()),
        ver -> ver == null ? -1 : curVersions.indexOf(ver)
    );
}
 
Example 2
Source File: LanguageVersionRangeSlider.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Var<LanguageVersion> maxVersionProperty() {
    return Var.mapBidirectional(
        highValueProperty(),
        num -> fromIndex(num.intValue()),
        ver -> ver == null ? curVersions.size() : curVersions.indexOf(ver)
    );
}
 
Example 3
Source File: ScaledVirtualized.java    From Flowless with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ScaledVirtualized(V content) {
    super();
    this.content = content;
    getChildren().add(content);
    getTransforms().add(zoom);

    estHeight = Val.combine(
            content.totalHeightEstimateProperty(),
            zoom.yProperty(),
            (estHeight, scaleFactor) -> estHeight * scaleFactor.doubleValue()
    );
    estWidth = Val.combine(
            content.totalWidthEstimateProperty(),
            zoom.xProperty(),
            (estWidth, scaleFactor) -> estWidth * scaleFactor.doubleValue()
    );
    estScrollX = Var.mapBidirectional(
            content.estimatedScrollXProperty(),
            scrollX -> scrollX * zoom.getX(),
            scrollX -> scrollX / zoom.getX()
    );
    estScrollY = Var.mapBidirectional(
            content.estimatedScrollYProperty(),
            scrollY -> scrollY * zoom.getY(),
            scrollY -> scrollY / zoom.getY()
    );

    zoom.xProperty()     .addListener((obs, ov, nv) -> requestLayout());
    zoom.yProperty()     .addListener((obs, ov, nv) -> requestLayout());
    zoom.zProperty()     .addListener((obs, ov, nv) -> requestLayout());
    zoom.pivotXProperty().addListener((obs, ov, nv) -> requestLayout());
    zoom.pivotYProperty().addListener((obs, ov, nv) -> requestLayout());
    zoom.pivotZProperty().addListener((obs, ov, nv) -> requestLayout());
}
 
Example 4
Source File: ReactfxUtil.java    From pmd-designer with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static Var<Boolean> booleanVar(BooleanProperty p) {
    return Var.mapBidirectional(p, Boolean::booleanValue, Function.identity());
}