From f1f33297f90b58e4fc669bb4af62876bdccc8354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 2 Dec 2019 18:22:52 +0800 Subject: [PATCH] CHART-11265 --- .../chartx/AbstractVanSingleDataPane.java | 4 -- .../component/AbstractMultiComponentPane.java | 18 ++++--- .../diff/MultiCategoryCellDataFieldsPane.java | 6 ++- .../diff/MultiCategoryDataSetFieldsPane.java | 6 ++- .../design/chartx/single/SingleDataPane.java | 4 -- .../AbstractMultiCategoryVanChartUI.java | 48 ++++--------------- 6 files changed, 29 insertions(+), 57 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/AbstractVanSingleDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/AbstractVanSingleDataPane.java index 81d5e953c4..1db85d8c58 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/AbstractVanSingleDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/AbstractVanSingleDataPane.java @@ -34,8 +34,4 @@ public abstract class AbstractVanSingleDataPane extends AbstractChartDataPane extends J private List categoryComponentList = new ArrayList(); - private boolean isCategoryAxis = true; + private boolean categoryAxis = true; protected abstract T createFirstFieldComponent(); @@ -44,8 +44,14 @@ public abstract class AbstractMultiComponentPane extends J protected abstract void updateField(T component, ColumnField field); - public void setIsCategoryAxis(boolean isCategoryAxis) { - this.isCategoryAxis = isCategoryAxis; + public void setCategoryAxis(boolean categoryAxis) { + this.categoryAxis = categoryAxis; + if(!categoryAxis){ + addButton.setEnabled(false); + for (JComponent component : categoryComponentList) { + component.setEnabled(false); + } + } } public AbstractMultiComponentPane() { @@ -131,7 +137,7 @@ public abstract class AbstractMultiComponentPane extends J } private boolean canAdd() { - return categoryComponentList.size() < 2 && isCategoryAxis; + return categoryComponentList.size() < 2 && categoryAxis; } public List componentList() { @@ -176,9 +182,9 @@ public abstract class AbstractMultiComponentPane extends J public void checkEnable(boolean hasUse) { //增加按钮是否灰化要根据是否选择了数据源,是否分类轴,分类数量是否超标三个判断 - boolean buttonUse = hasUse && isCategoryAxis && categoryComponentList.size() < 2; + boolean buttonUse = hasUse && categoryAxis && categoryComponentList.size() < 2; //额外的分类是否灰化根据是否选择了数据源,是否分类轴判断 - boolean categoryUse = hasUse && isCategoryAxis; + boolean categoryUse = hasUse && categoryAxis; addButton.setEnabled(buttonUse); for (JComponent component : categoryComponentList) { 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 12ba423433..505721d18e 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 @@ -53,8 +53,6 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS multiCategoryPane.populate(categoryList); - multiCategoryPane.setIsCategoryAxis(multiCategoryColumnFieldCollection.isCategoryAxis()); - populateSeriesValuePane(multiCategoryColumnFieldCollection); filterPane.populateMultiCategoryFieldCollection(multiCategoryColumnFieldCollection); @@ -74,4 +72,8 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS return fieldCollection; } + + public void setCategoryAxis(boolean categoryAxis){ + multiCategoryPane.setCategoryAxis(categoryAxis); + } } 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 7f03135794..cba3807a92 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 @@ -67,8 +67,6 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer multiCategoryPane.populate(categoryList); - multiCategoryPane.setIsCategoryAxis(multiCategoryColumnFieldCollection.isCategoryAxis()); - populateSeriesValuePane(multiCategoryColumnFieldCollection); filterPane.populateMultiCategoryFieldCollection(multiCategoryColumnFieldCollection); @@ -88,4 +86,8 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer return columnFieldCollection; } + + public void setCategoryAxis(boolean categoryAxis){ + multiCategoryPane.setCategoryAxis(categoryAxis); + } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java index 1049861b6a..dc4dfc65ad 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java @@ -89,8 +89,4 @@ public class SingleDataPane extends BasicBeanPane { protected String title4PopupWindow() { return null; } - - public void setSelectedIndex(int index) { - comboBoxPane.setSelectedIndex(index); - } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java index ae924b4485..05f5eb6475 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java @@ -3,11 +3,6 @@ package com.fr.van.chart.vanchart; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Plot; -import com.fr.chartx.data.AbstractDataDefinition; -import com.fr.chartx.data.CellDataDefinition; -import com.fr.chartx.data.ChartDataDefinitionProvider; -import com.fr.chartx.data.DataSetDefinition; -import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chartx.AbstractVanSingleDataPane; import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane; @@ -80,13 +75,19 @@ public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndependen @Override public ChartDataPane getChartDataPane(AttributeChangeListener listener) { return new AbstractVanSingleDataPane(listener) { + MultiCategoryDataSetFieldsPane multiCategoryDataSetFieldsPane; + MultiCategoryCellDataFieldsPane multiCategoryCellDataFieldsPane; + @Override protected SingleDataPane createSingleDataPane() { - return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); + multiCategoryDataSetFieldsPane = new MultiCategoryDataSetFieldsPane(); + multiCategoryCellDataFieldsPane = new MultiCategoryCellDataFieldsPane(); + return new SingleDataPane(multiCategoryDataSetFieldsPane, multiCategoryCellDataFieldsPane); } @Override public void populate(ChartCollection collection) { + super.populate(collection); if (collection == null) { return; } @@ -102,39 +103,8 @@ public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndependen axis = plot.getDefaultYAxis(); } - boolean isCategoryAxis = ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY); - MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection = new MultiCategoryColumnFieldCollection(); - multiCategoryColumnFieldCollection.setCategoryAxis(isCategoryAxis); - - //如果DataDefinition为空,对数据集数据源配置面板和单元格数据源配置面板进行更新。 - ChartDataDefinitionProvider definition = vanChart.getChartDataDefinition(); - if (definition == null) { - CellDataDefinition cellDataDefinition = new CellDataDefinition(); - cellDataDefinition.setColumnFieldCollection(multiCategoryColumnFieldCollection); - populate(cellDataDefinition); - - DataSetDefinition dataSetDefinition = new DataSetDefinition(); - dataSetDefinition.setColumnFieldCollection(multiCategoryColumnFieldCollection); - populate(dataSetDefinition); - return; - } - - MultiCategoryColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(MultiCategoryColumnFieldCollection.class); - columnFieldCollection.setCategoryAxis(isCategoryAxis); - super.populate(collection); - - //如果DataDefinition不为空,对另一种数据源配置进行更新 - if (definition instanceof DataSetDefinition) { - CellDataDefinition cellDataDefinition = new CellDataDefinition(); - cellDataDefinition.setColumnFieldCollection(multiCategoryColumnFieldCollection); - populate(cellDataDefinition); - setSelectedIndex(0); - } else { - DataSetDefinition dataSetDefinition = new DataSetDefinition(); - dataSetDefinition.setColumnFieldCollection(multiCategoryColumnFieldCollection); - populate(dataSetDefinition); - setSelectedIndex(1); - } + multiCategoryDataSetFieldsPane.setCategoryAxis(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY)); + multiCategoryCellDataFieldsPane.setCategoryAxis(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY)); } }; }