From 5aff955ed7ce5815fc4f5a1589c0b5bdc53bd2c4 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 26 Sep 2019 10:40:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=9B=B4=E5=A4=9A=E7=9A=84AP?= =?UTF-8?q?I?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/query/QueryConditionKit.java | 2 +- .../java/com/fanruan/api/report/PaintKit.java | 13 +++--- .../com/fanruan/api/report/SundryKit.java | 25 +++++++++++ .../api/report/export/BaseAppExporter.java | 43 +++++++++++++++++++ .../api/report/export/BaseOperate.java | 40 +++++++++++++++++ .../com/fanruan/api/report/page/PageKit.java | 5 ++- 6 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/fanruan/api/report/SundryKit.java create mode 100644 src/main/java/com/fanruan/api/report/export/BaseAppExporter.java create mode 100644 src/main/java/com/fanruan/api/report/export/BaseOperate.java diff --git a/src/main/java/com/fanruan/api/query/QueryConditionKit.java b/src/main/java/com/fanruan/api/query/QueryConditionKit.java index 451781c..0d3c4fe 100644 --- a/src/main/java/com/fanruan/api/query/QueryConditionKit.java +++ b/src/main/java/com/fanruan/api/query/QueryConditionKit.java @@ -20,7 +20,7 @@ public class QueryConditionKit { * * @return 查询条件 */ - public QueryCondition newQueryCondition() { + public static QueryCondition newQueryCondition() { return new QueryConditionImpl(); } } diff --git a/src/main/java/com/fanruan/api/report/PaintKit.java b/src/main/java/com/fanruan/api/report/PaintKit.java index 3b1787e..be56d7d 100644 --- a/src/main/java/com/fanruan/api/report/PaintKit.java +++ b/src/main/java/com/fanruan/api/report/PaintKit.java @@ -8,15 +8,16 @@ import java.awt.*; public class PaintKit { /** - * 如果value是ImageWithSuffix类的一个实例,则创建一个宽为width,高为height,类型为TYPE_4BYTE_ABGR的image,并将其按照比例和Style绘制。 - * @param value 传入的需要判断为是否是ImageWithSuffix实例的对象 + * 如果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的高 + * @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){ + 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/report/SundryKit.java b/src/main/java/com/fanruan/api/report/SundryKit.java new file mode 100644 index 0000000..d259fb1 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/SundryKit.java @@ -0,0 +1,25 @@ +package com.fanruan.api.report; + +import com.fanruan.api.util.IOKit; +import com.fr.base.Icon; +import com.fr.base.IconManager; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/9/26 + * 一些比较杂项的工具类 + */ +public class SundryKit { + + /** + * 将图标加载到内存中,可以供插件使用 + * + * @param name 图标的名字 + * @param path 图标的地址 + */ + public static void loadToolbarIcon(String name, String path) { + Icon icon = new Icon(name, IOKit.readImage(path)); + IconManager.getIconManager().addIcon(icon, true); + } +} diff --git a/src/main/java/com/fanruan/api/report/export/BaseAppExporter.java b/src/main/java/com/fanruan/api/report/export/BaseAppExporter.java new file mode 100644 index 0000000..d500b69 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/export/BaseAppExporter.java @@ -0,0 +1,43 @@ +package com.fanruan.api.report.export; + +import com.fr.io.exporter.AbstractAppExporter; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.page.PageSetProvider; + +import java.io.OutputStream; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/9/26 + * 导出接口 + */ +public abstract class BaseAppExporter extends AbstractAppExporter { + + public BaseAppExporter() { + + } + + /** + * 导出 + * + * @param outputStream 输出流 + * @param pageSetProvider 分页对象 + * @throws Exception 导出失败则抛出此异常 + */ + @Override + public void export(OutputStream outputStream, PageSetProvider pageSetProvider) throws Exception { + throw new UnsupportedOperationException(); + } + + /** + * 导出 + * + * @param outputStream 输出流 + * @param resultWorkBook 结果报表 + * @throws Exception 导出失败则抛出此异常 + */ + @Override + public abstract void export(OutputStream outputStream, ResultWorkBook resultWorkBook) throws Exception; + +} diff --git a/src/main/java/com/fanruan/api/report/export/BaseOperate.java b/src/main/java/com/fanruan/api/report/export/BaseOperate.java new file mode 100644 index 0000000..7a030d2 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/export/BaseOperate.java @@ -0,0 +1,40 @@ +package com.fanruan.api.report.export; + +import com.fr.io.collection.ExportCollection; +import com.fr.stable.web.SessionProvider; +import com.fr.web.core.reserve.Operate; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/9/26 + * 导出接口的抽象类 + */ +public abstract class BaseOperate implements Operate { + + @Override + public void setContent(HttpServletRequest req, HttpServletResponse res, String fileName, boolean isEmbed) { + + } + + @Override + public void setContent(HttpServletRequest req, HttpServletResponse res, SessionProvider sessionProvider, String fileName, boolean isEmbed) { + this.setContent(req, res, fileName, isEmbed); + } + + + /** + * 导出的实体操作 + * + * @param req http请求 + * @param res http响应 + * @param sessionProvider 模板访问会话信息 + * @param fileName 文件名 + * @return 导出实体操作对象 + */ + @Override + public abstract ExportCollection newExportCollection(HttpServletRequest req, HttpServletResponse res, SessionProvider sessionProvider, String fileName); +} diff --git a/src/main/java/com/fanruan/api/report/page/PageKit.java b/src/main/java/com/fanruan/api/report/page/PageKit.java index 447b4c2..e709bf8 100644 --- a/src/main/java/com/fanruan/api/report/page/PageKit.java +++ b/src/main/java/com/fanruan/api/report/page/PageKit.java @@ -1,8 +1,8 @@ package com.fanruan.api.report.page; +import com.fanruan.api.report.PrintKit; import com.fr.main.workbook.ResultWorkBook; import com.fr.page.PaperSettingProvider; -import com.fr.report.core.ReportUtils; import java.util.List; @@ -16,11 +16,12 @@ public class PageKit { /** * 获取报表的打印纸张设置信息 + * * @param rb 结果报表 * @return 打印纸张设置信息集合 */ public static PaperSettingProvider[] getPaperSettingListFromWorkBook(ResultWorkBook rb) { - List list = ReportUtils.getPaperSettingListFromWorkBook(rb); + List list = PrintKit.getPaperSettings(rb); return list == null ? new PaperSettingProvider[0] : list.toArray(new PaperSettingProvider[0]); } }