From 0f73d49e9e279e9c0e4df124da62a4f8d8420d53 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 12:07:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?KERNEL-1197=20=E6=96=B0=E5=A2=9Eutils?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=B8=80=E4=BA=9B=E7=B1=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/base/AbstractPainter.java | 4 ++++ .../com/fanruan/api/base/BaseFormula.java | 4 ++++ .../design/work/formula/TinyFormulaPane.java | 7 ++++++ .../fanruan/api/util/BaseHTMLWriterKit.java | 21 ++++++++++++++++++ .../java/com/fanruan/api/util/CellKit.java | 22 +++++++++++++++++++ .../java/com/fanruan/api/util/StableKit.java | 15 +++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 src/main/java/com/fanruan/api/base/AbstractPainter.java create mode 100644 src/main/java/com/fanruan/api/base/BaseFormula.java create mode 100644 src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java create mode 100644 src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java create mode 100644 src/main/java/com/fanruan/api/util/CellKit.java create mode 100644 src/main/java/com/fanruan/api/util/StableKit.java diff --git a/src/main/java/com/fanruan/api/base/AbstractPainter.java b/src/main/java/com/fanruan/api/base/AbstractPainter.java new file mode 100644 index 0000000..e236deb --- /dev/null +++ b/src/main/java/com/fanruan/api/base/AbstractPainter.java @@ -0,0 +1,4 @@ +package com.fanruan.api.base; + +public abstract class AbstractPainter extends com.fr.base.AbstractPainter { +} diff --git a/src/main/java/com/fanruan/api/base/BaseFormula.java b/src/main/java/com/fanruan/api/base/BaseFormula.java new file mode 100644 index 0000000..8529608 --- /dev/null +++ b/src/main/java/com/fanruan/api/base/BaseFormula.java @@ -0,0 +1,4 @@ +package com.fanruan.api.base; + +public abstract class BaseFormula extends com.fr.base.BaseFormula { +} diff --git a/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java b/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java new file mode 100644 index 0000000..23b7af5 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java @@ -0,0 +1,7 @@ +package com.fanruan.api.design.work.formula; + +public class TinyFormulaPane extends com.fr.design.formula.TinyFormulaPane { + public TinyFormulaPane() { + super(); + } +} diff --git a/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java b/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java new file mode 100644 index 0000000..ada9dde --- /dev/null +++ b/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java @@ -0,0 +1,21 @@ +package com.fanruan.api.util; + +import com.fr.stable.html.Tag; +import com.fr.stable.web.Repository; +import com.fr.web.BaseHTMLWriterUtils; + +import java.awt.*; + +public class BaseHTMLWriterKit { + + /** + * 根据原始的图片和指定的尺寸以及报表上下文生成图片的HTML标签,该方法只生成一个简单的img标签 + * @param image 原始图片 + * @param dimension 指定尺寸 + * @param repo 报表上下文 + * @return img图片标签 + */ + public static Tag createImageTag4RepoWithCheckVml(Image image, Dimension dimension, Repository repo){ + return BaseHTMLWriterUtils.createImageTag4RepoWithCheckVml(image, dimension, repo); + } +} diff --git a/src/main/java/com/fanruan/api/util/CellKit.java b/src/main/java/com/fanruan/api/util/CellKit.java new file mode 100644 index 0000000..7a6759f --- /dev/null +++ b/src/main/java/com/fanruan/api/util/CellKit.java @@ -0,0 +1,22 @@ +package com.fanruan.api.util; + +import com.fr.base.Style; +import com.fr.report.cell.cellattr.core.CellUtils; + +import java.awt.*; + +public class CellKit { + + /** + * 如果value是ImageWithSuffix类的一个实例,则创建一个宽为width,高为height,类型为TYPE_4BYTE_ABGR的image,并将其按照比例和Style绘制。 + * @param value 传入的需要判断为是否是ImageWithSuffix实例的对象 + * @param resolution 缩放比例的分母,缩放比例为1/resolution + * @param style 绘制image的style + * @param width 绘制image的宽 + * @param height 绘制image的高 + * @return + */ + public static Image value2Image(Object value, int resolution, Style style, int width, int height){ + return CellUtils.value2Image(value, resolution, style, width, height); + } +} diff --git a/src/main/java/com/fanruan/api/util/StableKit.java b/src/main/java/com/fanruan/api/util/StableKit.java new file mode 100644 index 0000000..1a67501 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/StableKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.util; + +import com.fr.stable.StableUtils; + +public class StableKit { + + /** + * 判断一个对象是否可以转化为公式 + * @param object 要判断的字符串 + * @return 如果该字符串是以"="开头,说明可以转化成公式,否则不能转化成公式 + */ + public static boolean canBeFormula(Object object){ + return StableUtils.canBeFormula(object); + } +} From ff5eba5ead5eb4fca6feb7ca58d92b843efeb0ad Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 12:45:08 +0800 Subject: [PATCH 2/4] =?UTF-8?q?KERNEL-1197=20=E6=8C=89=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/base/AbstractPainter.java | 4 ---- .../fanruan/api/design/work/formula/TinyFormulaPane.java | 7 ------- .../fanruan/api/{util => report}/BaseHTMLWriterKit.java | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/base/AbstractPainter.java delete mode 100644 src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java rename src/main/java/com/fanruan/api/{util => report}/BaseHTMLWriterKit.java (95%) diff --git a/src/main/java/com/fanruan/api/base/AbstractPainter.java b/src/main/java/com/fanruan/api/base/AbstractPainter.java deleted file mode 100644 index e236deb..0000000 --- a/src/main/java/com/fanruan/api/base/AbstractPainter.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.base; - -public abstract class AbstractPainter extends com.fr.base.AbstractPainter { -} diff --git a/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java b/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java deleted file mode 100644 index 23b7af5..0000000 --- a/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fanruan.api.design.work.formula; - -public class TinyFormulaPane extends com.fr.design.formula.TinyFormulaPane { - public TinyFormulaPane() { - super(); - } -} diff --git a/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java b/src/main/java/com/fanruan/api/report/BaseHTMLWriterKit.java similarity index 95% rename from src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java rename to src/main/java/com/fanruan/api/report/BaseHTMLWriterKit.java index ada9dde..fd9a07f 100644 --- a/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java +++ b/src/main/java/com/fanruan/api/report/BaseHTMLWriterKit.java @@ -1,4 +1,4 @@ -package com.fanruan.api.util; +package com.fanruan.api.report; import com.fr.stable.html.Tag; import com.fr.stable.web.Repository; From 1429f63c69236c6850a05a61acd0b2bb545d8ee1 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 16:35:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?KERNEL-1197=20=E6=96=B0=E5=A2=9E=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AA=E8=BF=94=E5=9B=9E=E5=80=BC?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=EF=BC=8C=E5=88=A0=E9=99=A4=E6=8E=89=E4=BA=86?= =?UTF-8?q?=E8=A2=AB=E6=A0=87=E8=AE=B0=E4=B8=BAOpen=E7=9A=84BaseFormula?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/base/BaseFormula.java | 4 ---- .../java/com/fanruan/api/util/CellKit.java | 2 +- .../com/fanruan/api/util/CellKitTest.java | 22 +++++++++++++++++++ .../com/fanruan/api/util/StableKitTest.java | 19 ++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/base/BaseFormula.java create mode 100644 src/test/java/com/fanruan/api/util/CellKitTest.java create mode 100644 src/test/java/com/fanruan/api/util/StableKitTest.java diff --git a/src/main/java/com/fanruan/api/base/BaseFormula.java b/src/main/java/com/fanruan/api/base/BaseFormula.java deleted file mode 100644 index 8529608..0000000 --- a/src/main/java/com/fanruan/api/base/BaseFormula.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.base; - -public abstract class BaseFormula extends com.fr.base.BaseFormula { -} diff --git a/src/main/java/com/fanruan/api/util/CellKit.java b/src/main/java/com/fanruan/api/util/CellKit.java index 7a6759f..c007b5b 100644 --- a/src/main/java/com/fanruan/api/util/CellKit.java +++ b/src/main/java/com/fanruan/api/util/CellKit.java @@ -14,7 +14,7 @@ public class CellKit { * @param style 绘制image的style * @param width 绘制image的宽 * @param height 绘制image的高 - * @return + * @return 返回宽为width,高为height,类型为TYPE_4BYTE_ABGR的image */ public static Image value2Image(Object value, int resolution, Style style, int width, int height){ return CellUtils.value2Image(value, resolution, style, width, height); diff --git a/src/test/java/com/fanruan/api/util/CellKitTest.java b/src/test/java/com/fanruan/api/util/CellKitTest.java new file mode 100644 index 0000000..5d22589 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/CellKitTest.java @@ -0,0 +1,22 @@ +package com.fanruan.api.util; + +import com.fr.base.Style; +import com.fr.plugin.present.fun.StarPainter; +import org.junit.Assert; +import org.junit.Test; + +import java.awt.*; + +import static org.junit.Assert.*; + +public class CellKitTest { + + @Test + public void value2Image() { + StarPainter star = new StarPainter(1); + Style style = Style.getInstance(); + Image image = CellKit.value2Image(star, 1, style, 30, 50); + Assert.assertEquals(30, image.getWidth(null)); + Assert.assertEquals(50, image.getHeight(null)); + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/StableKitTest.java b/src/test/java/com/fanruan/api/util/StableKitTest.java new file mode 100644 index 0000000..753edd3 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/StableKitTest.java @@ -0,0 +1,19 @@ +package com.fanruan.api.util; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class StableKitTest { + + @Test + public void canBeFormula() { + String s1 = "=1"; + String s2 = "=a+b+"; + String s3 = "ppp"; + Assert.assertTrue(StableKit.canBeFormula(s1)); + Assert.assertTrue(StableKit.canBeFormula(s2)); + Assert.assertFalse(StableKit.canBeFormula(s3)); + } +} \ No newline at end of file From b741f9b9d5757ece06ccda958ed8c95b3bb14f66 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 16:53:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?KERNEL-1197=20=E6=8C=89=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/FormulaKit.java | 11 +++++++++++ .../CellKit.java => report/PaintKit.java} | 4 ++-- .../java/com/fanruan/api/util/StableKit.java | 15 --------------- .../com/fanruan/api/cal/FormulaKitTest.java | 10 ++++++++++ .../{CellKitTest.java => PaintKitTest.java} | 7 +++---- .../com/fanruan/api/util/StableKitTest.java | 19 ------------------- 6 files changed, 26 insertions(+), 40 deletions(-) rename src/main/java/com/fanruan/api/{util/CellKit.java => report/PaintKit.java} (93%) delete mode 100644 src/main/java/com/fanruan/api/util/StableKit.java rename src/test/java/com/fanruan/api/util/{CellKitTest.java => PaintKitTest.java} (75%) delete mode 100644 src/test/java/com/fanruan/api/util/StableKitTest.java diff --git a/src/main/java/com/fanruan/api/cal/FormulaKit.java b/src/main/java/com/fanruan/api/cal/FormulaKit.java index 93cd52a..503a8ab 100644 --- a/src/main/java/com/fanruan/api/cal/FormulaKit.java +++ b/src/main/java/com/fanruan/api/cal/FormulaKit.java @@ -7,6 +7,7 @@ import com.fr.base.ScriptFormula; import com.fr.log.FineLoggerFactory; import com.fr.script.Calculator; import com.fr.stable.FormulaProvider; +import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.UtilEvalError; import com.fr.stable.script.CalculatorProvider; @@ -104,4 +105,14 @@ public class FormulaKit { } return checkFormulaContent(formula.getPureContent()); } + + /** + * 判断一个对象是否可以转化为公式 + * @param object 要判断的字符串 + * @return 如果该字符串是以"="开头,说明可以转化成公式,否则不能转化成公式 + */ + public static boolean canBeFormula(Object object){ + return StableUtils.canBeFormula(object); + } + } diff --git a/src/main/java/com/fanruan/api/util/CellKit.java b/src/main/java/com/fanruan/api/report/PaintKit.java similarity index 93% rename from src/main/java/com/fanruan/api/util/CellKit.java rename to src/main/java/com/fanruan/api/report/PaintKit.java index c007b5b..3b1787e 100644 --- a/src/main/java/com/fanruan/api/util/CellKit.java +++ b/src/main/java/com/fanruan/api/report/PaintKit.java @@ -1,11 +1,11 @@ -package com.fanruan.api.util; +package com.fanruan.api.report; import com.fr.base.Style; import com.fr.report.cell.cellattr.core.CellUtils; import java.awt.*; -public class CellKit { +public class PaintKit { /** * 如果value是ImageWithSuffix类的一个实例,则创建一个宽为width,高为height,类型为TYPE_4BYTE_ABGR的image,并将其按照比例和Style绘制。 diff --git a/src/main/java/com/fanruan/api/util/StableKit.java b/src/main/java/com/fanruan/api/util/StableKit.java deleted file mode 100644 index 1a67501..0000000 --- a/src/main/java/com/fanruan/api/util/StableKit.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.stable.StableUtils; - -public class StableKit { - - /** - * 判断一个对象是否可以转化为公式 - * @param object 要判断的字符串 - * @return 如果该字符串是以"="开头,说明可以转化成公式,否则不能转化成公式 - */ - public static boolean canBeFormula(Object object){ - return StableUtils.canBeFormula(object); - } -} diff --git a/src/test/java/com/fanruan/api/cal/FormulaKitTest.java b/src/test/java/com/fanruan/api/cal/FormulaKitTest.java index abed6cb..f2faf24 100644 --- a/src/test/java/com/fanruan/api/cal/FormulaKitTest.java +++ b/src/test/java/com/fanruan/api/cal/FormulaKitTest.java @@ -72,4 +72,14 @@ public class FormulaKitTest extends Prepare { assertEquals(true, FormulaKit.checkFormulaContent(new Formula("="))); assertEquals(false, FormulaKit.checkFormulaContent("=")); } + + @Test + public void canBeFormula() { + String s1 = "=1"; + String s2 = "=a+b+"; + String s3 = "ppp"; + Assert.assertTrue(FormulaKit.canBeFormula(s1)); + Assert.assertTrue(FormulaKit.canBeFormula(s2)); + Assert.assertFalse(FormulaKit.canBeFormula(s3)); + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/CellKitTest.java b/src/test/java/com/fanruan/api/util/PaintKitTest.java similarity index 75% rename from src/test/java/com/fanruan/api/util/CellKitTest.java rename to src/test/java/com/fanruan/api/util/PaintKitTest.java index 5d22589..33e2c17 100644 --- a/src/test/java/com/fanruan/api/util/CellKitTest.java +++ b/src/test/java/com/fanruan/api/util/PaintKitTest.java @@ -1,5 +1,6 @@ package com.fanruan.api.util; +import com.fanruan.api.report.PaintKit; import com.fr.base.Style; import com.fr.plugin.present.fun.StarPainter; import org.junit.Assert; @@ -7,15 +8,13 @@ import org.junit.Test; import java.awt.*; -import static org.junit.Assert.*; - -public class CellKitTest { +public class PaintKitTest { @Test public void value2Image() { StarPainter star = new StarPainter(1); Style style = Style.getInstance(); - Image image = CellKit.value2Image(star, 1, style, 30, 50); + Image image = PaintKit.value2Image(star, 1, style, 30, 50); Assert.assertEquals(30, image.getWidth(null)); Assert.assertEquals(50, image.getHeight(null)); } diff --git a/src/test/java/com/fanruan/api/util/StableKitTest.java b/src/test/java/com/fanruan/api/util/StableKitTest.java deleted file mode 100644 index 753edd3..0000000 --- a/src/test/java/com/fanruan/api/util/StableKitTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.api.util; - -import org.junit.Assert; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class StableKitTest { - - @Test - public void canBeFormula() { - String s1 = "=1"; - String s2 = "=a+b+"; - String s3 = "ppp"; - Assert.assertTrue(StableKit.canBeFormula(s1)); - Assert.assertTrue(StableKit.canBeFormula(s2)); - Assert.assertFalse(StableKit.canBeFormula(s3)); - } -} \ No newline at end of file