From 6aea867c867ff43ba59f4cae4d52c6114bf38739 Mon Sep 17 00:00:00 2001 From: WeiYanglu Date: Sun, 24 Jul 2022 23:33:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-75752=20=E8=A1=A8=E6=A0=BC=E8=BE=85?= =?UTF-8?q?=E5=8A=A9=E7=BA=BF=E7=9A=84=E5=8A=9F=E8=83=BD=E4=BB=8Efrm?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=88=B0dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JDashboard.java | 6 ++++ .../java/com/fr/design/utils/ColorUtils.java | 11 +++++++ .../java/com/fr/design/mainframe/JForm.java | 29 +++++++++++++++---- .../form/FormElementCasePaneDelegate.java | 23 ++------------- .../src/main/java/com/fr/grid/GridUI.java | 16 ++++++---- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JDashboard.java b/designer-base/src/main/java/com/fr/design/mainframe/JDashboard.java index d2b45f4ea1..e4e4e9be93 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JDashboard.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JDashboard.java @@ -1,5 +1,9 @@ package com.fr.design.mainframe; +import com.fr.report.worksheet.FormElementCase; + +import java.awt.Rectangle; + /** * @author Starryi * @version 1.0 @@ -7,4 +11,6 @@ package com.fr.design.mainframe; */ public interface JDashboard { void switchToDashBoardEditor(); + + Rectangle getElementCaseRectangle(FormElementCase elementCase); } diff --git a/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java b/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java index 739d394720..7c0daa111f 100644 --- a/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java @@ -27,4 +27,15 @@ public class ColorUtils { } } } + + public static boolean isDarkColor(Color color) { + if(color == null) { + return false; + } + int red = color.getRed(); + int green = color.getGreen(); + int blue = color.getBlue(); + int greyLevel = (int)(red * 0.299 + green * 0.587 + blue * 0.114); + return greyLevel < 192; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index b58932c8a7..a142ee297c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -41,6 +41,7 @@ import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fit.FormFitAttrAction; +import com.fr.design.fit.common.FormDesignerUtil; import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; @@ -109,12 +110,7 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.tree.TreePath; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; @@ -1307,4 +1303,25 @@ public class JForm extends JTemplate implements BaseJForm template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (!(template instanceof JForm)) { - return rectangle; + if (!(template instanceof JDashboard)) { + return new Rectangle(); } - - FormDesigner designer = ((JForm) template).getFormDesign(); - if (designer == null) { - return rectangle; - } - - XElementCase xElementCase = FormDesignerUtil.getXelementCase(designer.getRootComponent(), (FormElementCase) elementCase); - if (xElementCase != null) { - rectangle.setBounds(xElementCase.getBounds()); - - //减去内边距的宽和高 - Insets insets = xElementCase.getInsets(); - rectangle.width -= insets.left + insets.right; - rectangle.height -= insets.top + insets.bottom; - - } - return rectangle; + return ((JDashboard)template).getElementCaseRectangle((FormElementCase)elementCase); } diff --git a/designer-realize/src/main/java/com/fr/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index 6234acc953..7ae22a51fa 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -18,6 +18,7 @@ import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; import com.fr.design.roleAuthority.ReportAndFSManagePane; +import com.fr.design.utils.ColorUtils; import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils; import com.fr.general.Background; import com.fr.general.ComparatorUtils; @@ -1196,13 +1197,13 @@ public class GridUI extends ComponentUI { } //绘制吸附辅助线 - paintAdsorbLines(g2d, grid); + paintAdsorbLines(g2d, grid, elementCase); grid.ajustEditorComponentBounds(); // refresh size } //绘制吸附辅助线 - private void paintAdsorbLines(Graphics2D g2d, Grid grid) { + private void paintAdsorbLines(Graphics2D g2d, Grid grid, TemplateElementCase elementcase) { int verticalValue = grid.getVerticalValue(); int horizontalValue = grid.getHorizontalValue(); if (grid.getAdsorbWidth() <= 0 || grid.getAdsorbHeight() <= 0) { @@ -1212,13 +1213,18 @@ public class GridUI extends ComponentUI { - columnWidthList.getRangeValue(0, horizontalValue).toPixI(resolution)); int height = (int) (grid.getAdsorbHeight() * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution()) - rowHeightList.getRangeValue(0, verticalValue).toPixI(resolution)); - drawBoundsLine(g2d, width, height); + drawBoundsLine(g2d, width, height, elementcase); } - private void drawBoundsLine(Graphics2D g2d, int width, int height) { + private void drawBoundsLine(Graphics2D g2d, int width, int height, TemplateElementCase elementcase) { Paint oldPaint = g2d.getPaint(); Stroke oldStroke = g2d.getStroke(); - g2d.setPaint(Color.black); + Color backgroundColor = AdjustWorkBookDefaultStyleUtils.adjustBack(Color.WHITE); + if(ColorUtils.isDarkColor(backgroundColor)) { + g2d.setPaint(Color.white); + } else { + g2d.setPaint(Color.black); + } g2d.setStroke(GraphDrawHelper.getStroke(Constants.LINE_DASH_DOT)); g2d.drawLine(0, height, width, height); g2d.drawLine(width, 0, width, height); From db53e128aa55149959a1ea0e077e173519d79930 Mon Sep 17 00:00:00 2001 From: WeiYanglu Date: Mon, 25 Jul 2022 13:33:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-75752=20=E5=85=BC=E5=AE=B9=E4=B8=8B?= =?UTF-8?q?=E6=97=A7=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/form/FormElementCasePaneDelegate.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java index b975a8b19b..525b3c0ca4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java @@ -76,7 +76,13 @@ public class FormElementCasePaneDelegate extends ElementCasePane