Browse Source

CHART-2964 公式重新实现

master
zheng 6 years ago
parent
commit
3261167942
  1. 19
      src/com/fr/plugin/demo/DemoChart.java
  2. 5
      src/com/fr/plugin/demo/DemoTitlePane.java

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

@ -1,9 +1,8 @@
package com.fr.plugin.demo; package com.fr.plugin.demo;
import com.fr.base.BaseFormula;
import com.fr.extended.chart.AbstractChart; import com.fr.extended.chart.AbstractChart;
import com.fr.extended.chart.ExtendedHelper;
import com.fr.extended.chart.HyperLinkPara; import com.fr.extended.chart.HyperLinkPara;
import com.fr.extended.chart.StringFormula;
import com.fr.extended.chart.export.ExportProcessor; import com.fr.extended.chart.export.ExportProcessor;
import com.fr.extended.chart.export.JSExportProcessor; import com.fr.extended.chart.export.JSExportProcessor;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
@ -31,7 +30,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
private static final String ID = "DEMO_CHART"; private static final String ID = "DEMO_CHART";
private static final String NAME = "DEMO图表"; private static final String NAME = "DEMO图表";
private BaseFormula titleFormula; private StringFormula titleFormula = new StringFormula();
private ThemeType themeType = ThemeType.DARK; private ThemeType themeType = ThemeType.DARK;
@ -53,11 +52,11 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
this.themeType = themeType; this.themeType = themeType;
} }
public BaseFormula getTitleFormula() { public StringFormula getTitleFormula() {
return titleFormula; return titleFormula;
} }
public void setTitleFormula(BaseFormula titleFormula) { public void setTitleFormula(StringFormula titleFormula) {
this.titleFormula = titleFormula; this.titleFormula = titleFormula;
} }
@ -66,7 +65,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
super.readAttr(reader); super.readAttr(reader);
this.setThemeType(ThemeType.parseInt(reader.getAttrAsInt("theme", 0))); this.setThemeType(ThemeType.parseInt(reader.getAttrAsInt("theme", 0)));
this.setThreeDimensional(reader.getAttrAsBoolean("threeD", false)); this.setThreeDimensional(reader.getAttrAsBoolean("threeD", false));
this.setTitleFormula(ExtendedHelper.readFormula(reader, "title")); this.getTitleFormula().readAttr("title", reader);
} }
@Override @Override
@ -74,7 +73,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
super.writeAttr(writer); super.writeAttr(writer);
writer.attr("theme", getThemeType().ordinal()); writer.attr("theme", getThemeType().ordinal());
writer.attr("threeD", isThreeDimensional()); writer.attr("threeD", isThreeDimensional());
ExtendedHelper.writeFormula(this.getTitleFormula(), writer, "title"); this.getTitleFormula().writeAttr("title", writer);
} }
@Override @Override
@ -123,7 +122,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
protected void addJSON(DemoDataConfig dataConfig, JSONObject jsonObject, Repository repo) throws JSONException { protected void addJSON(DemoDataConfig dataConfig, JSONObject jsonObject, Repository repo) throws JSONException {
jsonObject.put("theme", getThemeType() == ThemeType.DARK ? "dark" : "sth whatever"); jsonObject.put("theme", getThemeType() == ThemeType.DARK ? "dark" : "sth whatever");
jsonObject.put("title", JSONFactory.createJSON(JSON.OBJECT).put("text", ExtendedHelper.getFormulaResult(titleFormula))); jsonObject.put("title", JSONFactory.createJSON(JSON.OBJECT).put("text", getTitleFormula().getResult()));
JSONArray array = JSONFactory.createJSON(JSON.ARRAY); JSONArray array = JSONFactory.createJSON(JSON.ARRAY);
@ -229,8 +228,8 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
} }
@Override @Override
protected List<BaseFormula> formulas() { protected List<StringFormula> formulas() {
List<BaseFormula> list = new ArrayList<BaseFormula>(); List<StringFormula> list = new ArrayList<StringFormula>();
list.add(this.getTitleFormula()); list.add(this.getTitleFormula());
return list; return list;
} }

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

@ -1,7 +1,6 @@
package com.fr.plugin.demo; package com.fr.plugin.demo;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
import com.fr.extended.chart.ExtendedHelper;
import com.fr.extended.chart.ExtendedScrollPane; import com.fr.extended.chart.ExtendedScrollPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -14,12 +13,12 @@ public class DemoTitlePane extends ExtendedScrollPane<DemoChart>{
private TinyFormulaPane title; private TinyFormulaPane title;
@Override @Override
public void populateBean(DemoChart ob) { public void populateBean(DemoChart ob) {
title.populateBean(ExtendedHelper.formulaToString(ob.getTitleFormula())); title.populateBean(ob.getTitleFormula().getContent());
} }
@Override @Override
public void updateBean(DemoChart ob) { public void updateBean(DemoChart ob) {
ob.setTitleFormula(ExtendedHelper.stringToFormula(title.updateBean())); ob.getTitleFormula().setContent(title.updateBean());
} }
@Override @Override

Loading…
Cancel
Save