Browse Source
* commit 'b741f9b9d5757ece06ccda958ed8c95b3bb14f66': KERNEL-1197 按要求修改 KERNEL-1197 新增两个单元测试,添加了一个返回值说明,删除掉了被标记为Open的BaseFormula KERNEL-1197 按要求修改。 KERNEL-1197 新增utils,以及一些类。pull/19/head
superman
5 years ago
5 changed files with 85 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||||||
|
package com.fanruan.api.report; |
||||||
|
|
||||||
|
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); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.fanruan.api.report; |
||||||
|
|
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.report.cell.cellattr.core.CellUtils; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
public class PaintKit { |
||||||
|
|
||||||
|
/** |
||||||
|
* 如果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 返回宽为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); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
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; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
public class PaintKitTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void value2Image() { |
||||||
|
StarPainter star = new StarPainter(1); |
||||||
|
Style style = Style.getInstance(); |
||||||
|
Image image = PaintKit.value2Image(star, 1, style, 30, 50); |
||||||
|
Assert.assertEquals(30, image.getWidth(null)); |
||||||
|
Assert.assertEquals(50, image.getHeight(null)); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue