From b741f9b9d5757ece06ccda958ed8c95b3bb14f66 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 16:53:52 +0800 Subject: [PATCH] =?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