diff --git a/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java new file mode 100644 index 0000000000..952bca3cdc --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java @@ -0,0 +1,21 @@ +package com.fr.design.chartx; + +import com.fr.design.chartx.fields.diff.MultiPieCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.MultiPieDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieChartDataPane extends MultiCategoryChartDataPane { + + public MultiPieChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new MultiPieDataSetFieldsPane(), new MultiPieCellDataFieldsPane()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java index 008a7d91cb..2a8154d7bb 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java @@ -21,7 +21,7 @@ import java.util.List; /** * Created by shine on 2019/4/10. - * 一列组件 可增可删 + * 一列组件 可增可删,通过JComponent后面的加减button增删。 */ public abstract class AbstractMultiComponentPane extends JPanel { private static final int COM_W = 96; diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java new file mode 100644 index 0000000000..b24743c762 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java @@ -0,0 +1,150 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + * 一列组件 可增可删,通过UISpinner增删。 + */ +public abstract class AbstractMultiComponentPaneWithUISpinner extends JPanel { + + private UISpinner levelNumSpinner; + + private List levelComponentList = new ArrayList(); + + private JPanel levelPane; + + private int currentNum = 3; + + public AbstractMultiComponentPaneWithUISpinner() { + initComps(); + } + + public List getComponentList() { + return levelComponentList; + } + + protected abstract T createJComponent(); + + protected abstract void populateField(T component, ColumnField field); + + protected abstract void updateField(T component, ColumnField field); + + protected void initComps() { + + this.setLayout(new BorderLayout(0, 6)); + + levelNumSpinner = new UISpinner(1, 15, 1, currentNum) { + @Override + protected void fireStateChanged() { + //先处理自身的空间布局 + refreshLevelPane(); + //然后更新数据 + super.fireStateChanged(); + } + + @Override + public void setTextFieldValue(double value) { + //如果为0,则没有改变值 + if (value == 0) { + return; + } + super.setTextFieldValue(value); + } + }; + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level_Number")), levelNumSpinner}, + }; + + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(components, new double[]{TableLayout.PREFERRED}, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6); + + this.add(northPane, BorderLayout.NORTH); + + initLevelPane(); + } + + private void initLevelPane() { + double[] rows = new double[currentNum]; + + Component[][] components = new Component[currentNum][2]; + + List newList = new ArrayList(); + + int maxSize = levelComponentList.size(); + for (int i = 0; i < currentNum; i++) { + rows[i] = TableLayout.PREFERRED; + T component = i < maxSize ? levelComponentList.get(i) : createJComponent(); + newList.add(component); + + components[i] = new Component[]{ + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level") + String.valueOf(i + 1)), + component + }; + } + + levelComponentList = newList; + + levelPane = TableLayoutHelper.createGapTableLayoutPane(components, rows, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6); + + this.add(levelPane, BorderLayout.CENTER); + } + + private void refreshLevelPane() { + if (levelNumSpinner == null) { + return; + } + + int newNum = (int) levelNumSpinner.getValue(); + + if (newNum != currentNum) { + currentNum = newNum; + this.remove(levelPane); + this.initLevelPane(); + } + + refreshPane(); + } + + private void refreshPane() { + this.validate(); + this.repaint(); + this.revalidate(); + } + + public void populate(List categoryList) { + int len = categoryList.size(); + levelNumSpinner.setValue(len); + + refreshLevelPane(); + + for (int i = 0; i < len; i++) { + ColumnField columnField = categoryList.get(i); + T component = levelComponentList.get(i); + populateField(component, columnField); + } + } + + public void update(List categoryList) { + categoryList.clear(); + + for (T comboBox : levelComponentList) { + ColumnField temp = new ColumnField(); + categoryList.add(temp); + updateField(comboBox, temp); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java index 37a110b7d4..f1716a0ae0 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java @@ -5,10 +5,18 @@ import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.extended.chart.UIComboBoxWithNone; +import java.util.ArrayList; +import java.util.List; + /** * Created by shine on 2019/4/12. */ public class MultiComboBoxPane extends AbstractMultiComponentPane { + private List currentBoxItems = new ArrayList(); + + public void setCurrentBoxItems(List currentBoxItems) { + this.currentBoxItems = currentBoxItems; + } @Override protected UIComboBox createFirstFieldComponent() { @@ -17,7 +25,7 @@ public class MultiComboBoxPane extends AbstractMultiComponentPane { @Override protected UIComboBox createOtherFieldComponent() { - return new UIComboBox(); + return new UIComboBox(currentBoxItems.toArray(new Object[currentBoxItems.size()])); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java new file mode 100644 index 0000000000..8b20768e2d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java @@ -0,0 +1,40 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiComboBoxPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner { + private List currentBoxList = new ArrayList(); + + @Override + protected void initComps() { + currentBoxList = new ArrayList(); + super.initComps(); + } + + public void setCurrentBoxList(List currentBoxList) { + this.currentBoxList = currentBoxList; + } + + @Override + protected UIComboBox createJComponent() { + return new UIComboBox(currentBoxList.toArray(new Object[currentBoxList.size()])); + } + + @Override + protected void populateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.updateField(component, field); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java new file mode 100644 index 0000000000..e3bbf4b848 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java @@ -0,0 +1,25 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; + +/** + * Created by shine on 2019/6/19. + */ +public class MultiTinyFormulaPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner { + @Override + protected TinyFormulaPane createJComponent() { + return new TinyFormulaPane(); + } + + @Override + protected void populateField(TinyFormulaPane component, ColumnField field) { + AbstractCellDataFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(TinyFormulaPane component, ColumnField field) { + AbstractCellDataFieldsPane.updateField(component, field); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java index 17fcfb2ba3..1abe2b1849 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -39,6 +39,12 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer return initMultiCategoryPane(); } + @Override + public void refreshBoxListWithSelectTableData(List columnNameList) { + super.refreshBoxListWithSelectTableData(columnNameList); + multiCategoryPane.setCurrentBoxItems(columnNameList); + } + @Override public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) { List categoryList = multiCategoryColumnFieldCollection.getCategoryList(); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java new file mode 100644 index 0000000000..950f49401a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java @@ -0,0 +1,67 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; +import com.fr.design.chartx.component.MultiTinyFormulaPaneWithUISpinner; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private UITextField nameField;//指标名称 + + private MultiTinyFormulaPaneWithUISpinner levelPane; + + private TinyFormulaPane value; + + @Override + protected void initComponents() { + nameField = new UITextField(); + levelPane = new MultiTinyFormulaPaneWithUISpinner(); + value = new TinyFormulaPane(); + super.initComponents(); + } + + @Override + protected JPanel createNorthPane() { + return levelPane; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{ + value + }; + } + + @Override + public void populateBean(MultiPieColumnFieldCollection ob) { + nameField.setText(ob.getTargetName()); + levelPane.populate(ob.getLevels()); + populateField(value, ob.getValue()); + } + + @Override + public MultiPieColumnFieldCollection updateBean() { + MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection(); + + result.setTargetName(nameField.getText()); + levelPane.update(result.getLevels()); + updateField(value, result.getValue()); + + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java new file mode 100644 index 0000000000..2a299ba6e9 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java @@ -0,0 +1,94 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; +import com.fr.design.chartx.component.MultiComboBoxPaneWithUISpinner; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; + +import javax.swing.JPanel; +import java.awt.Component; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieDataSetFieldsPane extends AbstractDataSetFieldsPane { + private UITextField nameField; + + private MultiComboBoxPaneWithUISpinner levelComboBoxPane; + + private UIComboBox value; + + private CalculateComboBox function; + + @Override + protected void initComponents() { + nameField = new UITextField(); + levelComboBoxPane = new MultiComboBoxPaneWithUISpinner(); + value = new UIComboBox(); + function = new CalculateComboBox(); + super.initComponents(); + } + + @Override + protected JPanel createNorthPane() { + return levelComboBoxPane; + } + + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + Toolkit.i18nText("Fine-Design_Chart_Summary_Method") + }; + } + + @Override + protected Component[] fieldComponents() { + return new UIComboBox[]{ + value, + function + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + List list = levelComboBoxPane.getComponentList(); + + int len = list.size(); + UIComboBox[] result = new UIComboBox[len + 1]; + for (int i = 0; i < len; i++) { + result[i] = list.get(i); + } + result[len] = value; + + return result; + } + + @Override + public void refreshBoxListWithSelectTableData(List columnNameList) { + super.refreshBoxListWithSelectTableData(columnNameList); + levelComboBoxPane.setCurrentBoxList(columnNameList); + } + + @Override + public void populateBean(MultiPieColumnFieldCollection ob) { + levelComboBoxPane.populate(ob.getLevels()); + populateFunctionField(value, function, ob.getValue()); + } + + @Override + public MultiPieColumnFieldCollection updateBean() { + MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection(); + + levelComboBoxPane.update(result.getLevels()); + + updateFunctionField(value, function, result.getValue()); + + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java index e25e55b064..06f0b0f75f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java @@ -2,14 +2,12 @@ package com.fr.van.chart.multilayer; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.MultiPieChartDataPane; import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; -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.van.chart.multilayer.data.MultiPiePlotReportDataContentPane; -import com.fr.van.chart.multilayer.data.MultiPiePlotTableDataContentPane; import com.fr.van.chart.multilayer.other.VanChartMultiPieConditionPane; import com.fr.van.chart.multilayer.style.VanChartMultiPieSeriesPane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; @@ -29,13 +27,8 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan } @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ - return new MultiPiePlotTableDataContentPane(parent); - } - - @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ - return new MultiPiePlotReportDataContentPane(parent); + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new MultiPieChartDataPane(listener); } public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){