Browse Source

KERNEL-1197 按要求修改

master
Mars.Ma 5 years ago
parent
commit
b741f9b9d5
  1. 11
      src/main/java/com/fanruan/api/cal/FormulaKit.java
  2. 4
      src/main/java/com/fanruan/api/report/PaintKit.java
  3. 15
      src/main/java/com/fanruan/api/util/StableKit.java
  4. 10
      src/test/java/com/fanruan/api/cal/FormulaKitTest.java
  5. 7
      src/test/java/com/fanruan/api/util/PaintKitTest.java
  6. 19
      src/test/java/com/fanruan/api/util/StableKitTest.java

11
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);
}
}

4
src/main/java/com/fanruan/api/util/CellKit.java → 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绘制

15
src/main/java/com/fanruan/api/util/StableKit.java

@ -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);
}
}

10
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));
}
}

7
src/test/java/com/fanruan/api/util/CellKitTest.java → 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));
}

19
src/test/java/com/fanruan/api/util/StableKitTest.java

@ -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));
}
}
Loading…
Cancel
Save