Search in sources :

Example 1 with RotationStep

use of org.csstudio.display.builder.model.properties.RotationStep in project org.csstudio.display.builder by kasemir.

the class TextUpdateRepresentation method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    if (dirty_style.checkAndClear()) {
        final RotationStep rotation = model_widget.propRotationStep().getValue();
        final int width = model_widget.propWidth().getValue(), height = model_widget.propHeight().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;
        }
        if (model_widget.propTransparent().getValue())
            // No fill
            jfx_node.setBackground(null);
        else {
            final Color color = JFXUtil.convert(model_widget.propBackgroundColor().getValue());
            jfx_node.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));
        }
        if (jfx_node instanceof Label) {
            final Label label = (Label) jfx_node;
            Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
            label.setTextFill(color);
            label.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
            label.setAlignment(pos);
            label.setWrapText(model_widget.propWrapWords().getValue());
        } else {
            final TextArea area = (TextArea) jfx_node;
            final StringBuilder style = new StringBuilder(100);
            style.append("-fx-text-fill:");
            JFXUtil.appendWebRGB(style, model_widget.propForegroundColor().getValue()).append(";");
            // http://stackoverflow.com/questions/27700006/how-do-you-change-the-background-color-of-a-textfield-without-changing-the-border
            final WidgetColor back_color = model_widget.propBackgroundColor().getValue();
            style.append("-fx-control-inner-background: ");
            JFXUtil.appendWebRGB(style, back_color).append(";");
            area.setStyle(style.toString());
            area.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
            // Alignment (pos) not supported
            area.setWrapText(model_widget.propWrapWords().getValue());
        }
    }
    if (dirty_content.checkAndClear()) {
        if (jfx_node instanceof Label)
            ((Label) jfx_node).setText(value_text);
        else
            ((TextArea) jfx_node).setText(value_text);
    }
}
Also used : RotationStep(org.csstudio.display.builder.model.properties.RotationStep) Rotate(javafx.scene.transform.Rotate) Background(javafx.scene.layout.Background) TextArea(javafx.scene.control.TextArea) Color(javafx.scene.paint.Color) WidgetColor(org.csstudio.display.builder.model.properties.WidgetColor) BackgroundFill(javafx.scene.layout.BackgroundFill) WidgetColor(org.csstudio.display.builder.model.properties.WidgetColor) Label(javafx.scene.control.Label) Translate(javafx.scene.transform.Translate)

Example 2 with RotationStep

use of org.csstudio.display.builder.model.properties.RotationStep in project org.csstudio.display.builder by kasemir.

the class ActionButtonRepresentation method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    if (dirty_actionls.checkAndClear()) {
        base = makeBaseButton();
        jfx_node.getChildren().setAll(base);
    }
    if (dirty_representation.checkAndClear()) {
        button_text = makeButtonText();
        base.setText(button_text);
        base.setTextFill(foreground);
        base.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
        final RotationStep rotation = model_widget.propRotationStep().getValue();
        final int width = model_widget.propWidth().getValue(), height = model_widget.propHeight().getValue();
        // Applying the transformation to the Pane does not exhibit this problem.
        switch(rotation) {
            case NONE:
                base.setPrefSize(width, height);
                if (was_ever_transformed)
                    jfx_node.getTransforms().clear();
                break;
            case NINETY:
                base.setPrefSize(height, width);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-height, 0));
                was_ever_transformed = true;
                break;
            case ONEEIGHTY:
                base.setPrefSize(width, height);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-width, -height));
                was_ever_transformed = true;
                break;
            case MINUS_NINETY:
                base.setPrefSize(height, width);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(0, -width));
                was_ever_transformed = true;
                break;
        }
    }
    if (dirty_enablement.checkAndClear()) {
        base.setDisable(!enabled);
        Styles.update(jfx_node, Styles.NOT_ENABLED, !enabled);
    }
}
Also used : RotationStep(org.csstudio.display.builder.model.properties.RotationStep) Rotate(javafx.scene.transform.Rotate) Translate(javafx.scene.transform.Translate)

Example 3 with RotationStep

use of org.csstudio.display.builder.model.properties.RotationStep 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 4 with RotationStep

use of org.csstudio.display.builder.model.properties.RotationStep 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)

Aggregations

Rotate (javafx.scene.transform.Rotate)4 Translate (javafx.scene.transform.Translate)4 RotationStep (org.csstudio.display.builder.model.properties.RotationStep)4 Background (javafx.scene.layout.Background)3 BackgroundFill (javafx.scene.layout.BackgroundFill)3 Color (javafx.scene.paint.Color)2 Dimension2D (javafx.geometry.Dimension2D)1 Label (javafx.scene.control.Label)1 TextArea (javafx.scene.control.TextArea)1 WidgetColor (org.csstudio.display.builder.model.properties.WidgetColor)1 ListInt (org.diirt.util.array.ListInt)1 ListNumber (org.diirt.util.array.ListNumber)1 VBoolean (org.diirt.vtype.VBoolean)1 VEnum (org.diirt.vtype.VEnum)1 VEnumArray (org.diirt.vtype.VEnumArray)1 VNumber (org.diirt.vtype.VNumber)1 VNumberArray (org.diirt.vtype.VNumberArray)1 VString (org.diirt.vtype.VString)1