Browse Source

哈哈哈

master
zheng 7 years ago
parent
commit
caa3717e64
  1. 2
      plugin-demochart.iml
  2. 22
      plugin.xml
  3. 14
      src/com/fr/plugin/demo/Demo.java
  4. 30
      src/com/fr/plugin/demo/DemoBackgroundPane.java
  5. 181
      src/com/fr/plugin/demo/DemoChart.java
  6. 63
      src/com/fr/plugin/demo/DemoDataConfig.java
  7. 55
      src/com/fr/plugin/demo/DemoReportDataPane.java
  8. 20
      src/com/fr/plugin/demo/DemoStylePane.java
  9. 54
      src/com/fr/plugin/demo/DemoTableDataPane.java
  10. 37
      src/com/fr/plugin/demo/DemoTitlePane.java
  11. 36
      src/com/fr/plugin/demo/DemoUI.java
  12. BIN
      src/com/fr/plugin/demo/demo.png
  13. 13
      src/com/fr/plugin/demo/demoWrapper.js
  14. 55833
      src/com/fr/plugin/demo/echarts-gl.js
  15. 81523
      src/com/fr/plugin/demo/echarts.js
  16. BIN
      src/com/fr/plugin/demo/icon.png
  17. 7
      src/com/fr/plugin/extended/chart/demo/DemoBar2DChart.java
  18. 7
      src/com/fr/plugin/extended/chart/demo/DemoBar2DTableDataPane.java

2
plugin-demochart.iml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4"> <module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/../env/webroot/WEB-INF/classes/production/plugin-demochart" /> <output url="file://$MODULE_DIR$/../env/webroot/WEB-INF/plugins/plugin-com.fr.plugin.demoChart-1.0.0/classes" />
<output-test url="file://$MODULE_DIR$/../env/webroot/WEB-INF/classes/test/plugin-demochart" /> <output-test url="file://$MODULE_DIR$/../env/webroot/WEB-INF/classes/test/plugin-demochart" />
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">

22
plugin.xml

@ -0,0 +1,22 @@
<?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>2018-3-31</jartime>
<vendor>finereport.shine</vendor>
<description><![CDATA[给开发者参考的图表插件demo]]></description>
<change-notes><![CDATA[]]></change-notes>
<function-recorder class="com.fr.plugin.demo.DemoChart"/>
<extra-chart>
<IndependentChartProvider class="com.fr.plugin.demo.Demo" plotID="DEMO_CHART"/>
</extra-chart>
<extra-chart-designer>
<IndependentChartUIProvider class="com.fr.plugin.demo.DemoUI" plotID="DEMO_CHART"/>
</extra-chart-designer>
</plugin>

14
src/com/fr/plugin/demo/Demo.java

@ -0,0 +1,14 @@
package com.fr.plugin.demo;
import com.fr.extended.chart.AbstractChart;
import com.fr.extended.chart.AbstractExtentChartProvider;
/**
* Created by shine on 2018/3/24.
*/
public class Demo extends AbstractExtentChartProvider {
@Override
protected AbstractChart createChart() {
return new DemoChart();
}
}

30
src/com/fr/plugin/demo/DemoBackgroundPane.java

@ -0,0 +1,30 @@
package com.fr.plugin.demo;
import com.fr.extended.chart.ExtendedScrollPane;
import javax.swing.JPanel;
/**
* Created by shine on 2018/3/25.
*/
public class DemoBackgroundPane extends ExtendedScrollPane<DemoChart>{
@Override
public void populateBean(DemoChart ob) {
}
@Override
public void updateBean(DemoChart ob) {
}
@Override
protected JPanel createContentPane() {
return new JPanel();
}
@Override
protected String title4PopupWindow() {
return "背景";
}
}

181
src/com/fr/plugin/demo/DemoChart.java

@ -0,0 +1,181 @@
package com.fr.plugin.demo;
import com.fr.base.BaseFormula;
import com.fr.extended.chart.AbstractChart;
import com.fr.extended.chart.ExtendedHelper;
import com.fr.extended.chart.HyperLinkPara;
import com.fr.extended.chart.export.ExportProcessor;
import com.fr.extended.chart.export.JSExportProcessor;
import com.fr.general.GeneralUtils;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.stable.web.Repository;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2018/3/24.
*/
@FunctionRecorder
public class DemoChart extends AbstractChart<DemoDataConfig>{
private static final String ID = "DEMO_CHART";
private static final String NAME = "DEMO图表";
private BaseFormula titleFormula;
public BaseFormula getTitleFormula() {
return titleFormula;
}
public void setTitleFormula(BaseFormula titleFormula) {
this.titleFormula = titleFormula;
}
@Override
protected void readAttr(XMLableReader reader) {
super.readAttr(reader);
this.setTitleFormula(ExtendedHelper.readFormula(reader, "title"));
}
@Override
protected void writeAttr(XMLPrintWriter writer) {
super.writeAttr(writer);
ExtendedHelper.writeFormula(this.getTitleFormula(), writer, "title");
}
@Override
protected String getChartID() {
return ID;
}
@Override
public String getChartName() {
return NAME;
}
@Override
protected String demoImagePath() {
return "com/fr/plugin/demo/demo.png";
}
@ExecuteFunctionRecord
@Override
protected void addJSON(DemoDataConfig dataConfig, JSONObject jsonObject, Repository repo) throws JSONException {
jsonObject.put("title", JSONFactory.createJSON(JSON.OBJECT).put("text", ExtendedHelper.getFormulaResult(titleFormula)));
JSONArray array = JSONFactory.createJSON(JSON.ARRAY);
List<Object> xValues = dataConfig.getX().getValues();
List<Object> yValues = dataConfig.getY().getValues();
List<Object> zValues = dataConfig.getZ().getValues();
double maxValue = Double.MIN_VALUE;
for (int i = 0, len = xValues.size(); i < len; i++) {
maxValue = Math.max(GeneralUtils.objectToNumber(zValues.get(i)).doubleValue(), maxValue);
array.put(JSONFactory.createJSON(JSON.ARRAY).put(xValues.get(i)).put(yValues.get(i)).put(zValues.get(i)));
}
jsonObject.put("series", JSONFactory.createJSON(JSON.OBJECT).put("type", "bar3D").put("data", array)
.put("bevelSize", 0.2).put("bevelSmoothness", 2).put("shading", "color"));
jsonObject.put("xAxis3D", JSONFactory.createJSON(JSON.OBJECT).put("type", "category"))
.put("yAxis3D", JSONFactory.createJSON(JSON.OBJECT).put("type", "category"))
.put("zAxis3D", JSONFactory.createJSON(JSON.OBJECT).put("type", "value"));
jsonObject.put("grid3D", JSONFactory.createJSON(JSON.OBJECT).put("boxWidth", 200).put("boxDepth", 80));
jsonObject.put("visualMap", JSONFactory.createJSON(JSON.OBJECT)
.put("max", maxValue)
.put("color", JSONFactory.createJSON(JSON.ARRAY).put("#d94e5d").put("#eac736").put("#50a3ba")));
}
@Override
protected String[] requiredJS() {
return new String[]{
"com/fr/plugin/demo/demoWrapper.js",
"com/fr/plugin/demo/echarts.js",
"com/fr/plugin/demo/echarts-gl.js"
};
}
@Override
protected String wrapperName() {
return "demoWrapper";
}
private static final HyperLinkPara X = new HyperLinkPara() {
@Override
public String getName() {
return "X轴";
}
@Override
public String getFormulaContent() {
return "X";
}
@Override
public String[] getProps() {
return new String[]{"data", "0"};
}
};
private static final HyperLinkPara Y = new HyperLinkPara() {
@Override
public String getName() {
return "Y轴";
}
@Override
public String getFormulaContent() {
return "Y";
}
@Override
public String[] getProps() {
return new String[]{"data", "1"};
}
};
private static final HyperLinkPara[] PARAS = new HyperLinkPara[]{
X,
Y
};
@Override
protected HyperLinkPara[] hyperLinkParas() {
return PARAS;
}
@Override
protected List<BaseFormula> formulas() {
List<BaseFormula> list = new ArrayList<BaseFormula>();
list.add(this.getTitleFormula());
return list;
}
@Override
protected ExportProcessor createExportProcessor() {
return new JSExportProcessor();
}
// @Override
// protected DemoDataConfig designerDataConfig() {
// DemoDataConfig demoDataConfig = new DemoDataConfig();
// demoDataConfig.setX(new ExtendedField("days", new String[]{"Monday","Tuesday"}));
// demoDataConfig.setY(new ExtendedField("name", new String[]{"Lily", "Marks"}));
// demoDataConfig.setZ(new ExtendedField("money", new String[]{"100", "200"}));
// return super.designerDataConfig();
// }
}

63
src/com/fr/plugin/demo/DemoDataConfig.java

@ -0,0 +1,63 @@
package com.fr.plugin.demo;
import com.fr.extended.chart.AbstractDataConfig;
import com.fr.extended.chart.ExtendedField;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
/**
* Created by shine on 2018/3/24.
*/
public class DemoDataConfig extends AbstractDataConfig {
private ExtendedField x = new ExtendedField();
private ExtendedField y = new ExtendedField();
private ExtendedField z = new ExtendedField();
public ExtendedField getX() {
return x;
}
public void setX(ExtendedField x) {
this.x = x;
}
public ExtendedField getY() {
return y;
}
public void setY(ExtendedField y) {
this.y = y;
}
public ExtendedField getZ() {
return z;
}
public void setZ(ExtendedField z) {
this.z = z;
}
@Override
protected void readAttr(XMLableReader reader) {
readExtendedField(x, "x", reader);
readExtendedField(y, "y", reader);
readExtendedField(z, "z", reader);
}
@Override
protected void writeAttr(XMLPrintWriter writer) {
writeExtendedField(x, "x", writer);
writeExtendedField(y, "y", writer);
writeExtendedField(z, "z", writer);
}
@Override
public ExtendedField[] dataSetFields() {
return new ExtendedField[]{
x,
y,
z
};
}
}

55
src/com/fr/plugin/demo/DemoReportDataPane.java

@ -0,0 +1,55 @@
package com.fr.plugin.demo;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.extended.chart.AbstractExtendedChartReportDataPane;
/**
* Created by shine on 2018/3/24.
*/
public class DemoReportDataPane extends AbstractExtendedChartReportDataPane<DemoDataConfig> {
private TinyFormulaPane xPane;
private TinyFormulaPane yPane;
private TinyFormulaPane zPane;
@Override
protected String[] fieldLabel() {
return new String[]{
"X轴",
"Y轴",
"Z轴"
};
}
@Override
protected TinyFormulaPane[] formulaPanes() {
if (xPane == null) {
xPane = new TinyFormulaPane();
yPane = new TinyFormulaPane();
zPane = new TinyFormulaPane();
}
return new TinyFormulaPane[]{
xPane,
yPane,
zPane
};
}
@Override
protected void populate(DemoDataConfig dataConf) {
populateField(xPane, dataConf.getX());
populateField(yPane, dataConf.getY());
populateField(zPane, dataConf.getZ());
}
@Override
protected DemoDataConfig update() {
DemoDataConfig dataConfig = new DemoDataConfig();
updateField(xPane, dataConfig.getX());
updateField(yPane, dataConfig.getY());
updateField(zPane, dataConfig.getZ());
return dataConfig;
}
}

20
src/com/fr/plugin/demo/DemoStylePane.java

@ -0,0 +1,20 @@
package com.fr.plugin.demo;
import com.fr.extended.chart.AbstractExtendedStylePane;
import com.fr.extended.chart.ExtendedScrollPane;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2018/3/25.
*/
public class DemoStylePane extends AbstractExtendedStylePane<DemoChart>{
@Override
protected List<ExtendedScrollPane<DemoChart>> initPaneList() {
List<ExtendedScrollPane<DemoChart>> list = new ArrayList<ExtendedScrollPane<DemoChart>>();
list.add(new DemoTitlePane());
list.add(new DemoBackgroundPane());
return list;
}
}

54
src/com/fr/plugin/demo/DemoTableDataPane.java

@ -0,0 +1,54 @@
package com.fr.plugin.demo;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.extended.chart.AbstractExtendedChartTableDataPane;
/**
* Created by shine on 2018/3/24.
*/
public class DemoTableDataPane extends AbstractExtendedChartTableDataPane<DemoDataConfig>{
private UIComboBox xComboBox;
private UIComboBox yComboBox;
private UIComboBox zComboBox;
@Override
protected String[] fieldLabel() {
return new String[]{
"X轴",
"Y轴",
"Z轴"
};
}
@Override
protected UIComboBox[] filedComboBoxes() {
if (xComboBox == null) {
xComboBox = new UIComboBox();
yComboBox = new UIComboBox();
zComboBox = new UIComboBox();
}
return new UIComboBox[]{
xComboBox,
yComboBox,
zComboBox
};
}
@Override
protected void populate(DemoDataConfig dataConf) {
populateField(xComboBox, dataConf.getX());
populateField(yComboBox, dataConf.getY());
populateField(zComboBox, dataConf.getZ());
}
@Override
protected DemoDataConfig update() {
DemoDataConfig dataConfig = new DemoDataConfig();
updateField(xComboBox, dataConfig.getX());
updateField(yComboBox, dataConfig.getY());
updateField(zComboBox, dataConfig.getZ());
return dataConfig;
}
}

37
src/com/fr/plugin/demo/DemoTitlePane.java

@ -0,0 +1,37 @@
package com.fr.plugin.demo;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.extended.chart.ExtendedHelper;
import com.fr.extended.chart.ExtendedScrollPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* Created by shine on 2018/3/25.
*/
public class DemoTitlePane extends ExtendedScrollPane<DemoChart>{
private TinyFormulaPane title;
@Override
public void populateBean(DemoChart ob) {
title.populateBean(ExtendedHelper.formulaToString(ob.getTitleFormula()));
}
@Override
public void updateBean(DemoChart ob) {
ob.setTitleFormula(ExtendedHelper.stringToFormula(title.updateBean()));
}
@Override
protected JPanel createContentPane() {
JPanel panel = new JPanel(new BorderLayout());
title = new TinyFormulaPane();
panel.add(title, BorderLayout.CENTER);
return panel;
}
@Override
protected String title4PopupWindow() {
return "标题";
}
}

36
src/com/fr/plugin/demo/DemoUI.java

@ -0,0 +1,36 @@
package com.fr.plugin.demo;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.extended.chart.AbstractExtendedChartTableDataPane;
import com.fr.extended.chart.AbstractExtendedChartUIProvider;
import com.fr.extended.chart.ExtendedOtherPane;
/**
* Created by shine on 2018/3/24.
*/
public class DemoUI extends AbstractExtendedChartUIProvider {
@Override
protected AbstractExtendedChartTableDataPane getTableDataSourcePane() {
return new DemoTableDataPane();
}
@Override
protected AbstractReportDataContentPane getReportDataSourcePane() {
return new DemoReportDataPane();
}
@Override
public String getIconPath() {
return "com/fr/plugin/demo/icon.png";
}
@Override
public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) {
return new AbstractChartAttrPane[]{
new DemoStylePane(),
new ExtendedOtherPane()
};
}
}

BIN
src/com/fr/plugin/demo/demo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

13
src/com/fr/plugin/demo/demoWrapper.js

@ -0,0 +1,13 @@
demoWrapper = ExtendedChart.extend({
_init: function (dom, option) {
var chart = echarts.init(dom);
chart.setOption(option);
return chart;
},
_refresh: function (chart, option) {
chart.setOption(option);
},
});

55833
src/com/fr/plugin/demo/echarts-gl.js

File diff suppressed because one or more lines are too long

81523
src/com/fr/plugin/demo/echarts.js

File diff suppressed because it is too large Load Diff

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

7
src/com/fr/plugin/extended/chart/demo/DemoBar2DChart.java

@ -1,7 +0,0 @@
package com.fr.plugin.extended.chart.demo;
/**
* Created by shine on 2018/3/24.
*/
public class DemoBar2DChart {
}

7
src/com/fr/plugin/extended/chart/demo/DemoBar2DTableDataPane.java

@ -1,7 +0,0 @@
package com.fr.plugin.extended.chart.demo;
/**
* Created by shine on 2018/3/24.
*/
public class DemoBar2DTableDataPane {
}
Loading…
Cancel
Save