From 17534e63dc2efb7d965c8686e984f8667d3aad16 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 22 Sep 2020 16:55:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-39601=20=E5=9C=A8=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC=E4=B8=AD=E6=8F=92=E5=85=A5=20=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E3=80=82=20=E5=AD=97=E4=BD=93=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=BA14=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=BB=99=E6=88=91=E5=8F=98=E6=88=9013=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/cell/editor/RichTextToolBar.java | 5 +- .../cell/editor/RichTextToolBarTest.java | 69 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 designer-realize/src/test/java/com/fr/design/cell/editor/RichTextToolBarTest.java diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java index a8f4b2ac1..fb904e219 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java @@ -502,14 +502,15 @@ public class RichTextToolBar extends BasicPane{ //pt转为px =*4/3 private int scaleUp(int fontSize) { - return (int) FontTransformUtil.pt2px(fontSize); + return roundUp(FontTransformUtil.pt2px(fontSize)); } //px转pt = *3/4 private int scaleDown(int fontSize) { - return (int) FontTransformUtil.px2pt(fontSize); + return roundUp(FontTransformUtil.px2pt(fontSize)); } + private DocumentListener inputListener = new DocumentListener() { @Override diff --git a/designer-realize/src/test/java/com/fr/design/cell/editor/RichTextToolBarTest.java b/designer-realize/src/test/java/com/fr/design/cell/editor/RichTextToolBarTest.java new file mode 100644 index 000000000..7cae136d7 --- /dev/null +++ b/designer-realize/src/test/java/com/fr/design/cell/editor/RichTextToolBarTest.java @@ -0,0 +1,69 @@ +package com.fr.design.cell.editor; + +import com.fr.invoke.Reflect; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by kerry on 2020-09-21 + */ +public class RichTextToolBarTest { + @Test + public void testScaleUpAndDown() { + RichTextToolBar textToolBar = EasyMock.mock(RichTextToolBar.class); + + int result = Reflect.on(textToolBar).call("scaleUp", 10).get(); + Assert.assertEquals(13, result); + result = Reflect.on(textToolBar).call("scaleDown", 13).get(); + Assert.assertEquals(10, result); + + result = Reflect.on(textToolBar).call("scaleUp", 11).get(); + Assert.assertEquals(15, result); + result = Reflect.on(textToolBar).call("scaleDown", 15).get(); + Assert.assertEquals(11, result); + + result = Reflect.on(textToolBar).call("scaleUp", 12).get(); + Assert.assertEquals(16, result); + result = Reflect.on(textToolBar).call("scaleDown", 16).get(); + Assert.assertEquals(12, result); + + + result = Reflect.on(textToolBar).call("scaleUp", 13).get(); + Assert.assertEquals(17, result); + result = Reflect.on(textToolBar).call("scaleDown", 17).get(); + Assert.assertEquals(13, result); + + result = Reflect.on(textToolBar).call("scaleUp", 14).get(); + Assert.assertEquals(19, result); + result = Reflect.on(textToolBar).call("scaleDown", 19).get(); + Assert.assertEquals(14, result); + + result = Reflect.on(textToolBar).call("scaleUp", 16).get(); + Assert.assertEquals(21, result); + result = Reflect.on(textToolBar).call("scaleDown", 21).get(); + Assert.assertEquals(16, result); + + + result = Reflect.on(textToolBar).call("scaleUp", 17).get(); + Assert.assertEquals(23, result); + result = Reflect.on(textToolBar).call("scaleDown", 23).get(); + Assert.assertEquals(17, result); + + result = Reflect.on(textToolBar).call("scaleUp", 17).get(); + Assert.assertEquals(23, result); + result = Reflect.on(textToolBar).call("scaleDown", 23).get(); + Assert.assertEquals(17, result); + + result = Reflect.on(textToolBar).call("scaleUp", 19).get(); + Assert.assertEquals(25, result); + result = Reflect.on(textToolBar).call("scaleDown", 25).get(); + Assert.assertEquals(19, result); + + result = Reflect.on(textToolBar).call("scaleUp", 20).get(); + Assert.assertEquals(27, result); + result = Reflect.on(textToolBar).call("scaleDown", 27).get(); + Assert.assertEquals(20, result); + } + +} From 31f74c939267b32f710b70f200b075b77ffd9e68 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 24 Sep 2020 14:44:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-38618=20=E3=80=90=E5=9B=9E=E5=BD=92?= =?UTF-8?q?=E3=80=91=E8=A1=A8=E5=8D=95-=E4=B8=8B=E6=96=B9=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E7=BC=A9=E5=B0=8F=E4=B9=8B=E5=90=8E=EF=BC=8C=E6=8B=96?= =?UTF-8?q?=E5=85=A5tab=E5=9D=97=EF=BC=8C=E6=9F=A5=E7=9C=8B=E5=8F=B3?= =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=A1=86=E7=BA=BF=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/FormDesignerUI.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index b75fbcf3c..233ee2a96 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -22,10 +22,12 @@ import com.fr.form.main.parameter.FormParameterUI; import com.fr.page.WatermarkPainter; import com.fr.report.core.ReportUtils; import com.fr.stable.ArrayUtils; +import com.fr.stable.Constants; import javax.swing.*; import javax.swing.plaf.ComponentUI; import java.awt.AlphaComposite; +import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; @@ -41,6 +43,8 @@ import java.util.ArrayList; */ public class FormDesignerUI extends ComponentUI { + private static final Color DESIGNER_BORDER_COLOR = new Color(198, 198, 198); + // 当前的设计器 private FormDesigner designer; private SelectionModel selectionModel; @@ -90,7 +94,7 @@ public class FormDesignerUI extends ComponentUI { designer.getDrawLineHelper().drawAuxiliaryLine(g); return; } - + paintBorder(g); paintSelection(g); if (DesignerMode.isAuthorityEditing()) { @@ -275,6 +279,19 @@ public class FormDesignerUI extends ComponentUI { clipg.dispose(); } + public void paintBorder(Graphics g) { + Rectangle bounds = designer.getTopContainer().getBounds(); + bounds.x = -designer.getHorizontalScaleValue(); + bounds.y = -designer.getVerticalScaleValue(); + Graphics clipg = g.create(); + clipg.clipRect(bounds.x, bounds.y, bounds.width, bounds.height); + Color oldColor = g.getColor(); + g.setColor(DESIGNER_BORDER_COLOR); + GraphHelper.draw(g, bounds, Constants.LINE_THIN); + clipg.dispose(); + g.setColor(oldColor); + } + /** * 画出当前选择、拖拽状态框 *