From 20fabc6fc34a35331c23c1031634bdb0e71325b1 Mon Sep 17 00:00:00 2001 From: Kay Date: Wed, 6 Apr 2022 12:42:23 -0400 Subject: [PATCH] Rectangle: Use either legacy "line" or "border" .. whichever has a larger "width". Honor the "border_color" instead of always using black resp. "Text" color. #2203 --- .../builder/model/widgets/OutlineSupport.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/OutlineSupport.java b/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/OutlineSupport.java index c8ab9e3fde..0814945935 100644 --- a/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/OutlineSupport.java +++ b/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/OutlineSupport.java @@ -1,6 +1,12 @@ package org.csstudio.display.builder.model.widgets; +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propLineColor; +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propLineStyle; +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propLineWidth; + +import java.util.Optional; + import org.csstudio.display.builder.model.Widget; import org.csstudio.display.builder.model.WidgetConfigurator; import org.csstudio.display.builder.model.persist.NamedWidgetColors; @@ -9,11 +15,6 @@ import org.phoebus.framework.persistence.XMLUtil; import org.w3c.dom.Element; -import java.util.Optional; - -import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.*; -import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propLineColor; - /** * A helper class for handling the outline "line" property or widgets */ @@ -29,7 +30,6 @@ public class OutlineSupport { */ public static void handleLegacyBorder(final Widget widget, final Element xml) throws Exception { - // Style tends to be a number, but could also be "None". final Optional style_text = XMLUtil.getChildString(xml, "border_style"); if (!style_text.isPresent()) @@ -42,6 +42,15 @@ public static void handleLegacyBorder(final Widget widget, final Element xml) th return; } + // There is a "border" configuration. + // Is there also a "line" configuration? + if (XMLUtil.getChildDouble(xml, "line_width").orElse(-1.0) > + XMLUtil.getChildDouble(xml, "border_width").orElse(-1.0)) + { + // Ignore the smaller "border", use "line" + return; + } + final int style; try { @@ -53,6 +62,11 @@ public static void handleLegacyBorder(final Widget widget, final Element xml) th final Optional xml_width = XMLUtil.getChildInteger(xml, "border_width"); + // If there's a border_color, use that for the line_color + Element el = XMLUtil.getChildElement(xml, "border_color"); + if (el != null) + widget.getProperty(propLineColor).readFromXML(null, el); + switch (style) { case 0: // NONE @@ -69,35 +83,30 @@ public static void handleLegacyBorder(final Widget widget, final Element xml) th xml_width.ifPresent(w -> { widget.getProperty(propLineWidth).setValue(w); }); - widget.getProperty(propLineColor).setValue(WidgetColorService.getColor(NamedWidgetColors.TEXT)); break; case 8: // DOTTED widget.getProperty(propLineStyle).setValue(LineStyle.DOT); xml_width.ifPresent(w -> { widget.getProperty(propLineWidth).setValue(w); }); - widget.getProperty(propLineColor).setValue(WidgetColorService.getColor(NamedWidgetColors.TEXT)); break; case 9: // DASHED widget.getProperty(propLineStyle).setValue(LineStyle.DASH); xml_width.ifPresent(w -> { widget.getProperty(propLineWidth).setValue(w); }); - widget.getProperty(propLineColor).setValue(WidgetColorService.getColor(NamedWidgetColors.TEXT)); break; case 10: // DASH_DOT widget.getProperty(propLineStyle).setValue(LineStyle.DASHDOT); xml_width.ifPresent(w -> { widget.getProperty(propLineWidth).setValue(w); }); - widget.getProperty(propLineColor).setValue(WidgetColorService.getColor(NamedWidgetColors.TEXT)); break; case 11: // DASH_DOT_DOT widget.getProperty(propLineStyle).setValue(LineStyle.DASHDOTDOT); xml_width.ifPresent(w -> { widget.getProperty(propLineWidth).setValue(w); }); - widget.getProperty(propLineColor).setValue(WidgetColorService.getColor(NamedWidgetColors.TEXT)); break; } }