From e191c65c9ca7afec2c14851c416f522a923a6f31 Mon Sep 17 00:00:00 2001 From: zheng Date: Thu, 18 Jul 2019 17:49:03 +0800 Subject: [PATCH] =?UTF-8?q?CHART-9141=20filter=E7=95=8C=E9=9D=A2&xml?= =?UTF-8?q?=E3=80=81processor=E4=B8=8D=E5=90=88=E7=90=86=E6=94=B9=E6=88=90?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E3=80=81result=E6=B5=81=E7=A8=8B=E4=B8=80?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/AbstractSingleFilterPane.java | 171 ++++++++++++++++++ .../diff/MultiCategoryCellDataFieldsPane.java | 47 +++++ .../diff/MultiCategoryDataSetFieldsPane.java | 47 +++++ .../actions/insert/flot/ChartFloatAction.java | 8 +- 4 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java new file mode 100644 index 0000000000..7c494aac1e --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java @@ -0,0 +1,171 @@ +package com.fr.design.chartx.component; + +import com.fr.base.Utils; +import com.fr.chartx.data.field.DataFilterProperties; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.TableLayout; +import com.fr.design.mainframe.chart.gui.data.PresentComboBox; +import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by shine on 2019/07/18. + */ +public abstract class AbstractSingleFilterPane extends AbstractChartTabPane { + + private static final int FIL_HEIGHT = 150; + + private UICheckBox useTopCheckBox; + + private UITextField topNumTextField; + private UICheckBox hideNullCheckBox; + private UICheckBox mergeOtherCheckBox; + + private PresentComboBox present; + + private AbstractAttrNoScrollPane parent; + + private JPanel topPane; + + public AbstractSingleFilterPane() { + super(true); + //todo@shinerefactor present的时候这边可以整理下 + // this.parent = parent; + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + dim.height = FIL_HEIGHT; + return dim; + } + + + protected void layoutContentPane() { + super.layoutContentPane(); + leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); + } + + public void reloaPane(JPanel pane) { + super.reloaPane(pane); + leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); + } + + @Override + protected JPanel createContentPane() { + this.setLayout(new BorderLayout()); + JPanel pane = initPane(); + this.add(pane, BorderLayout.NORTH); + return pane; + } + + + private JPanel initPane() { + useTopCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); + JPanel panel1 = new JPanel(new BorderLayout()); + JPanel panel2 = new JPanel(new BorderLayout()); + panel1.add(useTopCheckBox, BorderLayout.NORTH); + topNumTextField = new UITextField(); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Records_Num")); + mergeOtherCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); + mergeOtherCheckBox.setSelected(true); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + new Component[]{label, topNumTextField}, + new Component[]{mergeOtherCheckBox, null} + }; + + topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + topPane.setBorder(BorderFactory.createEmptyBorder(10, 15, 0, 0)); + //默认不显示 + topPane.setVisible(false); + panel1.add(topPane, BorderLayout.CENTER); + hideNullCheckBox = new UICheckBox(title4PopupWindow() + " is null, hidden"); + panel2.add(hideNullCheckBox, BorderLayout.NORTH); + + useTopCheckBox.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + checkBoxUse(); + } + }); + + present = new PresentComboBox() { + protected void fireChange() { + fire(); + } + }; + JPanel presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present"), present); + panel2.add(presentPane, BorderLayout.SOUTH); + + double[] column = {f}; + double[] row = {p, p}; + Component[][] coms = new Component[][]{ + new Component[]{panel1}, + new Component[]{panel2} + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(coms, row, column); + } + + + private void fire() { + if (this.parent != null) { + parent.attributeChanged(); + } + } + + /** + * 检查Box是否可用 + */ + public void checkBoxUse() { + topPane.setVisible(useTopCheckBox.isSelected()); + } + + @Override + public void populateBean(DataFilterProperties ob) { + useTopCheckBox.setSelected(ob.isUseTop()); + + topNumTextField.setText(String.valueOf(ob.getTop())); + + hideNullCheckBox.setSelected(ob.isHideNull()); + + mergeOtherCheckBox.setSelected(ob.isMerge()); + + present.populate(ob.getPresent()); + + checkBoxUse(); + } + + @Override + public DataFilterProperties updateBean() { + DataFilterProperties dataFilterProperties = new DataFilterProperties(); + + dataFilterProperties.setUseTop(useTopCheckBox.isSelected()); + + Number number = Utils.objectToNumber(topNumTextField.getText(), true); + if (number != null) { + dataFilterProperties.setTop(number.intValue()); + } + dataFilterProperties.setHideNull(hideNullCheckBox.isSelected()); + + dataFilterProperties.setMerge(mergeOtherCheckBox.isSelected()); + + dataFilterProperties.setPresent(present.update()); + + return dataFilterProperties; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java index 76588271e4..3645a08db7 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java @@ -1,9 +1,12 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; import com.fr.design.chartx.component.MultiTinyFormulaPane; import com.fr.design.formula.TinyFormulaPane; +import com.fr.van.chart.map.designer.VanChartGroupPane; import javax.swing.JPanel; import java.util.List; @@ -15,6 +18,9 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS private MultiTinyFormulaPane multiCategoryPane; + private AbstractSingleFilterPane seriesFilterPane; + private AbstractSingleFilterPane categoryFilterPane; + private void createMultiFormulaPane() { if (multiCategoryPane == null) { multiCategoryPane = new MultiTinyFormulaPane(); @@ -29,6 +35,28 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS return multiCategoryPane; } + @Override + protected JPanel createSouthPane() { + if (seriesFilterPane == null) { + seriesFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + //todo@shinerefactor + return "series"; + } + }; + categoryFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return "category"; + } + }; + } + return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} + , new JPanel[]{seriesFilterPane, categoryFilterPane}) { + }; + } + @Override protected String[] fieldLabels() { return new String[0]; @@ -51,6 +79,16 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS multiCategoryPane.populate(categoryList); populateSeriesValuePane(multiCategoryColumnFieldCollection); + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); + } } @Override @@ -63,6 +101,15 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS updateSeriesValuePane(fieldCollection); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); + } + return fieldCollection; } } 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 1abe2b1849..5b18d8ae83 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 @@ -1,9 +1,12 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; import com.fr.design.chartx.component.MultiComboBoxPane; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.van.chart.map.designer.VanChartGroupPane; import javax.swing.JPanel; import java.util.List; @@ -16,6 +19,9 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer private MultiComboBoxPane multiCategoryPane; + private AbstractSingleFilterPane seriesFilterPane; + private AbstractSingleFilterPane categoryFilterPane; + @Override protected String[] fieldLabels() { return new String[0]; @@ -39,6 +45,28 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer return initMultiCategoryPane(); } + @Override + protected JPanel createSouthPane() { + if (seriesFilterPane == null) { + seriesFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + //todo@shinerefactor + return "series"; + } + }; + categoryFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return "category"; + } + }; + } + return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} + , new JPanel[]{seriesFilterPane, categoryFilterPane}) { + }; + } + @Override public void refreshBoxListWithSelectTableData(List columnNameList) { super.refreshBoxListWithSelectTableData(columnNameList); @@ -52,6 +80,16 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer multiCategoryPane.populate(categoryList); populateSeriesValuePane(multiCategoryColumnFieldCollection); + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); + } } @Override @@ -64,6 +102,15 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer updateSeriesValuePane(columnFieldCollection); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = columnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); + } + return columnFieldCollection; } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java index d7ab0f9b15..b8f05c2e4a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java @@ -15,10 +15,9 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; import com.fr.design.module.DesignModuleFactory; -import com.fr.log.FineLoggerFactory; - import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; +import com.fr.log.FineLoggerFactory; import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; import com.fr.report.elementcase.TemplateElementCase; @@ -27,8 +26,8 @@ import com.fr.stable.bridge.StableFactory; import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; -import javax.swing.*; -import java.awt.*; +import javax.swing.KeyStroke; +import java.awt.Color; /** * 图表插入悬浮元素的操作. @@ -80,7 +79,6 @@ public class ChartFloatAction extends ElementCaseAction { reportPane.stopEditing(); final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG); - cc.removeAllNameObject(); final MiddleChartDialog chartDialog = DesignModuleFactory.getChartDialog(DesignerContext.getDesignerFrame()); chartDialog.populate(cc); chartDialog.addDialogActionListener(new DialogActionAdapter() {