Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public void updateChanges()
{
final Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
label.setTextFill(color);
setTextFillColorStyle(label, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
label.setFont(JFXUtil.convert(model_widget.propFont().getValue()));

led.setStyle("-fx-stroke: " + JFXUtil.webRgbOrHex(model_widget.propLineColor().getValue()));
Expand Down Expand Up @@ -279,12 +280,21 @@ else if (led instanceof Rectangle)
{ // Colors of text and LED are very close in brightness.
// Make text visible by forcing black resp. white
if (brightness > Brightness.BRIGHT_THRESHOLD)
{
label.setTextFill(Color.BLACK);
setTextFillColorStyle(label, "#000000");
}
else
{
label.setTextFill(Color.WHITE);
setTextFillColorStyle(label, "#FFFFFF");
}
}
else
{
label.setTextFill(text_color);
setTextFillColorStyle(label, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
}
}
}
jfx_node.layout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ private void addLEDs(final Pane pane, final double w, final double h, final bool
label.getStyleClass().add("led_label");
label.setFont(text_font);
label.setTextFill(text_color);
setTextFillColorStyle(label, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
label.setManaged(false);
}
else
Expand Down Expand Up @@ -436,12 +437,21 @@ public void updateChanges()
{ // Colors of text and LED are very close in brightness.
// Make text visible by forcing black resp. white
if (brightness > Brightness.BRIGHT_THRESHOLD)
{
save_labels[i].setTextFill(Color.BLACK);
setTextFillColorStyle(save_labels[i], "#000000");
}
else
{
save_labels[i].setTextFill(Color.WHITE);
setTextFillColorStyle(save_labels[i], "#FFFFFF");
}
}
else
else
{
save_labels[i].setTextFill(text_color);
setTextFillColorStyle(save_labels[i], JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
}
save_labels[i].layout();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.csstudio.display.builder.model.widgets.CheckBoxWidget;
import org.csstudio.display.builder.representation.javafx.JFXUtil;
import org.epics.vtype.VType;
import org.phoebus.ui.javafx.Styles;
import org.phoebus.ui.javafx.TextUtils;

import javafx.application.Platform;
Expand Down Expand Up @@ -223,6 +222,7 @@ public void updateChanges()
jfx_node.setText(label);
jfx_node.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
jfx_node.setTextFill(JFXUtil.convert(model_widget.propForegroundColor().getValue()));
setTextFillColorStyle(jfx_node, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));

// Don't disable the widget, because that would also remove the
// context menu etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public void updateChanges()
label.setPadding(TITLE_PADDING);
label.setPrefSize(width + ( ( !firstUpdate && hasChildren ) ? insets[2] : 0 ), inset);
label.setTextFill(foreground_color);
setTextFillColorStyle(label, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
label.setBackground(new Background(new BackgroundFill(line_color, CornerRadii.EMPTY, Insets.EMPTY)));
break;
}
Expand All @@ -233,6 +234,7 @@ public void updateChanges()
label.setPadding(TITLE_PADDING);
label.setPrefSize(Label.USE_COMPUTED_SIZE, Label.USE_COMPUTED_SIZE);
label.setTextFill(foreground_color);
setTextFillColorStyle(label, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
label.setBackground(new Background(new BackgroundFill(background_color, CornerRadii.EMPTY, Insets.EMPTY)));
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.csstudio.display.builder.model.Widget;
import org.csstudio.display.builder.model.WidgetProperty;
import org.csstudio.display.builder.model.properties.CommonWidgetProperties;
import org.csstudio.display.builder.model.widgets.GroupWidget;
import org.csstudio.display.builder.model.widgets.TabsWidget;
import org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty;
import org.csstudio.display.builder.representation.WidgetRepresentation;
Expand All @@ -34,8 +33,6 @@
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Parent;
import org.phoebus.core.types.ProcessVariable;
import org.phoebus.ui.dnd.DataFormats;
import org.phoebus.ui.javafx.Styles;

/** Base class for all JavaFX widget representations
Expand Down Expand Up @@ -378,4 +375,19 @@
}
}
}

/**
* Set the text fill using inline CSS
* TODO Remove this method after moving to JFX25!!

Check warning on line 381 in app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/JFXBaseRepresentation.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ-JuRq2ztpgaD9r9Znj&open=AZ-JuRq2ztpgaD9r9Znj&pullRequest=3892
* It is Required in JFX21 to workaround bug https://bugs.openjdk.org/browse/JDK-8336097
* meaning we cannot set the colour using setters after making the parent pane
* transparent.
* See Phoebus Github issue https://github.com/ControlSystemStudio/phoebus/issues/3891
*
* @param node JFX node
* @param color Colour as hex string
*/
public static void setTextFillColorStyle(Node node, String color){
node.setStyle("-fx-text-fill: "+ color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public void updateChanges()

Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
label.setTextFill(color);
setTextFillColorStyle(label, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
if (model_widget.propTransparent().getValue())
label.setBackground(null); // No fill
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.epics.vtype.VEnum;
import org.epics.vtype.VNumber;
import org.epics.vtype.VType;
import org.phoebus.ui.javafx.Styles;
import org.phoebus.ui.vtype.FormatOption;
import org.phoebus.ui.vtype.FormatOptionHandler;

Expand Down Expand Up @@ -304,6 +303,7 @@ public void updateChanges()
{
final RadioButton rb = (RadioButton) rb_node;
rb.setTextFill(fg);
setTextFillColorStyle(rb, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
rb.setFont(font);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.csstudio.display.builder.model.widgets.SlideButtonWidget;
import org.csstudio.display.builder.representation.javafx.JFXUtil;
import org.epics.vtype.VType;
import org.phoebus.ui.javafx.Styles;

import javafx.application.Platform;
import javafx.geometry.Pos;
Expand Down Expand Up @@ -94,6 +93,7 @@ public void updateChanges ( ) {
label.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
label.setText(labelContent);
label.setTextFill(foreground);
setTextFillColorStyle(label, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));

// Don't disable the widget, because that would also remove the context menu etc.
// Just apply a style that matches the disabled look.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ protected StackPane createJFXNode ( ) throws Exception {
indexLabel.setAlignment(Pos.CENTER);
indexLabel.setFont(Font.font(indexLabel.getFont().getFamily(), FontWeight.BOLD, 16));
indexLabel.setTextFill(Color.WHITE);
setTextFillColorStyle(indexLabel, "#FFFFFF");
indexLabel.setVisible(model_widget.propShowIndex().getValue());
indexLabel.textProperty().bind(Bindings.convert(imageIndexProperty()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public void updateChanges()
final Label label = (Label) tab.getGraphic();
label.setFont(tab_font);
label.setTextFill(Color.BLACK);
setTextFillColorStyle(label, "#000000");

// Set colors
tab.setStyle(style);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ protected Label createJFXNode ( ) throws Exception {
);
symbol.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
symbol.setTextFill(JFXUtil.convert(model_widget.propForegroundColor().getValue()));
setTextFillColorStyle(symbol, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
symbol.setText("\u263A");
symbol.setManaged(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ public void updateChanges()
final Label label = (Label) jfx_node;
Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
label.setTextFill(color);
setTextFillColorStyle(label, JFXUtil.webHex(model_widget.propForegroundColor().getValue()));
label.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
label.setAlignment(pos);
label.setWrapText(model_widget.propWrapWords().getValue());
Expand Down
Loading