From cfca5143a51e766d3f2e333d38ae462698bb6370 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 13 Oct 2021 10:10:48 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-60717=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E8=AE=BE=E7=BD=AE=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=86=85=E8=BE=B9=E8=B7=9D=E5=90=8E=E8=BE=B9=E6=A1=86=E7=BA=BF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 报表块/图表块内边距优化后,标题和body的分界线左右两侧 也出现了边距,分界线需要向外扩展 【改动思路】 同上 --- .../theme/preview/ComponentPreviewPane.java | 57 ++++++++++--------- .../creator/XBorderStyleWidgetCreator.java | 33 +---------- .../designer/creator/XWTitleLayout.java | 33 +++++++++++ 3 files changed, 65 insertions(+), 58 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java index 20e418960c..cfd2781aa8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java @@ -90,6 +90,37 @@ public abstract class ComponentPreviewPane extends UINoOpaquePanel implements Th } + @Override + protected void paintBorder(Graphics g) { + super.paintBorder(g); + + paintSeparator((Graphics2D) g); + } + + private void paintSeparator(Graphics2D g2d) { + Border border = getBorder(); + if (border instanceof LineBorder && titlePane != null) { + Border containerBorder = container.getBorder(); + Insets insets = containerBorder.getBorderInsets(container); + int y = titlePane.getHeight() + insets.top; + + Color oldColor = g2d.getColor(); + Stroke oldStroke = g2d.getStroke(); + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + Color lineColor = ((LineBorder) border).getLineColor(); + int thickness = ((LineBorder) border).getThickness(); + g2d.setColor(lineColor); + g2d.setStroke(new BasicStroke(thickness * 2)); + g2d.drawLine(0, y, getWidth(), y); + + g2d.setStroke(oldStroke); + g2d.setColor(oldColor); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + } + } + @Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; @@ -144,7 +175,6 @@ public abstract class ComponentPreviewPane extends UINoOpaquePanel implements Th data.setInsetImagePadding(titlePacker.getInsetImagePadding()); data.setInsetRelativeTextLeft(titlePacker.isInsetRelativeTextLeft()); data.setInsetRelativeTextRight(titlePacker.isInsetRelativeTextRight()); - this.setBorder(new BottomLineBorder(componentStyle.getStyle().getColor(), componentStyle.getStyle().getBorder())); } public Label getData(){ @@ -172,31 +202,6 @@ public abstract class ComponentPreviewPane extends UINoOpaquePanel implements Th } - public static class BottomLineBorder extends LineBorder { - - private BottomLineBorder(Color color, int thickness) { - super(color, thickness); - } - - @Override - public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - Graphics2D g2d = (Graphics2D) g; - - Color oldColor = g2d.getColor(); - Stroke oldStroke = g2d.getStroke(); - - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - g2d.setColor(getLineColor()); - g2d.setStroke(new BasicStroke(getThickness() * 2)); - g2d.drawLine(0, height, width, height); - - g2d.setStroke(oldStroke); - g2d.setColor(oldColor); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - } - private static class Utils { private static void paintBackground(Graphics2D g2d, Background background, Shape shape, float opacity) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index 60434f2cb8..f99864c629 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -273,12 +273,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ parentCreator.setBorder(border); // 容器绘制完整边框 bodyCreator.setBorder(BorderFactory.createEmptyBorder()); // body不绘制边框 - titleCreator.setBorder(BorderFactory.createEmptyBorder()); // title绘制底部边框 - if (border instanceof LineBorder) { - Color color = ((LineBorder) border).getLineColor(); - int thickness = ((LineBorder) border).getThickness(); - titleCreator.setBorder(new BottomLineBorder(color, thickness)); - } + titleCreator.setBorder(BorderFactory.createEmptyBorder()); // title不绘制边框 if (bodyCreator instanceof XBorderStyleWidgetCreator) { XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyCreator; @@ -407,32 +402,6 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } - // 适用于标题栏的底部边框 - public static class BottomLineBorder extends LineBorder { - - private BottomLineBorder(Color color, int thickness) { - super(color, thickness); - } - - @Override - public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - Graphics2D g2d = (Graphics2D)g; - - Color oldColor = g2d.getColor(); - Stroke oldStroke = g2d.getStroke(); - - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - g2d.setColor(getLineColor()); - g2d.setStroke(new BasicStroke(getThickness() * 2)); - g2d.drawLine(0, height, width, height); - - g2d.setStroke(oldStroke); - g2d.setColor(oldColor); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - } - public static class NoBackgroundPaneUI extends BasicPanelUI { @Override public void update(Graphics g, JComponent c) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index 7655095b18..d4757c184a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java @@ -15,6 +15,8 @@ import com.fr.form.ui.container.WTitleLayout; import com.fr.general.Background; import com.fr.general.ComparatorUtils; +import javax.swing.border.Border; +import javax.swing.border.LineBorder; import java.awt.*; import java.awt.event.ContainerEvent; import java.awt.geom.Rectangle2D; @@ -187,6 +189,37 @@ public class XWTitleLayout extends DedicateLayoutContainer { } + @Override + protected void paintBorder(Graphics g) { + super.paintBorder(g); + paintSeparator((Graphics2D) g); + } + + private void paintSeparator(Graphics2D g2d) { + Border border = getBorder(); + XCreator titleCreator = getTitleCreator(); + if (border instanceof LineBorder && titleCreator != null) { + int height = titleCreator.getHeight(); + Insets paddingInsets = getInsets(); + int y = height + paddingInsets.top; + + Color oldColor = g2d.getColor(); + Stroke oldStroke = g2d.getStroke(); + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + Color lineColor = ((LineBorder) border).getLineColor(); + int thickness = ((LineBorder) border).getThickness(); + g2d.setColor(lineColor); + g2d.setStroke(new BasicStroke(thickness * 2)); + g2d.drawLine(0, y, getWidth(), y); + + g2d.setStroke(oldStroke); + g2d.setColor(oldColor); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + } + } + @Override public void paintBackground(Graphics2D g2d) { if (getComponentCount() > 1) {