From 160b64b8ef8731e9686339a295ddbba03f43cd69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 23 Sep 2019 17:27:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?KERNEL-1167=20fineKit=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/design/chart/AbstractChartTypeUI.java | 71 ++++++++++++++++ .../api/design/chart/AbstractDataPane.java | 26 ++++++ .../api/design/chart/AbstractOtherPane.java | 31 +++++++ .../api/design/chart/DefaultTypePane.java | 81 +++++++++++++++++++ .../api/design/chart/SingleDataPane.java | 19 +++++ .../field/AbstractCellDataFieldsPane.java | 79 ++++++++++++++++++ .../field/AbstractDataSetFieldsPane.java | 78 ++++++++++++++++++ .../design/ui/component/UIButtonGroup.java | 31 +++++++ .../ui/component/chart/CalculateComboBox.java | 9 +++ .../api/engine/chart/AbstractChartType.java | 41 ++++++++++ .../engine/chart/AbstractChartWithData.java | 70 ++++++++++++++++ .../chart/field/ColumnFieldCollection.java | 12 +++ src/main/java/com/fanruan/api/util/IOKit.java | 14 +++- 13 files changed, 560 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/fanruan/api/design/chart/AbstractChartTypeUI.java create mode 100644 src/main/java/com/fanruan/api/design/chart/AbstractDataPane.java create mode 100644 src/main/java/com/fanruan/api/design/chart/AbstractOtherPane.java create mode 100644 src/main/java/com/fanruan/api/design/chart/DefaultTypePane.java create mode 100644 src/main/java/com/fanruan/api/design/chart/SingleDataPane.java create mode 100644 src/main/java/com/fanruan/api/design/chart/field/AbstractCellDataFieldsPane.java create mode 100644 src/main/java/com/fanruan/api/design/chart/field/AbstractDataSetFieldsPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UIButtonGroup.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java create mode 100644 src/main/java/com/fanruan/api/engine/chart/AbstractChartType.java create mode 100644 src/main/java/com/fanruan/api/engine/chart/AbstractChartWithData.java create mode 100644 src/main/java/com/fanruan/api/engine/chart/field/ColumnFieldCollection.java diff --git a/src/main/java/com/fanruan/api/design/chart/AbstractChartTypeUI.java b/src/main/java/com/fanruan/api/design/chart/AbstractChartTypeUI.java new file mode 100644 index 0000000..5b4c653 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/chart/AbstractChartTypeUI.java @@ -0,0 +1,71 @@ +package com.fanruan.api.design.chart; + +import com.fr.design.gui.frpane.AttributeChangeListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-19 + */ +public abstract class AbstractChartTypeUI extends com.fr.design.chart.fun.impl.AbstractChartTypeUI { + + /** + * 定义图表类型选择界面 + * + * @return 类型选择界面 + */ + @Override + public DefaultTypePane getPlotTypePane() { + return new DefaultTypePane(); + } + + /** + * 定义图表数据配置界面 + * + * @return 数据配置界面 + */ + @Override + public abstract AbstractDataPane getChartDataPane(AttributeChangeListener listener); + + /** + * 定义其他界面 + * + * @return 其他界面集合 + */ + @Override + public abstract AbstractOtherPane[] getAttrPaneArray(AttributeChangeListener listener); + + /** + * 定义图表类型选择界面子类型的名称 + * + * @return 图表子类型名称集合 + */ + @Override + public String[] getSubName() { + return super.getSubName(); + } + + /** + * 定义图表的icon图片路径 + * + * @return icon图片路径 + */ + @Override + public abstract String getIconPath(); + + /** + * 定义图表图表类型选择界面的类型名称 + * + * @return 图表类型名称 + */ + @Override + public abstract String getName(); + + /** + * 定义图表类型选择界面子类型的示例图片路径 + * + * @return 图表子类型图片路径集合 + */ + @Override + public abstract String[] getDemoImagePath(); +} diff --git a/src/main/java/com/fanruan/api/design/chart/AbstractDataPane.java b/src/main/java/com/fanruan/api/design/chart/AbstractDataPane.java new file mode 100644 index 0000000..5e97167 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/chart/AbstractDataPane.java @@ -0,0 +1,26 @@ +package com.fanruan.api.design.chart; + +import com.fr.design.gui.frpane.AttributeChangeListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-18 + */ +public abstract class AbstractDataPane extends com.fr.design.chartx.impl.AbstractDataPane { + + /** + * 构造函数 + */ + public AbstractDataPane(AttributeChangeListener listener) { + super(listener); + } + + + /** + * 创建数据配置面板 + * + * @return 数据配置面板 + */ + protected abstract SingleDataPane createSingleDataPane(); +} diff --git a/src/main/java/com/fanruan/api/design/chart/AbstractOtherPane.java b/src/main/java/com/fanruan/api/design/chart/AbstractOtherPane.java new file mode 100644 index 0000000..556ad4a --- /dev/null +++ b/src/main/java/com/fanruan/api/design/chart/AbstractOtherPane.java @@ -0,0 +1,31 @@ +package com.fanruan.api.design.chart; + +import com.fanruan.api.engine.chart.AbstractChartWithData; + +import javax.swing.JPanel; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-17 + */ +public abstract class AbstractOtherPane extends com.fr.design.chartx.impl.AbstractOtherPane { + + /** + * 创建内容面板 + * + * @return 面板 + */ + @Override + protected abstract JPanel createContentPane(); + + /** + * 界面标题 + * + * @return 标题 + */ + @Override + public String title4PopupWindow() { + return super.title4PopupWindow(); + } +} diff --git a/src/main/java/com/fanruan/api/design/chart/DefaultTypePane.java b/src/main/java/com/fanruan/api/design/chart/DefaultTypePane.java new file mode 100644 index 0000000..16001f3 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/chart/DefaultTypePane.java @@ -0,0 +1,81 @@ +package com.fanruan.api.design.chart; + +import com.fanruan.api.engine.chart.AbstractChartWithData; +import com.fr.chartx.attr.ChartProvider; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-18 + */ +public class DefaultTypePane extends com.fr.design.chartx.impl.DefaultTypePane { + + /** + * 获取图表类型界面图表选择子类型的缩略图路径,默认使用UI界面插入图表时子类型的图片路径 + * + * @return 图片路径集合 + */ + @Override + protected String[] getTypeIconPath() { + return super.getTypeIconPath(); + } + + /** + * 获取图表类型界面图表选择子类型的缩略图提示内容,默认使用UI界面插入图表时的图表子类型名称 + * + * @return 提示内容集合 + */ + @Override + protected String[] getTypeTipName() { + return super.getTypeTipName(); + } + + /** + * 获取图表子类型对象,默认使用AbstractChartType.getChartTypes()返回的第一个对象 + * + * @return 图表对象 + */ + @Override + public ChartProvider getDefaultChart() { + return super.getDefaultChart(); + } + + /** + * 获取图表类型界面切换图表类型名称。默认使用UI界面插入图表时的图表名称。 + * + * @return 图表名称 + */ + @Override + public String title4PopupWindow() { + return super.title4PopupWindow(); + } + + /** + * 根据图表对象返回该图表对象的所对应的子类型序号,默认返回0 + * + * @return 子类型序号 + */ + @Override + protected int getSelectIndexInChart(T chart) { + return super.getSelectIndexInChart(chart); + } + + /** + * 根据图表子类型序号,还原图表对象对应的属性。 + */ + @Override + protected void setSelectIndexInChart(T chart, int index) { + super.setSelectIndexInChart(chart, index); + } + + /** + * 根据图表子类型序号,还原图表对象对应的属性。 + */ + @Override + protected Component[][] getPaneComponents(JPanel typePane) { + return super.getPaneComponents(typePane); + } +} diff --git a/src/main/java/com/fanruan/api/design/chart/SingleDataPane.java b/src/main/java/com/fanruan/api/design/chart/SingleDataPane.java new file mode 100644 index 0000000..29db9b9 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/chart/SingleDataPane.java @@ -0,0 +1,19 @@ +package com.fanruan.api.design.chart; + +import com.fanruan.api.design.chart.field.AbstractCellDataFieldsPane; +import com.fanruan.api.design.chart.field.AbstractDataSetFieldsPane; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-18 + */ +public class SingleDataPane extends com.fr.design.chartx.single.SingleDataPane { + + /** + * 构造函数,组合数据集数据源配置面板和单元格数据源配置面板 + */ + public SingleDataPane(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) { + super(dataSetFieldsPane, cellDataFieldsPane); + } +} diff --git a/src/main/java/com/fanruan/api/design/chart/field/AbstractCellDataFieldsPane.java b/src/main/java/com/fanruan/api/design/chart/field/AbstractCellDataFieldsPane.java new file mode 100644 index 0000000..0247d9f --- /dev/null +++ b/src/main/java/com/fanruan/api/design/chart/field/AbstractCellDataFieldsPane.java @@ -0,0 +1,79 @@ +package com.fanruan.api.design.chart.field; + +import com.fanruan.api.design.ui.component.formula.UIFormulaTextField; +import com.fanruan.api.engine.chart.field.ColumnFieldCollection; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-17 + */ +public abstract class AbstractCellDataFieldsPane extends com.fr.design.chartx.fields.AbstractCellDataFieldsPane { + + /** + * 初始化面板布局,默认会加载北部、中部和南部的面板 + */ + @Override + protected void initComponents() { + super.initComponents(); + } + + /** + * 创建中部位置的面板,默认会通过所有的组件和组件名称生成面板。 + * + * @return 面板 + */ + @Override + protected JPanel createCenterPane() { + return super.createCenterPane(); + } + + /** + * 创建北部位置的面板,默认生成空面板 + * + * @return 面板 + */ + @Override + protected JPanel createNorthPane() { + return super.createNorthPane(); + } + + /** + * 创建南部位置的面板,默认生成空面板 + * + * @return 面板 + */ + @Override + protected JPanel createSouthPane() { + return super.createSouthPane(); + } + + /** + * 面板中所有组件,默认会去获取所有公式组件 + * + * @return 所有组件的集合 + */ + @Override + protected Component[] fieldComponents() { + return super.fieldComponents(); + } + + /** + * 面板中所有组件的名称 + * + * @return 所有组件的名称集合 + */ + @Override + protected abstract String[] fieldLabels(); + + /** + * 面板中的公式组件 + * + * @return 公式组件的集合 + */ + @Override + protected abstract UIFormulaTextField[] formulaPanes(); +} diff --git a/src/main/java/com/fanruan/api/design/chart/field/AbstractDataSetFieldsPane.java b/src/main/java/com/fanruan/api/design/chart/field/AbstractDataSetFieldsPane.java new file mode 100644 index 0000000..5e2169e --- /dev/null +++ b/src/main/java/com/fanruan/api/design/chart/field/AbstractDataSetFieldsPane.java @@ -0,0 +1,78 @@ +package com.fanruan.api.design.chart.field; + +import com.fanruan.api.design.ui.component.UIComboBox; +import com.fanruan.api.engine.chart.field.ColumnFieldCollection; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-17 + */ +public abstract class AbstractDataSetFieldsPane extends com.fr.design.chartx.fields.AbstractDataSetFieldsPane { + /** + * 初始化面板布局,默认会加载北部、中部和南部的面板 + */ + @Override + protected void initComponents() { + super.initComponents(); + } + + /** + * 创建中部位置的面板,默认会通过所有的组件和组件名称生成面板。 + * + * @return 面板 + */ + @Override + protected JPanel createCenterPane() { + return super.createCenterPane(); + } + + /** + * 创建北部位置的面板,默认生成空面板 + * + * @return 面板 + */ + @Override + protected JPanel createNorthPane() { + return super.createNorthPane(); + } + + /** + * 创建南部位置的面板,默认生成空面板 + * + * @return 面板 + */ + @Override + protected JPanel createSouthPane() { + return super.createSouthPane(); + } + + /** + * 面板中所有组件,默认会去获取所有下拉框组件 + * + * @return 所有组件的集合 + */ + @Override + protected Component[] fieldComponents() { + return super.fieldComponents(); + } + + /** + * 面板中所有组件的名称 + * + * @return 所有组件的名称集合 + */ + @Override + protected abstract String[] fieldLabels(); + + /** + * 面板中的下拉框组件 + * + * @return 下拉框组件的集合 + */ + @Override + protected abstract UIComboBox[] filedComboBoxes(); +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UIButtonGroup.java b/src/main/java/com/fanruan/api/design/ui/component/UIButtonGroup.java new file mode 100644 index 0000000..4af87f9 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UIButtonGroup.java @@ -0,0 +1,31 @@ +package com.fanruan.api.design.ui.component; + +import javax.swing.Icon; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-19 + */ +public class UIButtonGroup extends com.fr.design.gui.ibutton.UIButtonGroup { + + public UIButtonGroup(String[] textArray) { + super(textArray); + } + + public UIButtonGroup(Icon[] iconArray) { + super(iconArray); + } + + public UIButtonGroup(Icon[][] iconArray) { + super(iconArray); + } + + public UIButtonGroup(Icon[] iconArray, T[] objects) { + super(iconArray, objects); + } + + public UIButtonGroup(Icon[][] iconArray, T[] objects) { + super(iconArray, objects); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java b/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java new file mode 100644 index 0000000..88c459d --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java @@ -0,0 +1,9 @@ +package com.fanruan.api.design.ui.component.chart; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-23 + */ +public class CalculateComboBox extends com.fr.design.mainframe.chart.gui.data.CalculateComboBox { +} diff --git a/src/main/java/com/fanruan/api/engine/chart/AbstractChartType.java b/src/main/java/com/fanruan/api/engine/chart/AbstractChartType.java new file mode 100644 index 0000000..e84b71e --- /dev/null +++ b/src/main/java/com/fanruan/api/engine/chart/AbstractChartType.java @@ -0,0 +1,41 @@ +package com.fanruan.api.engine.chart; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-17 + */ +public abstract class AbstractChartType extends com.fr.chart.impl.AbstractChartType { + + /** + * 该种图表所有的图表对象实例,比如柱形图就有堆积柱形图,百分比堆积柱形图等等 + * + * @return 图表所有的对象实例 + */ + @Override + public abstract AbstractChartWithData[] getChartTypes(); + + /** + * 图表在web端展现时需要的JS文件路径 + * + * @return JS文件路径数组 + */ + @Override + public abstract String[] getRequiredJS(); + + /** + * 图表在web端展现时需要的CSS文件路径 + * + * @return CSS文件路径数组 + */ + @Override + public abstract String[] getRequiredCss(); + + /** + * JS对象名,该对象一般是一个函数,执行后会在给定的dom中绘制图表 + * + * @return JS对象名 + */ + @Override + public abstract String getWrapperName(); +} diff --git a/src/main/java/com/fanruan/api/engine/chart/AbstractChartWithData.java b/src/main/java/com/fanruan/api/engine/chart/AbstractChartWithData.java new file mode 100644 index 0000000..41df1ea --- /dev/null +++ b/src/main/java/com/fanruan/api/engine/chart/AbstractChartWithData.java @@ -0,0 +1,70 @@ +package com.fanruan.api.engine.chart; + +import com.fanruan.api.engine.chart.field.ColumnFieldCollection; +import com.fr.base.chart.cross.FormulaProcessor; +import com.fr.chart.ChartWebPara; +import com.fr.js.NameJavaScriptGroup; +import com.fr.json.JSONObject; + +import java.awt.Image; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-17 + */ +public abstract class AbstractChartWithData extends com.fr.chart.impl.AbstractChartWithData { + + /** + * 获取所有的超链 + * + * @return 超链集合 + */ + @Override + public NameJavaScriptGroup getHotHyperlink(String linkKey) { + return super.getHotHyperlink(linkKey); + } + + /** + * 处理公式,调用formulaProcessor.dealWith方法,覆写该方法需要调用父类的方法。 + */ + @Override + public void dealFormula(FormulaProcessor formulaProcessor) { + super.dealFormula(formulaProcessor); + } + + /** + * 生成设计器中显示的图片,默认返回一个饼图的图片 + * + * @return 图片 + */ + @Override + public Image toImage(int width, int height, int resolution, ChartWebPara chartWebPara) { + return super.toImage(width, height, resolution, chartWebPara); + } + + /** + * 生成图表预览的options + * + * @return JSON对象 + */ + @Override + public abstract JSONObject createAttributeConfig(ChartWebPara chartWebPara); + + /** + * 定义图表的ID,与plugin.xml中的chartID对应 + * + * @return ID + */ + @Override + public abstract String getID(); + + /** + * 获取字段集合对象 + * + * @return 字段集合对象 + */ + public T getColumnFieldCollection(Class var1) { + return super.getFieldCollection(var1); + } +} diff --git a/src/main/java/com/fanruan/api/engine/chart/field/ColumnFieldCollection.java b/src/main/java/com/fanruan/api/engine/chart/field/ColumnFieldCollection.java new file mode 100644 index 0000000..974ba47 --- /dev/null +++ b/src/main/java/com/fanruan/api/engine/chart/field/ColumnFieldCollection.java @@ -0,0 +1,12 @@ +package com.fanruan.api.engine.chart.field; + +import com.fr.chartx.data.field.AbstractColumnFieldCollection; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-17 + */ +public class ColumnFieldCollection extends AbstractColumnFieldCollection { + +} diff --git a/src/main/java/com/fanruan/api/util/IOKit.java b/src/main/java/com/fanruan/api/util/IOKit.java index d7b560d..acc311c 100644 --- a/src/main/java/com/fanruan/api/util/IOKit.java +++ b/src/main/java/com/fanruan/api/util/IOKit.java @@ -4,8 +4,7 @@ import com.fr.general.CommonIOUtils; import com.fr.general.IOUtils; import com.fr.io.utils.ResourceIOUtils; -import javax.swing.*; -import java.awt.image.BufferedImage; +import javax.swing.Icon; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -15,6 +14,7 @@ import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.channels.Channel; import java.nio.charset.Charset; +import java.awt.image.BufferedImage; /** * @author richie @@ -173,6 +173,16 @@ public class IOKit { return IOUtils.readImage(resource); } + /** + * 直接从磁盘中读取图片,并对图片进行缓存 + * + * @param resource 图片的路径 + * @return 图片 + */ + public static BufferedImage readImageWithCache(String resource) { + return IOUtils.readImageWithCache(resource); + } + /** * 读取图标,该方法启用了缓存 * From 3a40ec0125bf2a794c7ab88c3e9ba4e9df67fa11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 24 Sep 2019 16:19:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?KERNEL-1167=20=E5=91=BD=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9&=E9=83=A8=E5=88=86=E7=B1=BB=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/claim.md | 8 +- ...tChartTypeUI.java => BaseChartTypeUI.java} | 7 +- ...bstractDataPane.java => BaseDataPane.java} | 5 +- ...tractOtherPane.java => BaseOtherPane.java} | 5 +- .../api/design/chart/DefaultTypePane.java | 70 +++++++++-- .../api/design/chart/SingleDataPane.java | 6 +- .../field/AbstractDataSetFieldsPane.java | 78 ------------ ...sPane.java => BaseCellDataFieldsPane.java} | 20 ++- .../chart/field/BaseDataSetFieldsPane.java | 118 ++++++++++++++++++ .../ui/component/chart/CalculateComboBox.java | 52 +++++++- .../ui/component/chart/DataFunctionType.java | 65 ++++++++++ ...tractChartType.java => BaseChartType.java} | 6 +- ...rtWithData.java => BaseChartWithData.java} | 7 +- ...on.java => BaseColumnFieldCollection.java} | 2 +- 14 files changed, 340 insertions(+), 109 deletions(-) rename src/main/java/com/fanruan/api/design/chart/{AbstractChartTypeUI.java => BaseChartTypeUI.java} (81%) rename src/main/java/com/fanruan/api/design/chart/{AbstractDataPane.java => BaseDataPane.java} (69%) rename src/main/java/com/fanruan/api/design/chart/{AbstractOtherPane.java => BaseOtherPane.java} (68%) delete mode 100644 src/main/java/com/fanruan/api/design/chart/field/AbstractDataSetFieldsPane.java rename src/main/java/com/fanruan/api/design/chart/field/{AbstractCellDataFieldsPane.java => BaseCellDataFieldsPane.java} (68%) create mode 100644 src/main/java/com/fanruan/api/design/chart/field/BaseDataSetFieldsPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/chart/DataFunctionType.java rename src/main/java/com/fanruan/api/engine/chart/{AbstractChartType.java => BaseChartType.java} (84%) rename src/main/java/com/fanruan/api/engine/chart/{AbstractChartWithData.java => BaseChartWithData.java} (84%) rename src/main/java/com/fanruan/api/engine/chart/field/{ColumnFieldCollection.java => BaseColumnFieldCollection.java} (70%) diff --git a/docs/claim.md b/docs/claim.md index 020e125..166fc99 100644 --- a/docs/claim.md +++ b/docs/claim.md @@ -38,4 +38,10 @@ com.fr.web.struct.Registry com.fr.web.struct.category.ScriptPath -com.fr.web.struct.category.StylePath \ No newline at end of file +com.fr.web.struct.category.StylePath + +com.fr.chart.ChartWebPara + +com.fr.chartx.data.field.ColumnField + +com.fr.js.NameJavaScriptGroup \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/design/chart/AbstractChartTypeUI.java b/src/main/java/com/fanruan/api/design/chart/BaseChartTypeUI.java similarity index 81% rename from src/main/java/com/fanruan/api/design/chart/AbstractChartTypeUI.java rename to src/main/java/com/fanruan/api/design/chart/BaseChartTypeUI.java index 5b4c653..679edb5 100644 --- a/src/main/java/com/fanruan/api/design/chart/AbstractChartTypeUI.java +++ b/src/main/java/com/fanruan/api/design/chart/BaseChartTypeUI.java @@ -1,5 +1,6 @@ package com.fanruan.api.design.chart; +import com.fr.design.chart.fun.impl.AbstractChartTypeUI; import com.fr.design.gui.frpane.AttributeChangeListener; /** @@ -7,7 +8,7 @@ import com.fr.design.gui.frpane.AttributeChangeListener; * @version 10.0 * Created by Bjorn on 2019-09-19 */ -public abstract class AbstractChartTypeUI extends com.fr.design.chart.fun.impl.AbstractChartTypeUI { +public abstract class BaseChartTypeUI extends AbstractChartTypeUI { /** * 定义图表类型选择界面 @@ -25,7 +26,7 @@ public abstract class AbstractChartTypeUI extends com.fr.design.chart.fun.impl.A * @return 数据配置界面 */ @Override - public abstract AbstractDataPane getChartDataPane(AttributeChangeListener listener); + public abstract BaseDataPane getChartDataPane(AttributeChangeListener listener); /** * 定义其他界面 @@ -33,7 +34,7 @@ public abstract class AbstractChartTypeUI extends com.fr.design.chart.fun.impl.A * @return 其他界面集合 */ @Override - public abstract AbstractOtherPane[] getAttrPaneArray(AttributeChangeListener listener); + public abstract BaseOtherPane[] getAttrPaneArray(AttributeChangeListener listener); /** * 定义图表类型选择界面子类型的名称 diff --git a/src/main/java/com/fanruan/api/design/chart/AbstractDataPane.java b/src/main/java/com/fanruan/api/design/chart/BaseDataPane.java similarity index 69% rename from src/main/java/com/fanruan/api/design/chart/AbstractDataPane.java rename to src/main/java/com/fanruan/api/design/chart/BaseDataPane.java index 5e97167..ee6b307 100644 --- a/src/main/java/com/fanruan/api/design/chart/AbstractDataPane.java +++ b/src/main/java/com/fanruan/api/design/chart/BaseDataPane.java @@ -1,5 +1,6 @@ package com.fanruan.api.design.chart; +import com.fr.design.chartx.impl.AbstractDataPane; import com.fr.design.gui.frpane.AttributeChangeListener; /** @@ -7,12 +8,12 @@ import com.fr.design.gui.frpane.AttributeChangeListener; * @version 10.0 * Created by Bjorn on 2019-09-18 */ -public abstract class AbstractDataPane extends com.fr.design.chartx.impl.AbstractDataPane { +public abstract class BaseDataPane extends AbstractDataPane { /** * 构造函数 */ - public AbstractDataPane(AttributeChangeListener listener) { + public BaseDataPane(AttributeChangeListener listener) { super(listener); } diff --git a/src/main/java/com/fanruan/api/design/chart/AbstractOtherPane.java b/src/main/java/com/fanruan/api/design/chart/BaseOtherPane.java similarity index 68% rename from src/main/java/com/fanruan/api/design/chart/AbstractOtherPane.java rename to src/main/java/com/fanruan/api/design/chart/BaseOtherPane.java index 556ad4a..d60b489 100644 --- a/src/main/java/com/fanruan/api/design/chart/AbstractOtherPane.java +++ b/src/main/java/com/fanruan/api/design/chart/BaseOtherPane.java @@ -1,6 +1,7 @@ package com.fanruan.api.design.chart; -import com.fanruan.api.engine.chart.AbstractChartWithData; +import com.fanruan.api.engine.chart.BaseChartWithData; +import com.fr.design.chartx.impl.AbstractOtherPane; import javax.swing.JPanel; @@ -9,7 +10,7 @@ import javax.swing.JPanel; * @version 10.0 * Created by Bjorn on 2019-09-17 */ -public abstract class AbstractOtherPane extends com.fr.design.chartx.impl.AbstractOtherPane { +public abstract class BaseOtherPane extends AbstractOtherPane { /** * 创建内容面板 diff --git a/src/main/java/com/fanruan/api/design/chart/DefaultTypePane.java b/src/main/java/com/fanruan/api/design/chart/DefaultTypePane.java index 16001f3..37e86e5 100644 --- a/src/main/java/com/fanruan/api/design/chart/DefaultTypePane.java +++ b/src/main/java/com/fanruan/api/design/chart/DefaultTypePane.java @@ -1,7 +1,11 @@ package com.fanruan.api.design.chart; -import com.fanruan.api.engine.chart.AbstractChartWithData; +import com.fanruan.api.engine.chart.BaseChartWithData; +import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; +import com.fr.design.ChartTypeInterfaceManager; +import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.gui.type.ChartImagePane; import javax.swing.JPanel; import java.awt.Component; @@ -11,7 +15,7 @@ import java.awt.Component; * @version 10.0 * Created by Bjorn on 2019-09-18 */ -public class DefaultTypePane extends com.fr.design.chartx.impl.DefaultTypePane { +public class DefaultTypePane extends AbstractChartTypePane { /** * 获取图表类型界面图表选择子类型的缩略图路径,默认使用UI界面插入图表时子类型的图片路径 @@ -20,7 +24,7 @@ public class DefaultTypePane extends com.fr.des */ @Override protected String[] getTypeIconPath() { - return super.getTypeIconPath(); + return ChartTypeInterfaceManager.getInstance().getDemoImagePath(getPlotID()); } /** @@ -30,7 +34,7 @@ public class DefaultTypePane extends com.fr.des */ @Override protected String[] getTypeTipName() { - return super.getTypeTipName(); + return ChartTypeInterfaceManager.getInstance().getSubName(getPlotID()); } /** @@ -40,7 +44,7 @@ public class DefaultTypePane extends com.fr.des */ @Override public ChartProvider getDefaultChart() { - return super.getDefaultChart(); + return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0]; } /** @@ -50,7 +54,7 @@ public class DefaultTypePane extends com.fr.des */ @Override public String title4PopupWindow() { - return super.title4PopupWindow(); + return ChartTypeInterfaceManager.getInstance().getName(getPlotID()); } /** @@ -58,24 +62,68 @@ public class DefaultTypePane extends com.fr.des * * @return 子类型序号 */ - @Override protected int getSelectIndexInChart(T chart) { - return super.getSelectIndexInChart(chart); + return 0; } /** * 根据图表子类型序号,还原图表对象对应的属性。 */ - @Override protected void setSelectIndexInChart(T chart, int index) { - super.setSelectIndexInChart(chart, index); } /** - * 根据图表子类型序号,还原图表对象对应的属性。 + * 通过图表对象的属性,还原选择的图表类型 + */ + @Override + public void populateBean(T ob) { + if (getTypeIconPath().length > 0) { + for (ChartImagePane imagePane : typeDemo) { + imagePane.isPressing = false; + } + typeDemo.get(getSelectIndexInChart(ob)).isPressing = true; + checkDemosBackground(); + } + } + + /** + * 根据所选择的图表类型,还原图表类型的属性。 + */ + @Override + public void updateBean(T ob) { + if (getTypeIconPath().length > 0) { + for (int index = 0, len = typeDemo.size(); index < len; index++) { + if (typeDemo.get(index).isPressing) { + setSelectIndexInChart(ob, index); + return; + } + } + } + } + + /** + * 构建类型选择面板的组件。 + * + * @return 面板组件集合 */ @Override protected Component[][] getPaneComponents(JPanel typePane) { return super.getPaneComponents(typePane); } + + //TODO 已经在父类中加了默认实现,jar包更新后直接删除 + @Override + protected String[] getTypeLayoutPath() { + return new String[0]; + } + + @Override + protected String[] getTypeLayoutTipName() { + return new String[0]; + } + + @Override + protected String getPlotTypeID() { + return null; + } } diff --git a/src/main/java/com/fanruan/api/design/chart/SingleDataPane.java b/src/main/java/com/fanruan/api/design/chart/SingleDataPane.java index 29db9b9..e9ebded 100644 --- a/src/main/java/com/fanruan/api/design/chart/SingleDataPane.java +++ b/src/main/java/com/fanruan/api/design/chart/SingleDataPane.java @@ -1,7 +1,7 @@ package com.fanruan.api.design.chart; -import com.fanruan.api.design.chart.field.AbstractCellDataFieldsPane; -import com.fanruan.api.design.chart.field.AbstractDataSetFieldsPane; +import com.fanruan.api.design.chart.field.BaseCellDataFieldsPane; +import com.fanruan.api.design.chart.field.BaseDataSetFieldsPane; /** * @author Bjorn @@ -13,7 +13,7 @@ public class SingleDataPane extends com.fr.design.chartx.single.SingleDataPane { /** * 构造函数,组合数据集数据源配置面板和单元格数据源配置面板 */ - public SingleDataPane(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) { + public SingleDataPane(BaseDataSetFieldsPane dataSetFieldsPane, BaseCellDataFieldsPane cellDataFieldsPane) { super(dataSetFieldsPane, cellDataFieldsPane); } } diff --git a/src/main/java/com/fanruan/api/design/chart/field/AbstractDataSetFieldsPane.java b/src/main/java/com/fanruan/api/design/chart/field/AbstractDataSetFieldsPane.java deleted file mode 100644 index 5e2169e..0000000 --- a/src/main/java/com/fanruan/api/design/chart/field/AbstractDataSetFieldsPane.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.fanruan.api.design.chart.field; - -import com.fanruan.api.design.ui.component.UIComboBox; -import com.fanruan.api.engine.chart.field.ColumnFieldCollection; - -import javax.swing.JPanel; -import java.awt.Component; - -/** - * @author Bjorn - * @version 10.0 - * Created by Bjorn on 2019-09-17 - */ -public abstract class AbstractDataSetFieldsPane extends com.fr.design.chartx.fields.AbstractDataSetFieldsPane { - /** - * 初始化面板布局,默认会加载北部、中部和南部的面板 - */ - @Override - protected void initComponents() { - super.initComponents(); - } - - /** - * 创建中部位置的面板,默认会通过所有的组件和组件名称生成面板。 - * - * @return 面板 - */ - @Override - protected JPanel createCenterPane() { - return super.createCenterPane(); - } - - /** - * 创建北部位置的面板,默认生成空面板 - * - * @return 面板 - */ - @Override - protected JPanel createNorthPane() { - return super.createNorthPane(); - } - - /** - * 创建南部位置的面板,默认生成空面板 - * - * @return 面板 - */ - @Override - protected JPanel createSouthPane() { - return super.createSouthPane(); - } - - /** - * 面板中所有组件,默认会去获取所有下拉框组件 - * - * @return 所有组件的集合 - */ - @Override - protected Component[] fieldComponents() { - return super.fieldComponents(); - } - - /** - * 面板中所有组件的名称 - * - * @return 所有组件的名称集合 - */ - @Override - protected abstract String[] fieldLabels(); - - /** - * 面板中的下拉框组件 - * - * @return 下拉框组件的集合 - */ - @Override - protected abstract UIComboBox[] filedComboBoxes(); -} diff --git a/src/main/java/com/fanruan/api/design/chart/field/AbstractCellDataFieldsPane.java b/src/main/java/com/fanruan/api/design/chart/field/BaseCellDataFieldsPane.java similarity index 68% rename from src/main/java/com/fanruan/api/design/chart/field/AbstractCellDataFieldsPane.java rename to src/main/java/com/fanruan/api/design/chart/field/BaseCellDataFieldsPane.java index 0247d9f..590e01a 100644 --- a/src/main/java/com/fanruan/api/design/chart/field/AbstractCellDataFieldsPane.java +++ b/src/main/java/com/fanruan/api/design/chart/field/BaseCellDataFieldsPane.java @@ -1,7 +1,9 @@ package com.fanruan.api.design.chart.field; import com.fanruan.api.design.ui.component.formula.UIFormulaTextField; -import com.fanruan.api.engine.chart.field.ColumnFieldCollection; +import com.fanruan.api.engine.chart.field.BaseColumnFieldCollection; +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; import javax.swing.JPanel; import java.awt.Component; @@ -11,7 +13,7 @@ import java.awt.Component; * @version 10.0 * Created by Bjorn on 2019-09-17 */ -public abstract class AbstractCellDataFieldsPane extends com.fr.design.chartx.fields.AbstractCellDataFieldsPane { +public abstract class BaseCellDataFieldsPane extends AbstractCellDataFieldsPane { /** * 初始化面板布局,默认会加载北部、中部和南部的面板 @@ -76,4 +78,18 @@ public abstract class AbstractCellDataFieldsPane extends AbstractDataSetFieldsPane { + /** + * 初始化面板布局,默认会加载北部、中部和南部的面板 + */ + @Override + protected void initComponents() { + super.initComponents(); + } + + /** + * 创建中部位置的面板,默认会通过所有的组件和组件名称生成面板。 + * + * @return 面板 + */ + @Override + protected JPanel createCenterPane() { + return super.createCenterPane(); + } + + /** + * 创建北部位置的面板,默认生成空面板 + * + * @return 面板 + */ + @Override + protected JPanel createNorthPane() { + return super.createNorthPane(); + } + + /** + * 创建南部位置的面板,默认生成空面板 + * + * @return 面板 + */ + @Override + protected JPanel createSouthPane() { + return super.createSouthPane(); + } + + /** + * 面板中所有组件,默认会去获取所有下拉框组件 + * + * @return 所有组件的集合 + */ + @Override + protected Component[] fieldComponents() { + return super.fieldComponents(); + } + + /** + * 面板中所有组件的名称 + * + * @return 所有组件的名称集合 + */ + @Override + protected abstract String[] fieldLabels(); + + /** + * 面板中的下拉框组件 + * + * @return 下拉框组件的集合 + */ + @Override + protected abstract UIComboBox[] filedComboBoxes(); + + /** + * 根据字段对象的属性,更新下拉选择组件的值 + */ + protected void populateField(UIComboBox comboBox, ColumnField field) { + AbstractDataSetFieldsPane.populateField(comboBox, field); + } + + /** + * 根据下拉选择组件的值,更新字段对象的属性 + */ + protected void updateField(UIComboBox comboBox, ColumnField field) { + AbstractDataSetFieldsPane.updateField(comboBox, field); + } + + /** + * 根据字段对象的属性,更新下拉选择组件和汇总方式选择组件的值 + */ + protected void populateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) { + comboBox.setSelectedItem(field.getFieldName()); + if (calculateComboBox != null) { + calculateComboBox.populateBean(field.getDataFunction()); + } + } + + /** + * 根据下拉选择组件和汇总方式选择组件的值,更新字段对象的属性 + */ + protected void updateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) { + field.setFieldName(GeneralUtils.objectToString(comboBox.getSelectedItem())); + if (calculateComboBox != null) { + field.setDataFunction(calculateComboBox.updateBean()); + } else { + field.setDataFunction(null); + } + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java b/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java index 88c459d..afc0b36 100644 --- a/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java +++ b/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java @@ -1,9 +1,59 @@ package com.fanruan.api.design.ui.component.chart; +import com.fanruan.api.design.ui.component.UIComboBox; +import com.fr.data.util.function.DataFunction; +import com.fr.design.i18n.Toolkit; +import com.fr.log.FineLoggerFactory; + /** * @author Bjorn * @version 10.0 * Created by Bjorn on 2019-09-23 */ -public class CalculateComboBox extends com.fr.design.mainframe.chart.gui.data.CalculateComboBox { +public class CalculateComboBox extends UIComboBox { + + private static String[] functionName = initItem(); + + private static String[] initItem() { + String[] functionLocaleNames = DataFunctionType.getFunctionLocaleNames(); + for (int i = 0; i < functionLocaleNames.length; i++) { + functionLocaleNames[i] = Toolkit.i18nText(functionLocaleNames[i]); + } + return functionLocaleNames; + } + + public CalculateComboBox() { + super(functionName); + setSelectedIndex(0); + } + + public void reset() { + this.setSelectedItem(0); + } + + /** + * 通过公式对象,更新界面的公式选择 + */ + public void populateBean(DataFunction function) { + int index = DataFunctionType.getIndexByFunction(function); + if (index > 0) { + this.setSelectedIndex(index); + } + } + + /** + * 根据界面选择的公式,返回公式对象 + */ + public DataFunction updateBean() { + try { + int selectIndex = getSelectedIndex(); + DataFunction functionByIndex = DataFunctionType.getFunctionByIndex(selectIndex); + return functionByIndex; + } catch (InstantiationException e) { + FineLoggerFactory.getLogger().error("Function Error"); + } catch (IllegalAccessException e) { + FineLoggerFactory.getLogger().error("Function Error"); + } + return null; + } } diff --git a/src/main/java/com/fanruan/api/design/ui/component/chart/DataFunctionType.java b/src/main/java/com/fanruan/api/design/ui/component/chart/DataFunctionType.java new file mode 100644 index 0000000..ce9bc0b --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/chart/DataFunctionType.java @@ -0,0 +1,65 @@ +package com.fanruan.api.design.ui.component.chart; + +import com.fr.data.util.function.AverageFunction; +import com.fr.data.util.function.CountFunction; +import com.fr.data.util.function.DataFunction; +import com.fr.data.util.function.MaxFunction; +import com.fr.data.util.function.MinFunction; +import com.fr.data.util.function.NoneFunction; +import com.fr.data.util.function.SumFunction; +import com.fr.general.ComparatorUtils; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-24 + */ +public enum DataFunctionType { + + NONE_FUNCTION("Fine-Design_Chart_Data_Function_None", NoneFunction.class), + SUM_FUNCTION("Fine-Design_Chart_Data_Function_Sum", SumFunction.class), + AVERAGE_FUNCTION("Fine-Design_Chart_Data_Function_Average", AverageFunction.class), + MAX_FUNCTION("Fine-Design_Chart_Data_Function_Max", MaxFunction.class), + MIN_FUNCTION("Fine-Design_Chart_Data_Function_Min", MinFunction.class), + COUNT_FUNCTION("Fine-Design_Chart_Data_Function_Count", CountFunction.class); + + String functionLocaleName; + + Class functionClass; + + public static final int NONE_FUNCTION_INDEX = 0; + + DataFunctionType(String functionLocaleName, Class functionClass) { + this.functionLocaleName = functionLocaleName; + this.functionClass = functionClass; + } + + public static int getIndexByFunction(DataFunction function) { + if (function == null) { + return NONE_FUNCTION_INDEX; + } + for (DataFunctionType dataFunctionType : DataFunctionType.values()) { + if (ComparatorUtils.equals(dataFunctionType.functionClass, function.getClass())) { + return dataFunctionType.ordinal(); + } + } + return NONE_FUNCTION_INDEX; + } + + public static DataFunction getFunctionByIndex(int index) throws IllegalAccessException, InstantiationException { + DataFunctionType[] values = DataFunctionType.values(); + if (index < values.length) { + return (DataFunction) values[index].functionClass.newInstance(); + } + return null; + } + + public static String[] getFunctionLocaleNames() { + DataFunctionType[] values = DataFunctionType.values(); + String[] functionLocaleNames = new String[values.length]; + for (int i = 0; i < values.length; i++) { + functionLocaleNames[i] = values[i].functionLocaleName; + } + return functionLocaleNames; + } +} diff --git a/src/main/java/com/fanruan/api/engine/chart/AbstractChartType.java b/src/main/java/com/fanruan/api/engine/chart/BaseChartType.java similarity index 84% rename from src/main/java/com/fanruan/api/engine/chart/AbstractChartType.java rename to src/main/java/com/fanruan/api/engine/chart/BaseChartType.java index e84b71e..1886f8f 100644 --- a/src/main/java/com/fanruan/api/engine/chart/AbstractChartType.java +++ b/src/main/java/com/fanruan/api/engine/chart/BaseChartType.java @@ -1,11 +1,13 @@ package com.fanruan.api.engine.chart; +import com.fr.chart.impl.AbstractChartType; + /** * @author Bjorn * @version 10.0 * Created by Bjorn on 2019-09-17 */ -public abstract class AbstractChartType extends com.fr.chart.impl.AbstractChartType { +public abstract class BaseChartType extends AbstractChartType { /** * 该种图表所有的图表对象实例,比如柱形图就有堆积柱形图,百分比堆积柱形图等等 @@ -13,7 +15,7 @@ public abstract class AbstractChartType extends com.fr.chart.impl.AbstractChartT * @return 图表所有的对象实例 */ @Override - public abstract AbstractChartWithData[] getChartTypes(); + public abstract BaseChartWithData[] getChartTypes(); /** * 图表在web端展现时需要的JS文件路径 diff --git a/src/main/java/com/fanruan/api/engine/chart/AbstractChartWithData.java b/src/main/java/com/fanruan/api/engine/chart/BaseChartWithData.java similarity index 84% rename from src/main/java/com/fanruan/api/engine/chart/AbstractChartWithData.java rename to src/main/java/com/fanruan/api/engine/chart/BaseChartWithData.java index 41df1ea..e53acfd 100644 --- a/src/main/java/com/fanruan/api/engine/chart/AbstractChartWithData.java +++ b/src/main/java/com/fanruan/api/engine/chart/BaseChartWithData.java @@ -1,8 +1,9 @@ package com.fanruan.api.engine.chart; -import com.fanruan.api.engine.chart.field.ColumnFieldCollection; +import com.fanruan.api.engine.chart.field.BaseColumnFieldCollection; import com.fr.base.chart.cross.FormulaProcessor; import com.fr.chart.ChartWebPara; +import com.fr.chart.impl.AbstractChartWithData; import com.fr.js.NameJavaScriptGroup; import com.fr.json.JSONObject; @@ -13,7 +14,7 @@ import java.awt.Image; * @version 10.0 * Created by Bjorn on 2019-09-17 */ -public abstract class AbstractChartWithData extends com.fr.chart.impl.AbstractChartWithData { +public abstract class BaseChartWithData extends AbstractChartWithData { /** * 获取所有的超链 @@ -64,7 +65,7 @@ public abstract class AbstractChartWithData extends com.fr.chart.impl.AbstractCh * * @return 字段集合对象 */ - public T getColumnFieldCollection(Class var1) { + public T getColumnFieldCollection(Class var1) { return super.getFieldCollection(var1); } } diff --git a/src/main/java/com/fanruan/api/engine/chart/field/ColumnFieldCollection.java b/src/main/java/com/fanruan/api/engine/chart/field/BaseColumnFieldCollection.java similarity index 70% rename from src/main/java/com/fanruan/api/engine/chart/field/ColumnFieldCollection.java rename to src/main/java/com/fanruan/api/engine/chart/field/BaseColumnFieldCollection.java index 974ba47..9d8bceb 100644 --- a/src/main/java/com/fanruan/api/engine/chart/field/ColumnFieldCollection.java +++ b/src/main/java/com/fanruan/api/engine/chart/field/BaseColumnFieldCollection.java @@ -7,6 +7,6 @@ import com.fr.chartx.data.field.AbstractColumnFieldCollection; * @version 10.0 * Created by Bjorn on 2019-09-17 */ -public class ColumnFieldCollection extends AbstractColumnFieldCollection { +public class BaseColumnFieldCollection extends AbstractColumnFieldCollection { }