diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b677e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +*.xml +!plugin.xml +!build.xml +.idea/ +.DS_Store +*.jar +*.zip +plugin-demochart.iml \ No newline at end of file diff --git a/plugin-demochart.iml b/plugin-demochart.iml index a1baaf2..496d61b 100644 --- a/plugin-demochart.iml +++ b/plugin-demochart.iml @@ -1,7 +1,7 @@ - + @@ -9,27 +9,93 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + @@ -37,5 +103,7 @@ + + \ No newline at end of file diff --git a/src/com/fr/plugin/demo/DemoChart.java b/src/com/fr/plugin/demo/DemoChart.java index 1ba5bbe..e331181 100644 --- a/src/com/fr/plugin/demo/DemoChart.java +++ b/src/com/fr/plugin/demo/DemoChart.java @@ -6,7 +6,6 @@ import com.fr.extended.chart.ExtendedHelper; import com.fr.extended.chart.HyperLinkPara; import com.fr.extended.chart.export.ExportProcessor; import com.fr.extended.chart.export.JSExportProcessor; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.json.JSON; import com.fr.json.JSONArray; @@ -36,6 +35,16 @@ public class DemoChart extends AbstractChart{ private ThemeType themeType = ThemeType.DARK; + private boolean threeDimensional = false; + + public boolean isThreeDimensional() { + return threeDimensional; + } + + public void setThreeDimensional(boolean threeDimensional) { + this.threeDimensional = threeDimensional; + } + public ThemeType getThemeType() { return themeType; } @@ -56,6 +65,7 @@ public class DemoChart extends AbstractChart{ protected void readAttr(XMLableReader reader) { super.readAttr(reader); this.setThemeType(ThemeType.parseInt(reader.getAttrAsInt("theme", 0))); + this.setThreeDimensional(reader.getAttrAsBoolean("threeD", false)); this.setTitleFormula(ExtendedHelper.readFormula(reader, "title")); } @@ -63,6 +73,7 @@ public class DemoChart extends AbstractChart{ protected void writeAttr(XMLPrintWriter writer) { super.writeAttr(writer); writer.attr("theme", getThemeType().ordinal()); + writer.attr("threeD", isThreeDimensional()); ExtendedHelper.writeFormula(this.getTitleFormula(), writer, "title"); } @@ -73,12 +84,13 @@ public class DemoChart extends AbstractChart{ result.setTitleFormula(this.getTitleFormula().clone()); } result.setThemeType(this.getThemeType()); + result.setThreeDimensional(this.isThreeDimensional()); return result; } @Override public int hashCode() { - return super.hashCode() + AssistUtils.hashCode(this.getTitleFormula(), this.getThemeType()); + return super.hashCode() + AssistUtils.hashCode(this.getTitleFormula(), this.getThemeType(), this.isThreeDimensional()); } @Override @@ -87,6 +99,7 @@ public class DemoChart extends AbstractChart{ && ob instanceof DemoChart && AssistUtils.equals(this.getTitleFormula(), ((DemoChart) ob).getTitleFormula()) && AssistUtils.equals(this.getThemeType(), ((DemoChart) ob).getThemeType()) + && AssistUtils.equals(this.isThreeDimensional(), ((DemoChart) ob).isThreeDimensional()) ; } @@ -114,15 +127,18 @@ public class DemoChart extends AbstractChart{ JSONArray array = JSONFactory.createJSON(JSON.ARRAY); - List xValues = dataConfig.getX().getValues(); - List yValues = dataConfig.getY().getValues(); - List zValues = dataConfig.getZ().getValues(); - double maxValue = Double.MIN_VALUE; - for (int i = 0, len = xValues.size(); i < len; i++) { - maxValue = Math.max(GeneralUtils.objectToNumber(zValues.get(i)).doubleValue(), maxValue); - array.put(JSONFactory.createJSON(JSON.ARRAY).put(xValues.get(i)).put(yValues.get(i)).put(zValues.get(i))); + if (dataConfig != null) { + List xValues = dataConfig.getX().getValues(); + List yValues = dataConfig.getY().getValues(); + List zValues = dataConfig.getZ().getValues(); + + for (int i = 0, len = xValues.size(); i < len; i++) { + maxValue = Math.max(GeneralUtils.objectToNumber(zValues.get(i)).doubleValue(), maxValue); + + array.put(JSONFactory.createJSON(JSON.ARRAY).put(xValues.get(i)).put(yValues.get(i)).put(zValues.get(i))); + } } jsonObject.put("series", JSONFactory.createJSON(JSON.OBJECT).put("type", "bar3D").put("data", array) @@ -148,6 +164,13 @@ public class DemoChart extends AbstractChart{ }; } + @Override + protected String[] requiredCSS() { + return new String[]{ + "com/fr/plugin/demo/demo.css" + }; + } + @Override protected String wrapperName() { return "demoWrapper"; diff --git a/src/com/fr/plugin/demo/DemoTypePane.java b/src/com/fr/plugin/demo/DemoTypePane.java index 7467d8e..c20e17b 100644 --- a/src/com/fr/plugin/demo/DemoTypePane.java +++ b/src/com/fr/plugin/demo/DemoTypePane.java @@ -1,11 +1,17 @@ package com.fr.plugin.demo; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.extended.chart.ExtendedTypePane; +import javax.swing.JPanel; +import java.awt.Component; + /** * Created by shine on 2018/4/19. */ public class DemoTypePane extends ExtendedTypePane { + private UIButtonGroup buttonGroup; + @Override protected String[] getTypeIconPath() { return new String[]{ @@ -31,4 +37,25 @@ public class DemoTypePane extends ExtendedTypePane { protected void setType(DemoChart chart, int index) { chart.setThemeType(ThemeType.parseInt(index)); } + + @Override + protected Component[][] getPaneComponents(JPanel typePane) { + buttonGroup = new UIButtonGroup(new String[]{"3d", "2d"}); + return new Component[][]{ + new Component[]{typePane}, + new Component[]{buttonGroup} + }; + } + + @Override + protected void populate(DemoChart chart) { + super.populate(chart); + buttonGroup.setSelectedIndex(chart.isThreeDimensional() ? 0 : 1); + } + + @Override + protected void update(DemoChart chart) { + super.update(chart); + chart.setThreeDimensional(buttonGroup.getSelectedIndex() == 0); + } } diff --git a/src/com/fr/plugin/demo/DemoUI.java b/src/com/fr/plugin/demo/DemoUI.java index 60f6763..612347e 100644 --- a/src/com/fr/plugin/demo/DemoUI.java +++ b/src/com/fr/plugin/demo/DemoUI.java @@ -2,6 +2,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.ChartDataPane; 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; @@ -28,6 +29,11 @@ public class DemoUI extends AbstractExtendedChartUIProvider { return new DemoReportDataPane(); } +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return null; +// } + @Override public String getIconPath() { return "com/fr/plugin/demo/icon.png"; diff --git a/src/com/fr/plugin/demo/demo.css b/src/com/fr/plugin/demo/demo.css new file mode 100644 index 0000000..68fefc7 --- /dev/null +++ b/src/com/fr/plugin/demo/demo.css @@ -0,0 +1,4 @@ +.demo-style { + width: 400px; + height: 300px; +} \ No newline at end of file