From 1810907a62e25e978c8ffb8bc10fe5a9ccd6349e Mon Sep 17 00:00:00 2001 From: eason-skx Date: Tue, 25 Feb 2020 11:57:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=88=E5=B9=B6=E5=86=B2?= =?UTF-8?q?=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/AbstractMultiComponentPane.java | 42 ++++++-- .../component/CategorySeriesFilterPane.java | 99 +++++++++++++++++++ .../component/MultiTinyFormulaPane.java | 8 +- ...ractCellDataFieldsWithSeriesValuePane.java | 10 +- ...tractDataSetFieldsWithSeriesValuePane.java | 10 +- .../diff/MultiCategoryCellDataFieldsPane.java | 82 +++++---------- 6 files changed, 173 insertions(+), 78 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/CategorySeriesFilterPane.java 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 2a8154d7b..d22d95741 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 @@ -10,13 +10,13 @@ import com.fr.general.IOUtils; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; /** @@ -24,7 +24,6 @@ import java.util.List; * 一列组件 可增可删,通过JComponent后面的加减button增删。 */ public abstract class AbstractMultiComponentPane extends JPanel { - private static final int COM_W = 96; private static final int H = 20; private static final int ICON_W = 20; @@ -35,6 +34,7 @@ public abstract class AbstractMultiComponentPane extends J private List categoryComponentList = new ArrayList(); + private boolean categoryAxis = true; protected abstract T createFirstFieldComponent(); @@ -44,13 +44,23 @@ public abstract class AbstractMultiComponentPane extends J protected abstract void updateField(T component, ColumnField field); + public void setCategoryAxis(boolean categoryAxis) { + this.categoryAxis = categoryAxis; + if(!categoryAxis){ + addButton.setEnabled(false); + for (JComponent component : categoryComponentList) { + component.setEnabled(false); + } + } + } + public AbstractMultiComponentPane() { UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); firstFieldComponent = createFirstFieldComponent(); - firstFieldComponent.setPreferredSize(new Dimension(COM_W, H)); + firstFieldComponent.setPreferredSize(new Dimension(componentWidth(), H)); addButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); addButton.setPreferredSize(new Dimension(ICON_W, H)); @@ -64,7 +74,7 @@ public abstract class AbstractMultiComponentPane extends J }); final JPanel panel = new JPanel(); - panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 2)); panel.add(label); panel.add(firstFieldComponent); @@ -78,6 +88,10 @@ public abstract class AbstractMultiComponentPane extends J this.add(boxPane, BorderLayout.CENTER); } + protected int componentWidth() { + return 96; + } + private JPanel addComboBoxAndButtonToBox(T uiComboBox, UIButton uiButton) { final JPanel panel = new JPanel(); panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); @@ -93,7 +107,7 @@ public abstract class AbstractMultiComponentPane extends J private void addNewComboBox() { final T comboBox = createOtherFieldComponent(); - comboBox.setPreferredSize(new Dimension(COM_W, H)); + comboBox.setPreferredSize(new Dimension(componentWidth(), H)); UIButton delButton = new UIButton(IOUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); delButton.setPreferredSize(new Dimension(ICON_W, H)); @@ -123,7 +137,7 @@ public abstract class AbstractMultiComponentPane extends J } private boolean canAdd() { - return categoryComponentList.size() < 3; + return categoryComponentList.size() < 2 && categoryAxis; } public List componentList() { @@ -165,4 +179,16 @@ public abstract class AbstractMultiComponentPane extends J updateField(comboBox, temp); } } -} + + public void checkEnable(boolean hasUse) { + //增加按钮是否灰化要根据是否选择了数据源,是否分类轴,分类数量是否超标三个判断 + boolean buttonUse = hasUse && categoryAxis && categoryComponentList.size() < 2; + //额外的分类是否灰化根据是否选择了数据源,是否分类轴判断 + boolean categoryUse = hasUse && categoryAxis; + + addButton.setEnabled(buttonUse); + for (JComponent component : categoryComponentList) { + component.setEnabled(categoryUse); + } + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CategorySeriesFilterPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CategorySeriesFilterPane.java new file mode 100644 index 000000000..d344004c8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CategorySeriesFilterPane.java @@ -0,0 +1,99 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.DataFilterProperties; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.map.designer.VanChartGroupPane; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.util.List; +import java.awt.BorderLayout; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/9/26 + */ +public class CategorySeriesFilterPane extends JPanel { + + private AbstractSingleFilterPane seriesFilterPane; + private AbstractSingleFilterPane categoryFilterPane; + + public CategorySeriesFilterPane() { + seriesFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + categoryFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Style_Category"); + } + }; + + JPanel groupPane = new VanChartGroupPane(new String[]{categoryFilterPane.title4PopupWindow(), seriesFilterPane.title4PopupWindow()} + , new JPanel[]{categoryFilterPane, seriesFilterPane}) { + }; + + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(groupPane, BorderLayout.CENTER); + groupPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); + this.setLayout(new BorderLayout()); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + public void populateMultiCategoryFieldCollection(MultiCategoryColumnFieldCollection fieldCollection) { + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + populateSeries(seriesValueCorrelationDefinition.getFilterProperties()); + + } + + List categoryList = fieldCollection.getCategoryList(); + if (!categoryList.isEmpty()) { + populateCategory(categoryList.get(0).getFilterProperties()); + } + } + + public void updateMultiCategoryFieldCollection(MultiCategoryColumnFieldCollection fieldCollection) { + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(updateSeries()); + } + + List categoryList = fieldCollection.getCategoryList(); + if (!categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(updateCategory()); + } + } + + private void populateSeries(DataFilterProperties series) { + seriesFilterPane.populateBean(series); + + } + + private void populateCategory(DataFilterProperties category) { + categoryFilterPane.populateBean(category); + + } + + private DataFilterProperties updateSeries() { + return seriesFilterPane.updateBean(); + + } + + private DataFilterProperties updateCategory() { + return categoryFilterPane.updateBean(); + } + + +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java index 5e56b967c..bec7e6e7b 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java @@ -8,6 +8,12 @@ import com.fr.design.formula.TinyFormulaPane; * Created by shine on 2019/4/12. */ public class MultiTinyFormulaPane extends AbstractMultiComponentPane { + + @Override + protected int componentWidth() { + return 116; + } + @Override protected TinyFormulaPane createFirstFieldComponent() { return new TinyFormulaPane(); @@ -28,4 +34,4 @@ public class MultiTinyFormulaPane extends AbstractMultiComponentPane +public abstract class AbstractCellDataFieldsWithSeriesValuePane extends AbstractCellDataFieldsPane { private CellDataSeriesValueCorrelationPane seriesValueFieldsPane; @@ -41,12 +41,12 @@ public abstract class AbstractCellDataFieldsWithSeriesValuePane +public abstract class AbstractDataSetFieldsWithSeriesValuePane extends AbstractDataSetFieldsPane { private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane; @@ -61,11 +61,11 @@ public abstract class AbstractDataSetFieldsWithSeriesValuePane list = multiCategoryPane.componentList(); return list.toArray(new TinyFormulaPane[list.size()]); } @@ -80,15 +55,7 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS populateSeriesValuePane(multiCategoryColumnFieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); - - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); - } + filterPane.populateMultiCategoryFieldCollection(multiCategoryColumnFieldCollection); } @Override @@ -101,15 +68,12 @@ 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()); - } + filterPane.updateMultiCategoryFieldCollection(fieldCollection); return fieldCollection; } -} + + public void setCategoryAxis(boolean categoryAxis){ + multiCategoryPane.setCategoryAxis(categoryAxis); + } +} \ No newline at end of file