From c203418493a93177dcff78f7214fe5a044d8521f Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 15:06:29 +0800 Subject: [PATCH 01/13] =?UTF-8?q?REPORT-55715=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E9=A2=9C=E8=89=B2=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E5=92=8C=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=87=8C?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=9C=B0=E6=96=B9=E7=9A=84=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=E4=B8=8D=E5=A4=AA=E4=B8=80=E6=A0=B7?= =?UTF-8?q?=EF=BC=8C=E7=9C=8B=E8=B5=B7=E6=9D=A5=E6=9C=89=E7=82=B9=E5=A5=87?= =?UTF-8?q?=E6=80=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 修改边框颜色选择器类型,与单元格中的边框颜色选择器保持一致 【改动思路】 同上 --- .../design/gui/xpane/BorderLineAndImagePane.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java index 324213bc3..b25d66e30 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java @@ -26,6 +26,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.backgroundpane.ImagePreviewPane; import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.color.NewColorSelectBox; import com.fr.env.utils.DesignerInteractionHistory; import com.fr.form.ui.LayoutBorderStyle; import com.fr.general.Background; @@ -85,7 +86,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { private UIObserverListener uiObserverListener; private BorderLineAndImageComboBox borderLineCombo; - private UIColorButton borderColorPane; + private NewColorSelectBox borderColorPane; private ImagePreviewPane imagePreviewPane; private UIButton chooseImageButton; private UIButton tweakNinePointHelpButton; @@ -104,10 +105,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { private void initComponents() { borderLineCombo = new BorderLineAndImageComboBox(); - borderColorPane = new UIColorButton(null) {{ - setUI(createButtonUI(this)); - set4ToolbarButton(); - }}; + borderColorPane = new NewColorSelectBox(145); imagePreviewPane = new ImagePreviewPane() {{ setImageStyle(Style.DEFAULT_STYLE); }}; @@ -228,7 +226,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { getComponent(2).setVisible(borderLineCombo.isSelectedBorderImage()); if (!borderLineCombo.isSelectedBorderLine()) { - borderColorPane.setColor(Color.BLACK); + borderColorPane.setSelectObject(Color.BLACK); } if (!borderLineCombo.isSelectedBorderImage()) { imagePreviewPane.setImageWithSuffix(null); @@ -294,7 +292,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { Color borderColor = style.getColor(); this.borderLineCombo.setSelectedLineStyle(borderLine); - this.borderColorPane.setColor(borderColor); + this.borderColorPane.setSelectObject(borderColor); Background borderImage = style.getBorderImage(); if (borderImage instanceof ImageBackground) { @@ -332,13 +330,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { } this.borderLineCombo.setSelectedLineStyle(style.getBorder()); - this.borderColorPane.setColor(style.getColor()); + this.borderColorPane.setSelectObject(style.getColor()); } public void updateBean(LayoutBorderStyle style) { style.setBorder(this.borderLineCombo.getSelectedLineStyle()); - style.setColor(this.borderColorPane.getColor()); + style.setColor(this.borderColorPane.getSelectObject()); style.setBorderImage(null); if (this.borderLineCombo.isSelectedBorderImage()) { From ca6a506c5ab2562fe06b1cd494962d116ffc7d6a Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 16:02:04 +0800 Subject: [PATCH 02/13] =?UTF-8?q?REPORT-55658=20=E3=80=90=E7=A8=B3?= =?UTF-8?q?=E5=AE=9A=E5=85=B1=E5=88=9B=E3=80=91=E7=BB=84=E4=BB=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE-=E5=9B=BE=E8=A1=A8=E5=9D=97=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E5=9B=BE=E6=A1=88-=E5=88=A0=E9=99=A4=E5=90=8E=E5=86=8D?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 点击删除按钮后,删除按钮,遮罩层都是visible,只是父布局不可见了,导致 下次选中图片后,就直接出现了删除按钮和遮罩层 【改动思路】 点击删除按钮时,隐藏遮罩层和删除按钮 --- .../design/gui/xpane/TitleInsetImagePane.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java index 6b5391fb1..48d1028e6 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java @@ -57,6 +57,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { private UIButton imageChooseButton; private UIButton imageDeleteButton; private ImagePreviewPane imagePreviewPane; + private JPanel imagePreviewOverlayPane; private UIButtonGroup imageLocationPane; private UISpinner imagePaddingPane; @@ -89,24 +90,24 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { deletableImagePreviewPane.setLayout(null); deletableImagePreviewPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); deletableImagePreviewPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE)); - JPanel overlayPane = new JPanel(); - overlayPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2)); - overlayPane.setBackground(IMAGE_PREVIEW_OVERLAY_COLOR); + imagePreviewOverlayPane = new JPanel(); + imagePreviewOverlayPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2)); + imagePreviewOverlayPane.setBackground(IMAGE_PREVIEW_OVERLAY_COLOR); imagePreviewPane.setBounds(0, 0, IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE); - overlayPane.setBounds(1, 1, IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2); + imagePreviewOverlayPane.setBounds(1, 1, IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2); imageDeleteButton.setBounds(IMAGE_PREVIEW_SIZE - DELETE_BUTTON_SIZE, 0, DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE); deletableImagePreviewPane.add(imageDeleteButton, 0); - deletableImagePreviewPane.add(overlayPane, 1); + deletableImagePreviewPane.add(imagePreviewOverlayPane, 1); deletableImagePreviewPane.add(imagePreviewPane, 2); - overlayPane.setVisible(false); + imagePreviewOverlayPane.setVisible(false); imageDeleteButton.setVisible(false); imageDeleteButton.setEnabled(false); deletableImagePreviewPane.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { super.mouseEntered(e); - overlayPane.setVisible(true); + imagePreviewOverlayPane.setVisible(true); imageDeleteButton.setVisible(true); imageDeleteButton.setEnabled(true); } @@ -117,7 +118,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { int x = e.getX(); int y = e.getY(); if (x <= 0 || getWidth() <= x || y <= 0 || y >= getHeight()) { - overlayPane.setVisible(false); + imagePreviewOverlayPane.setVisible(false); imageDeleteButton.setVisible(false); imageDeleteButton.setEnabled(false); } @@ -216,6 +217,9 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { imagePreviewPane.setImageWithSuffix(null); imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX); imagePaddingPane.setValue(DEFAULT_INSET_PADDING); + imagePreviewOverlayPane.setVisible(false); + imageDeleteButton.setVisible(false); + imageDeleteButton.setEnabled(false); getComponent(1).setVisible(false); fireStateChanged(); From 6c47174cddde33f6315c5f32f753163b0c26a559 Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 18:52:18 +0800 Subject: [PATCH 03/13] =?UTF-8?q?REPORT-55719=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E6=8A=A5=E8=A1=A8=E5=9D=97?= =?UTF-8?q?=E5=9C=A8=E7=94=BB=E5=B8=83=E5=86=85=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20REPORT-55737=20=E3=80=90=E7=BB=84=E4=BB=B6=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84=E4=BB=B6=E5=A4=8D?= =?UTF-8?q?=E7=94=A8-=E4=B8=BB=E4=BD=93=E8=83=8C=E6=99=AF=E9=81=AE?= =?UTF-8?q?=E6=8C=A1=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 设计器端无法预览边框点九图的效果 2. 由XTitleLayout绘制的边框图片,会被BodyWidget负责绘制的背景遮挡 【改动思路】 1. 实现点九图的绘制和设计器端画布上的预览 2. 点九图的绘制需要对原始图片进行切割,分别缩放绘制, 耗时较长,因此考虑在点九图分割位置变化时 进行子图的创建,从而提高性能 2. 背景由XWTitleLayout负责绘制,但需要向下偏移标题栏的高度,以满足兼容性要求 --- .../creator/XBorderStyleWidgetCreator.java | 88 ++++++++++++++++--- 1 file changed, 77 insertions(+), 11 deletions(-) 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 645f38706..158712658 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 @@ -35,6 +35,9 @@ import java.awt.geom.RoundRectangle2D; public class XBorderStyleWidgetCreator extends XWidgetCreator{ protected static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150); protected Background background4Painting; // 设计器预览界面中绘制组件背景图 + protected double backgroundOpacity4Painting; // 设计器预览界面中绘制组件背景图 + protected Background borderImage4Painting; // 设计器预览界面中绘制边框图片 + protected double borderImageOpacity4Painting; public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { super(widget, initSize); @@ -54,6 +57,30 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ this.repaint(); } + public double getBackgroundOpacity4Painting() { + return backgroundOpacity4Painting; + } + + public void setBackgroundOpacity4Painting(double backgroundOpacity4Painting) { + this.backgroundOpacity4Painting = backgroundOpacity4Painting; + } + + public Background getBorderImage4Painting() { + return borderImage4Painting; + } + + public void setBorderImage4Painting(Background borderImage4Painting) { + this.borderImage4Painting = borderImage4Painting; + } + + public double getBorderImageOpacity4Painting() { + return borderImageOpacity4Painting; + } + + public void setBorderImageOpacity4Painting(double borderImageOpacity4Painting) { + this.borderImageOpacity4Painting = borderImageOpacity4Painting; + } + /** * 返回容器对应的widget * @return 同上 @@ -102,8 +129,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } this.setBorder(border); + this.setBorderImage4Painting(style != null ? style.getBorderImage() : null); + this.setBorderImageOpacity4Painting(style != null ? style.getBorderImageOpacity() : 0.0); this.setBackground4Painting(style != null ? style.getBackground() : null); + this.setBackgroundOpacity4Painting(style != null ? style.getAlpha() : 0.0); } private void clearTitleWidget() { @@ -194,14 +224,27 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ titleCreator.setBorder(new BottomLineBorder(color, thickness)); } - // 主体背景的生效范围暂时保持原样,不作用于包含标题区域的整体范围内 -// if (bodyXCreator instanceof XBorderStyleWidgetCreator) { -// XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator; -// Background background4Painting = styledBodyXCreator.getBackground4Painting(); -// -// styledBodyXCreator.setBackground4Painting(null); // body不绘制背景 -// titleParent.setBackground4Painting(background4Painting); // 容器绘制完整背景 -// } + if (bodyXCreator instanceof XBorderStyleWidgetCreator) { + XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator; + Background borderImage4Painting = styledBodyXCreator.getBorderImage4Painting(); + double opacity = styledBodyXCreator.getBorderImageOpacity4Painting(); + + styledBodyXCreator.setBorderImage4Painting(null); // body不绘制图片边框 + styledBodyXCreator.setBorderImageOpacity4Painting(0.0); + titleParent.setBorderImage4Painting(borderImage4Painting); // 容器绘制完整图片边框 + titleParent.setBorderImageOpacity4Painting(opacity); + } + + if (bodyXCreator instanceof XBorderStyleWidgetCreator) { + XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator; + Background background4Painting = styledBodyXCreator.getBackground4Painting(); + double opacity = styledBodyXCreator.getBackgroundOpacity4Painting(); + + styledBodyXCreator.setBackground4Painting(null); // body不绘制背景 + styledBodyXCreator.setBackgroundOpacity4Painting(0.0); + titleParent.setBackground4Painting(background4Painting); // 容器绘制完整背景 + titleParent.setBackgroundOpacity4Painting(opacity); + } } } } @@ -226,10 +269,32 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ public void paintBackground(Graphics2D g2d) { Background background4Painting = getBackground4Painting(); if (background4Painting != null) { - BorderPacker style = toData().getBorderStyle(); Composite oldComposite = g2d.getComposite(); - g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, style.getAlpha())); - background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight())); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) backgroundOpacity4Painting)); + + Shape shape = new Rectangle2D.Double(0, 0, getWidth(), getHeight()); + if (this instanceof XWTitleLayout) { + // 兼容性考虑,组件样式背景不作用在标题范围内,只作用在控件整体,但同时不能遮挡作用于整体的边框图片 + // 所以考虑样式背景与边框图片都由XWTitleLayout绘制,但样式背景要向下偏移标题栏的高度 + XWTitleLayout titleParent = (XWTitleLayout) this; + if (getComponentCount() > 1) { + XCreator titleCreator = titleParent.getTitleCreator(); + int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0; + shape = new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight); + } + } + background4Painting.paint(g2d, shape); + + g2d.setComposite(oldComposite); + } + } + + public void paintBorderImage(Graphics2D g2d) { + Background borderImage4Painting = getBorderImage4Painting(); + if (borderImage4Painting != null) { + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) borderImageOpacity4Painting)); + borderImage4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight())); g2d.setComposite(oldComposite); } } @@ -243,6 +308,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ public void paint(Graphics g) { this.clipByRoundedBorder((Graphics2D) g); this.paintBackground((Graphics2D) g); + this.paintBorderImage((Graphics2D) g); this.paintForeground((Graphics2D) g); } From 1141caecc2024ad931054833c66e48291661162a Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 18:54:23 +0800 Subject: [PATCH 04/13] =?UTF-8?q?REPORT-55669=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E7=BA=BF=E5=9E=8B=E8=BE=B9?= =?UTF-8?q?=E6=A1=86=E5=9C=A8=E8=AE=BE=E8=AE=A1=E7=94=BB=E5=B8=83=E9=87=8C?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=9C=8B=E5=88=B0=EF=BC=8C=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E5=92=8C=E7=BB=84=E4=BB=B6=E5=86=85=E5=AE=B9=E4=B9=8B=E9=97=B4?= =?UTF-8?q?=E6=98=AF=E6=9C=89=E6=98=BE=E7=A4=BA=E8=BE=B9=E6=A1=86=E7=BA=BF?= =?UTF-8?q?=E7=9A=84=EF=BC=8C=E4=BD=86=E6=98=AF=E9=A2=84=E8=A7=88=E6=97=B6?= =?UTF-8?q?=E8=BF=99=E9=87=8C=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA=E8=BE=B9?= =?UTF-8?q?=E6=A1=86=E7=BA=BF=EF=BC=8C=E4=B8=8D=E7=AC=A6=E5=90=88=E6=89=80?= =?UTF-8?q?=E8=A7=81=E5=8D=B3=E6=89=80=E5=BE=97=EF=BC=8C=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E7=9C=8B=E4=B8=8B=E9=A2=84=E6=9C=9F=E6=98=AF=E4=BB=80=E4=B9=88?= =?UTF-8?q?=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 标题栏下边框过细,在windows端不显示 【改动思路】 按照LineBorder原始内部实现,线宽size应该是thickness的两倍,所以绘制线时乘2 --- .../fr/design/designer/creator/XBorderStyleWidgetCreator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 158712658..398dcc1f2 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 @@ -359,7 +359,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(getLineColor()); - g2d.setStroke(new BasicStroke(getThickness())); + g2d.setStroke(new BasicStroke(getThickness() * 2)); g2d.drawLine(0, height, width, height); g2d.setStroke(oldStroke); From 93f7fb7396b4b27c05dd2867709d1227b3b63bce Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 19:59:12 +0800 Subject: [PATCH 05/13] =?UTF-8?q?REPORT-55554=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-mac=E4=B8=8A=EF=BC=8C=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=A0=87=E9=A2=98=E7=9A=84=E9=BB=98=E8=AE=A4=E5=AD=97?= =?UTF-8?q?=E4=BD=93=20=E5=92=8C=20=E5=8D=95=E5=85=83=E6=A0=BC=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=AD=97=E4=BD=93=20=E4=B8=8D=E6=98=AF=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=AD=97=E4=BD=93=EF=BC=9Bwindows=E8=BF=99=E8=BE=B9?= =?UTF-8?q?=E6=98=AF=E4=B8=80=E8=87=B4=E7=9A=84=EF=BC=8C=E9=83=BD=E6=98=AF?= =?UTF-8?q?=E5=AE=8B=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 LayoutStyle中的默认标题字体确实和单元格的默认字体一致,但是字体控件的默认字体并不一致。 正常控件在拖拽到面板上是,会调用样式面板的LayoutStylePane.populate(LayoutBorderStyle) 方法,根据组件的样式数据,更新样式面板,所以最终样式面板中标题字体是和LayoutStyle中默认字体 一致,也就是和单元格默认字体一致。 但复用组件拖拽到面板上后,右侧栏实际上还是组件商城,需要点击一下右侧栏的组件设置按钮才能实例化 和初始化样式面板,就因为这点击了一下(设计器总体的问题,右侧栏的任何操作都被认为是UI发生了更新, 需要同步到数据模型),导致代码中调用了LayoutStylePane.update,从右侧栏的样式面板获取样式 数据,再设置到组件上,而右侧栏的字体控件默认值和单元格默认字体不一致,所以出现了问题。 【改动思路】 在字体控件实例化的时候,直接使用空的默认样式中的标题字体初始化它,保证UI和数据模型一致 --- .../java/com/fr/design/gui/xpane/LayoutStylePane.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java index c0ad60ad4..3144e572f 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java @@ -215,6 +215,15 @@ public class LayoutStylePane extends BasicBeanPane { titleTextPane = new TinyFormulaPane(); titleFontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + TitlePacker title = style.getTitle(); + if (title != null) { + FRFont frFont = title.getFrFont(); + if (frFont != null) { + String fontFamily = frFont.getFamily(); + // 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性 + this.titleFontFamilyComboBox.setSelectedItem(fontFamily); + } + } titleFontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family")); titleFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); From 006ae3f93654c74121787bf120021014d4ce1aa6 Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 20:34:47 +0800 Subject: [PATCH 06/13] =?UTF-8?q?REPORT-55715=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E9=A2=9C=E8=89=B2=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E5=92=8C=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=87=8C?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=9C=B0=E6=96=B9=E7=9A=84=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=E4=B8=8D=E5=A4=AA=E4=B8=80=E6=A0=B7?= =?UTF-8?q?=EF=BC=8C=E7=9C=8B=E8=B5=B7=E6=9D=A5=E6=9C=89=E7=82=B9=E5=A5=87?= =?UTF-8?q?=E6=80=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 新颜色选择框的右侧Button与UIComboBox右侧的Button风格不一致,导致视觉上开起来不和谐; 而且因为因为新颜色选择框右侧Button背景为白色边框为灰色,而UIComboBox边框和背景都为灰色, 所以即使给颜色选择框和UIComboBox相同的宽度,看起来也不没有对齐 【改动思路】 统一下颜色选择框的右侧按钮显示效果,保持与UIComboBox中右侧按钮一致 --- .../fr/design/style/AbstractSelectBox.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java b/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java index 8b727e099..1d66094f1 100644 --- a/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java +++ b/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java @@ -10,16 +10,20 @@ import java.awt.RenderingHints; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import javax.swing.AbstractButton; import javax.swing.JPanel; import javax.swing.border.AbstractBorder; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; +import javax.swing.plaf.ButtonUI; import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.stable.Constants; +import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.style.background.BackgroundJComponent; +import com.fr.stable.Constants; /** * @author kunsnat E-mail:kunsnat@gmail.com @@ -29,7 +33,7 @@ import com.fr.design.style.background.BackgroundJComponent; public abstract class AbstractSelectBox extends AbstractPopBox implements MouseListener { private static final long serialVersionUID = 2355250206956896774L; - private UIToggleButton triggleButton; + private UIButton triggleButton; protected void initBox(int preWidth) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -37,8 +41,34 @@ public abstract class AbstractSelectBox extends AbstractPopBox implements Mou displayComponent = new BackgroundJComponent(); displayComponent.setEmptyBackground(); displayComponent.setBorder(new TriggleLineBorder()); - triggleButton = new UIToggleButton(UIConstants.ARROW_DOWN_ICON); + triggleButton = new UIButton(UIConstants.ARROW_DOWN_ICON) { + public boolean shouldResponseChangeListener() { + return false; + } + + @Override + public ButtonUI getUI() { + return new UIButtonUI() { + @Override + protected boolean isPressed(AbstractButton b) { + return model.isArmed() && model.isPressed(); + } + + @Override + protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { + if (isPressed(b) && b.isPressedPainted()) { + GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), UIConstants.COMBOBOX_BTN_PRESS); + } else if (isRollOver(b)) { + GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_ROLLOVER); + } else if (b.isNormalPainted()) { + GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_NORMAL); + } + } + }; + } + }; triggleButton.setPreferredSize(new Dimension(20, 20)); + triggleButton.setRoundBorder(true, Constants.LEFT); JPanel displayPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); displayPane.add(displayComponent, BorderLayout.CENTER); From bd2f4287505d9668dc7f1f634ef13bc1b892f6f2 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 23 Jul 2021 22:53:41 +0800 Subject: [PATCH 07/13] =?UTF-8?q?REPORT-55228=20ctrl/shift=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E6=97=B6=E4=B8=8D=E5=87=BA=E7=8E=B0=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=20+=20=E8=80=81=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A0=8F=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/extra/PluginWebBridge.java | 2 ++ .../main/java/com/fr/design/mainframe/ComponentTree.java | 6 ++++++ .../java/com/fr/design/mainframe/EditingMouseListener.java | 2 +- .../java/com/fr/design/mainframe/FormCreatorDropTarget.java | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java index 93f8021d8..f45568641 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java @@ -399,6 +399,8 @@ public class PluginWebBridge { if (uiDialog != null) { uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); uiDialog.setVisible(false); + } + if (uiDialog == DesignerPluginContext.getPluginDialog()) { DesignerPluginContext.setPluginDialog(null); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 0c838b61e..f9a944091 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -408,6 +408,9 @@ public class ComponentTree extends JTree { @Override public void mouseReleased(MouseEvent e) { + if (e.isControlDown() || e.isShiftDown()) { + return; + } if (e.getButton() == MouseEvent.BUTTON1 && selectedCreator != null) { showSelectedPopup(selectedCreator); } @@ -426,6 +429,9 @@ public class ComponentTree extends JTree { * @param consumer */ private void onMouseEvent(final MouseEvent e, Consumer consumer) { + if (e.isControlDown() || e.isShiftDown()) { + return; + } Point p = e.getPoint(); // 解析组件树路径 获取选中的组件 int selRow = tree.getRowForLocation(p.x, p.y); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index c1d834fa9..4e44e134e 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -647,7 +647,7 @@ public class EditingMouseListener extends MouseInputAdapter { @Override public void run() { for (XCreator xCreator : xCreators) { - xCreator.setSelected(!e.isShiftDown()); + xCreator.setSelected(!e.isShiftDown() && !e.isControlDown()); } } }); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index d1aa9fc56..7a6a73f4b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -145,6 +145,11 @@ public class FormCreatorDropTarget extends DropTarget { tabDragInner.tryDragIn(); } else { Toolkit.getDefaultToolkit().beep(); + // 拖入失败 取消选中 + XCreator creator = addingModel.getXCreator(); + if (creator != null) { + creator.setSelected(false); + } } // 取消提示 designer.setPainter(null); From b24f4e92623a526f2862f26f532326a8705fcf0d Mon Sep 17 00:00:00 2001 From: Starryi Date: Sat, 24 Jul 2021 12:29:16 +0800 Subject: [PATCH 08/13] =?UTF-8?q?REPORT-55743=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E5=9C=A8=E6=96=B0jar=E4=B8=8B?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E7=9A=84=E6=8A=A5=E8=A1=A8=E5=9D=97=EF=BC=8C?= =?UTF-8?q?=E6=94=BE=E5=88=B0=E6=97=A7=E7=89=88=E6=9C=ACjar=E4=B8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=98=BE=E7=A4=BA=E9=BB=91=E8=89=B2?= =?UTF-8?q?=E7=BC=A9=E7=95=A5=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 新设计器要能在布局画布上预览背景图,所以报表块的缩略图要变成支持透明的, 但是创建的缩略图BufferImage的透明背景时(0, 0, 0, 0) 2. 旧设计器在从XML中读取缩略图时,只读取RGB数据,也就是只读取了(0, 0, 0), 所以显示了黑色 【改动思路】 新设计器创建的缩略图透明背景为(255, 255, 255, 1) --- .../mainframe/form/FormElementCaseDesigner.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index b2892e722..567345ff2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -39,14 +39,17 @@ import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.WorkSheet; +import javax.imageio.ImageIO; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JScrollBar; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Transparency; import java.awt.image.BufferedImage; +import java.io.File; /** * 表单中的ElementCase编辑面板 @@ -132,13 +135,22 @@ public class FormElementCaseDesigner int width = size.width; int height = size.height; - image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + // 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image, + // 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0) + // 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图 + image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = image.createGraphics(); // 创建一个支持透明背景的buffer image image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); g2d.dispose(); g2d = image.createGraphics(); + // 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image, + // 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0) + // 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图 + g2d.setColor(new Color(255, 255, 255, 1)); + g2d.fillRect(0, 0, (int) size.getWidth(), (int) size.getHeight()); + Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; if (grid != null) { boolean oldTranslucent = grid.isTranslucent(); @@ -148,6 +160,8 @@ public class FormElementCaseDesigner grid.setTranslucent(oldTranslucent); } + ImageIO.write(image, "png", new File("/Users/Starryi/test.png")); + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } From 796c285d8269a6074f190419ebaba3225a4c72c8 Mon Sep 17 00:00:00 2001 From: Starryi Date: Sat, 24 Jul 2021 15:59:57 +0800 Subject: [PATCH 09/13] =?UTF-8?q?EPORT-55747=20=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A4=8D=E7=94=A8-=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E6=95=88=E6=9E=9C=EF=BC=8C=E6=A0=87=E9=A2=98=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E9=81=AE=E6=8C=A1=E8=BE=B9=E6=A1=86=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 边框图片被标题背景遮挡。 标题背景由XLabel绘制,边框图片由XWTitleLayout绘制导致的 【改动思路】 1. 标题背景/主体背景/边框图片均由XWTitleLayout绘制 2. 整理下背景/边框绘制相关的接口 --- .../creator/XBorderStyleWidgetCreator.java | 119 +++++++++--------- .../fr/design/designer/creator/XLabel.java | 8 +- .../designer/creator/XWTitleLayout.java | 54 ++++++++ .../form/FormElementCaseDesigner.java | 4 - 4 files changed, 119 insertions(+), 66 deletions(-) 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 398dcc1f2..d17351f58 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 @@ -52,33 +52,26 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ return this.background4Painting; } - public void setBackground4Painting(Background background4Painting) { - this.background4Painting = background4Painting; - this.repaint(); - } - public double getBackgroundOpacity4Painting() { return backgroundOpacity4Painting; } - public void setBackgroundOpacity4Painting(double backgroundOpacity4Painting) { - this.backgroundOpacity4Painting = backgroundOpacity4Painting; + public void setBackground4Painting(Background background, double opacity) { + this.background4Painting = background; + this.backgroundOpacity4Painting = opacity; } public Background getBorderImage4Painting() { return borderImage4Painting; } - public void setBorderImage4Painting(Background borderImage4Painting) { - this.borderImage4Painting = borderImage4Painting; - } - public double getBorderImageOpacity4Painting() { return borderImageOpacity4Painting; } - public void setBorderImageOpacity4Painting(double borderImageOpacity4Painting) { - this.borderImageOpacity4Painting = borderImageOpacity4Painting; + public void setBorderImage4Painting(Background borderImage, double opacity) { + this.borderImage4Painting = borderImage; + this.borderImageOpacity4Painting = opacity; } /** @@ -129,11 +122,13 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } this.setBorder(border); - this.setBorderImage4Painting(style != null ? style.getBorderImage() : null); - this.setBorderImageOpacity4Painting(style != null ? style.getBorderImageOpacity() : 0.0); - - this.setBackground4Painting(style != null ? style.getBackground() : null); - this.setBackgroundOpacity4Painting(style != null ? style.getAlpha() : 0.0); + if (style != null) { + this.setBorderImage4Painting(style.getBorderImage(), style.getBorderImageOpacity()); + this.setBackground4Painting(style.getBackground(), style.getAlpha()); + } else { + this.setBorderImage4Painting(null, 0.0); + this.setBackground4Painting(null, 0.0); + } } private void clearTitleWidget() { @@ -213,42 +208,56 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ XCreator titleCreator = titleParent.getTitleCreator(); XCreator bodyXCreator = titleParent.getBodyCreator(); - Border border = bodyXCreator.getBorder(); - - titleParent.setBorder(border); // 容器绘制完整边框 - bodyXCreator.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)); - } - - if (bodyXCreator instanceof XBorderStyleWidgetCreator) { - XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator; - Background borderImage4Painting = styledBodyXCreator.getBorderImage4Painting(); - double opacity = styledBodyXCreator.getBorderImageOpacity4Painting(); - - styledBodyXCreator.setBorderImage4Painting(null); // body不绘制图片边框 - styledBodyXCreator.setBorderImageOpacity4Painting(0.0); - titleParent.setBorderImage4Painting(borderImage4Painting); // 容器绘制完整图片边框 - titleParent.setBorderImageOpacity4Painting(opacity); - } - - if (bodyXCreator instanceof XBorderStyleWidgetCreator) { - XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator; - Background background4Painting = styledBodyXCreator.getBackground4Painting(); - double opacity = styledBodyXCreator.getBackgroundOpacity4Painting(); - - styledBodyXCreator.setBackground4Painting(null); // body不绘制背景 - styledBodyXCreator.setBackgroundOpacity4Painting(0.0); - titleParent.setBackground4Painting(background4Painting); // 容器绘制完整背景 - titleParent.setBackgroundOpacity4Painting(opacity); - } + reshuffleBorderPaintingEffectIfTitleExists(titleParent, titleCreator, bodyXCreator); + reshuffleBackgroundPaintingEffectIfTitleExists(titleParent, titleCreator, bodyXCreator); } } } + private void reshuffleBorderPaintingEffectIfTitleExists(XWTitleLayout parentCreator, XCreator titleCreator, XCreator bodyCreator) { + Border border = bodyCreator.getBorder(); + + 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)); + } + + if (bodyCreator instanceof XBorderStyleWidgetCreator) { + XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyCreator; + Background borderImage= styledBodyXCreator.getBorderImage4Painting(); + double opacity = styledBodyXCreator.getBorderImageOpacity4Painting(); + + styledBodyXCreator.setBorderImage4Painting(null, 0.0); // body不绘制图片边框 + parentCreator.setBorderImage4Painting(borderImage, opacity); // 容器绘制完整图片边框 + } + } + + private void reshuffleBackgroundPaintingEffectIfTitleExists(XWTitleLayout parentCreator, XCreator titleCreator, XCreator bodyCreator) { + if (titleCreator instanceof XLabel) { + XLabel labelCreator = (XLabel) titleCreator; + Label titleLabel = labelCreator.toData(); + + Background background = titleLabel.getBackground(); + double opacity = titleLabel.getBackgroundOpacity(); + + labelCreator.setEnabledBackgroundPainting(false); // 标题不绘制背景 + parentCreator.setTitleBackground4Painting(background, opacity); // 容器绘制完整背景 + } + + if (bodyCreator instanceof XBorderStyleWidgetCreator) { + XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyCreator; + Background background = styledBodyXCreator.getBackground4Painting(); + double opacity = styledBodyXCreator.getBackgroundOpacity4Painting(); + + styledBodyXCreator.setBackground4Painting(null, 0.0); // body不绘制背景 + parentCreator.setBodyBackground4Painting(background, opacity); // 容器绘制完整背景 + } + } + // 根据当前组件边框裁剪内容,如果当前组件存在圆角,则应当按圆角裁剪内容 private void clipByRoundedBorder(Graphics2D g2d) { @@ -273,16 +282,6 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) backgroundOpacity4Painting)); Shape shape = new Rectangle2D.Double(0, 0, getWidth(), getHeight()); - if (this instanceof XWTitleLayout) { - // 兼容性考虑,组件样式背景不作用在标题范围内,只作用在控件整体,但同时不能遮挡作用于整体的边框图片 - // 所以考虑样式背景与边框图片都由XWTitleLayout绘制,但样式背景要向下偏移标题栏的高度 - XWTitleLayout titleParent = (XWTitleLayout) this; - if (getComponentCount() > 1) { - XCreator titleCreator = titleParent.getTitleCreator(); - int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0; - shape = new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight); - } - } background4Painting.paint(g2d, shape); g2d.setComposite(oldComposite); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java index 13358f2b2..3993c4daa 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java @@ -19,7 +19,6 @@ import com.fr.form.ui.Label; import com.fr.form.ui.container.WParameterLayout; import com.fr.general.Background; -import com.fr.general.act.BorderPacker; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; import com.fr.stable.core.PropertyChangeAdapter; @@ -36,11 +35,16 @@ import java.beans.IntrospectionException; public class XLabel extends XWidgetCreator { private int cornerSize = 15; + private boolean enabledBackgroundPainting = true; public XLabel(Label widget, Dimension initSize) { super(widget, initSize); } + public void setEnabledBackgroundPainting(boolean enable) { + this.enabledBackgroundPainting = enable; + } + /** * 生成creator对应的控件widget * @@ -93,7 +97,7 @@ public class XLabel extends XWidgetCreator { Dimension size = this.getSize(); //先画背景,再画标题 Background background = label.getBackground(); - if (background != null) { + if (background != null && enabledBackgroundPainting) { Graphics2D g2d = (Graphics2D) g; Composite oldComposite = g2d.getComposite(); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, label.getBackgroundOpacity())); 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 ba864e607..c04c93a38 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 @@ -12,10 +12,12 @@ import com.fr.form.ui.Widget; import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WTitleLayout; +import com.fr.general.Background; import com.fr.general.ComparatorUtils; import java.awt.*; import java.awt.event.ContainerEvent; +import java.awt.geom.Rectangle2D; /** * 一些控件 如图表、报表块,有标题设置,且标题的高度字体等不变 @@ -31,6 +33,11 @@ public class XWTitleLayout extends DedicateLayoutContainer { private static final int INDEX = 0; + protected Background titleBackground4Painting; // 设计器预览界面中绘制title背景图 + protected double titleBackgroundOpacity4Painting; + protected Background bodyBackground4Painting; // 设计器预览界面中绘制body背景图 + protected double bodyBackgroundOpacity4Painting; + public XWTitleLayout() { super(new WTitleLayout("titlePane"), new Dimension()); } @@ -45,6 +52,16 @@ public class XWTitleLayout extends DedicateLayoutContainer { super(widget, initSize); } + public void setTitleBackground4Painting(Background background, double opacity) { + this.titleBackground4Painting = background; + this.titleBackgroundOpacity4Painting = opacity; + } + + public void setBodyBackground4Painting(Background background, double opacity) { + this.bodyBackground4Painting = background; + this.bodyBackgroundOpacity4Painting = opacity; + } + @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); @@ -150,6 +167,43 @@ public class XWTitleLayout extends DedicateLayoutContainer { } + @Override + public void paintBackground(Graphics2D g2d) { + if (getComponentCount() > 1) { + paintTitleBackground(g2d); + paintBodyBackground(g2d); + } + } + + private void paintTitleBackground(Graphics2D g2d) { + if (titleBackground4Painting != null) { + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) this.titleBackgroundOpacity4Painting)); + XCreator titleCreator = getTitleCreator(); + int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0; + + Shape shape = new Rectangle2D.Double(0, 0, getWidth(), titleHeight); + titleBackground4Painting.paint(g2d, shape); + + g2d.setComposite(oldComposite); + } + } + + private void paintBodyBackground(Graphics2D g2d) { + if (bodyBackground4Painting != null) { + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) this.bodyBackgroundOpacity4Painting)); + + XCreator titleCreator = getTitleCreator(); + int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0; + // 兼容性考虑,组件样式背景不作用在标题范围内,只作用在控件整体,但同时不能遮挡作用于整体的边框图片 + // 所以考虑样式背景与边框图片都由XWTitleLayout绘制,但样式背景要向下偏移标题栏的高度 + Shape shape = new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight); + bodyBackground4Painting.paint(g2d, shape); + + g2d.setComposite(oldComposite); + } + } /** * 将WLayout转换为XLayoutContainer diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index 567345ff2..2dd3dbbb7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -39,7 +39,6 @@ import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.WorkSheet; -import javax.imageio.ImageIO; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JScrollBar; @@ -49,7 +48,6 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Transparency; import java.awt.image.BufferedImage; -import java.io.File; /** * 表单中的ElementCase编辑面板 @@ -160,8 +158,6 @@ public class FormElementCaseDesigner grid.setTranslucent(oldTranslucent); } - ImageIO.write(image, "png", new File("/Users/Starryi/test.png")); - } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } From e421a9dfe508acda372b3ab61ccd37f95b210a0f Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 24 Jul 2021 17:53:30 +0800 Subject: [PATCH 10/13] =?UTF-8?q?REPORT-55748=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E7=BB=84=E4=BB=B6=E6=82=AC?= =?UTF-8?q?=E6=B5=AE=E7=8A=B6=E6=80=81=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=93=9D=E8=89=B2=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/mainframe/CoverPane.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java b/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java index 6bafb317f..2c071a70b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java @@ -2,12 +2,13 @@ package com.fr.design.mainframe; import com.fr.base.GraphHelper; import com.fr.design.form.util.XCreatorConstants; -import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; import com.fr.general.IOUtils; import com.fr.stable.Constants; +import java.awt.BasicStroke; +import java.awt.Stroke; import javax.swing.JComponent; import java.awt.AlphaComposite; import java.awt.Color; @@ -32,6 +33,8 @@ public class CoverPane extends JComponent { protected static final int BORDER_WIDTH = 2; public static final int EDIT_BTN_W = 75; public static final int EDIT_BTN_H = 20; + private static final int BORDER_GAP = 2; + private static final BasicStroke BORDER_STROKE = new BasicStroke(2f); public static void paintEditButton(Graphics g, Component component) { int x = 0; @@ -82,6 +85,11 @@ public class CoverPane extends JComponent { g2d.setColor(XCreatorConstants.COVER_COLOR); g2d.fillRect(0, 0, component.getWidth(), component.getHeight()); g2d.setComposite(oldComposite); + g2d.setColor(XCreatorConstants.FORM_BORDER_COLOR); + Stroke oldStroke = g2d.getStroke(); + g2d.setStroke(BORDER_STROKE); + g2d.drawRect(BORDER_GAP, BORDER_GAP, component.getWidth() - BORDER_GAP * 2, component.getHeight() - BORDER_GAP * 2); + g2d.setStroke(oldStroke); } public CoverPane() { From 9de0d420d48693aefd9822fb9ef01345413f7b2e Mon Sep 17 00:00:00 2001 From: hades Date: Sun, 25 Jul 2021 13:20:04 +0800 Subject: [PATCH 11/13] =?UTF-8?q?REPORT-55753=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E5=B7=A5=E5=85=B7=E6=A0=8F?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA=E4=BD=8D=E7=BD=AE=E4=B8=8D=E8=B6=85?= =?UTF-8?q?=E8=BF=87=E7=BB=98=E5=88=B6=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/designer/creator/XCreator.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index dbc956c85..3b991d4a0 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -776,8 +776,13 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo if (popup == null) { popup = new SelectedPopupDialog(this, designer); } - int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale()); - int extraY = (int) (bounds.y * designer.getScale()); + int creatorRightX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale()); + int creatorRightY = (int) (bounds.y * designer.getScale()); + int formDesignerWidth = designer.getWidth(); + int formDesignerHeight = designer.getHeight(); + // 不超过可绘制区域 + int extraX = Math.min(creatorRightX, formDesignerWidth); + int extraY = creatorRightY < 0 ? 0 : Math.min(creatorRightY, formDesignerHeight); // 放到事件尾部执行 SwingUtilities.invokeLater(new Runnable() { @Override From ee9905dc20cd9824b826261e7b72d5a95cde71aa Mon Sep 17 00:00:00 2001 From: Starryi Date: Sun, 25 Jul 2021 18:41:06 +0800 Subject: [PATCH 12/13] =?UTF-8?q?REPORT-53175=20-=20=E3=80=9010.0.18?= =?UTF-8?q?=E3=80=91=E7=BB=84=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB?= =?UTF-8?q?=E4=B8=BA=E6=A0=87=E9=A2=98/=E8=83=8C=E6=99=AF/=E8=BE=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 修改组件样式面板分组标签头字体颜色 【改动思路】 同上 --- .../com/fr/design/gui/xpane/LayoutStylePane.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java index 3144e572f..518d272e8 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java @@ -138,8 +138,11 @@ public class LayoutStylePane extends BasicBeanPane { double[] rowSize = {p, p, p, p}; double[] columnSize = {SETTING_LABEL_WIDTH, f}; + UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")); + uiLabel.setForeground(new Color(143, 143, 146)); + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")), null}, + {uiLabel, null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, {this.borderLineAndImagePane, null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, @@ -168,8 +171,10 @@ public class LayoutStylePane extends BasicBeanPane { this.backgroundPane, this.backgroundOpacityPane); + UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")); + uiLabel.setForeground(new Color(143, 143, 146)); JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")), null}, + {uiLabel, null}, {bodyBackground, null}, }, rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); @@ -298,8 +303,10 @@ public class LayoutStylePane extends BasicBeanPane { visibleComposedPane.add(titleVisibleCheckbox, BorderLayout.WEST); visibleComposedPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); + UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")); + uiLabel.setForeground(new Color(143, 143, 146)); JPanel topPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] { - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")), null}, + {uiLabel, null}, {visibleComposedPane, null} }, new double[]{p, p}, new double[]{SETTING_LABEL_WIDTH, p}, IntervalConstants.INTERVAL_L1); topPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); From bf1240d40842bd84b0372758e9e4a8219f4785d6 Mon Sep 17 00:00:00 2001 From: Starryi Date: Sun, 25 Jul 2021 18:54:57 +0800 Subject: [PATCH 13/13] =?UTF-8?q?REPORT-53175=20-=20=E3=80=9010.0.18?= =?UTF-8?q?=E3=80=91=E7=BB=84=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB?= =?UTF-8?q?=E4=B8=BA=E6=A0=87=E9=A2=98/=E8=83=8C=E6=99=AF/=E8=BE=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 修改组件样式面板分组标签头字体颜色 【改动思路】 同上 --- .../main/java/com/fr/design/gui/xpane/LayoutStylePane.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java index 518d272e8..7c2094dd7 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java @@ -139,6 +139,8 @@ public class LayoutStylePane extends BasicBeanPane { double[] columnSize = {SETTING_LABEL_WIDTH, f}; UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")); + Font font = uiLabel.getFont().deriveFont(Font.BOLD); + uiLabel.setFont(font); uiLabel.setForeground(new Color(143, 143, 146)); JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ @@ -172,6 +174,8 @@ public class LayoutStylePane extends BasicBeanPane { this.backgroundOpacityPane); UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")); + Font font = uiLabel.getFont().deriveFont(Font.BOLD); + uiLabel.setFont(font); uiLabel.setForeground(new Color(143, 143, 146)); JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ {uiLabel, null}, @@ -304,6 +308,8 @@ public class LayoutStylePane extends BasicBeanPane { visibleComposedPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")); + Font font = uiLabel.getFont().deriveFont(Font.BOLD); + uiLabel.setFont(font); uiLabel.setForeground(new Color(143, 143, 146)); JPanel topPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] { {uiLabel, null},