From f934a2d15611b355b0fbe930057a8a2bc2d798cc Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 22 Jul 2021 16:54:02 +0800 Subject: [PATCH 01/12] =?UTF-8?q?REPORT-55689=20mac=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=96=B0=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=E4=B9=9F=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E6=8F=90=E7=A4=BA=E4=B8=8B=E6=9B=B4=E6=96=B0=E6=96=B0?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-base/src/main/java/com/fr/design/upm/UpmFinder.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index db0661b1f..f3284c11e 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -15,7 +15,6 @@ import com.fr.event.Listener; import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; -import com.fr.stable.os.OperatingSystem; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; @@ -32,7 +31,7 @@ public class UpmFinder { private static final String UPM_DIR = "/upm"; private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html"; - private static final String JXBROWSER = OperatingSystem.isWindows() ? "com.teamdev.jxbrowser.browser.Browser" : "com.teamdev.jxbrowser.chromium.Browser"; + private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser"; public static String installHome = FRContext.getCommonOperator().getWebRootPath(); From 52edf38baaaf0d8e00b7fd9ac10aa633f43c082d Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 22 Jul 2021 16:01:55 +0800 Subject: [PATCH 02/12] =?UTF-8?q?REPORT-55491=20=E3=80=90=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E9=AA=8C=E6=94=B6=E3=80=91=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=E5=9C=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=B1=9E=E6=80=A7=E4=B8=8B=E7=9A=84=E3=80=8C=E4=B8=BB?= =?UTF-8?q?=E4=BD=93=E8=83=8C=E6=99=AF=E3=80=8D=E8=AE=BE=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=EF=BC=8C=E7=9C=8B=E4=B8=8D=E5=88=B0=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 绘制报表块缩略图时,填充了白色背景,导致组件样式背景被覆盖 2. 优化报表块缩略图时,即在ElementCaseImage中截取部分缩略图时,丢弃了Alpha通道 3. 表单布局预览绘制表格缩略图时使用了默认的白色纸张背景(表单报表块的表格没有纸张背景的概念) 【改动思路】 1. 绘制报表块缩略图时,不要使用白色背景填充,保持透明 2. 优化报表块缩略图时,使用subImage完成截取功能,保留Alpha通道 3. 表单布局预览绘制表格缩略图时,忽略纸张背景 4. 替换默认的报表块预览图(此图用于将报表块拖拽到面板中时显示作为 报表块的缩略图使用),因此也要支持半透明 --- .../design/designer/creator/XElementCase.java | 8 +++--- .../form/FormElementCaseDesigner.java | 26 +++++++++++-------- .../src/main/java/com/fr/grid/Grid.java | 11 ++++++++ .../src/main/java/com/fr/grid/GridUI.java | 6 +++-- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java index 7ed22c52d..b5cc813ae 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java @@ -41,7 +41,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme static { try { - DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase.png"); + DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase_translucent.png"); } catch (Throwable e) { //IBM jdk 1.5.0_22 并发下读取图片有时会异常(EOFException), 这个图片反正只有设计器用到, 捕获住 DEFAULT_BACKGROUND = CoreGraphHelper.createBufferedImage(0, 0); @@ -183,7 +183,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme if (editor == null) { setBorder(DEFALUTBORDER); editor = new JPanel(); - editor.setBackground(null); + editor.setOpaque(false); + editor.setBackground(new Color(0, 0, 0, 0)); editor.setLayout(null); imageLable = initImageBackground(); @@ -218,7 +219,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme private void setLabelBackground(Image image, UILabel imageLable) { ImageIcon icon = new ImageIcon(image); imageLable.setIcon(icon); - imageLable.setOpaque(true); + imageLable.setOpaque(false); + imageLable.setBackground(new Color(0, 0, 0, 0)); imageLable.setLayout(null); imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); } 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 7af39737d..b2892e722 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 @@ -43,9 +43,9 @@ 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.Graphics; +import java.awt.Graphics2D; +import java.awt.Transparency; import java.awt.image.BufferedImage; /** @@ -129,19 +129,23 @@ public class FormElementCaseDesigner public BufferedImage getElementCaseImage(Dimension size) { BufferedImage image = null; try { - image = new java.awt.image.BufferedImage(size.width, size.height, - java.awt.image.BufferedImage.TYPE_INT_RGB); - Graphics g = image.getGraphics(); + int width = size.width; + int height = size.height; - //填充白色背景, 不然有黑框 - Color oldColor = g.getColor(); - g.setColor(Color.WHITE); - g.fillRect(0, 0, size.width, size.height); - g.setColor(oldColor); + image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = image.createGraphics(); + // 创建一个支持透明背景的buffer image + image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); + g2d.dispose(); + g2d = image.createGraphics(); Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; if (grid != null) { - grid.paintAll(g); + boolean oldTranslucent = grid.isTranslucent(); + // 截缩图图时grid需支持半透明,不能用默认白色填充画布,否则会遮挡组件样式背景 + grid.setTranslucent(true); + grid.paint(g2d); + grid.setTranslucent(oldTranslucent); } } catch (Exception e) { diff --git a/designer-realize/src/main/java/com/fr/grid/Grid.java b/designer-realize/src/main/java/com/fr/grid/Grid.java index abbd60928..b55f60bb5 100644 --- a/designer-realize/src/main/java/com/fr/grid/Grid.java +++ b/designer-realize/src/main/java/com/fr/grid/Grid.java @@ -134,6 +134,9 @@ public class Grid extends BaseGridComponent { private boolean needRequestFocus = true; + // 截取缩略图时需透明(不能用默认白色填充),否则会遮挡组件样式的背景,其余情况的绘制可以用白色等默认颜色填充 + private boolean isTranslucent = false; + public Grid(int resolution) { this.resolution = resolution; // 能触发processEvent,不管是否给component增加listener @@ -1458,4 +1461,12 @@ public class Grid extends BaseGridComponent { this.paginateLineShowType = paginateLineShowType; this.getElementCasePane().repaint(); } + + public boolean isTranslucent() { + return isTranslucent; + } + + public void setTranslucent(boolean translucent) { + isTranslucent = translucent; + } } 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 711ecee83..10934a7cc 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -1128,8 +1128,10 @@ public class GridUI extends ComponentUI { double realWidth = gridSize.getWidth();// 宽度 double realHeight = gridSize.getHeight();// 高度 - // 画背景 - this.paintBackground(g2d, grid, elementCase, resolution); + if (!grid.isTranslucent()) { + // 画背景 + this.paintBackground(g2d, grid, elementCase, resolution); + } // 画Grid Line this.paintGridLine(g2d, grid, elementCase, realWidth, realHeight, resolution); From 907cca3f83130780511bdb731c89592097a51a52 Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 22 Jul 2021 16:57:50 +0800 Subject: [PATCH 03/12] =?UTF-8?q?REPORT-55672=20=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E5=85=83=E7=B4=A0-=E6=96=B0=E5=BB=BA=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=B7=BB=E5=8A=A0=E7=9A=84=E6=82=AC?= =?UTF-8?q?=E6=B5=AE=E5=85=83=E7=B4=A0=E4=B8=8D=E8=83=BD=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 resizingBackupBounds仅在拖拽改变尺寸,光标改变时初始化,所以导致拖拽移动时,出现NPE 【改动思路】 resizingBackupBounds只在等比例尺寸缩放拖拽改变尺寸时需要 --- .../java/com/fr/grid/GridMouseAdapter.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index 0ae21bf4d..1cb3e6242 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -408,11 +408,11 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous int currentWidth = currentRight - currentLeft; int currentHeight = currentBottom - currentTop; - int backupWidth= resizingBackupBounds[2]; - int backupHeight= resizingBackupBounds[3]; - if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) { - if (aspectRatio) { + if (aspectRatio && resizingBackupBounds != null) { + int backupWidth= resizingBackupBounds[2]; + int backupHeight= resizingBackupBounds[3]; + double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2); double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2); @@ -452,7 +452,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous floatElement.setTopDistance(topDistance); floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu)); - if (aspectRatio) { + if (aspectRatio && resizingBackupBounds != null) { + int backupWidth= resizingBackupBounds[2]; + int backupHeight= resizingBackupBounds[3]; + currentWidth = backupWidth * currentHeight / backupHeight; currentRight = currentLeft + currentWidth; FU floatX1_fu = FU.valueOfPix(currentLeft, resolution); @@ -465,7 +468,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous floatElement.setLeftDistance(leftDistance); floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu)); - if (aspectRatio) { + if (aspectRatio && resizingBackupBounds != null) { + int backupWidth= resizingBackupBounds[2]; + int backupHeight= resizingBackupBounds[3]; + currentHeight = backupHeight * currentWidth / backupWidth; currentBottom = currentTop + currentHeight; FU floatY1_fu = FU.valueOfPix(currentTop, resolution); From 4145aa26f3b1c367cfb12e426747a9b409cf7269 Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 22 Jul 2021 20:03:22 +0800 Subject: [PATCH 04/12] =?UTF-8?q?REPORT-55694=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=8E=A7?= =?UTF-8?q?=E4=BB=B6=E9=94=81=E5=AE=9A=E6=97=B6=EF=BC=8C=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=8F=B3=E4=BE=A7=E8=AE=BE=E7=BD=AE=E9=9D=A2=E6=9D=BF=E5=85=88?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=BD=E5=BA=A6=E6=97=B6=EF=BC=8C=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E4=B8=8D=E5=8F=98=EF=BC=9B=E4=BD=86=E5=87=8F=E5=B0=8F?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E6=97=B6=EF=BC=8C=E9=AB=98=E5=BA=A6=E4=BC=9A?= =?UTF-8?q?1=E5=8D=95=E4=BD=8D1=E5=8D=95=E4=BD=8D=E5=87=8F=E5=B0=8F?= =?UTF-8?q?=EF=BC=8C=E6=9C=80=E5=90=8E=E7=BB=84=E4=BB=B6=E5=8F=98=E6=88=90?= =?UTF-8?q?=E4=B8=80=E6=9D=A1=E6=A8=AA=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 直接编辑宽度和高度,互相联动,存在小数舍入的问题,比如20.75,只取20,导致越来越小 2. 在锁定比例功能从未启动到启动时,需要保存尺寸比例,并持久化,否则再次打开模版后,原有的比例数据 就消失了 【改动思路】 1. WidgetBoundPane.java中widthSpinner和heightSpinner互相关联时, 使用Math.round取整,而不是直接取整数部分 2. 在启用比例锁定时,保存当前的aspectRatioBackup,除非关闭比例锁定,否则不更新改值 3. 高度或宽度为0时,取消比例锁定,避免出现除0问题 4. 绝对布局内组件移入移出时,重新计算锁定的尺寸比例 --- .../layout/FRAbsoluteLayoutAdapter.java | 7 ++ .../designer/creator/XWAbsoluteLayout.java | 18 ++++- .../design/designer/ui/PopupControlPanel.java | 13 +++- .../mainframe/FormCreatorDropTarget.java | 7 +- .../designer/component/WidgetBoundPane.java | 68 ++++++++++++------- 5 files changed, 87 insertions(+), 26 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index 4b3147c0a..e4426f61a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -9,6 +9,7 @@ import com.fr.design.designer.properties.BoundsGroupModel; import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; +import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -295,6 +296,12 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { */ @Override public void fix(XCreator creator) { + Widget widget = creator.toData(); + Rectangle bounds = creator.getBounds(); + if (widget != null && widget.isAspectRatioLocked() && (bounds.width == 0 || bounds.height == 0)) { + widget.setAspectRatioLocked(false); + widget.setAspectRatioBackup(-1.0); + } WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData(); fix(creator,creator.getX(),creator.getY()); wabs.setBounds(creator.toData(),creator.getBounds()); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index fdd62d1b0..44d1588df 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -386,7 +386,18 @@ public class XWAbsoluteLayout extends XLayoutContainer { if (!creator.acceptType(XWFitLayout.class)) { creator.setDirections(Direction.ALL); } - wabs.addWidget(new BoundsWidget(creator.toData(), creator.getBounds())); + Widget wgt = creator.toData(); + if (wgt != null && wgt.isAspectRatioLocked() && wgt.getAspectRatioBackup() <= 0) { + // 将比例锁定的组件重新移会绝对布局内时(如body修改绝对布局),尺寸比例可能失效,需要重新计算 + Rectangle bounds = creator.getBounds(); + if (bounds.width > 0 && bounds.height > 0) { + wgt.setAspectRatioBackup(1.0 * bounds.width / bounds.height); + } else { + wgt.setAspectRatioLocked(false); + wgt.setAspectRatioBackup(-1); + } + } + wabs.addWidget(new BoundsWidget(wgt, creator.getBounds())); } /** @@ -402,6 +413,11 @@ public class XWAbsoluteLayout extends XLayoutContainer { WAbsoluteLayout wlayout = this.toData(); XWidgetCreator xwc = ((XWidgetCreator) e.getChild()); Widget wgt = xwc.toData(); + + // 将比例锁定的组件重新移出绝对布局时(如body修改为自适应布局),锁定的尺寸比例失效 + if (wgt != null) { + wgt.setAspectRatioBackup(-1.0); + } BoundsWidget bw = new BoundsWidget(wgt, xwc.getBounds()); wlayout.removeWidget(bw); } diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java b/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java index ad003ff69..f806a72c0 100644 --- a/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java +++ b/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java @@ -13,6 +13,7 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; +import com.fr.form.ui.Widget; import com.fr.general.IOUtils; import com.fr.stable.ArrayUtils; @@ -94,7 +95,17 @@ public class PopupControlPanel extends JPanel { JToggleButton toggleBtn = (JToggleButton) e.getSource(); String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio"); toggleBtn.setToolTipText(toolTipText); - creator.toData().setAspectRatioLocked(toggleBtn.isSelected()); + Widget widget = creator.toData(); + if (widget != null) { + Rectangle bounds = new Rectangle(creator.getBounds()); + if (toggleBtn.isSelected() && bounds.width > 0 && bounds.height > 0) { + widget.setAspectRatioLocked(true); + widget.setAspectRatioBackup(1.0 * bounds.width / bounds.height); + } else { + widget.setAspectRatioLocked(false); + widget.setAspectRatioBackup(-1.0); + } + } designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RESIZED); } }); 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 11fa1dc3b..d1aa9fc56 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 @@ -112,7 +112,12 @@ public class FormCreatorDropTarget extends DropTarget { if (addingXCreator.isShared()) { if (container.acceptType(XWAbsoluteLayout.class)) { // 绝对布局中新添加的共享组件默认锁定尺寸比例 - addingXCreator.toData().setAspectRatioLocked(true); + Rectangle bounds = new Rectangle(addingXCreator.getBounds()); + Widget addingWidget = addingXCreator.toData(); + if (addingWidget != null && bounds.width > 0 && bounds.height > 0) { + addingXCreator.toData().setAspectRatioLocked(true); + addingXCreator.toData().setAspectRatioBackup(1.0 * bounds.width / bounds.height); + } } String shareId = addingXCreator.getShareId(); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java index d046a6a9e..2fdec31e1 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java @@ -103,14 +103,11 @@ public class WidgetBoundPane extends BasicPane { } public void populate() { - Rectangle bounds = new Rectangle(creator.getBounds()); - if (ratioLockedButton != null) { - // 临时禁止尺寸比例锁定,关掉widthSpinner/heightSpinner之间的数值关联,以更新其高度和宽度值 - ratioLockedButton.setLocked(false); - } - width.setValue(bounds.width); - height.setValue(bounds.height); - if (ratioLockedButton != null) { + if (ratioLockedButton == null) { + Rectangle bounds = new Rectangle(creator.getBounds()); + width.setValue(bounds.width); + height.setValue(bounds.height); + } else { ratioLockedButton.populate(creator); } } @@ -213,8 +210,7 @@ public class WidgetBoundPane extends BasicPane { private final UISpinner mWidthSpinner; private final UISpinner mHeightSpinner; - protected double width4Backup = 0; - protected double height4Backup = 0; + protected double aspectRatioBackup = 0; public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner) { setUI(new BasicButtonUI()); @@ -229,12 +225,16 @@ public class WidgetBoundPane extends BasicPane { addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // 改变图标icon - setLocked(!isLocked()); - - if (isLocked() && isLockEnabled()) { - width4Backup = mWidthSpinner.getValue(); - height4Backup = mHeightSpinner.getValue(); + double width = mWidthSpinner.getValue(); + double height = mHeightSpinner.getValue(); + boolean nextLocked = !isLocked(); + + if (nextLocked && width > 0 && height > 0) { + setLocked(true); + aspectRatioBackup = width / height; + } else { + setLocked(false); + aspectRatioBackup = -1; } if (globalNameListener != null) { @@ -250,16 +250,26 @@ public class WidgetBoundPane extends BasicPane { mWidthSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) { - mHeightSpinner.setValue(mWidthSpinner.getValue() * height4Backup / width4Backup, false); + if (isLockEnabled() && isLocked()) { + if (mWidthSpinner.getValue() == 0) { + setLocked(false); + aspectRatioBackup = -1; + } else if (aspectRatioBackup > 0) { + double value = mWidthSpinner.getValue() / aspectRatioBackup; + mHeightSpinner.setValue(Math.round(value), false); + } } } }); mHeightSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) { - mWidthSpinner.setValue(mHeightSpinner.getValue() * width4Backup / height4Backup, false); + if (isLockEnabled() && isLocked()) { + setLocked(false); + aspectRatioBackup = -1; + } else if (aspectRatioBackup > 0) { + double value = mHeightSpinner.getValue() * aspectRatioBackup; + mWidthSpinner.setValue(Math.round(value), false); } } }); @@ -301,14 +311,26 @@ public class WidgetBoundPane extends BasicPane { public void populate(XCreator creator) { Rectangle bounds = new Rectangle(creator.getBounds()); - width4Backup = bounds.width; - height4Backup = bounds.height; Widget widget = creator.toData(); + + aspectRatioBackup = widget.getAspectRatioBackup(); setLocked(widget.isAspectRatioLocked()); + + mWidthSpinner.setValue(bounds.width, false); + mHeightSpinner.setValue(bounds.height, false); } public void update(XCreator creator) { - creator.toData().setAspectRatioLocked(this.isLocked()); + Widget widget = creator.toData(); + if (widget != null) { + if (this.isLocked()) { + widget.setAspectRatioLocked(true); + widget.setAspectRatioBackup(this.aspectRatioBackup); + } else { + widget.setAspectRatioLocked(false); + widget.setAspectRatioBackup(-1.0); + } + } } @Override From ada963198322026d313a8ba21bfef5576b7ffd7d Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 01:50:34 +0800 Subject: [PATCH 05/12] =?UTF-8?q?REPORT-55491=20=E3=80=90=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E9=AA=8C=E6=94=B6=E3=80=91=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=E5=9C=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=B1=9E=E6=80=A7=E4=B8=8B=E7=9A=84=E3=80=8C=E4=B8=BB?= =?UTF-8?q?=E4=BD=93=E8=83=8C=E6=99=AF=E3=80=8D=E8=AE=BE=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=EF=BC=8C=E7=9C=8B=E4=B8=8D=E5=88=B0=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 绘制图表块时,填充了白色背景,导致组件样式背景被覆盖 2. 图表进入编辑模式下,ChartComponent被绘制两次,差 了一个像素,又因为ChartComponent支持半透明,导致出现了 重影 【改动思路】 1. 表单布局面板上预览报表块时,不使用白色背景填充,保持透明 2. DesignerEditor绘制Editor时,补充下差了的一个 像素(默认灰色边框) --- .../java/com/fr/design/chart/gui/ChartComponent.java | 12 +++++++----- .../design/designer/beans/events/DesignerEditor.java | 2 +- .../com/fr/design/designer/creator/XChartEditor.java | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index 1a5088a27..1ce2fbffd 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -43,6 +43,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene public ChartComponent() { super(); + setOpaque(true); addMouseListener(this); addMouseMotionListener(this); } @@ -148,11 +149,12 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false); Graphics2D g2d = (Graphics2D) g; - Paint oldPaint = g2d.getPaint(); - - g2d.setPaint(Color.WHITE); - g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height); - g2d.setPaint(oldPaint); + if (this.isOpaque()) { + Paint oldPaint = g2d.getPaint(); + g2d.setPaint(Color.WHITE); + g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height); + g2d.setPaint(oldPaint); + } g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2); diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java b/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java index f53f66d31..58f58c075 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java @@ -93,7 +93,7 @@ public class DesignerEditor implements PropertyChangeListe comp.setSize(new Dimension(width, height)); LayoutUtils.layoutContainer(comp); - comp.setBounds(comp.getX() + x, comp.getY() + y, width, height); + comp.setBounds(comp.getX() + x - 1, comp.getY() + y - 1, width, height); Graphics clipg = g.create(x, y, width, height); this.comp.paint(clipg); } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index 8633c0bd5..ad328b85e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -231,7 +231,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator { public void paintForeground(Graphics2D g) { Dimension size = getSize(); PaddingMargin margin = toData().getMargin(); + designerEditor.paintEditor(g, size, margin); + if (coverPanel != null) { int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0; int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0; @@ -289,6 +291,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection()); if (chartComponent != null) { JComponent jChart = chartComponent; + chartComponent.setOpaque(false); jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray)); designerEditor = new DesignerEditor(jChart); chartComponent.addStopEditingListener(designerEditor); From 5cd2c395b1c3a25c056e53391f69c51f0db398fe Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 23 Jul 2021 10:50:05 +0800 Subject: [PATCH 06/12] =?UTF-8?q?REPORT-55629=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=8E=A7=E4=BB=B6/=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=88=9A=E6=8B=96=E5=85=A5=E8=AE=BE=E8=AE=A1=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E6=97=B6=EF=BC=8C=E5=B7=A5=E5=85=B7=E6=A0=8F=E6=B2=A1?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=AE=8C=E5=85=A8=EF=BC=8C=E5=8F=AA=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BA=86=E4=B8=80=E6=9D=A1=E7=BA=BF=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E9=BC=A0=E6=A0=87=E7=9A=84=E8=AF=9D=E6=89=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/designer/creator/XCreator.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 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 fa9267b1a..185c834f7 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 @@ -33,6 +33,7 @@ import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.border.Border; import java.awt.BorderLayout; import java.awt.Color; @@ -776,10 +777,16 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale()); int extraY = (int) (bounds.y * designer.getScale()); - popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); - popup.updatePane(designer); - popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible()); - popup.setRelativeBounds(bounds); + // 放到事件尾部执行 + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); + popup.updatePane(designer); + popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible()); + popup.setRelativeBounds(bounds); + } + }); } /** From bace88981dd5994bbbe2e577617df973df797477 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 23 Jul 2021 10:50:53 +0800 Subject: [PATCH 07/12] =?UTF-8?q?REPORT-55228=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=81=B6=E7=8E=B0=EF=BC=8C?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A0=8F=E4=BC=9A=E7=95=99=E5=9C=A8=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E9=A1=B5=E9=9D=A2=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/PluginClassRefreshManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java b/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java index 4ff6beda2..9e1d57dfd 100644 --- a/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java +++ b/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java @@ -27,6 +27,8 @@ public class PluginClassRefreshManager { private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() { @Override public void on(PluginEvent event) { + // 重载模版之前 触发下hide + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); // 兼容之前版本特性 for (String tag : context) { if (event.getContext().contain(tag)) { @@ -51,6 +53,7 @@ public class PluginClassRefreshManager { public void on(PluginEvent event) { PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); } } From 888488b9e87cac871d90546cb9eb22acb63e9bf9 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 23 Jul 2021 12:53:13 +0800 Subject: [PATCH 08/12] =?UTF-8?q?REPORT-55492=20=E3=80=90=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E9=AA=8C=E6=94=B6=E3=80=91=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=91macos=E4=B8=AD?= =?UTF-8?q?=E5=B0=8F=E5=B7=A5=E5=85=B7=E6=A0=8F=E7=9A=84=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E6=B5=AE=E5=88=B0=E6=9C=80=E4=B8=8A=E9=9D=A2?= =?UTF-8?q?=E6=9D=A5=E4=BA=86=EF=BC=88=E5=BA=94=E8=AF=A5=E8=A2=ABdialog?= =?UTF-8?q?=E8=A6=86=E7=9B=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/mainframe/DesignerFrame.java | 6 ++++++ .../java/com/fr/design/designer/ui/SelectedPopupDialog.java | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 890b6fa04..b7bc51838 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -212,6 +212,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } + @Override + public void windowIconified(WindowEvent e) { + // 最小化时 hide工具栏 + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); + } + }; private JComponent closeButton = new JComponent() { diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java b/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java index 285bbc3b8..44978ad66 100644 --- a/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java +++ b/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java @@ -3,8 +3,11 @@ package com.fr.design.designer.ui; import com.fr.design.designer.creator.XCreator; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormDesigner; +import com.fr.stable.os.OperatingSystem; + import java.awt.Rectangle; import javax.swing.JDialog; +import javax.swing.JFrame; /** * @author hades @@ -23,7 +26,7 @@ public class SelectedPopupDialog extends JDialog { private boolean canVisible = true; public SelectedPopupDialog(XCreator creator, FormDesigner designer) { - super(DesignerContext.getDesignerFrame()); + super(OperatingSystem.isMacos() ? new JFrame() : DesignerContext.getDesignerFrame()); this.setUndecorated(true); this.setModal(false); this.setFocusableWindowState(false); From f90fa77a28952cb376743015b3edf260096a71b6 Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 13:01:11 +0800 Subject: [PATCH 09/12] =?UTF-8?q?REPORT-55553=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=8E=B0=E5=9C=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=8F=B3=E4=BE=A7=E8=AE=BE=E7=BD=AE=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E7=9A=84=E5=B1=82=E6=AC=A1=E6=95=88=E6=9E=9C=E5=92=8C=E8=A7=86?= =?UTF-8?q?=E8=A7=89=E7=A8=BF=E4=B8=8D=E4=B8=80=E6=A0=B7=EF=BC=8C=E5=B1=82?= =?UTF-8?q?=E6=AC=A1=E9=97=B4=E9=9A=94=E4=B8=8D=E6=B8=85=E6=99=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1.windows上边框线没显示出来 2.变动下层级结构,突出背景只作用于控件主体 【改动思路】 1. 绘制边框线时,边框线的大小应该是thickness的2倍 2. 修改Body样式面板的效果,去除多余的文字标签 3. 修改层级结构 --- .../fr/design/gui/xpane/LayoutStylePane.java | 89 +++++++++++++------ 1 file changed, 63 insertions(+), 26 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 81ce5fa7e..c0ad60ad4 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 @@ -1,10 +1,8 @@ package com.fr.design.gui.xpane; -import com.fr.base.GraphHelper; import com.fr.base.Utils; import com.fr.base.svg.IconUtils; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.constants.UIConstants; import com.fr.design.designer.IntervalConstants; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.formula.TinyFormulaPane; @@ -13,7 +11,6 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; @@ -105,42 +102,46 @@ public class LayoutStylePane extends BasicBeanPane { boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); JPanel titlePane = createTitleStylePane(); + JPanel bodyContentPane = currentIsRootLayout ? createBodyContentPane4RootLayout() : createBodyContentPane(); + JPanel backgroundPane = createBackgroundStylePane(); + if (titlePane != null) { container.add(titlePane, BorderLayout.NORTH); if (currentIsRootLayout) { titlePane.setVisible(false); } } + JPanel nextContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.add(nextContainerPane, BorderLayout.CENTER); - //界面上表单主体只有背景和透明度可以设置 - JPanel mainStylePane = currentIsRootLayout ? createMainStylePane4RootLayout() : createMainStylePane4WidgetLayout(); - if (mainStylePane != null) { - container.add(mainStylePane, BorderLayout.CENTER); + if (bodyContentPane != null) { + //界面上表单主体只有背景和透明度可以设置 + nextContainerPane.add(bodyContentPane, BorderLayout.NORTH); + } + if (backgroundPane != null) { + nextContainerPane.add(backgroundPane, BorderLayout.CENTER); + if (currentIsRootLayout) { + backgroundPane.setVisible(false); + } } this.add(container, BorderLayout.CENTER); } - protected void initMainComponents() { + protected JPanel createBackgroundStylePane() { borderStyleCombo = new UIComboBox(BORDER_STYLE); borderLineAndImagePane = new BorderLineAndImagePane(); cornerSpinner = new UISpinner(0,1000,1,0); - backgroundPane = new LayoutBackgroundSpecialPane(); - backgroundOpacityPane = new UIPercentDragPane(); - } - protected JPanel createMainStylePane4WidgetLayout() { - initMainComponents(); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] rowSize = {p, p, p, p, p}; + double[] rowSize = {p, p, p, p}; double[] columnSize = {SETTING_LABEL_WIDTH, f}; JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")), null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, {this.borderLineAndImagePane, null}, - {this.createMainBackgroundAndOpacityPane(), null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, }, rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); @@ -153,16 +154,23 @@ public class LayoutStylePane extends BasicBeanPane { return container; } - protected JPanel createMainStylePane4RootLayout() { - initMainComponents(); + protected JPanel createBodyContentPane() { + backgroundPane = new LayoutBackgroundSpecialPane(); + backgroundOpacityPane = new UIPercentDragPane(); + double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] rowSize = {p, p}; double[] columnSize = {SETTING_LABEL_WIDTH, f}; + JPanel bodyBackground = createBackgroundAndOpacityPane( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"), + this.backgroundPane, + this.backgroundOpacityPane); + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, - {this.createMainBackgroundAndOpacityPane(), null}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")), null}, + {bodyBackground, null}, }, rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); @@ -174,11 +182,31 @@ public class LayoutStylePane extends BasicBeanPane { return container; } - protected JPanel createMainBackgroundAndOpacityPane() { - return createBackgroundAndOpacityPane( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background"), + protected JPanel createBodyContentPane4RootLayout() { + backgroundPane = new LayoutBackgroundSpecialPane(); + backgroundOpacityPane = new UIPercentDragPane(); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + JPanel bodyBackground = createBackgroundAndOpacityPane( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"), this.backgroundPane, this.backgroundOpacityPane); + + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + {bodyBackground, null}, + }, + rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setBorder(new BottomLineBorder()); + container.add(contentPane, BorderLayout.NORTH); + + return container; } protected void initTitleComponents() { @@ -489,16 +517,25 @@ public class LayoutStylePane extends BasicBeanPane { protected static class BottomLineBorder extends LineBorder { public BottomLineBorder() { - super(Color.lightGray, 1); + super(new Color(217, 218, 221), 1); } @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2d = (Graphics2D) g; + Color oldColor = g2d.getColor(); - g2d.setColor(this.lineColor); - GraphHelper.drawLine(g, 0, height, width, height, 1); + 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); } } From 2f0a6e485c7b444c28dfb22be7ada47cbcc5a73f Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 13:23:52 +0800 Subject: [PATCH 10/12] =?UTF-8?q?REPORT-55709=20frm=E4=B8=ADbody=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E8=AE=BE=E7=BD=AE=E4=BA=86=E8=83=8C=E6=99=AF=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E9=80=8F=E6=98=8E=E5=BA=A6=E8=AE=BE=E7=BD=AE0%?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=80=8F=E6=98=8E=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 绘制背景时没有考虑透明度 【改动思路】 绘制组件主体背景和标题背景时设置透明度 --- .../designer/creator/XBorderStyleWidgetCreator.java | 4 ++++ .../java/com/fr/design/designer/creator/XLabel.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 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 26d65cb5d..645f38706 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 @@ -226,7 +226,11 @@ 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(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 154091a29..13358f2b2 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,6 +19,7 @@ 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; @@ -91,8 +92,13 @@ public class XLabel extends XWidgetCreator { Label label = (Label) data; Dimension size = this.getSize(); //先画背景,再画标题 - if (toData().getBackground() != null) { - toData().getBackground().paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight())); + Background background = label.getBackground(); + if (background != null) { + Graphics2D g2d = (Graphics2D) g; + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, label.getBackgroundOpacity())); + background.paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight())); + g2d.setComposite(oldComposite); } if (label.getWidgetValue() != null) { Graphics2D g2d = (Graphics2D) g.create(); From e527377c5cd696b02b462aadab3ed27278e084c2 Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 13:43:01 +0800 Subject: [PATCH 11/12] =?UTF-8?q?REPORT-55694=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=8E=A7?= =?UTF-8?q?=E4=BB=B6=E9=94=81=E5=AE=9A=E6=97=B6=EF=BC=8C=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=8F=B3=E4=BE=A7=E8=AE=BE=E7=BD=AE=E9=9D=A2=E6=9D=BF=E5=85=88?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=BD=E5=BA=A6=E6=97=B6=EF=BC=8C=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E4=B8=8D=E5=8F=98=EF=BC=9B=E4=BD=86=E5=87=8F=E5=B0=8F?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E6=97=B6=EF=BC=8C=E9=AB=98=E5=BA=A6=E4=BC=9A?= =?UTF-8?q?1=E5=8D=95=E4=BD=8D1=E5=8D=95=E4=BD=8D=E5=87=8F=E5=B0=8F?= =?UTF-8?q?=EF=BC=8C=E6=9C=80=E5=90=8E=E7=BB=84=E4=BB=B6=E5=8F=98=E6=88=90?= =?UTF-8?q?=E4=B8=80=E6=9D=A1=E6=A8=AA=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 直接编辑宽度和高度,互相联动,存在小数舍入的问题,比如20.75,只取20,导致越来越小 2. 在锁定比例功能从未启动到启动时,需要保存尺寸比例,并持久化,否则再次打开模版后,原有的比例数据 就消失了 【改动思路】 1. WidgetBoundPane.java中widthSpinner和heightSpinner互相关联时, 使用Math.round取整,而不是直接取整数部分 2. 在启用比例锁定时,保存当前的aspectRatioBackup,除非关闭比例锁定,否则不更新改值 3. 高度或宽度为0时,取消比例锁定,避免出现除0问题 4. 绝对布局内组件移入移出时,重新计算锁定的尺寸比例 --- .../ui/designer/component/WidgetBoundPane.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java index 2fdec31e1..a462a8aed 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java @@ -265,11 +265,13 @@ public class WidgetBoundPane extends BasicPane { @Override public void stateChanged(ChangeEvent e) { if (isLockEnabled() && isLocked()) { - setLocked(false); - aspectRatioBackup = -1; - } else if (aspectRatioBackup > 0) { - double value = mHeightSpinner.getValue() * aspectRatioBackup; - mWidthSpinner.setValue(Math.round(value), false); + if (mHeightSpinner.getValue() == 0) { + setLocked(false); + aspectRatioBackup = -1; + }else if (aspectRatioBackup > 0) { + double value = mHeightSpinner.getValue() * aspectRatioBackup; + mWidthSpinner.setValue(Math.round(value), false); + } } } }); From a821024929f83bde6ee045b69f957359aa69bf18 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 23 Jul 2021 15:45:26 +0800 Subject: [PATCH 12/12] =?UTF-8?q?REPORT-55228=20=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E9=97=AE=E9=A2=98=20=20&&=20REPORT-55228=20=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E5=90=AF=E5=8A=A8=E5=BC=95=E5=AF=BC=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=B8=8E=E5=88=87=E6=8D=A2=E8=B4=A6=E5=8F=B7=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=20=E4=B9=9F=E8=A6=81=E6=8F=90=E7=A4=BA"=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9B=B8=E5=85=B3=E7=BB=84=E4=BB=B6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/login/DesignerLoginHelper.java | 4 +++- .../com/fr/design/login/DesignerLoginShowDialog.java | 2 ++ .../com/fr/design/login/guide/DesignerGuideHelper.java | 2 +- .../java/com/fr/design/designer/creator/XCreator.java | 10 +++++++++- .../com/fr/design/mainframe/EditingMouseListener.java | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java index 5da006fa7..2d2dd935d 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java @@ -6,6 +6,7 @@ import com.fr.design.extra.WebViewDlgHelper; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.os.impl.SupportOSImpl; +import com.fr.design.plugin.DesignerPluginContext; import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.general.GeneralContext; import java.awt.Dialog; @@ -25,7 +26,7 @@ import javax.swing.WindowConstants; public class DesignerLoginHelper { private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/login.html"; - private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser"; + private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser"; private static UIDialog dialog = null; @@ -91,6 +92,7 @@ public class DesignerLoginHelper { dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setVisible(false); dialog = null; + DesignerPluginContext.setPluginDialog(null); } } diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java index 031ec4941..53e4556e4 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java @@ -1,6 +1,7 @@ package com.fr.design.login; import com.fr.design.dialog.UIDialog; +import com.fr.design.plugin.DesignerPluginContext; import com.fr.design.utils.gui.GUICoreUtils; import java.awt.BorderLayout; import java.awt.Component; @@ -36,6 +37,7 @@ public class DesignerLoginShowDialog extends UIDialog { setSize(DEFAULT); GUICoreUtils.centerWindow(this); setResizable(false); + DesignerPluginContext.setPluginDialog(this); } @Override diff --git a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java index 92e417146..b3513bb6d 100644 --- a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java +++ b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java @@ -22,7 +22,7 @@ import javax.swing.WindowConstants; public class DesignerGuideHelper { private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/guide.html"; - private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser"; + private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser"; private static final long ONE_WEEK = 7 * 24 * 3600 * 1000L; private static final long ONE_MONTH = 30 * 24 * 3600 * 1000L; private static final long SIX_MONTH = 6 * ONE_MONTH; 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 185c834f7..dbc956c85 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 @@ -23,6 +23,7 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.plugin.DesignerPluginContext; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; @@ -783,12 +784,19 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo public void run() { popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); popup.updatePane(designer); - popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible()); + popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog()); popup.setRelativeBounds(bounds); } }); } + private boolean isShowPluginDialog() { + if (DesignerPluginContext.getPluginDialog() == null) { + return false; + } + return DesignerPluginContext.getPluginDialog().isVisible(); + } + /** * 创建右击弹出菜单 * 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 5cd045835..c1d834fa9 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(true); + xCreator.setSelected(!e.isShiftDown()); } } });