Browse Source

CHART-10233 demo图表

pull/1/head
白岳 5 years ago
commit
a195714a2f
  1. 5
      .gitignore
  2. 128
      build.xml
  3. BIN
      lib/finekit-10.0.jar
  4. 26
      plugin.xml
  5. 43
      pom.xml
  6. 64
      src/main/java/com/fr/plugin/demo/DemoCellDataFieldsPane.java
  7. 202
      src/main/java/com/fr/plugin/demo/DemoChart.java
  8. 35
      src/main/java/com/fr/plugin/demo/DemoColumnFieldCollection.java
  9. 69
      src/main/java/com/fr/plugin/demo/DemoDataSetFieldsPane.java
  10. 19
      src/main/java/com/fr/plugin/demo/DemoLocaleFinder.java
  11. 41
      src/main/java/com/fr/plugin/demo/DemoTitlePane.java
  12. 62
      src/main/java/com/fr/plugin/demo/DemoType.java
  13. 56
      src/main/java/com/fr/plugin/demo/DemoTypePane.java
  14. 64
      src/main/java/com/fr/plugin/demo/DemoUI.java
  15. 20
      src/main/java/com/fr/plugin/demo/PieType.java
  16. 4
      src/main/resources/com/fr/plugin/demo/demo.css
  17. 24
      src/main/resources/com/fr/plugin/demo/demoWrapper.js
  18. 7
      src/main/resources/com/fr/plugin/demo/echarts-adapter.js
  19. 81519
      src/main/resources/com/fr/plugin/demo/echarts.js
  20. BIN
      src/main/resources/com/fr/plugin/demo/icon.png
  21. BIN
      src/main/resources/com/fr/plugin/demo/pie.png
  22. BIN
      src/main/resources/com/fr/plugin/demo/pieType.png
  23. BIN
      src/main/resources/com/fr/plugin/demo/ring.png
  24. BIN
      src/main/resources/com/fr/plugin/demo/ringType.png
  25. 9
      src/main/resources/com/fr/plugin/locale/demo.properties
  26. 9
      src/main/resources/com/fr/plugin/locale/demo_en_US.properties
  27. 9
      src/main/resources/com/fr/plugin/locale/demo_zh_CN.properties

5
.gitignore vendored

@ -0,0 +1,5 @@
*.iml
.idea/
lib/report/*.jar
.DS_Store
.classpath

128
build.xml

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="jar" name="plugin">
<!-- JDK路径,根据自己机器上实际位置修改-->
<property name="jdk.home" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"/>
<property name="libs" value="${basedir}/lib"/>
<property name="publicLibs" value=""/>
<property name="reportLibs" value="${basedir}/lib/report"/>
<property name="destLoc" value="."/>
<property name="classes" value="classes"/>
<xmlproperty file="${basedir}/plugin.xml"/>
<property name="plugin.version" value="1.0.0"/>
<property name="plugin.name" value="DEMO_CHART"/>
<property name="current-version" value="${plugin.version}"/>
<!-- 插件版本-->
<property name="plugin-version" value="${current-version}"/>
<!-- 插件名字-->
<property name="plugin-name" value="extendedCharts"/>
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/>
<target name="prepare">
<delete dir="${classes}"/>
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/>
<xmlproperty file="${basedir}/plugin.xml"/>
<delete dir="${destLoc}/${plugin.name}"/>
</target>
<path id="compile.classpath">
<fileset dir="${libs}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${publicLibs}">
<include name="**/*.jar"/>
</fileset>
<!--<fileset dir="${reportLibs}">-->
<!--<include name="**/*.jar"/>-->
<!--</fileset>-->
</path>
<patternset id="resources4Jar">
<exclude name="**/.settings/**"/>
<exclude name=".classpath"/>
<exclude name=".project"/>
<exclude name="**/*.java"/>
<exclude name="**/*.db"/>
<exclude name="**/*.g"/>
<exclude name="**/package.html"/>
</patternset>
<target name="copy_resources">
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/>
<delete dir="tmp"/>
<copy todir="tmp">
<fileset dir="${resources_from}/src/main/resources">
<patternset refid="resources4Jar"/>
</fileset>
</copy>
<copy todir="${classes}">
<fileset dir="tmp"/>
</copy>
<delete dir="tmp"/>
</target>
<target name="compile_javas">
<echo message="编译${compile_files}下的Java文件"/>
<javac destdir="${classes}" debug="false" includeantruntime="false" optimize="on" source="${source_jdk_version}"
target="${target_jdk_version}"
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}"
executable="${compile_jdk_version}/bin/javac">
<src path="${basedir}/src/main/java"/>
<exclude name="**/.svn/**"/>
<compilerarg line="-encoding UTF8 "/>
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="jar_classes">
<echo message="打Jar包:${jar_name}"/>
<delete file="${basedir}/${jar_name}"/>
<jar jarfile="${basedir}/${jar_name}">
<fileset dir="${classes}">
</fileset>
</jar>
</target>
<target name="super_jar" depends="prepare">
<antcall target="copy_resources">
<param name="resources_from" value="${basedir}"/>
</antcall>
<antcall target="compile_javas">
<param name="source_jdk_version" value="1.6"/>
<param name="target_jdk_version" value="1.6"/>
<param name="compile_jdk_version" value="${jdk.home}"/>
<param name="compile_files" value="${basedir}/src"/>
</antcall>
<echo message="compile plugin success!"/>
<antcall target="jar_classes">
<param name="jar_name" value="${plugin-jar}"/>
</antcall>
<delete dir="${classes}"/>
</target>
<target name="jar" depends="super_jar">
<antcall target="zip"/>
</target>
<target name="zip">
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/>
<echo message="----------zip files----------"/>
<mkdir dir="${plugin-folder}"/>
<copy todir="${plugin-folder}">
<fileset dir=".">
<include name="${plugin-jar}"/>
<include name="plugin.xml"/>
</fileset>
<fileset dir="${libs}">
<include name="*.jar"/>
<include name="*.dll"/>
</fileset>
</copy>
<zip destfile="${basedir}/${plugin-folder}.zip" basedir=".">
<include name="${plugin-folder}/*.jar"/>
<include name="${plugin-folder}/*.dll"/>
<include name="${plugin-folder}/plugin.xml"/>
</zip>
<move file="${plugin-folder}.zip" todir="${destLoc}/${plugin.name}"/>
</target>
</project>

BIN
lib/finekit-10.0.jar

Binary file not shown.

26
plugin.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.fr.plugin.demoChart</id>
<name><![CDATA[DEMO图表]]></name>
<active>yes</active>
<version>1.0.0</version>
<env-version>10.0</env-version>
<jartime>2019-10-09</jartime>
<vendor>Bjorn</vendor>
<description><![CDATA[给开发者参考的图表插件demo]]></description>
<change-notes><![CDATA[]]></change-notes>
<function-recorder class="com.fr.plugin.demo.DemoChart"/>
<extra-chart>
<ChartTypeProvider class="com.fr.plugin.demo.DemoType" chartID="DEMO_CHART"/>
</extra-chart>
<extra-core>
<LocaleFinder class="com.fr.plugin.demo.DemoLocaleFinder"/>
</extra-core>
<extra-chart-designer>
<ChartTypeUIProvider class="com.fr.plugin.demo.DemoUI" chartID="DEMO_CHART"/>
</extra-chart-designer>
</plugin>

43
pom.xml

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--<parent>
<groupId>com.fr.plugin</groupId>
<artifactId>starter</artifactId>
<version>10.0</version>
</parent>-->
<parent>
<groupId>com.fr.maven</groupId>
<artifactId>finereport-maven</artifactId>
<version>10.0</version>
</parent>
<artifactId>demo-chart-pie</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.fanruan.api</groupId>
<artifactId>finekit</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/finekit-10.0.jar</systemPath>
</dependency>
</dependencies>
<build>
<!---如果要更改调试插件,改这里的配置就可以了-->
<outputDirectory>
${project.basedir}/../finereport-maven/start/webapps/webroot/WEB-INF/plugins/plugin-com.fr.plugin.demoChart-1.0.0/classes
</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

64
src/main/java/com/fr/plugin/demo/DemoCellDataFieldsPane.java

@ -0,0 +1,64 @@
package com.fr.plugin.demo;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.chart.field.BaseCellDataFieldsPane;
import com.fanruan.api.design.ui.component.formula.UIFormulaTextField;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-05
*/
public class DemoCellDataFieldsPane extends BaseCellDataFieldsPane<DemoColumnFieldCollection> {
private UIFormulaTextField categoryPane;
private UIFormulaTextField valuePane;
public void initComponents(){
categoryPane = new UIFormulaTextField();
valuePane = new UIFormulaTextField();
super.initComponents();
}
@Override
protected String[] fieldLabels() {
return new String[]{
DesignKit.i18nText("Fine-Plugin_Demo_Category"),
DesignKit.i18nText("Fine-Plugin_Demo_Value")
};
}
@Override
protected Component[] fieldComponents() {
return new Component[]{
categoryPane,
valuePane
};
}
@Override
protected UIFormulaTextField[] formulaPanes() {
return new UIFormulaTextField[]{
categoryPane,
valuePane
};
}
@Override
public void populateBean(DemoColumnFieldCollection dataConf) {
populateField(categoryPane, dataConf.getCategory());
populateField(valuePane, dataConf.getValue());
}
@Override
public DemoColumnFieldCollection updateBean() {
DemoColumnFieldCollection dataConfig = new DemoColumnFieldCollection();
updateField(categoryPane, dataConfig.getCategory());
updateField(valuePane, dataConfig.getValue());
return dataConfig;
}
}

202
src/main/java/com/fr/plugin/demo/DemoChart.java

@ -0,0 +1,202 @@
package com.fr.plugin.demo;
import com.fanruan.api.cal.FormulaKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.report.chart.BaseChartWithData;
import com.fanruan.api.script.FineCanvas;
import com.fanruan.api.util.AssistKit;
import com.fanruan.api.util.IOKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.BaseFormula;
import com.fr.base.chart.cross.FormulaProcessor;
import com.fr.chart.ChartWebParaProvider;
import com.fr.extended.chart.HyperLinkPara;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import java.util.List;
import java.awt.Image;
import java.awt.image.BufferedImage;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-06
*/
@FunctionRecorder
public class DemoChart extends BaseChartWithData {
private static final String ID = "DEMO_CHART";
private BaseFormula titleFormula = FormulaKit.newFormula(StringKit.EMPTY);
private PieType pieType = PieType.PIE;
private String legendPosition = "left";
public PieType getPieType() {
return pieType;
}
public void setPieType(PieType pieType) {
this.pieType = pieType;
}
public BaseFormula getTitleFormula() {
return titleFormula;
}
public void setTitleFormula(BaseFormula titleFormula) {
this.titleFormula = titleFormula;
}
public String getLegendPosition() {
return legendPosition;
}
public void setLegendPosition(String legendPosition) {
this.legendPosition = legendPosition;
}
@Override
protected Image designImage(int width, int height, int resolution, ChartWebParaProvider chartWebPara) {
switch (pieType) {
case PIE:
return IOKit.readImageWithCache("com/fr/plugin/demo/pieType.png");
default:
return IOKit.readImageWithCache("com/fr/plugin/demo/ringType.png");
}
}
@Override
protected Image exportImage(int width, int height, int resolution, ChartWebParaProvider chartWebPara) {
BufferedImage bufferedImage = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
try {
FineCanvas canvas = new FineCanvas("/com/fr/plugin/demo/echarts-adapter.js", "/com/fr/plugin/demo/echarts.js");
canvas.loadText("canvas.height = " + height, "canvas.width = " + width);
canvas.loadText("var myChart = echarts.init(canvas)");
canvas.loadText("option = " + createAttributeConfig(chartWebPara).toString());
canvas.loadText("myChart.setOption(option);");
bufferedImage = canvas.paint();
} catch (Exception ex) {
LogKit.error(ex.getMessage(), ex);
}
return bufferedImage;
}
@Override
public DemoChart clone() throws CloneNotSupportedException {
DemoChart result = (DemoChart) super.clone();
if (getTitleFormula() != null) {
result.setTitleFormula(this.getTitleFormula().clone());
}
result.setPieType(this.getPieType());
result.setLegendPosition(this.getLegendPosition());
return result;
}
@Override
public int hashCode() {
return super.hashCode() + AssistKit.hashCode(this.getTitleFormula(), this.getPieType(), this.getLegendPosition());
}
@Override
public boolean equals(Object ob) {
return super.equals(ob)
&& ob instanceof DemoChart
&& AssistKit.equals(this.getTitleFormula(), ((DemoChart) ob).getTitleFormula())
&& AssistKit.equals(this.getPieType(), ((DemoChart) ob).getPieType())
&& AssistKit.equals(this.getLegendPosition(), ((DemoChart) ob).getLegendPosition());
}
@Override
public JSONObject createAttributeConfig(ChartWebParaProvider chartWebPara) {
JSONObject jsonObject = super.createAttributeConfig(chartWebPara);
jsonObject.put("title", JSONFactory.createJSON(JSON.OBJECT).put("text", getTitleFormula().getResult()).put("x", "center"));
jsonObject.put("tooltip", JSONFactory.createJSON(JSON.OBJECT).put("trigger", "item").put("formatter", "{b}: {c} ({d}%)"));
DemoColumnFieldCollection columnFieldCollection = getFieldCollection(DemoColumnFieldCollection.class);
List<Object> category = columnFieldCollection.getCategory().getValues();
List<Object> values = columnFieldCollection.getValue().getValues();
JSONArray legendData = JSONFactory.createJSON(JSON.ARRAY);
JSONArray seriesData = JSONFactory.createJSON(JSON.ARRAY);
for (int i = 0; i < category.size(); i++) {
legendData.put(category.get(i));
seriesData.put(JSONFactory.createJSON(JSON.OBJECT).put("name", category.get(i)).put("value", values.get(i)));
}
jsonObject.put("legend", JSONFactory.createJSON(JSON.OBJECT).put("orient", "vertical").put("left", getLegendPosition()).put("data", legendData));
JSONObject series = JSONFactory.createJSON(JSON.OBJECT);
series.put("type", "pie");
switch (pieType) {
case PIE:
series.put("radius", "55%");
break;
default:
series.put("radius", JSONFactory.createJSON(JSON.ARRAY).put("35%").put("55%"));
break;
}
series.put("data", seriesData);
jsonObject.put("series", series);
return jsonObject;
}
@Override
public void dealFormula(FormulaProcessor formulaProcessor) {
if (titleFormula != null) {
formulaProcessor.dealWith(titleFormula);
}
super.dealFormula(formulaProcessor);
}
@Override
public String getID() {
return ID;
}
@Override
public void readAttr(XMLableReader xmLableReader) {
super.readAttr(xmLableReader);
this.setPieType(PieType.parseInt(xmLableReader.getAttrAsInt("pieType", 0)));
this.setTitleFormula(FormulaKit.newFormula(xmLableReader.getAttrAsString("title", "新建图表标题")));
this.setLegendPosition(xmLableReader.getAttrAsString("legendPosition", StringKit.EMPTY));
}
@Override
public void writeAttr(XMLPrintWriter xmlPrintWriter) {
super.writeAttr(xmlPrintWriter);
xmlPrintWriter.attr("pieType", pieType.ordinal())
.attr("title", titleFormula.toString())
.attr("legendPosition", legendPosition);
}
private static final HyperLinkPara Category = new HyperLinkPara() {
@Override
public String getName() {
return "分类";
}
@Override
public String getFormulaContent() {
return "Category";
}
@Override
public String[] getProps() {
return new String[]{"data", "name"};
}
};
@Override
protected HyperLinkPara[] hyperLinkParas() {
return new HyperLinkPara[]{
Category,
};
}
}

35
src/main/java/com/fr/plugin/demo/DemoColumnFieldCollection.java

@ -0,0 +1,35 @@
package com.fr.plugin.demo;
import com.fanruan.api.report.chart.field.BaseColumnFieldCollection;
import com.fr.chartx.data.annotations.KeyField;
import com.fr.chartx.data.field.ColumnField;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-05
*/
public class DemoColumnFieldCollection extends BaseColumnFieldCollection {
@KeyField
private ColumnField category = new ColumnField();
private ColumnField value = new ColumnField();
public ColumnField getCategory() {
return category;
}
public void setCategory(ColumnField category) {
this.category = category;
}
public ColumnField getValue() {
return value;
}
public void setValue(ColumnField value) {
this.value = value;
}
}

69
src/main/java/com/fr/plugin/demo/DemoDataSetFieldsPane.java

@ -0,0 +1,69 @@
package com.fr.plugin.demo;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.chart.field.BaseDataSetFieldsPane;
import com.fanruan.api.design.ui.component.UIComboBox;
import com.fanruan.api.design.ui.component.chart.CalculateComboBox;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-05
*/
public class DemoDataSetFieldsPane extends BaseDataSetFieldsPane<DemoColumnFieldCollection> {
private UIComboBox categoryPane;
private UIComboBox valuePane;
private CalculateComboBox calculateComboBox;
public void initComponents() {
categoryPane = new UIComboBox();
valuePane = new UIComboBox();
calculateComboBox = new CalculateComboBox();
super.initComponents();
}
@Override
protected String[] fieldLabels() {
return new String[]{
DesignKit.i18nText("Fine-Plugin_Demo_Category"),
DesignKit.i18nText("Fine-Plugin_Demo_Value"),
DesignKit.i18nText("Fine-Plugin_Demo_Summary_Method")
};
}
@Override
protected Component[] fieldComponents() {
return new Component[]{
categoryPane,
valuePane,
calculateComboBox
};
}
@Override
protected UIComboBox[] filedComboBoxes() {
return new UIComboBox[]{
categoryPane,
valuePane
};
}
@Override
public void populateBean(DemoColumnFieldCollection dataConf) {
populateField(categoryPane, dataConf.getCategory());
populateFunctionField(valuePane, calculateComboBox, dataConf.getValue());
}
@Override
public DemoColumnFieldCollection updateBean() {
DemoColumnFieldCollection dataConfig = new DemoColumnFieldCollection();
updateField(categoryPane, dataConfig.getCategory());
updateFunctionField(valuePane, calculateComboBox, dataConfig.getValue());
return dataConfig;
}
}

19
src/main/java/com/fr/plugin/demo/DemoLocaleFinder.java

@ -0,0 +1,19 @@
package com.fr.plugin.demo;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.stable.fun.impl.AbstractLocaleFinder;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-25
*/
@FunctionRecorder
public class DemoLocaleFinder extends AbstractLocaleFinder {
@Override
@ExecuteFunctionRecord
public String find() {
return "com/fr/plugin/locale/demo";
}
}

41
src/main/java/com/fr/plugin/demo/DemoTitlePane.java

@ -0,0 +1,41 @@
package com.fr.plugin.demo;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.chart.BaseOtherPane;
import com.fanruan.api.design.ui.component.formula.UIFormulaTextField;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-06
*/
public class DemoTitlePane extends BaseOtherPane<DemoChart> {
private UIFormulaTextField title;
@Override
public void populate(DemoChart ob) {
title.populateBean(ob.getTitleFormula().toString());
}
@Override
public void update(DemoChart ob) {
ob.getTitleFormula().setContent(title.updateBean());
}
@Override
protected JPanel createContentPane() {
JPanel panel = new JPanel(new BorderLayout(0, 6));
title = new UIFormulaTextField();
panel.add(title, BorderLayout.CENTER);
return panel;
}
@Override
public String title4PopupWindow() {
return DesignKit.i18nText("Fine-Plugin_Demo_Title");
}
}

62
src/main/java/com/fr/plugin/demo/DemoType.java

@ -0,0 +1,62 @@
package com.fr.plugin.demo;
import com.fanruan.api.report.chart.BaseChartType;
import com.fanruan.api.report.chart.BaseChartWithData;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-06
*/
public class DemoType extends BaseChartType {
/**
* 该种图表所有的图表对象实例比如柱形图就有堆积柱形图百分比堆积柱形图等等
*
* @return 所有的图表对象实例
*/
public BaseChartWithData[] getChartTypes() {
return new BaseChartWithData[]{
createDemoChart(PieType.PIE),
createDemoChart(PieType.RING)
};
}
/**
* 图表在web端展现时需要的JS文件
*
* @return JS文件数组
*/
public String[] getRequiredJS() {
return new String[]{
"com/fr/plugin/demo/demoWrapper.js",
"com/fr/plugin/demo/echarts.js"
};
}
/**
* 图表在web端展现时需要的CSS文件
*
* @return CSS文件数组
*/
public String[] getRequiredCss() {
return new String[]{
"com/fr/plugin/demo/demo.css"
};
}
/**
* JS对象名该对象一般是一个函数执行后会在给定的dom中绘制图表
*
* @return JS对象名
*/
public String getWrapperName() {
return "demoWrapper";
}
private DemoChart createDemoChart(PieType pieType) {
DemoChart demoChart = new DemoChart();
demoChart.setPieType(pieType);
return demoChart;
}
}

56
src/main/java/com/fr/plugin/demo/DemoTypePane.java

@ -0,0 +1,56 @@
package com.fr.plugin.demo;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.chart.DefaultTypePane;
import com.fanruan.api.design.ui.component.UIButtonGroup;
import com.fanruan.api.util.StringKit;
import javax.swing.JPanel;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-05
*/
public class DemoTypePane extends DefaultTypePane<DemoChart> {
private UIButtonGroup buttonGroup = new UIButtonGroup(new String[]{DesignKit.i18nText("Fine-Plugin_Legend_Right"), DesignKit.i18nText("Fine-Plugin_Legend_Left")});
@Override
protected String[] getTypeIconPath() {
return new String[]{
"com/fr/plugin/demo/pieType.png",
"com/fr/plugin/demo/ringType.png"
};
}
@Override
protected int getSelectIndexInChart(DemoChart chart) {
return chart.getPieType().ordinal();
}
@Override
protected void setSelectIndexInChart(DemoChart chart, int index) {
chart.setPieType(PieType.parseInt(index));
}
@Override
protected Component[][] getPaneComponents(JPanel typePane) {
return new Component[][]{
new Component[]{typePane},
new Component[]{buttonGroup}
};
}
@Override
public void populateBean(DemoChart ob) {
super.populateBean(ob);
buttonGroup.setSelectedIndex(StringKit.equals("left", ob.getLegendPosition()) ? 0 : 1);
}
@Override
public void updateBean(DemoChart ob) {
super.updateBean(ob);
ob.setLegendPosition(buttonGroup.getSelectedIndex() == 0 ? "left" : "right");
}
}

64
src/main/java/com/fr/plugin/demo/DemoUI.java

@ -0,0 +1,64 @@
package com.fr.plugin.demo;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.chart.BaseChartTypeUI;
import com.fanruan.api.design.chart.BaseDataPane;
import com.fanruan.api.design.chart.BaseOtherPane;
import com.fanruan.api.design.chart.DefaultOtherPane;
import com.fanruan.api.design.chart.DefaultTypePane;
import com.fanruan.api.design.chart.SingleDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-05
*/
public class DemoUI extends BaseChartTypeUI {
@Override
public DefaultTypePane getPlotTypePane() {
return new DemoTypePane();
}
@Override
public BaseDataPane getChartDataPane(AttributeChangeListener listener) {
return new BaseDataPane(listener) {
@Override
protected SingleDataPane createSingleDataPane() {
return new SingleDataPane(new DemoDataSetFieldsPane(), new DemoCellDataFieldsPane());
}
};
}
@Override
public BaseOtherPane[] getAttrPaneArray(AttributeChangeListener listener) {
return new BaseOtherPane[]{new DemoTitlePane(), new DefaultOtherPane()};
}
@Override
public String getIconPath() {
return "com/fr/plugin/demo/icon.png";
}
@Override
public String getName() {
return DesignKit.i18nText("Fine-Plugin_Demo_Chart");
}
@Override
public String[] getSubName() {
return new String[]{
DesignKit.i18nText("Fine-Plugin_Pie"),
DesignKit.i18nText("Fine-Plugin_Ring")
};
}
@Override
public String[] getDemoImagePath() {
return new String[]{
"com/fr/plugin/demo/pie.png",
"com/fr/plugin/demo/ring.png"
};
}
}

20
src/main/java/com/fr/plugin/demo/PieType.java

@ -0,0 +1,20 @@
package com.fr.plugin.demo;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-05
*/
public enum PieType {
PIE,
RING;
public static PieType parseInt(int index) {
for (PieType type : PieType.values()) {
if (type.ordinal() == index) {
return type;
}
}
return PIE;
}
}

4
src/main/resources/com/fr/plugin/demo/demo.css

@ -0,0 +1,4 @@
.demo-style {
width: 400px;
height: 300px;
}

24
src/main/resources/com/fr/plugin/demo/demoWrapper.js

@ -0,0 +1,24 @@
!(function () {
Van.FRChartBridge.demoWrapper = Van.FRChartBridge.AbstractChart.extend({
_init: function (dom, option) {
var chart = echarts.init(dom);
//绑定点击触发超链函数
chart.on('click', this.getLinkFun());
chart.setOption(option);
return chart;
},
_refresh: function (chart, option) {
chart.setOption(option);
},
_resize: function (chart) {
chart.resize();
},
_emptyData: function (options) {
return options.series.data.length === 0;
}
})
})();

7
src/main/resources/com/fr/plugin/demo/echarts-adapter.js

@ -0,0 +1,7 @@
var document = {
createElement: function(element) {
if (element == 'canvas') {
return new Canvas();
}
},
};

81519
src/main/resources/com/fr/plugin/demo/echarts.js

File diff suppressed because it is too large Load Diff

BIN
src/main/resources/com/fr/plugin/demo/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
src/main/resources/com/fr/plugin/demo/pie.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

BIN
src/main/resources/com/fr/plugin/demo/pieType.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

BIN
src/main/resources/com/fr/plugin/demo/ring.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
src/main/resources/com/fr/plugin/demo/ringType.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

9
src/main/resources/com/fr/plugin/locale/demo.properties

@ -0,0 +1,9 @@
Fine-Plugin_Demo_Category=category
Fine-Plugin_Demo_Value=value
Fine-Plugin_Demo_Summary_Method=Summary Method
Fine-Plugin_Demo_Title=Title
Fine-Plugin_Demo_Chart=Demo Chart
Fine-Plugin_Legend_Right=left legend
Fine-Plugin_Legend_Left=right legend
Fine-Plugin_Pie=Pie
Fine-Plugin_Ring=Ring

9
src/main/resources/com/fr/plugin/locale/demo_en_US.properties

@ -0,0 +1,9 @@
Fine-Plugin_Demo_Category=category
Fine-Plugin_Demo_Value=value
Fine-Plugin_Demo_Summary_Method=Summary Method
Fine-Plugin_Demo_Title=Title
Fine-Plugin_Demo_Chart=Demo Chart
Fine-Plugin_Legend_Right=left legend
Fine-Plugin_Legend_Left=right legend
Fine-Plugin_Pie=Pie
Fine-Plugin_Ring=Ring

9
src/main/resources/com/fr/plugin/locale/demo_zh_CN.properties

@ -0,0 +1,9 @@
Fine-Plugin_Demo_Category=\u5206\u7C7B
Fine-Plugin_Demo_Value=\u503C
Fine-Plugin_Demo_Summary_Method=\u6C47\u603B\u65B9\u5F0F
Fine-Plugin_Demo_Title=\u6807\u9898
Fine-Plugin_Demo_Chart=Demo\u56FE\u8868
Fine-Plugin_Legend_Right=\u56FE\u4F8B\u5C45\u5DE6
Fine-Plugin_Legend_Left=\u56FE\u4F8B\u5C45\u53F3
Fine-Plugin_Pie=\u997C\u56FE
Fine-Plugin_Ring=\u5706\u73AF\u56FE
Loading…
Cancel
Save