Browse Source

echarts饼图实现

pull/1/head
richie 9 years ago
parent
commit
9b8299b2a1
  1. 8
      plugin.xml
  2. 15
      src/com/fr/solution/plugin/chart/echarts/ChineseMap.java
  3. 8
      src/com/fr/solution/plugin/chart/echarts/ChineseMapUI.java
  4. 45
      src/com/fr/solution/plugin/chart/echarts/EChartsPie.java
  5. 37
      src/com/fr/solution/plugin/chart/echarts/EChartsPieUI.java
  6. 5
      src/com/fr/solution/plugin/chart/echarts/base/AbstractIndependentEChartsProvider.java
  7. 42
      src/com/fr/solution/plugin/chart/echarts/base/ECharts.java
  8. 28
      src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlotGlyph.java
  9. 50
      src/com/fr/solution/plugin/chart/echarts/glyph/EChartsGlyph.java
  10. 2
      src/com/fr/solution/plugin/chart/echarts/glyph/EChartsLegendGlyph.java
  11. 30
      src/com/fr/solution/plugin/chart/echarts/glyph/EChartsPlotGlyph.java
  12. 6
      src/com/fr/solution/plugin/chart/echarts/glyph/EChartsTitleGlyph.java
  13. 106
      src/com/fr/solution/plugin/chart/echarts/glyph/NewGlyph.java
  14. 10
      src/com/fr/solution/plugin/chart/echarts/glyph/NewSeriesGlyph.java
  15. 72
      src/com/fr/solution/plugin/chart/echarts/glyph/map/ChineseMapPlotGlyph.java
  16. 26
      src/com/fr/solution/plugin/chart/echarts/glyph/pie/EChartsPiePlotGlyph.java
  17. BIN
      src/com/fr/solution/plugin/chart/echarts/images/pie/pie.png
  18. BIN
      src/com/fr/solution/plugin/chart/echarts/images/pie/pie256.png
  19. BIN
      src/com/fr/solution/plugin/chart/echarts/images/pie/pie_type1.png
  20. BIN
      src/com/fr/solution/plugin/chart/echarts/images/pie/pie_type2.png
  21. 10
      src/com/fr/solution/plugin/chart/echarts/legend/EChartsLegend.java
  22. 3
      src/com/fr/solution/plugin/chart/echarts/locale/echarts.properties
  23. 3
      src/com/fr/solution/plugin/chart/echarts/locale/echarts_zh_CN.properties
  24. 15
      src/com/fr/solution/plugin/chart/echarts/monitor/MonitorMap.java
  25. 27
      src/com/fr/solution/plugin/chart/echarts/monitor/MonitorPie.java
  26. 20
      src/com/fr/solution/plugin/chart/echarts/plot/EChartsPlot.java
  27. 10
      src/com/fr/solution/plugin/chart/echarts/plot/map/ChineseMapPlot.java
  28. 99
      src/com/fr/solution/plugin/chart/echarts/plot/pie/EChartsPiePlot.java
  29. 40
      src/com/fr/solution/plugin/chart/echarts/plot/pie/PieType.java
  30. 16
      src/com/fr/solution/plugin/chart/echarts/title/EChartsTitle.java
  31. 16
      src/com/fr/solution/plugin/chart/echarts/title/NewTitle.java
  32. 73
      src/com/fr/solution/plugin/chart/echarts/ui/AbstractEChartsTypePane.java
  33. 14
      src/com/fr/solution/plugin/chart/echarts/ui/AbstractIndependentEChartsUI.java
  34. 10
      src/com/fr/solution/plugin/chart/echarts/ui/data/AbstractEChartsReportDataContentPane.java
  35. 164
      src/com/fr/solution/plugin/chart/echarts/ui/data/AbstractEChartsTableDataContentPane.java
  36. 36
      src/com/fr/solution/plugin/chart/echarts/ui/filter/NewDataFilterPane.java
  37. 2
      src/com/fr/solution/plugin/chart/echarts/ui/map/ChineseChartTypePane.java
  38. 48
      src/com/fr/solution/plugin/chart/echarts/ui/map/ChineseMapTableDataContentPane.java
  39. 67
      src/com/fr/solution/plugin/chart/echarts/ui/pie/EChartsPieChartTypePane.java
  40. 9
      src/com/fr/solution/plugin/chart/echarts/ui/pie/EChartsPieReportDataContentPane.java
  41. 14
      src/com/fr/solution/plugin/chart/echarts/ui/pie/EChartsPieTableDataContentPane.java
  42. 159
      src/com/fr/solution/plugin/chart/echarts/ui/series/NewSeriesTypeUsePane.java

8
plugin.xml

@ -3,13 +3,15 @@
<id>com.fr.solution.plugin.chart.echarts</id>
<name><![CDATA[ECharts图表]]></name>
<active>yes</active>
<version>1.1</version>
<version>2.0</version>
<env-version>8.0</env-version>
<jartime>2016-01-11</jartime>
<vendor>solution</vendor>
<description><![CDATA[ECharts图表]]></description>
<change-notes><![CDATA[
<p>[2016-01-01]中国地图</p>
<p>[2016-02-18]饼图</p>
]]></change-notes>
<extra-core>
<LocaleFinder class="com.fr.solution.plugin.chart.echarts.EChartsLocaleFinder"/>
@ -19,11 +21,15 @@
<extra-designer/>
<extra-platform/>
<extra-chart>
<IndependentChartProvider class="com.fr.solution.plugin.chart.echarts.EChartsPie"
plotID="EChartsPiePlot"/>
<IndependentChartProvider class="com.fr.solution.plugin.chart.echarts.ChineseMap"
plotID="EChartsChinaMapPlot"/>
</extra-chart>
<extra-chart-designer>
<IndependentChartUIProvider class="com.fr.solution.plugin.chart.echarts.EChartsPieUI"
plotID="EChartsPiePlot"/>
<IndependentChartUIProvider class="com.fr.solution.plugin.chart.echarts.ChineseMapUI"
plotID="EChartsChinaMapPlot"/>
</extra-chart-designer>

15
src/com/fr/solution/plugin/chart/echarts/ChineseMap.java

@ -3,20 +3,20 @@ package com.fr.solution.plugin.chart.echarts;
import com.fr.chart.chartattr.Chart;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.base.AbstractIndependentEChartsProvider;
import com.fr.solution.plugin.chart.echarts.base.NewChart;
import com.fr.solution.plugin.chart.echarts.core.map.ChineseMapPlot;
import com.fr.solution.plugin.chart.echarts.base.ECharts;
import com.fr.solution.plugin.chart.echarts.plot.map.ChineseMapPlot;
/**
* Created by richie on 16/1/29.
*/
public class ChineseMap extends AbstractIndependentEChartsProvider {
private static NewChart createChineseMap() {
private static ECharts createChineseMap() {
ChineseMapPlot plot = new ChineseMapPlot();
return new NewChart(plot);
return new ECharts(plot);
}
public static NewChart[] charts = new NewChart[] {
public static ECharts[] charts = new ECharts[] {
createChineseMap()
};
@ -41,9 +41,4 @@ public class ChineseMap extends AbstractIndependentEChartsProvider {
return "com/fr/solution/plugin/chart/echarts/images/map/map256.png";
}
@Override
public String getWrapperName() {
return "EChartsFactory";
}
}

8
src/com/fr/solution/plugin/chart/echarts/ChineseMapUI.java

@ -6,6 +6,7 @@ import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.solution.plugin.chart.echarts.ui.AbstractIndependentEChartsUI;
import com.fr.solution.plugin.chart.echarts.ui.map.ChineseMapReportDataContentPane;
import com.fr.solution.plugin.chart.echarts.ui.map.ChineseMapTableDataContentPane;
import com.fr.solution.plugin.chart.echarts.ui.map.ChineseChartTypePane;
@ -13,7 +14,7 @@ import com.fr.solution.plugin.chart.echarts.ui.map.ChineseChartTypePane;
/**
* Created by richie on 16/1/29.
*/
public class ChineseMapUI extends AbstractIndependentChartUI {
public class ChineseMapUI extends AbstractIndependentEChartsUI {
@Override
public AbstractChartTypePane getPlotTypePane() {
return new ChineseChartTypePane();
@ -33,9 +34,4 @@ public class ChineseMapUI extends AbstractIndependentChartUI {
public String getIconPath() {
return "com/fr/solution/plugin/chart/echarts/images/map/chinese.png";
}
@Override
public boolean isUseDefaultPane() {
return false;
}
}

45
src/com/fr/solution/plugin/chart/echarts/EChartsPie.java

@ -0,0 +1,45 @@
package com.fr.solution.plugin.chart.echarts;
import com.fr.chart.chartattr.Chart;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.base.AbstractIndependentEChartsProvider;
import com.fr.solution.plugin.chart.echarts.base.ECharts;
import com.fr.solution.plugin.chart.echarts.plot.pie.EChartsPiePlot;
import com.fr.solution.plugin.chart.echarts.plot.pie.PieType;
/**
* Created by richie on 16/2/18.
*/
public class EChartsPie extends AbstractIndependentEChartsProvider {
private static ECharts createPie(PieType type) {
EChartsPiePlot plot = new EChartsPiePlot(type);
return new ECharts(plot);
}
public static ECharts[] charts = new ECharts[] {
createPie(PieType.REGULAR),
createPie(PieType.CIRCLE)
};
@Override
public String getChartName() {
return "Plugin-ECharts_Pie";
}
@Override
public String getChartUseName() {
return Inter.getLocText("Plugin-ECharts_Pie");
}
@Override
public Chart[] getChartTypes() {
return charts;
}
@Override
public String getChartImagePath() {
return "com/fr/solution/plugin/chart/echarts/images/pie/pie256.png";
}
}

37
src/com/fr/solution/plugin/chart/echarts/EChartsPieUI.java

@ -0,0 +1,37 @@
package com.fr.solution.plugin.chart.echarts;
import com.fr.chart.chartattr.Plot;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.solution.plugin.chart.echarts.ui.AbstractIndependentEChartsUI;
import com.fr.solution.plugin.chart.echarts.ui.pie.EChartsPieChartTypePane;
import com.fr.solution.plugin.chart.echarts.ui.pie.EChartsPieReportDataContentPane;
import com.fr.solution.plugin.chart.echarts.ui.pie.EChartsPieTableDataContentPane;
/**
* Created by richie on 16/1/29.
*/
public class EChartsPieUI extends AbstractIndependentEChartsUI {
@Override
public AbstractChartTypePane getPlotTypePane() {
return new EChartsPieChartTypePane();
}
@Override
public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) {
return new EChartsPieTableDataContentPane(parent);
}
@Override
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) {
return new EChartsPieReportDataContentPane();
}
@Override
public String getIconPath() {
return "com/fr/solution/plugin/chart/echarts/images/pie/pie.png";
}
}

5
src/com/fr/solution/plugin/chart/echarts/base/AbstractIndependentEChartsProvider.java

@ -13,4 +13,9 @@ public abstract class AbstractIndependentEChartsProvider extends AbstractIndepen
"/com/fr/solution/plugin/chart/echarts/web/echarts.bridge.js"
};
}
@Override
public String getWrapperName() {
return "EChartsFactory";
}
}

42
src/com/fr/solution/plugin/chart/echarts/base/NewChart.java → src/com/fr/solution/plugin/chart/echarts/base/ECharts.java

@ -7,44 +7,44 @@ import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.general.ComparatorUtils;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.solution.plugin.chart.echarts.glyph.NewGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.NewLegendGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.NewTitleGlyph;
import com.fr.solution.plugin.chart.echarts.plot.NewPlot;
import com.fr.solution.plugin.chart.echarts.title.NewTitle;
import com.fr.stable.xml.XMLReadable;
import com.fr.solution.plugin.chart.echarts.glyph.EChartsGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.EChartsLegendGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.EChartsTitleGlyph;
import com.fr.solution.plugin.chart.echarts.plot.EChartsPlot;
import com.fr.solution.plugin.chart.echarts.title.EChartsTitle;
import com.fr.stable.xml.XMLableReader;
/**
* Created by richie on 16/1/29.
*/
public class NewChart extends Chart {
public class ECharts extends Chart {
public NewChart() {
public ECharts() {
setWrapperName("EChartsFactory");
setTitle(new NewTitle());
setTitle(new EChartsTitle());
}
public NewChart(NewPlot plot) {
public ECharts(EChartsPlot plot) {
super(plot);
setWrapperName("EChartsFactory");
setTitle(new NewTitle());
setTitle(new EChartsTitle());
}
@Override
public BaseChartGlyph createGlyph(ChartData chartData) {
NewGlyph glyph = new NewGlyph();
EChartsGlyph glyph = new EChartsGlyph();
glyph.setGeneralInfo(this);
NewPlot newPlot = (NewPlot) getPlot();
if (newPlot != null) {
PlotGlyph plotGlyph = newPlot.createPlotGlyph(chartData);
NewLegendGlyph legendGlyph = newPlot.createLegendGlyph(plotGlyph);
EChartsPlot EChartsPlot = (EChartsPlot) getPlot();
if (EChartsPlot != null) {
PlotGlyph plotGlyph = EChartsPlot.createPlotGlyph(chartData);
glyph.setPlotGlyph(plotGlyph);
EChartsLegendGlyph legendGlyph = EChartsPlot.createLegendGlyph(plotGlyph);
glyph.setLegendGlyph(legendGlyph);
}
NewTitle title = (NewTitle)getTitle();
EChartsTitle title = (EChartsTitle)getTitle();
if (title != null) {
NewTitleGlyph titleGlyph = title.createGlyph();
EChartsTitleGlyph titleGlyph = title.createGlyph();
glyph.setTitleGlyph(titleGlyph);
}
@ -62,7 +62,7 @@ public class NewChart extends Chart {
* @return 是否是obClass对象
*/
public boolean accept(Class<? extends Chart> obClass){
return ComparatorUtils.equals(NewChart.class, obClass);
return ComparatorUtils.equals(ECharts.class, obClass);
}
@ -71,8 +71,8 @@ public class NewChart extends Chart {
if (reader.isChildNode()) {
String tmpNodeName = reader.getTagName();
if (tmpNodeName.equals(NewTitle.XML_TAG)) {
setTitle(new NewTitle());
if (tmpNodeName.equals(EChartsTitle.XML_TAG)) {
setTitle(new EChartsTitle());
reader.readXMLObject(getTitle());
} else if (tmpNodeName.equals(Plot.XML_TAG)) {
setPlot((Plot) GeneralXMLTools.readXMLable(reader));

28
src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlotGlyph.java

@ -1,28 +0,0 @@
package com.fr.solution.plugin.chart.echarts.core.map;
import com.fr.chart.chartglyph.PlotGlyph;
/**
* Created by richie on 16/1/29.
*/
public class ChineseMapPlotGlyph extends PlotGlyph {
@Override
public void layoutAxisGlyph(int resolution) {
}
@Override
public void layoutDataSeriesGlyph(int resolution) {
}
@Override
public String getPlotGlyphType() {
return "ChineseMapPlotGlyph";
}
@Override
public String getChartType() {
return "ChineseMap";
}
}

50
src/com/fr/solution/plugin/chart/echarts/glyph/EChartsGlyph.java

@ -0,0 +1,50 @@
package com.fr.solution.plugin.chart.echarts.glyph;
import com.fr.chart.chartglyph.ChartGlyph;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.web.Repository;
/**
* Created by richie on 16/1/29.
*/
public class EChartsGlyph extends ChartGlyph {
@Override
public JSONObject toJSONObject(Repository repo) throws JSONException {
JSONObject jo = new JSONObject();
EChartsTitleGlyph titleGlyph = (EChartsTitleGlyph) getTitleGlyph();
if (titleGlyph != null) {
jo.put("title", titleGlyph.toJSONObject(repo));
}
jo.put("tooltip", createTooltip(repo));
EChartsLegendGlyph legendGlyph = (EChartsLegendGlyph) getLegendGlyph();
if (legendGlyph != null) {
jo.put("legend", legendGlyph.toJSONObject(repo));
}
jo.put("dataRange", createDataRange(repo));
EChartsPlotGlyph plotGlyph = (EChartsPlotGlyph) getPlotGlyph();
if (plotGlyph != null) {
jo.put("series", plotGlyph.toSeriesData(repo));
}
return jo;
}
private JSONObject createTooltip(Repository repo) throws JSONException {
return JSONObject.create()
.put("trigger", "item");
}
private JSONObject createDataRange(Repository repo) throws JSONException {
return JSONObject.create()
.put("min", 0)
.put("max", 2500)
.put("x", "left")
.put("y", "bottom")
.put("text", JSONArray.create().put("高").put("低"));
}
}

2
src/com/fr/solution/plugin/chart/echarts/glyph/NewLegendGlyph.java → src/com/fr/solution/plugin/chart/echarts/glyph/EChartsLegendGlyph.java

@ -9,7 +9,7 @@ import com.fr.stable.web.Repository;
/**
* Created by richie on 16/2/2.
*/
public class NewLegendGlyph extends LegendGlyph {
public class EChartsLegendGlyph extends LegendGlyph {
@Override
public JSONObject toJSONObject(Repository repo) throws JSONException {

30
src/com/fr/solution/plugin/chart/echarts/glyph/EChartsPlotGlyph.java

@ -0,0 +1,30 @@
package com.fr.solution.plugin.chart.echarts.glyph;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.web.Repository;
/**
* Created by richie on 16/2/18.
*/
public abstract class EChartsPlotGlyph extends PlotGlyph {
@Override
public void layoutAxisGlyph(int resolution) {
}
@Override
public void layoutDataSeriesGlyph(int resolution) {
}
@Override
public JSONObject toJSONObject(Repository repo) throws JSONException {
throw new UnsupportedOperationException("Not support yet!");
}
public abstract JSONArray toSeriesData(Repository repo) throws JSONException;
}

6
src/com/fr/solution/plugin/chart/echarts/glyph/NewTitleGlyph.java → src/com/fr/solution/plugin/chart/echarts/glyph/EChartsTitleGlyph.java

@ -8,13 +8,13 @@ import com.fr.stable.web.Repository;
/**
* Created by richie on 16/2/2.
*/
public class NewTitleGlyph extends TitleGlyph {
public class EChartsTitleGlyph extends TitleGlyph {
public NewTitleGlyph() {
public EChartsTitleGlyph() {
}
public NewTitleGlyph(String title, String subTitle) {
public EChartsTitleGlyph(String title, String subTitle) {
}

106
src/com/fr/solution/plugin/chart/echarts/glyph/NewGlyph.java

@ -1,106 +0,0 @@
package com.fr.solution.plugin.chart.echarts.glyph;
import com.fr.chart.chartglyph.ChartGlyph;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.solution.plugin.chart.echarts.glyph.NewLegendGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.NewTitleGlyph;
import com.fr.stable.web.Repository;
/**
* Created by richie on 16/1/29.
*/
public class NewGlyph extends ChartGlyph {
private NewTitleGlyph titleGlyph;
private NewLegendGlyph legendGlyph;
public void setTitleGlyph(NewTitleGlyph titleGlyph) {
this.titleGlyph = titleGlyph;
}
@Override
public NewLegendGlyph getLegendGlyph() {
return legendGlyph;
}
public void setLegendGlyph(NewLegendGlyph legendGlyph) {
this.legendGlyph = legendGlyph;
}
@Override
public JSONObject toJSONObject(Repository repo) throws JSONException {
JSONObject jo = new JSONObject();
//jo.put("title", createTitle(repo));
if (titleGlyph != null) {
jo.put("title", titleGlyph.toJSONObject(repo));
}
jo.put("tooltip", createTooltip(repo));
// jo.put("legend", createLegend(repo));
if (legendGlyph != null) {
jo.put("legend", legendGlyph.toJSONObject(repo));
}
jo.put("dataRange", createDataRange(repo));
jo.put("series", createSeries(repo));
return jo;
}
private JSONObject createTooltip(Repository repo) throws JSONException {
return JSONObject.create()
.put("trigger", "item");
}
private JSONObject createDataRange(Repository repo) throws JSONException {
return JSONObject.create()
.put("min", 0)
.put("max", 2500)
.put("x", "left")
.put("y", "bottom")
.put("text", JSONArray.create().put("高").put("低"));
}
private JSONArray createSeries(Repository repo) throws JSONException {
JSONArray series = JSONArray.create();
series.put(JSONObject.create()
.put("name", "iPhone3")
.put("type", "map")
.put("mapType", "china")
.put("itemStyle", createItemStyle(repo))
.put("data", JSONArray.create().put(JSONObject.create().put("name", "北京").put("value", 20)))
);
series.put(JSONObject.create()
.put("name", "iPhone4")
.put("type", "map")
.put("mapType", "china")
.put("itemStyle", createItemStyle(repo))
.put("data", JSONArray.create().put(JSONObject.create().put("name", "江苏").put("value", 20)))
);
series.put(JSONObject.create()
.put("name", "iPhone5")
.put("type", "map")
.put("mapType", "china")
.put("itemStyle", createItemStyle(repo))
.put("data", JSONArray.create().put(JSONObject.create().put("name", "四川").put("value", 20)))
);
return series;
}
private JSONObject createItemStyle(Repository repo) throws JSONException {
JSONObject itemStyle = JSONObject.create();
itemStyle.put("normal", JSONObject.create().put("label", JSONObject.create().put("show", true)));
itemStyle.put("emphasis", JSONObject.create().put("label", JSONObject.create().put("show", true)));
return itemStyle;
}
}

10
src/com/fr/solution/plugin/chart/echarts/glyph/NewSeriesGlyph.java

@ -1,10 +0,0 @@
package com.fr.solution.plugin.chart.echarts.glyph;
import com.fr.chart.chartglyph.ChartGlyph;
/**
* Created by richie on 16/2/2.
*/
public class NewSeriesGlyph extends ChartGlyph {
}

72
src/com/fr/solution/plugin/chart/echarts/glyph/map/ChineseMapPlotGlyph.java

@ -0,0 +1,72 @@
package com.fr.solution.plugin.chart.echarts.glyph.map;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.solution.plugin.chart.echarts.glyph.EChartsPlotGlyph;
import com.fr.stable.web.Repository;
/**
* Created by richie on 16/1/29.
*/
public class ChineseMapPlotGlyph extends EChartsPlotGlyph {
@Override
public void layoutAxisGlyph(int resolution) {
}
@Override
public void layoutDataSeriesGlyph(int resolution) {
}
@Override
public String getPlotGlyphType() {
return "ChineseMapPlotGlyph";
}
@Override
public String getChartType() {
return "ChineseMap";
}
public JSONArray toSeriesData(Repository repo) throws JSONException {
JSONArray series = JSONArray.create();
series.put(JSONObject.create()
.put("name", "iPhone3")
.put("type", "map")
.put("mapType", "china")
.put("itemStyle", createItemStyle(repo))
.put("data", JSONArray.create().put(JSONObject.create().put("name", "北京").put("value", 20)))
);
series.put(JSONObject.create()
.put("name", "iPhone4")
.put("type", "map")
.put("mapType", "china")
.put("itemStyle", createItemStyle(repo))
.put("data", JSONArray.create()
.put(JSONObject.create().put("name", "江苏").put("value", 20))
.put(JSONObject.create().put("name", "四川").put("value", 300))
)
);
series.put(JSONObject.create()
.put("name", "iPhone5")
.put("type", "map")
.put("mapType", "china")
.put("itemStyle", createItemStyle(repo))
.put("data", JSONArray.create().put(JSONObject.create().put("name", "四川").put("value", 20)))
);
return series;
}
private JSONObject createItemStyle(Repository repo) throws JSONException {
JSONObject itemStyle = JSONObject.create();
itemStyle.put("normal", JSONObject.create().put("label", JSONObject.create().put("show", true)));
itemStyle.put("emphasis", JSONObject.create().put("label", JSONObject.create().put("show", true)));
return itemStyle;
}
}

26
src/com/fr/solution/plugin/chart/echarts/glyph/pie/EChartsPiePlotGlyph.java

@ -0,0 +1,26 @@
package com.fr.solution.plugin.chart.echarts.glyph.pie;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.solution.plugin.chart.echarts.glyph.EChartsPlotGlyph;
import com.fr.stable.web.Repository;
/**
* Created by richie on 16/2/18.
*/
public class EChartsPiePlotGlyph extends EChartsPlotGlyph {
@Override
public String getPlotGlyphType() {
return "EChartsPiePlotGlyph";
}
@Override
public String getChartType() {
return "EChartsPie";
}
public JSONArray toSeriesData(Repository repo) throws JSONException {
JSONArray series = JSONArray.create();
return series;
}
}

BIN
src/com/fr/solution/plugin/chart/echarts/images/pie/pie.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/com/fr/solution/plugin/chart/echarts/images/pie/pie256.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
src/com/fr/solution/plugin/chart/echarts/images/pie/pie_type1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
src/com/fr/solution/plugin/chart/echarts/images/pie/pie_type2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

10
src/com/fr/solution/plugin/chart/echarts/legend/NewLegend.java → src/com/fr/solution/plugin/chart/echarts/legend/EChartsLegend.java

@ -1,17 +1,17 @@
package com.fr.solution.plugin.chart.echarts.legend;
import com.fr.chart.chartattr.Legend;
import com.fr.solution.plugin.chart.echarts.glyph.NewLegendGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.EChartsLegendGlyph;
/**
* Created by richie on 16/2/18.
*/
public class NewLegend extends Legend {
public class EChartsLegend extends Legend {
public static final String XML_TAG = "NewLegend";
public static final String XML_TAG = "EChartsLegend";
public NewLegendGlyph createLegendGlyph() {
NewLegendGlyph resultLegendGlyph = new NewLegendGlyph();
public EChartsLegendGlyph createLegendGlyph() {
EChartsLegendGlyph resultLegendGlyph = new EChartsLegendGlyph();
resultLegendGlyph.setFont(getFRFont());
resultLegendGlyph.setGeneralInfo(this);

3
src/com/fr/solution/plugin/chart/echarts/locale/echarts.properties

@ -1 +1,2 @@
Plugin-ECharts_Chinese_Map=Chinese Map
Plugin-ECharts_Chinese_Map=Chinese Map
Plugin-ECharts_Pie=Pie(ECharts)

3
src/com/fr/solution/plugin/chart/echarts/locale/echarts_zh_CN.properties

@ -1 +1,2 @@
Plugin-ECharts_Chinese_Map=\u4E2D\u56FD\u5730\u56FE
Plugin-ECharts_Chinese_Map=\u4E2D\u56FD\u5730\u56FE
Plugin-ECharts_Pie=\u997C\u56FE(ECharts)

15
src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapFunctionProcessor.java → src/com/fr/solution/plugin/chart/echarts/monitor/MonitorMap.java

@ -1,16 +1,19 @@
package com.fr.solution.plugin.chart.echarts.core.map;
package com.fr.solution.plugin.chart.echarts.monitor;
import com.fr.general.Inter;
import com.fr.stable.fun.FunctionHelper;
import com.fr.stable.fun.FunctionProcessor;
import com.fr.stable.fun.impl.AbstractFunctionProcessor;
/**
* Created by richie on 16/1/29.
* Created by richie on 16/2/18.
*/
public class ChineseMapFunctionProcessor extends AbstractFunctionProcessor {
public class MonitorMap extends AbstractFunctionProcessor {
public static FunctionProcessor MAP = new ChineseMapFunctionProcessor();
private static MonitorMap instance = new MonitorMap();
public static MonitorMap getInstance() {
return instance;
}
@Override
public int getId() {
@ -21,4 +24,4 @@ public class ChineseMapFunctionProcessor extends AbstractFunctionProcessor {
public String toString() {
return Inter.getLocText("Plugin-ECharts_Chinese_Map");
}
}
}

27
src/com/fr/solution/plugin/chart/echarts/monitor/MonitorPie.java

@ -0,0 +1,27 @@
package com.fr.solution.plugin.chart.echarts.monitor;
import com.fr.general.Inter;
import com.fr.stable.fun.FunctionHelper;
import com.fr.stable.fun.impl.AbstractFunctionProcessor;
/**
* Created by richie on 16/2/18.
*/
public class MonitorPie extends AbstractFunctionProcessor {
private static MonitorPie instance = new MonitorPie();
public static MonitorPie getInstance() {
return instance;
}
@Override
public int getId() {
return FunctionHelper.generateFunctionID("com.fr.solution.plugin.chart.echarts");
}
@Override
public String toString() {
return Inter.getLocText("Plugin-ECharts_Pie");
}
}

20
src/com/fr/solution/plugin/chart/echarts/plot/NewPlot.java → src/com/fr/solution/plugin/chart/echarts/plot/EChartsPlot.java

@ -4,26 +4,26 @@ import com.fr.chart.chartattr.Legend;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.general.ComparatorUtils;
import com.fr.solution.plugin.chart.echarts.glyph.NewLegendGlyph;
import com.fr.solution.plugin.chart.echarts.legend.NewLegend;
import com.fr.solution.plugin.chart.echarts.glyph.EChartsLegendGlyph;
import com.fr.solution.plugin.chart.echarts.legend.EChartsLegend;
import com.fr.stable.xml.XMLableReader;
/**
* Created by richie on 16/2/2.
*/
public abstract class NewPlot extends Plot {
public abstract class EChartsPlot extends Plot {
public NewPlot() {
setLegend(new NewLegend());
public EChartsPlot() {
setLegend(new EChartsLegend());
}
public boolean accept(Class<? extends Plot> obClass) {
return ComparatorUtils.equals(NewPlot.class, obClass);
return ComparatorUtils.equals(EChartsPlot.class, obClass);
}
@Override
public NewLegendGlyph createLegendGlyph(PlotGlyph plotGlyph) {
NewLegend legend = (NewLegend) getLegend();
public EChartsLegendGlyph createLegendGlyph(PlotGlyph plotGlyph) {
EChartsLegend legend = (EChartsLegend) getLegend();
return legend.createLegendGlyph();
}
@ -31,8 +31,8 @@ public abstract class NewPlot extends Plot {
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if (NewLegend.XML_TAG.equals(tagName)) {
setLegend((Legend)reader.readXMLObject(new NewLegend()));
if (EChartsLegend.XML_TAG.equals(tagName)) {
setLegend((Legend)reader.readXMLObject(new EChartsLegend()));
}
}
}

10
src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java → src/com/fr/solution/plugin/chart/echarts/plot/map/ChineseMapPlot.java

@ -1,4 +1,4 @@
package com.fr.solution.plugin.chart.echarts.core.map;
package com.fr.solution.plugin.chart.echarts.plot.map;
import com.fr.base.chart.chartdata.ChartData;
import com.fr.chart.chartattr.Plot;
@ -6,13 +6,15 @@ import com.fr.chart.chartdata.NormalChartData;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.plot.NewPlot;
import com.fr.solution.plugin.chart.echarts.glyph.map.ChineseMapPlotGlyph;
import com.fr.solution.plugin.chart.echarts.monitor.MonitorMap;
import com.fr.solution.plugin.chart.echarts.plot.EChartsPlot;
import com.fr.stable.fun.FunctionProcessor;
/**
* Created by richie on 16/1/29.
*/
public class ChineseMapPlot extends NewPlot {
public class ChineseMapPlot extends EChartsPlot {
@Override
public PlotGlyph createPlotGlyph(ChartData chartData) {
@ -38,7 +40,7 @@ public class ChineseMapPlot extends NewPlot {
@Override
public FunctionProcessor getFunctionToRecord() {
return ChineseMapFunctionProcessor.MAP;
return MonitorMap.getInstance();
}
public boolean accept(Class<? extends Plot> obClass) {

99
src/com/fr/solution/plugin/chart/echarts/plot/pie/EChartsPiePlot.java

@ -0,0 +1,99 @@
package com.fr.solution.plugin.chart.echarts.plot.pie;
import com.fr.base.chart.chartdata.ChartData;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.NormalChartData;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.glyph.pie.EChartsPiePlotGlyph;
import com.fr.solution.plugin.chart.echarts.monitor.MonitorPie;
import com.fr.solution.plugin.chart.echarts.plot.EChartsPlot;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.FunctionProcessor;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
/**
* Created by richie on 16/2/18.
*/
public class EChartsPiePlot extends EChartsPlot {
private PieType pieType;
public EChartsPiePlot() {
this(PieType.REGULAR);
}
public EChartsPiePlot(PieType pieType) {
this.pieType = pieType;
}
public void setPieType(PieType pieType) {
this.pieType = pieType;
}
@Override
public PlotGlyph createPlotGlyph(ChartData chartData) {
PlotGlyph glyph = new EChartsPiePlotGlyph();
install4PlotGlyph(glyph, chartData);
return glyph;
}
@Override
public String getPlotID() {
return "EChartsPiePlot";
}
@Override
public boolean matchPlotType(Plot newPlot) {
return newPlot instanceof EChartsPiePlot;
}
@Override
public ChartData defaultChartData() {
return new NormalChartData();
}
@Override
public FunctionProcessor getFunctionToRecord() {
return MonitorPie.getInstance();
}
public boolean accept(Class<? extends Plot> obClass) {
return ComparatorUtils.equals(EChartsPiePlot.class, obClass);
}
@Override
public String getPlotName() {
return Inter.getLocText("Plugin-ECharts_Pie");
}
protected void readPlotXML(XMLableReader reader) {
super.readPlotXML(reader);
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if (tagName.equals("PieAttr4ECharts")) {
pieType = PieType.parse(reader.getAttrAsString("pieType", StringUtils.EMPTY));
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
writer.startTAG("PieAttr4ECharts");
writer.attr("pieType", pieType.toTypeString());
writer.end();
}
@Override
public boolean equals(Object ob) {
return ob instanceof EChartsPiePlot
&& super.equals(ob)
&& ComparatorUtils.equals(((EChartsPiePlot) ob).pieType, pieType);
}
}

40
src/com/fr/solution/plugin/chart/echarts/plot/pie/PieType.java

@ -0,0 +1,40 @@
package com.fr.solution.plugin.chart.echarts.plot.pie;
import com.fr.general.ComparatorUtils;
/**
* Created by richie on 16/2/18.
*/
public enum PieType {
REGULAR("regular"), CIRCLE("circle");
private String type;
PieType(String type) {
this.type = type;
}
public String toTypeString() {
return type;
}
private static PieType[] positions;
/**
* 将字符串转换成枚举类型
* @param p 待转换的整数
* @return 枚举
*/
public static PieType parse(String p) {
if (positions == null) {
positions = PieType.values();
}
for (PieType ip : positions) {
if (ComparatorUtils.equals(p, ip.type)) {
return ip;
}
}
return REGULAR;
}
}

16
src/com/fr/solution/plugin/chart/echarts/title/EChartsTitle.java

@ -0,0 +1,16 @@
package com.fr.solution.plugin.chart.echarts.title;
import com.fr.chart.chartattr.Title;
import com.fr.solution.plugin.chart.echarts.glyph.EChartsTitleGlyph;
/**
* Created by richie on 16/2/18.
*/
public class EChartsTitle extends Title {
public static final String XML_TAG = "EChartsTitle";
@Override
public EChartsTitleGlyph createGlyph() {
return new EChartsTitleGlyph();
}
}

16
src/com/fr/solution/plugin/chart/echarts/title/NewTitle.java

@ -1,16 +0,0 @@
package com.fr.solution.plugin.chart.echarts.title;
import com.fr.chart.chartattr.Title;
import com.fr.solution.plugin.chart.echarts.glyph.NewTitleGlyph;
/**
* Created by richie on 16/2/18.
*/
public class NewTitle extends Title {
public static final String XML_TAG = "NewTitle";
@Override
public NewTitleGlyph createGlyph() {
return new NewTitleGlyph();
}
}

73
src/com/fr/solution/plugin/chart/echarts/ui/AbstractEChartsTypePane.java

@ -0,0 +1,73 @@
package com.fr.solution.plugin.chart.echarts.ui;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionCollection;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.gui.type.ChartImagePane;
import com.fr.solution.plugin.chart.echarts.base.ECharts;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractEChartsTypePane extends AbstractChartTypePane{
private static final long serialVersionUID = 7743244512351499265L;
//新图表暂时还没有平面3d,渐变高光等布局。
@Override
protected List<ChartImagePane> initStyleList() {
return new ArrayList<ChartImagePane>();
}
@Override
protected String[] getTypeLayoutPath() {
return new String[]{
};
}
/**
* 保存界面属性
*/
public void updateBean(Chart chart) {
checkTypeChange();
Plot oldPlot = chart.getPlot();
Plot newPlot = getSelectedClonedPlot();
boolean samePlot = accept(chart);
if(typeChanged && samePlot){
//同一中图表切换不同类型
cloneOldPlot2New(oldPlot, newPlot);
chart.setPlot(newPlot);
} else if(!samePlot){
//不同的图表类型切换
chart.setPlot(newPlot);
}
}
public boolean accept(Object ob) {
return ob instanceof ECharts;
}
protected void checkTypeChange(){
for(int i = 0; i < typeDemo.size(); i++){
if(typeDemo.get(i).isPressing && i != lastTypeIndex){
typeChanged = true;
lastTypeIndex = i;
break;
}
typeChanged = false;
}
}
/**
* 同一个图表 类型之间切换
*/
protected void cloneOldPlot2New(Plot oldPlot, Plot newPlot) {
}
protected void cloneOldConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{
if (oldPlot.getConditionCollection() != null) {
newPlot.setConditionCollection((ConditionCollection)oldPlot.getConditionCollection().clone());
}
}
}

14
src/com/fr/solution/plugin/chart/echarts/ui/AbstractIndependentEChartsUI.java

@ -0,0 +1,14 @@
package com.fr.solution.plugin.chart.echarts.ui;
import com.fr.design.chart.fun.impl.AbstractIndependentChartUI;
/**
* Created by richie on 16/2/18.
*/
public abstract class AbstractIndependentEChartsUI extends AbstractIndependentChartUI {
@Override
public boolean isUseDefaultPane() {
return false;
}
}

10
src/com/fr/solution/plugin/chart/echarts/ui/data/AbstractEChartsReportDataContentPane.java

@ -0,0 +1,10 @@
package com.fr.solution.plugin.chart.echarts.ui.data;
import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotReportDataContentPane;
/**
* Created by richie on 16/2/18.
*/
public class AbstractEChartsReportDataContentPane extends CategoryPlotReportDataContentPane {
}

164
src/com/fr/solution/plugin/chart/echarts/ui/data/AbstractEChartsTableDataContentPane.java

@ -0,0 +1,164 @@
package com.fr.solution.plugin.chart.echarts.ui.data;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartdata.NormalTableDataDefinition;
import com.fr.chart.chartdata.TopDefinition;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.ui.series.NewSeriesTypeUsePane;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Created by richie on 16/1/29.
*/
public class AbstractEChartsTableDataContentPane extends AbstractTableDataContentPane {
protected UIComboBox categoryComboBox;
protected NewSeriesTypeUsePane seriesTypeUsePane;
public AbstractEChartsTableDataContentPane(ChartDataPane parent) {
categoryComboBox = new UIComboBox();
JPanel categoryPane = new JPanel(new BorderLayout(4, 0));
categoryPane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground()));
UILabel label1 = new BoldFontTextLabel(Inter.getLocText("FR-Chart-Category_Name") + ":", SwingConstants.RIGHT);
label1.setPreferredSize(new Dimension(75, 20));
categoryComboBox.setPreferredSize(new Dimension(100, 20));
categoryComboBox.addItem(Inter.getLocText("Chart-Use_None"));
categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryComboBox, null, null, label1, null}));
this.setLayout(new BorderLayout());
this.add(categoryPane, BorderLayout.NORTH);
seriesTypeUsePane = new NewSeriesTypeUsePane(parent, new Bar2DPlot());
this.add(seriesTypeUsePane, BorderLayout.SOUTH);
categoryComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
checkSeriseUse(categoryComboBox.getSelectedItem() != null);
makeToolTipUse(categoryComboBox);
}
});
}
protected void makeToolTipUse(UIComboBox comBox) {
if (comBox.getSelectedItem() != null) {
comBox.setToolTipText(comBox.getSelectedItem().toString());
} else {
comBox.setToolTipText(null);
}
}
/**
* 检查 某些Box是否可用
*
* @param hasUse 是否使用.
*/
public void checkBoxUse(boolean hasUse) {
categoryComboBox.setEnabled(hasUse);
checkSeriseUse(hasUse);
}
protected void checkSeriseUse(boolean hasUse) {
if (seriesTypeUsePane != null) {
seriesTypeUsePane.checkUseBox(hasUse && categoryComboBox.getSelectedItem() != null);
}
}
protected void refreshBoxListWithSelectTableData(java.util.List list) {
refreshBoxItems(categoryComboBox, list);
categoryComboBox.addItem(Inter.getLocText("Chart-Use_None"));
seriesTypeUsePane.refreshBoxListWithSelectTableData(list);
}
/**
* 清空所有的box设置
*/
public void clearAllBoxList() {
clearBoxItems(categoryComboBox);
categoryComboBox.addItem(Inter.getLocText("Chart-Use_None"));
seriesTypeUsePane.clearAllBoxList();
}
/**
* 保存界面内容到ChartCollection
*/
public void updateBean(ChartCollection collection) {
seriesTypeUsePane.updateBean(collection);
NormalTableDataDefinition dataDefinition = (NormalTableDataDefinition) collection.getSelectedChart().getFilterDefinition();
if (dataDefinition == null) {
return;
}
Object categoryName = categoryComboBox.getSelectedItem();
if (ArrayUtils.contains(ChartConstants.NONE_KEYS, categoryName)) {
dataDefinition.setCategoryName(StringUtils.EMPTY);
} else {
dataDefinition.setCategoryName(categoryName == null ? null : categoryName.toString());
}
}
/**
* 根据ChartCollection 更新界面
*/
public void populateBean(ChartCollection collection) {
super.populateBean(collection);
TopDefinition top = (TopDefinition) collection.getSelectedChart().getFilterDefinition();
if (!(top instanceof NormalTableDataDefinition)) {
return;
}
NormalTableDataDefinition data = (NormalTableDataDefinition) top;
if (data == null || ComparatorUtils.equals(data.getCategoryName(), StringUtils.EMPTY)) {
categoryComboBox.setSelectedItem(Inter.getLocText("Chart-Use_None"));
} else if (data != null && !this.boxItemsContainsObject(categoryComboBox, data.getCategoryName())) {
categoryComboBox.setSelectedItem(null);
} else {
combineCustomEditValue(categoryComboBox, data == null ? null : data.getCategoryName());
}
seriesTypeUsePane.populateBean(collection, this.isNeedSummaryCaculateMethod());
}
private boolean boxItemsContainsObject(UIComboBox box, Object item) {
if (box == null) {
return false;
}
ComboBoxModel dataModel = box.getModel();
for (int i = 0; i < dataModel.getSize(); i++) {
if (ComparatorUtils.equals(dataModel.getElementAt(i), item)) {
return true;
}
}
return false;
}
/**
* 重新布局整个面板
*/
public void redoLayoutPane() {
seriesTypeUsePane.relayoutPane(this.isNeedSummaryCaculateMethod());
}
}

36
src/com/fr/solution/plugin/chart/echarts/ui/filter/NewDataFilterPane.java

@ -0,0 +1,36 @@
package com.fr.solution.plugin.chart.echarts.ui.filter;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.style.ThirdTabPane;
import java.util.ArrayList;
import java.util.List;
/**
* Created by richie on 16/2/18.
*/
public class NewDataFilterPane extends ThirdTabPane<ChartCollection> {
public NewDataFilterPane(Plot plot, ChartDataPane parent) {
super(plot, parent);
}
@Override
protected List<NamePane> initPaneList(Plot plot, AbstractAttrNoScrollPane parent) {
List<NamePane> paneList = new ArrayList<NamePane>();
return paneList;
}
@Override
public void populateBean(ChartCollection ob) {
}
@Override
protected String title4PopupWindow() {
return null;
}
}

2
src/com/fr/solution/plugin/chart/echarts/ui/map/ChineseChartTypePane.java

@ -4,7 +4,7 @@ import com.fr.chart.chartattr.Chart;
import com.fr.design.mainframe.chart.gui.type.UserDefinedChartTypePane;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.ChineseMap;
import com.fr.solution.plugin.chart.echarts.core.map.ChineseMapPlot;
import com.fr.solution.plugin.chart.echarts.plot.map.ChineseMapPlot;
/**
* Created by richie on 16/1/29.

48
src/com/fr/solution/plugin/chart/echarts/ui/map/ChineseMapTableDataContentPane.java

@ -1,56 +1,14 @@
package com.fr.solution.plugin.chart.echarts.ui.map;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import javax.swing.*;
import java.awt.*;
import java.util.List;
import com.fr.solution.plugin.chart.echarts.ui.data.AbstractEChartsTableDataContentPane;
/**
* Created by richie on 16/1/29.
*/
public class ChineseMapTableDataContentPane extends AbstractTableDataContentPane implements UIObserver {
private UICorrelationPane correlationPane;
public class ChineseMapTableDataContentPane extends AbstractEChartsTableDataContentPane {
public ChineseMapTableDataContentPane(ChartDataPane parent) {
setLayout(new BorderLayout());
UILabel label = new UILabel("测试布局");
setBorder(BorderFactory.createLineBorder(Color.RED));
add(label, BorderLayout.NORTH);
correlationPane = new UICorrelationPane("区域名", "区域值");
add(correlationPane, BorderLayout.CENTER);
}
@Override
public void updateBean(ChartCollection ob) {
}
@Override
public void clearAllBoxList() {
}
@Override
protected void refreshBoxListWithSelectTableData(List columnNameList) {
}
@Override
public void registerChangeListener(UIObserverListener listener) {
}
@Override
public boolean shouldResponseChangeListener() {
return true;
super(parent);
}
}

67
src/com/fr/solution/plugin/chart/echarts/ui/pie/EChartsPieChartTypePane.java

@ -0,0 +1,67 @@
package com.fr.solution.plugin.chart.echarts.ui.pie;
import com.fr.chart.chartattr.Chart;
import com.fr.design.mainframe.chart.gui.type.ChartImagePane;
import com.fr.design.mainframe.chart.gui.type.UserDefinedChartTypePane;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.EChartsPie;
import com.fr.solution.plugin.chart.echarts.plot.pie.EChartsPiePlot;
import com.fr.solution.plugin.chart.echarts.ui.AbstractEChartsTypePane;
import java.util.ArrayList;
import java.util.List;
/**
* Created by richie on 16/1/29.
*/
public class EChartsPieChartTypePane extends AbstractEChartsTypePane {
/**
* 弹出框的标题
*
* @return 弹出框的标题
*/
public String title4PopupWindow() {
return Inter.getLocText("Plugin-ECharts_Pie");
}
public void updateBean(Chart chart) {
if (chart != null) {
chart.setPlot(new EChartsPiePlot());
}
}
/**
* 界面是否接受
*
* @param ob 对象是否为chart
* @return 界面是否接受对象
*/
public boolean accept(Object ob) {
return (ob instanceof Chart) && ((Chart) ob).getPlot().accept(EChartsPiePlot.class);
}
@Override
public Chart getDefaultChart() {
return EChartsPie.charts[0];
}
@Override
protected List<ChartImagePane> initDemoList() {
List <ChartImagePane> demoList = new ArrayList<ChartImagePane>();
String[] iconPaths = getTypeIconPath();
ChartImagePane pane = new ChartImagePane(iconPaths[0], "Regular");
pane.isPressing = true;
demoList.add(pane);
demoList.add(new ChartImagePane(iconPaths[1], "Circle"));
return demoList;
}
@Override
protected String[] getTypeIconPath() {
return new String[]{
"/com/fr/solution/plugin/chart/echarts/images/pie/pie_type1.png",
"/com/fr/solution/plugin/chart/echarts/images/pie/pie_type2.png"
};
}
}

9
src/com/fr/solution/plugin/chart/echarts/ui/pie/EChartsPieReportDataContentPane.java

@ -0,0 +1,9 @@
package com.fr.solution.plugin.chart.echarts.ui.pie;
import com.fr.solution.plugin.chart.echarts.ui.data.AbstractEChartsReportDataContentPane;
/**
* Created by richie on 16/2/18.
*/
public class EChartsPieReportDataContentPane extends AbstractEChartsReportDataContentPane {
}

14
src/com/fr/solution/plugin/chart/echarts/ui/pie/EChartsPieTableDataContentPane.java

@ -0,0 +1,14 @@
package com.fr.solution.plugin.chart.echarts.ui.pie;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.solution.plugin.chart.echarts.ui.data.AbstractEChartsTableDataContentPane;
/**
* Created by richie on 16/2/18.
*/
public class EChartsPieTableDataContentPane extends AbstractEChartsTableDataContentPane {
public EChartsPieTableDataContentPane(ChartDataPane parent) {
super(parent);
}
}

159
src/com/fr/solution/plugin/chart/echarts/ui/series/NewSeriesTypeUsePane.java

@ -0,0 +1,159 @@
package com.fr.solution.plugin.chart.echarts.ui.series;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.MoreNameCDDefinition;
import com.fr.chart.chartdata.OneValueCDDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldNamePane;
import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldValuePane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.ui.filter.NewDataFilterPane;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class NewSeriesTypeUsePane extends UIComboBoxPane<ChartCollection> {
private SeriesNameUseFieldValuePane nameFieldValuePane;
private SeriesNameUseFieldNamePane nameFieldNamePane;
private NewDataFilterPane dataFilterPane;
private ChartDataPane parent;
private Plot initplot;
private boolean isNeedSummary = true;
public NewSeriesTypeUsePane(ChartDataPane parent, Plot initPlot) {
cards = initPaneList();
this.parent = parent;
this.initplot = initPlot;
this.isNeedSummary = true;
initComponents();
}
protected void initLayout() {
this.setLayout(new BorderLayout(4, LayoutConstants.VGAP_MEDIUM));
JPanel northPane = new JPanel(new BorderLayout(4, 0));
UILabel label1 = new UILabel(Inter.getLocText("ChartF-Series_Name_From") + ":", SwingConstants.RIGHT);
label1.setPreferredSize(new Dimension(75, 20));
northPane.add(GUICoreUtils.createBorderLayoutPane(
jcb, BorderLayout.CENTER,
label1, BorderLayout.WEST
));
northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1));
add(northPane, BorderLayout.NORTH);
add(cardPane, BorderLayout.CENTER);
dataFilterPane = new NewDataFilterPane(initplot, parent);
add(dataFilterPane, BorderLayout.SOUTH);
}
/**
* 检查box 是否使用, hasUse, 表示上层已经使用, 否则, 则此界面都可使用
*
* @param hasUse 是否使用
*/
public void checkUseBox(boolean hasUse) {
jcb.setEnabled(hasUse);
nameFieldValuePane.checkUse(hasUse);
}
/**
* 切换 变更数据集时, 刷新Box选中项目
*
* @param list 列表
*/
public void refreshBoxListWithSelectTableData(List list) {
nameFieldValuePane.refreshBoxListWithSelectTableData(list);
nameFieldNamePane.refreshBoxListWithSelectTableData(list);
}
/**
* 清空所有的box设置
*/
public void clearAllBoxList() {
nameFieldValuePane.clearAllBoxList();
nameFieldNamePane.clearAllBoxList();
}
/**
* 界面标题
*
* @return 界面标题
*/
protected String title4PopupWindow() {
return Inter.getLocText("ChartF-Series_Name_From");
}
@Override
protected List<FurtherBasicBeanPane<? extends ChartCollection>> initPaneList() {
nameFieldValuePane = new SeriesNameUseFieldValuePane();
nameFieldNamePane = new SeriesNameUseFieldNamePane();
List<FurtherBasicBeanPane<? extends ChartCollection>> paneList = new ArrayList<FurtherBasicBeanPane<? extends ChartCollection>>();
paneList.add(nameFieldValuePane);
paneList.add(nameFieldNamePane);
return paneList;
}
public void populateBean(ChartCollection ob, boolean isNeedSummary) {
this.isNeedSummary = isNeedSummary;
TopDefinitionProvider definition = ob.getSelectedChart().getFilterDefinition();
if (definition instanceof OneValueCDDefinition) {
this.setSelectedIndex(0);
nameFieldValuePane.populateBean(ob, isNeedSummary);
} else if (definition instanceof MoreNameCDDefinition) {
this.setSelectedIndex(1);
nameFieldNamePane.populateBean(ob, isNeedSummary);
}
}
/**
* 重新布局整个面板
*
* @param isNeedSummary 是否需要汇总
*/
public void relayoutPane(boolean isNeedSummary) {
this.isNeedSummary = isNeedSummary;
if (jcb.getSelectedIndex() == 0) {
nameFieldValuePane.relayoutPane(this.isNeedSummary);
} else {
nameFieldNamePane.relayoutPane(this.isNeedSummary);
}
}
@Override
protected void comboBoxItemStateChanged() {
if (jcb.getSelectedIndex() == 0) {
nameFieldValuePane.relayoutPane(this.isNeedSummary);
} else {
nameFieldNamePane.relayoutPane(this.isNeedSummary);
}
}
public void populateBean(ChartCollection ob) {
this.populateBean(ob, true);
}
/**
* 保存界面属性到Ob-ChartCollection
*/
public void updateBean(ChartCollection ob) {
if (this.getSelectedIndex() == 0) {
nameFieldValuePane.updateBean(ob);
} else {
nameFieldNamePane.updateBean(ob);
}
}
}
Loading…
Cancel
Save