Browse Source

类型界面开出多种详细类型设置

master
zheng 7 years ago
parent
commit
b4beb7914f
  1. 15
      src/com/fr/plugin/demo/DemoChart.java
  2. 34
      src/com/fr/plugin/demo/DemoTypePane.java
  3. 7
      src/com/fr/plugin/demo/DemoUI.java
  4. 18
      src/com/fr/plugin/demo/ThemeType.java
  5. BIN
      src/com/fr/plugin/demo/dark.png
  6. BIN
      src/com/fr/plugin/demo/white.png

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

@ -33,6 +33,16 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
private BaseFormula titleFormula;
private ThemeType themeType = ThemeType.DARK;
public ThemeType getThemeType() {
return themeType;
}
public void setThemeType(ThemeType themeType) {
this.themeType = themeType;
}
public BaseFormula getTitleFormula() {
return titleFormula;
}
@ -44,12 +54,14 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
@Override
protected void readAttr(XMLableReader reader) {
super.readAttr(reader);
this.setThemeType(ThemeType.parseInt(reader.getAttrAsInt("theme", 0)));
this.setTitleFormula(ExtendedHelper.readFormula(reader, "title"));
}
@Override
protected void writeAttr(XMLPrintWriter writer) {
super.writeAttr(writer);
writer.attr("theme", getThemeType().ordinal());
ExtendedHelper.writeFormula(this.getTitleFormula(), writer, "title");
}
@ -59,6 +71,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
if (getTitleFormula() != null) {
result.setTitleFormula(this.getTitleFormula().clone());
}
result.setThemeType(this.getThemeType());
return result;
}
@ -67,6 +80,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
return super.equals(ob)
&& ob instanceof DemoChart
&& ComparatorUtils.equals(this.getTitleFormula(), ((DemoChart) ob).getTitleFormula())
&& ComparatorUtils.equals(this.getThemeType(), ((DemoChart) ob).getThemeType())
;
}
@ -88,6 +102,7 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
@ExecuteFunctionRecord
@Override
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)));

34
src/com/fr/plugin/demo/DemoTypePane.java

@ -0,0 +1,34 @@
package com.fr.plugin.demo;
import com.fr.extended.chart.ExtendedTypePane;
/**
* Created by shine on 2018/4/19.
*/
public class DemoTypePane extends ExtendedTypePane<DemoChart> {
@Override
protected String[] getTypeIconPath() {
return new String[]{
"com/fr/plugin/demo/dark.png",
"com/fr/plugin/demo/white.png"
};
}
@Override
protected String[] getTypeTipName() {
return new String[]{
"深色主题",
"浅色主题"
};
}
@Override
protected int getTypeIndex(DemoChart chart) {
return chart.getThemeType().ordinal();
}
@Override
protected void setType(DemoChart chart, int index) {
chart.setThemeType(ThemeType.parseInt(index));
}
}

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

@ -3,6 +3,7 @@ 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.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.extended.chart.AbstractExtendedChartTableDataPane;
import com.fr.extended.chart.AbstractExtendedChartUIProvider;
import com.fr.extended.chart.ExtendedOtherPane;
@ -11,6 +12,12 @@ import com.fr.extended.chart.ExtendedOtherPane;
* Created by shine on 2018/3/24.
*/
public class DemoUI extends AbstractExtendedChartUIProvider {
@Override
public AbstractChartTypePane getPlotTypePane() {
return new DemoTypePane();
}
@Override
protected AbstractExtendedChartTableDataPane getTableDataSourcePane() {
return new DemoTableDataPane();

18
src/com/fr/plugin/demo/ThemeType.java

@ -0,0 +1,18 @@
package com.fr.plugin.demo;
/**
* Created by shine on 2018/4/19.
*/
public enum ThemeType {
DARK,
WHITE;
public static ThemeType parseInt(int index) {
for (ThemeType type : ThemeType.values()) {
if (type.ordinal() == index) {
return type;
}
}
return DARK;
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Loading…
Cancel
Save