Search in sources :

Example 1 with Effect

use of javafx.scene.effect.Effect in project jphp by jphp-compiler.

the class UXNode method setAnchorFlags.

@Setter
public void setAnchorFlags(ArrayMemory value) {
    Parent parent = getWrappedObject().getParent();
    Bounds parentBounds = parent == null ? null : parent.getLayoutBounds();
    if (parent == null) {
        return;
    }
    Effect effect = getWrappedObject().getEffect();
    getWrappedObject().setEffect(null);
    Bounds bounds = getBoundsInParent();
    Border border = parent instanceof Region ? ((Region) parent).getBorder() : null;
    Insets borderInsets = border == null ? Insets.EMPTY : border.getInsets();
    if (value.containsKey("left")) {
        boolean left = value.valueOfIndex("left").toBoolean();
        if (left) {
            setLeftAnchor(DoubleMemory.valueOf(bounds.getMinX() - borderInsets.getLeft()));
        } else {
            setLeftAnchor(Memory.NULL);
        }
    }
    if (value.containsKey("top")) {
        boolean top = value.valueOfIndex("top").toBoolean();
        if (top) {
            setTopAnchor(DoubleMemory.valueOf(bounds.getMinY() - borderInsets.getTop()));
        } else {
            setTopAnchor(Memory.NULL);
        }
    }
    if (value.containsKey("right")) {
        boolean right = value.valueOfIndex("right").toBoolean();
        if (right) {
            setRightAnchor(DoubleMemory.valueOf(parentBounds.getWidth() - bounds.getMaxX() - borderInsets.getRight()));
        } else {
            setRightAnchor(Memory.NULL);
        }
    }
    if (value.containsKey("bottom")) {
        boolean bottom = value.valueOfIndex("bottom").toBoolean();
        if (bottom) {
            setBottomAnchor(DoubleMemory.valueOf(parentBounds.getHeight() - bounds.getMaxY() - borderInsets.getBottom()));
        } else {
            setBottomAnchor(Memory.NULL);
        }
    }
    getWrappedObject().setEffect(effect);
}
Also used : Insets(javafx.geometry.Insets) Bounds(javafx.geometry.Bounds) Region(javafx.scene.layout.Region) Effect(javafx.scene.effect.Effect) Border(javafx.scene.layout.Border)

Example 2 with Effect

use of javafx.scene.effect.Effect in project fxexperience2 by EricCanull.

the class MainController method setIconBinding.

// Adjusts the color of the toogle icons upon selection
private void setIconBinding(ToggleButton toggle) {
    ImageView icon = (ImageView) toggle.getGraphic();
    icon.effectProperty().bind(new ObjectBinding<Effect>() {

        {
            bind(toggle.selectedProperty());
        }

        @Override
        protected Effect computeValue() {
            return toggle.isSelected() ? null : new ColorAdjust(0, -1, 0, 0);
        }
    });
}
Also used : Effect(javafx.scene.effect.Effect) ColorAdjust(javafx.scene.effect.ColorAdjust) ImageView(javafx.scene.image.ImageView)

Aggregations

Effect (javafx.scene.effect.Effect)2 Bounds (javafx.geometry.Bounds)1 Insets (javafx.geometry.Insets)1 ColorAdjust (javafx.scene.effect.ColorAdjust)1 ImageView (javafx.scene.image.ImageView)1 Border (javafx.scene.layout.Border)1 Region (javafx.scene.layout.Region)1