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