From a08aa70acacfd14ac489f7be840c3e61e23adeb0 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 18 Feb 2016 12:02:30 +0800 Subject: [PATCH] =?UTF-8?q?echarts=E5=9F=BA=E6=9C=AC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/chart/echarts/base/NewChart.java | 39 ++++++++++++++++++- .../plugin/chart/echarts/base/NewPlot.java | 25 ------------ .../echarts/core/map/ChineseMapPlot.java | 3 +- .../echarts/{base => glyph}/NewGlyph.java | 4 +- .../{base => glyph}/NewLegendGlyph.java | 2 +- .../{base => glyph}/NewSeriesGlyph.java | 2 +- .../{base => glyph}/NewTitleGlyph.java | 9 +++-- .../chart/echarts/legend/NewLegend.java | 24 ++++++++++++ .../plugin/chart/echarts/plot/NewPlot.java | 39 +++++++++++++++++++ .../plugin/chart/echarts/title/NewTitle.java | 16 ++++++++ 10 files changed, 128 insertions(+), 35 deletions(-) delete mode 100644 src/com/fr/solution/plugin/chart/echarts/base/NewPlot.java rename src/com/fr/solution/plugin/chart/echarts/{base => glyph}/NewGlyph.java (94%) rename src/com/fr/solution/plugin/chart/echarts/{base => glyph}/NewLegendGlyph.java (92%) rename src/com/fr/solution/plugin/chart/echarts/{base => glyph}/NewSeriesGlyph.java (71%) rename src/com/fr/solution/plugin/chart/echarts/{base => glyph}/NewTitleGlyph.java (76%) create mode 100644 src/com/fr/solution/plugin/chart/echarts/legend/NewLegend.java create mode 100644 src/com/fr/solution/plugin/chart/echarts/plot/NewPlot.java create mode 100644 src/com/fr/solution/plugin/chart/echarts/title/NewTitle.java diff --git a/src/com/fr/solution/plugin/chart/echarts/base/NewChart.java b/src/com/fr/solution/plugin/chart/echarts/base/NewChart.java index af29583..3436439 100644 --- a/src/com/fr/solution/plugin/chart/echarts/base/NewChart.java +++ b/src/com/fr/solution/plugin/chart/echarts/base/NewChart.java @@ -3,7 +3,17 @@ package com.fr.solution.plugin.chart.echarts.base; import com.fr.base.chart.BaseChartGlyph; import com.fr.base.chart.chartdata.ChartData; import com.fr.chart.chartattr.Chart; +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.stable.xml.XMLableReader; /** * Created by richie on 16/1/29. @@ -13,11 +23,13 @@ public class NewChart extends Chart { public NewChart() { setWrapperName("EChartsFactory"); + setTitle(new NewTitle()); } public NewChart(NewPlot plot) { super(plot); setWrapperName("EChartsFactory"); + setTitle(new NewTitle()); } @Override @@ -26,9 +38,16 @@ public class NewChart extends Chart { glyph.setGeneralInfo(this); NewPlot newPlot = (NewPlot) getPlot(); if (newPlot != null) { - glyph.setLegendGlyph(newPlot.createChartLegendGlyph(chartData)); - glyph.setTitleGlyph(newPlot.createChartTitleGlyph(chartData)); + PlotGlyph plotGlyph = newPlot.createPlotGlyph(chartData); + NewLegendGlyph legendGlyph = newPlot.createLegendGlyph(plotGlyph); + glyph.setLegendGlyph(legendGlyph); } + NewTitle title = (NewTitle)getTitle(); + if (title != null) { + NewTitleGlyph titleGlyph = title.createGlyph(); + glyph.setTitleGlyph(titleGlyph); + } + glyph.setWrapperName(getWrapperName()); glyph.setChartImagePath(getImagePath()); glyph.setRequiredJS(getRequiredJS()); @@ -45,4 +64,20 @@ public class NewChart extends Chart { public boolean accept(Class obClass){ return ComparatorUtils.equals(NewChart.class, obClass); } + + + @Override + protected void readChartXML(XMLableReader reader) { + if (reader.isChildNode()) { + String tmpNodeName = reader.getTagName(); + + if (tmpNodeName.equals(NewTitle.XML_TAG)) { + setTitle(new NewTitle()); + reader.readXMLObject(getTitle()); + } else if (tmpNodeName.equals(Plot.XML_TAG)) { + setPlot((Plot) GeneralXMLTools.readXMLable(reader)); + } + } + } + } \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/base/NewPlot.java b/src/com/fr/solution/plugin/chart/echarts/base/NewPlot.java deleted file mode 100644 index 734e777..0000000 --- a/src/com/fr/solution/plugin/chart/echarts/base/NewPlot.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fr.solution.plugin.chart.echarts.base; - -import com.fr.base.chart.chartdata.ChartData; -import com.fr.chart.chartattr.Plot; -import com.fr.general.ComparatorUtils; - -/** - * Created by richie on 16/2/2. - */ -public abstract class NewPlot extends Plot { - - public boolean accept(Class obClass) { - return ComparatorUtils.equals(NewPlot.class, obClass); - } - - - - public NewTitleGlyph createChartTitleGlyph(ChartData chartData) { - return new NewTitleGlyph("iPhone", "iPhone"); - } - - public NewLegendGlyph createChartLegendGlyph(ChartData chartData) { - return new NewLegendGlyph(); - } -} \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java b/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java index 6384b43..7628eea 100644 --- a/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java +++ b/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java @@ -3,11 +3,10 @@ package com.fr.solution.plugin.chart.echarts.core.map; import com.fr.base.chart.chartdata.ChartData; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartdata.NormalChartData; -import com.fr.chart.chartglyph.LegendGlyph; import com.fr.chart.chartglyph.PlotGlyph; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; -import com.fr.solution.plugin.chart.echarts.base.NewPlot; +import com.fr.solution.plugin.chart.echarts.plot.NewPlot; import com.fr.stable.fun.FunctionProcessor; /** diff --git a/src/com/fr/solution/plugin/chart/echarts/base/NewGlyph.java b/src/com/fr/solution/plugin/chart/echarts/glyph/NewGlyph.java similarity index 94% rename from src/com/fr/solution/plugin/chart/echarts/base/NewGlyph.java rename to src/com/fr/solution/plugin/chart/echarts/glyph/NewGlyph.java index deecb7b..edf89d0 100644 --- a/src/com/fr/solution/plugin/chart/echarts/base/NewGlyph.java +++ b/src/com/fr/solution/plugin/chart/echarts/glyph/NewGlyph.java @@ -1,9 +1,11 @@ -package com.fr.solution.plugin.chart.echarts.base; +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; /** diff --git a/src/com/fr/solution/plugin/chart/echarts/base/NewLegendGlyph.java b/src/com/fr/solution/plugin/chart/echarts/glyph/NewLegendGlyph.java similarity index 92% rename from src/com/fr/solution/plugin/chart/echarts/base/NewLegendGlyph.java rename to src/com/fr/solution/plugin/chart/echarts/glyph/NewLegendGlyph.java index 86717c9..a091729 100644 --- a/src/com/fr/solution/plugin/chart/echarts/base/NewLegendGlyph.java +++ b/src/com/fr/solution/plugin/chart/echarts/glyph/NewLegendGlyph.java @@ -1,4 +1,4 @@ -package com.fr.solution.plugin.chart.echarts.base; +package com.fr.solution.plugin.chart.echarts.glyph; import com.fr.chart.chartglyph.LegendGlyph; import com.fr.json.JSONArray; diff --git a/src/com/fr/solution/plugin/chart/echarts/base/NewSeriesGlyph.java b/src/com/fr/solution/plugin/chart/echarts/glyph/NewSeriesGlyph.java similarity index 71% rename from src/com/fr/solution/plugin/chart/echarts/base/NewSeriesGlyph.java rename to src/com/fr/solution/plugin/chart/echarts/glyph/NewSeriesGlyph.java index 7f60aae..722bac3 100644 --- a/src/com/fr/solution/plugin/chart/echarts/base/NewSeriesGlyph.java +++ b/src/com/fr/solution/plugin/chart/echarts/glyph/NewSeriesGlyph.java @@ -1,4 +1,4 @@ -package com.fr.solution.plugin.chart.echarts.base; +package com.fr.solution.plugin.chart.echarts.glyph; import com.fr.chart.chartglyph.ChartGlyph; diff --git a/src/com/fr/solution/plugin/chart/echarts/base/NewTitleGlyph.java b/src/com/fr/solution/plugin/chart/echarts/glyph/NewTitleGlyph.java similarity index 76% rename from src/com/fr/solution/plugin/chart/echarts/base/NewTitleGlyph.java rename to src/com/fr/solution/plugin/chart/echarts/glyph/NewTitleGlyph.java index 01d5718..76df7c1 100644 --- a/src/com/fr/solution/plugin/chart/echarts/base/NewTitleGlyph.java +++ b/src/com/fr/solution/plugin/chart/echarts/glyph/NewTitleGlyph.java @@ -1,6 +1,6 @@ -package com.fr.solution.plugin.chart.echarts.base; +package com.fr.solution.plugin.chart.echarts.glyph; -import com.fr.chart.chartglyph.ChartGlyph; +import com.fr.chart.chartglyph.TitleGlyph; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.stable.web.Repository; @@ -8,8 +8,11 @@ import com.fr.stable.web.Repository; /** * Created by richie on 16/2/2. */ -public class NewTitleGlyph extends ChartGlyph { +public class NewTitleGlyph extends TitleGlyph { + public NewTitleGlyph() { + + } public NewTitleGlyph(String title, String subTitle) { diff --git a/src/com/fr/solution/plugin/chart/echarts/legend/NewLegend.java b/src/com/fr/solution/plugin/chart/echarts/legend/NewLegend.java new file mode 100644 index 0000000..1b16add --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/legend/NewLegend.java @@ -0,0 +1,24 @@ +package com.fr.solution.plugin.chart.echarts.legend; + +import com.fr.chart.chartattr.Legend; +import com.fr.solution.plugin.chart.echarts.glyph.NewLegendGlyph; + +/** + * Created by richie on 16/2/18. + */ +public class NewLegend extends Legend { + + public static final String XML_TAG = "NewLegend"; + + public NewLegendGlyph createLegendGlyph() { + NewLegendGlyph resultLegendGlyph = new NewLegendGlyph(); + + resultLegendGlyph.setFont(getFRFont()); + resultLegendGlyph.setGeneralInfo(this); + resultLegendGlyph.setPosition(getPosition()); + resultLegendGlyph.setVisible(isLegendVisible()); + + return resultLegendGlyph; + } + +} diff --git a/src/com/fr/solution/plugin/chart/echarts/plot/NewPlot.java b/src/com/fr/solution/plugin/chart/echarts/plot/NewPlot.java new file mode 100644 index 0000000..71d32c8 --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/plot/NewPlot.java @@ -0,0 +1,39 @@ +package com.fr.solution.plugin.chart.echarts.plot; + +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.stable.xml.XMLableReader; + +/** + * Created by richie on 16/2/2. + */ +public abstract class NewPlot extends Plot { + + public NewPlot() { + setLegend(new NewLegend()); + } + + public boolean accept(Class obClass) { + return ComparatorUtils.equals(NewPlot.class, obClass); + } + + @Override + public NewLegendGlyph createLegendGlyph(PlotGlyph plotGlyph) { + NewLegend legend = (NewLegend) getLegend(); + return legend.createLegendGlyph(); + } + + protected void readPlotXML(XMLableReader reader){ + if (reader.isChildNode()) { + String tagName = reader.getTagName(); + + if (NewLegend.XML_TAG.equals(tagName)) { + setLegend((Legend)reader.readXMLObject(new NewLegend())); + } + } + } +} \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/title/NewTitle.java b/src/com/fr/solution/plugin/chart/echarts/title/NewTitle.java new file mode 100644 index 0000000..7c39adc --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/title/NewTitle.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.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(); + } +}