Search in sources :

Example 56 with Background

use of javafx.scene.layout.Background in project org.csstudio.display.builder by kasemir.

the class SpinnerRepresentation method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    if (dirty_style.checkAndClear()) {
        final String color = JFXUtil.webRGB(model_widget.propForegroundColor().getValue());
        jfx_node.editorProperty().getValue().setStyle("-fx-text-fill:" + color);
        final Color background = JFXUtil.convert(model_widget.propBackgroundColor().getValue());
        jfx_node.editorProperty().getValue().setBackground(new Background(new BackgroundFill(background, CornerRadii.EMPTY, Insets.EMPTY)));
        jfx_node.setPrefWidth(model_widget.propWidth().getValue());
        jfx_node.setPrefHeight(model_widget.propHeight().getValue());
        final boolean enabled = model_widget.propEnabled().getValue();
        Styles.update(jfx_node, Styles.NOT_ENABLED, !enabled);
        jfx_node.setEditable(!toolkit.isEditMode() && enabled);
        int x = jfx_node.getStyleClass().indexOf(Spinner.STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL);
        if (model_widget.propButtonsOnLeft().getValue()) {
            if (x < 0)
                jfx_node.getStyleClass().add(Spinner.STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL);
        } else if (x > 0)
            jfx_node.getStyleClass().remove(x);
    }
    if (dirty_content.checkAndClear()) {
        ((TextSpinnerValueFactory) jfx_node.getValueFactory()).setVTypeValue(value);
        jfx_node.getValueFactory().setValue(value_text);
    }
}
Also used : Background(javafx.scene.layout.Background) Color(javafx.scene.paint.Color) BackgroundFill(javafx.scene.layout.BackgroundFill)

Example 57 with Background

use of javafx.scene.layout.Background in project org.csstudio.display.builder by kasemir.

the class TextSymbolRepresentation method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    Object value;
    if (dirtyGeometry.checkAndClear()) {
        value = model_widget.propVisible().getValue();
        if (!Objects.equals(value, jfx_node.isVisible())) {
            jfx_node.setVisible((boolean) value);
        }
        jfx_node.setLayoutX(model_widget.propX().getValue());
        jfx_node.setLayoutY(model_widget.propY().getValue());
        jfx_node.setPrefWidth(model_widget.propWidth().getValue());
        jfx_node.setPrefHeight(model_widget.propHeight().getValue());
    }
    if (dirtyContent.checkAndClear()) {
        value = model_widget.propArrayIndex().getValue();
        if (!Objects.equals(value, arrayIndex)) {
            arrayIndex = Math.max(0, (int) value);
        }
        symbolIndex = Math.min(Math.max(symbolIndex, 0), model_widget.propSymbols().size() - 1);
        jfx_node.setText((symbolIndex >= 0) ? model_widget.propSymbols().getElement(symbolIndex).getValue() : "\u263A");
    }
    if (dirtyStyle.checkAndClear()) {
        final int width = model_widget.propWidth().getValue();
        final int height = model_widget.propHeight().getValue();
        final RotationStep rotation = model_widget.propRotationStep().getValue();
        switch(rotation) {
            case NONE:
                jfx_node.setPrefSize(width, height);
                if (was_ever_transformed) {
                    jfx_node.getTransforms().clear();
                }
                break;
            case NINETY:
                jfx_node.setPrefSize(height, width);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-height, 0));
                was_ever_transformed = true;
                break;
            case ONEEIGHTY:
                jfx_node.setPrefSize(width, height);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-width, -height));
                was_ever_transformed = true;
                break;
            case MINUS_NINETY:
                jfx_node.setPrefSize(height, width);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(0, -width));
                was_ever_transformed = true;
                break;
        }
        value = model_widget.propEnabled().getValue();
        if (!Objects.equals(value, enabled)) {
            enabled = (boolean) value;
            Styles.update(jfx_node, Styles.NOT_ENABLED, !enabled);
        }
        jfx_node.setAlignment(JFXUtil.computePos(model_widget.propHorizontalAlignment().getValue(), model_widget.propVerticalAlignment().getValue()));
        jfx_node.setBackground(model_widget.propTransparent().getValue() ? null : new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), CornerRadii.EMPTY, Insets.EMPTY)));
        jfx_node.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
        jfx_node.setTextFill(JFXUtil.convert(model_widget.propForegroundColor().getValue()));
        jfx_node.setWrapText(model_widget.propWrapWords().getValue());
    }
    if (dirtyValue.checkAndClear() && updatingValue.compareAndSet(false, true)) {
        try {
            value = model_widget.runtimePropValue().getValue();
            if (value != null) {
                if (value instanceof VBoolean) {
                    symbolIndex = ((VBoolean) value).getValue() ? 1 : 0;
                } else if (value instanceof VString) {
                    try {
                        symbolIndex = Integer.parseInt(((VString) value).getValue());
                    } catch (NumberFormatException nfex) {
                        logger.log(Level.FINE, "Failure parsing the string value: {0} [{1}].", new Object[] { ((VString) value).getValue(), nfex.getMessage() });
                    }
                } else if (value instanceof VNumber) {
                    symbolIndex = ((VNumber) value).getValue().intValue();
                } else if (value instanceof VEnum) {
                    symbolIndex = ((VEnum) value).getIndex();
                } else if (value instanceof VNumberArray) {
                    ListNumber array = ((VNumberArray) value).getData();
                    if (array.size() > 0) {
                        symbolIndex = array.getInt(Math.min(arrayIndex, array.size() - 1));
                    }
                } else if (value instanceof VEnumArray) {
                    ListInt array = ((VEnumArray) value).getIndexes();
                    if (array.size() > 0) {
                        symbolIndex = array.getInt(Math.min(arrayIndex, array.size() - 1));
                    }
                }
            }
        } finally {
            updatingValue.set(false);
        }
        symbolIndex = Math.min(Math.max(symbolIndex, 0), model_widget.propSymbols().size() - 1);
        jfx_node.setText((symbolIndex >= 0) ? model_widget.propSymbols().getElement(symbolIndex).getValue() : "\u263A");
    }
}
Also used : VEnumArray(org.diirt.vtype.VEnumArray) ListInt(org.diirt.util.array.ListInt) Rotate(javafx.scene.transform.Rotate) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) VNumber(org.diirt.vtype.VNumber) VBoolean(org.diirt.vtype.VBoolean) VEnum(org.diirt.vtype.VEnum) VNumberArray(org.diirt.vtype.VNumberArray) RotationStep(org.csstudio.display.builder.model.properties.RotationStep) ListNumber(org.diirt.util.array.ListNumber) VString(org.diirt.vtype.VString) Translate(javafx.scene.transform.Translate)

Example 58 with Background

use of javafx.scene.layout.Background in project org.csstudio.display.builder by kasemir.

the class TextSymbolRepresentation method createJFXNode.

@Override
protected Label createJFXNode() throws Exception {
    Label symbol = new Label();
    symbol.setAlignment(JFXUtil.computePos(model_widget.propHorizontalAlignment().getValue(), model_widget.propVerticalAlignment().getValue()));
    symbol.setBackground(model_widget.propTransparent().getValue() ? null : new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), CornerRadii.EMPTY, Insets.EMPTY)));
    symbol.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
    symbol.setTextFill(JFXUtil.convert(model_widget.propForegroundColor().getValue()));
    symbol.setText("\u263A");
    enabled = model_widget.propEnabled().getValue();
    Styles.update(symbol, Styles.NOT_ENABLED, !enabled);
    return symbol;
}
Also used : Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) Label(javafx.scene.control.Label)

Example 59 with Background

use of javafx.scene.layout.Background in project org.csstudio.display.builder by kasemir.

the class LabelRepresentation method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    if (dirty_style.checkAndClear()) {
        final int width = model_widget.propWidth().getValue();
        final int height = model_widget.propHeight().getValue();
        final RotationStep rotation = model_widget.propRotationStep().getValue();
        switch(rotation) {
            case NONE:
                jfx_node.setPrefSize(width, height);
                if (was_ever_transformed)
                    jfx_node.getTransforms().clear();
                break;
            case NINETY:
                jfx_node.setPrefSize(height, width);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-height, 0));
                was_ever_transformed = true;
                break;
            case ONEEIGHTY:
                jfx_node.setPrefSize(width, height);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-width, -height));
                was_ever_transformed = true;
                break;
            case MINUS_NINETY:
                jfx_node.setPrefSize(height, width);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(0, -width));
                was_ever_transformed = true;
                break;
        }
        jfx_node.setAlignment(pos);
        jfx_node.setWrapText(model_widget.propWrapWords().getValue());
        Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
        jfx_node.setTextFill(color);
        if (model_widget.propTransparent().getValue())
            // No fill
            jfx_node.setBackground(null);
        else {
            // Fill background
            color = JFXUtil.convert(model_widget.propBackgroundColor().getValue());
            jfx_node.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));
        }
        jfx_node.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
    }
    if (dirty_content.checkAndClear()) {
        final String text = model_widget.propText().getValue();
        jfx_node.setText(text);
        if (model_widget.propAutoSize().getValue()) {
            final Dimension2D size = TextUtils.computeTextSize(JFXUtil.convert(model_widget.propFont().getValue()), text);
            model_widget.propWidth().setValue((int) Math.ceil(size.getWidth()));
            model_widget.propHeight().setValue((int) Math.ceil(size.getHeight()));
        }
    }
}
Also used : RotationStep(org.csstudio.display.builder.model.properties.RotationStep) Rotate(javafx.scene.transform.Rotate) Background(javafx.scene.layout.Background) Color(javafx.scene.paint.Color) BackgroundFill(javafx.scene.layout.BackgroundFill) Dimension2D(javafx.geometry.Dimension2D) Translate(javafx.scene.transform.Translate)

Example 60 with Background

use of javafx.scene.layout.Background in project org.csstudio.display.builder by kasemir.

the class NavigationTabsRepresentation method representContent.

/**
 * @param content_model Model to represent
 */
private void representContent(final DisplayModel content_model) {
    try {
        toolkit.representModel(body, content_model);
        // Set 'body' of navtabs to color of the embedded model
        body.setBackground(new Background(new BackgroundFill(JFXUtil.convert(content_model.propBackgroundColor().getValue()), CornerRadii.EMPTY, Insets.EMPTY)));
    } catch (final Exception ex) {
        logger.log(Level.WARNING, "Failed to represent embedded display", ex);
    }
}
Also used : Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill)

Aggregations

Background (javafx.scene.layout.Background)86 BackgroundFill (javafx.scene.layout.BackgroundFill)82 Insets (javafx.geometry.Insets)30 CornerRadii (javafx.scene.layout.CornerRadii)24 Scene (javafx.scene.Scene)18 StackPane (javafx.scene.layout.StackPane)15 Color (javafx.scene.paint.Color)15 Label (javafx.scene.control.Label)14 Border (javafx.scene.layout.Border)14 BorderStroke (javafx.scene.layout.BorderStroke)14 BorderWidths (javafx.scene.layout.BorderWidths)12 Pane (javafx.scene.layout.Pane)12 Text (javafx.scene.text.Text)9 BorderPane (javafx.scene.layout.BorderPane)8 Region (javafx.scene.layout.Region)8 HBox (javafx.scene.layout.HBox)7 ArrayList (java.util.ArrayList)6 MouseEvent (javafx.scene.input.MouseEvent)6 VBox (javafx.scene.layout.VBox)6 Rectangle (javafx.scene.shape.Rectangle)5