Search in sources :

Example 96 with Color

use of javafx.scene.paint.Color in project org.csstudio.display.builder by kasemir.

the class XYPlotRepresentation method updateConfig.

private void updateConfig() {
    final Color foreground = JFXUtil.convert(model_widget.propForeground().getValue());
    plot.setForeground(foreground);
    plot.setBackground(JFXUtil.convert(model_widget.propBackground().getValue()));
    plot.setGridColor(JFXUtil.convert(model_widget.propGridColor().getValue()));
    plot.setTitleFont(JFXUtil.convert(model_widget.propTitleFont().getValue()));
    plot.setTitle(model_widget.propTitle().getValue());
    plot.showToolbar(model_widget.propToolbar().getValue());
    // Show trace names either in legend or on axis
    final boolean legend = model_widget.propLegend().getValue();
    plot.showLegend(legend);
    // Update X Axis
    updateAxisConfig(plot.getXAxis(), model_widget.propXAxis());
    // Use X axis font for legend
    plot.setLegendFont(JFXUtil.convert(model_widget.propXAxis().titleFont().getValue()));
    // Update Y Axes
    final List<AxisWidgetProperty> model_y = model_widget.propYAxes().getValue();
    if (plot.getYAxes().size() != model_y.size()) {
        logger.log(Level.WARNING, "Plot has " + plot.getYAxes().size() + " while model has " + model_y.size() + " Y axes");
        return;
    }
    int i = 0;
    for (YAxis<Double> plot_axis : plot.getYAxes()) {
        plot_axis.useTraceNames(!legend);
        updateAxisConfig(plot_axis, model_y.get(i));
        ++i;
    }
}
Also used : AxisWidgetProperty(org.csstudio.display.builder.model.widgets.plots.PlotWidgetProperties.AxisWidgetProperty) Color(javafx.scene.paint.Color) ArrayDouble(org.diirt.util.array.ArrayDouble)

Example 97 with Color

use of javafx.scene.paint.Color in project org.csstudio.display.builder by kasemir.

the class RegionBaseRepresentation method custom_border_changed.

private void custom_border_changed(final WidgetProperty<?> property, final Object old_value, final Object new_value) {
    final Integer width = border_width_prop.getValue();
    if (width <= 0)
        custom_border = null;
    else {
        final Color color = JFXUtil.convert(border_color_prop.getValue());
        final CornerRadii corners = computeCornerRadii();
        custom_border = new Border(new BorderStroke(color, solid, corners, new BorderWidths(width)));
    }
    dirty_border.mark();
    toolkit.scheduleUpdate(this);
}
Also used : BorderWidths(javafx.scene.layout.BorderWidths) WidgetColor(org.csstudio.display.builder.model.properties.WidgetColor) Color(javafx.scene.paint.Color) CommonWidgetProperties.propBorderColor(org.csstudio.display.builder.model.properties.CommonWidgetProperties.propBorderColor) BorderStroke(javafx.scene.layout.BorderStroke) CornerRadii(javafx.scene.layout.CornerRadii) Border(javafx.scene.layout.Border)

Example 98 with Color

use of javafx.scene.paint.Color in project org.csstudio.display.builder by kasemir.

the class ArrayRepresentation method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    if (dirty_number.checkAndClear()) {
        final int diff = children.size() - numChildren;
        if (diff != 0) {
            isAddingRemoving = true;
            if (diff > 0)
                removeChildren(children, diff);
            else
                addChildren(children, -diff);
            isAddingRemoving = false;
        }
        arrangeChildren();
    }
    if (dirty_look.checkAndClear()) {
        if (height > 0)
            jfx_node.setPrefHeight(height);
        if (width > 0)
            jfx_node.setPrefWidth(width);
        Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
        jfx_node.setBorder(new Border(new BorderStroke(color, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT, new Insets(inset / 2))));
        color = JFXUtil.convert(model_widget.displayBackgroundColor().getValue());
        jfx_node.setBackground(new Background(new BackgroundFill(color, null, null)));
    }
}
Also used : Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) WidgetColor(org.csstudio.display.builder.model.properties.WidgetColor) Color(javafx.scene.paint.Color) BackgroundFill(javafx.scene.layout.BackgroundFill) BorderStroke(javafx.scene.layout.BorderStroke) Border(javafx.scene.layout.Border)

Example 99 with Color

use of javafx.scene.paint.Color in project org.csstudio.display.builder by kasemir.

the class BaseGaugeRepresentation method updateChanges.

@SuppressWarnings("unchecked")
@Override
public void updateChanges() {
    if (jfx_node == null) {
        return;
    }
    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());
        clipper.setWidth(model_widget.propWidth().getValue() + 10);
        clipper.setHeight(model_widget.propHeight().getValue() + 10);
    }
    if (dirtyLook.checkAndClear()) {
        value = model_widget.propAutoScale().getValue();
        if (!Objects.equals(value, jfx_node.isAutoScale())) {
            jfx_node.setAutoScale((boolean) value);
        }
        Color bgColor = JFXUtil.convert(model_widget.propBackgroundColor().getValue());
        if (model_widget.propTransparent().getValue()) {
            bgColor = bgColor.deriveColor(0, 1, 1, 0);
        }
        if (!Objects.equals(bgColor, jfx_node.getBackgroundPaint())) {
            jfx_node.setBackgroundPaint(bgColor);
        }
        value = JFXUtil.convert(model_widget.propForegroundColor().getValue());
        if (!Objects.equals(value, jfx_node.getTitleColor())) {
            Color fgColor = (Color) value;
            jfx_node.setMajorTickMarkColor(fgColor);
            jfx_node.setMediumTickMarkColor(fgColor);
            jfx_node.setMinorTickMarkColor(fgColor);
            jfx_node.setTickLabelColor(fgColor);
            jfx_node.setTickMarkColor(fgColor);
            jfx_node.setTitleColor(fgColor);
            jfx_node.setUnitColor(fgColor);
            jfx_node.setValueColor(fgColor);
            jfx_node.setZeroColor(fgColor);
        }
        value = model_widget.propMajorTickSpace().getValue();
        if (!Objects.equals(value, jfx_node.getMajorTickSpace())) {
            jfx_node.setMajorTickSpace((double) value);
        }
        value = model_widget.propMinorTickSpace().getValue();
        if (!Objects.equals(value, jfx_node.getMinorTickSpace())) {
            jfx_node.setMinorTickSpace((double) value);
        }
        value = model_widget.propTitle().getValue();
        if (!Objects.equals(value, jfx_node.getTitle())) {
            jfx_node.setTitle((String) value);
        }
        value = model_widget.propValueVisible().getValue();
        if (!Objects.equals(value, jfx_node.isValueVisible())) {
            jfx_node.setValueVisible((boolean) value);
        }
    }
    if (dirtyContent.checkAndClear()) {
        value = FormatOptionHandler.actualPrecision(model_widget.runtimePropValue().getValue(), model_widget.propPrecision().getValue());
        if (!Objects.equals(value, jfx_node.getDecimals())) {
            jfx_node.setDecimals((int) value);
        }
    }
    if (dirtyLimits.checkAndClear()) {
        if (!Objects.equals(max, jfx_node.getMaxValue())) {
            jfx_node.setMaxValue(max);
        }
        if (!Objects.equals(min, jfx_node.getMinValue())) {
            jfx_node.setMinValue(min);
        }
        value = areZonesVisible();
        if (!Objects.equals(value, jfx_node.getSectionsVisible())) {
            jfx_node.setSectionsVisible((boolean) value);
        }
        value = createZones();
        if (!Objects.equals(value, jfx_node.getSections())) {
            jfx_node.setSections((List<Section>) value);
        }
    }
    if (dirtyUnit.checkAndClear()) {
        value = getUnit();
        if (!Objects.equals(value, jfx_node.getUnit())) {
            jfx_node.setUnit((String) value);
        }
    }
    if (dirtyStyle.checkAndClear()) {
        Styles.update(jfx_node, Styles.NOT_ENABLED, !model_widget.propEnabled().getValue());
    }
    if (dirtyValue.checkAndClear() && updatingValue.compareAndSet(false, true)) {
        try {
            final VType vtype = model_widget.runtimePropValue().getValue();
            double newval = VTypeUtil.getValueNumber(vtype).doubleValue();
            if (!Double.isNaN(newval)) {
                if (newval < min) {
                    newval = min;
                } else if (newval > max) {
                    newval = max;
                }
                jfx_node.setValue(newval);
            } else {
            // TODO: CR: do something!!!
            }
        } finally {
            updatingValue.set(false);
        }
    }
}
Also used : VType(org.diirt.vtype.VType) Color(javafx.scene.paint.Color) Section(eu.hansolo.medusa.Section)

Example 100 with Color

use of javafx.scene.paint.Color in project org.csstudio.display.builder by kasemir.

the class BaseGaugeRepresentation method changeSkin.

/**
 * Change the skin type, resetting some of the gauge parameters.
 *
 * @param skinType The new skin to be set.
 */
protected void changeSkin(final Gauge.SkinType skinType) {
    jfx_node.setSkinType(skinType);
    jfx_node.setPrefWidth(model_widget.propWidth().getValue());
    jfx_node.setPrefHeight(model_widget.propHeight().getValue());
    Color fgColor = JFXUtil.convert(model_widget.propForegroundColor().getValue());
    jfx_node.setAnimated(false);
    jfx_node.setAutoScale(model_widget.propAutoScale().getValue());
    jfx_node.setBackgroundPaint(model_widget.propTransparent().getValue() ? Color.TRANSPARENT : JFXUtil.convert(model_widget.propBackgroundColor().getValue()));
    jfx_node.setCheckAreasForValue(false);
    jfx_node.setCheckSectionsForValue(false);
    jfx_node.setCheckThreshold(false);
    jfx_node.setDecimals(FormatOptionHandler.actualPrecision(model_widget.runtimePropValue().getValue(), model_widget.propPrecision().getValue()));
    jfx_node.setHighlightAreas(false);
    jfx_node.setInnerShadowEnabled(false);
    jfx_node.setInteractive(false);
    jfx_node.setLedVisible(false);
    jfx_node.setMajorTickMarkColor(fgColor);
    jfx_node.setMajorTickSpace(model_widget.propMajorTickSpace().getValue());
    jfx_node.setMediumTickMarkColor(fgColor);
    jfx_node.setMinorTickMarkColor(fgColor);
    jfx_node.setMinorTickSpace(model_widget.propMinorTickSpace().getValue());
    jfx_node.setReturnToZero(false);
    jfx_node.setSectionIconsVisible(false);
    jfx_node.setSectionTextVisible(false);
    jfx_node.setTickLabelColor(fgColor);
    jfx_node.setTickMarkColor(fgColor);
    jfx_node.setTitle(model_widget.propTitle().getValue());
    jfx_node.setTitleColor(fgColor);
    jfx_node.setUnit(model_widget.propUnit().getValue());
    jfx_node.setUnitColor(fgColor);
    jfx_node.setValueColor(fgColor);
    jfx_node.setValueVisible(model_widget.propValueVisible().getValue());
    jfx_node.setZeroColor(fgColor);
}
Also used : Color(javafx.scene.paint.Color)

Aggregations

Color (javafx.scene.paint.Color)510 Test (org.junit.Test)59 Scene (javafx.scene.Scene)37 ArrayList (java.util.ArrayList)35 List (java.util.List)35 Label (javafx.scene.control.Label)34 Background (javafx.scene.layout.Background)34 Node (javafx.scene.Node)33 Stop (javafx.scene.paint.Stop)33 BackgroundFill (javafx.scene.layout.BackgroundFill)31 Paint (javafx.scene.paint.Paint)31 Text (javafx.scene.text.Text)30 ObjectProperty (javafx.beans.property.ObjectProperty)29 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)29 Group (javafx.scene.Group)28 GraphicsContext (javafx.scene.canvas.GraphicsContext)28 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)26 Insets (javafx.geometry.Insets)26 DoubleProperty (javafx.beans.property.DoubleProperty)25 Dimension2D (javafx.geometry.Dimension2D)25