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;
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.StringFormula;
import com.fr.extended.chart.export.ExportProcessor;
import com.fr.extended.chart.export.JSExportProcessor;
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 NAME = "DEMO图表";
private BaseFormula titleFormula;
private StringFormula titleFormula = new StringFormula();
private ThemeType themeType = ThemeType.DARK;
@ -53,11 +52,11 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
this.themeType = themeType;
}
public BaseFormula getTitleFormula() {
public StringFormula getTitleFormula() {
return titleFormula;
}
public void setTitleFormula(BaseFormula titleFormula) {
public void setTitleFormula(StringFormula titleFormula) {
this.titleFormula = titleFormula;
}
@ -66,7 +65,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
super.readAttr(reader);
this.setThemeType(ThemeType.parseInt(reader.getAttrAsInt("theme", 0)));
this.setThreeDimensional(reader.getAttrAsBoolean("threeD", false));
this.setTitleFormula(ExtendedHelper.readFormula(reader, "title"));
this.getTitleFormula().readAttr("title", reader);
}
@Override
@ -74,7 +73,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
super.writeAttr(writer);
writer.attr("theme", getThemeType().ordinal());
writer.attr("threeD", isThreeDimensional());
ExtendedHelper.writeFormula(this.getTitleFormula(), writer, "title");
this.getTitleFormula().writeAttr("title", writer);
}
@Override
@ -123,7 +122,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
protected void addJSON(DemoDataConfig dataConfig, JSONObject jsonObject, Repository repo) throws JSONException {
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);
@ -229,8 +228,8 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
}
@Override
protected List<BaseFormula> formulas() {
List<BaseFormula> list = new ArrayList<BaseFormula>();
protected List<StringFormula> formulas() {
List<StringFormula> list = new ArrayList<StringFormula>();
list.add(this.getTitleFormula());
return list;
}

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

@ -1,7 +1,6 @@
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;
@ -14,12 +13,12 @@ public class DemoTitlePane extends ExtendedScrollPane<DemoChart>{
private TinyFormulaPane title;
@Override
public void populateBean(DemoChart ob) {
title.populateBean(ExtendedHelper.formulaToString(ob.getTitleFormula()));
title.populateBean(ob.getTitleFormula().getContent());
}
@Override
public void updateBean(DemoChart ob) {
ob.setTitleFormula(ExtendedHelper.stringToFormula(title.updateBean()));
ob.getTitleFormula().setContent(title.updateBean());
}
@Override

Loading…
Cancel
Save