From 65b2c1635851e40c7ed1d8a0c3b87304268a8689 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 16:29:29 +0800 Subject: [PATCH] =?UTF-8?q?CHART-11265=20=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A4=9A=E5=88=86=E7=B1=BB=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E8=BD=B4=E7=B1=BB=E5=9E=8B=E5=88=A4=E6=96=AD=E7=81=B0=E5=8C=96?= =?UTF-8?q?=20&&=20CHART-11446=20=E4=B8=8B=E6=8B=89=E6=A1=86=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E9=BB=98=E8=AE=A4=E6=97=A0=E7=9A=84=E9=80=89?= =?UTF-8?q?=E9=A1=B9=EF=BC=8C=E7=B3=BB=E5=88=97=E5=88=A0=E9=99=A4=E4=BA=86?= =?UTF-8?q?=E5=AF=B9=E6=B1=87=E6=80=BB=E6=96=B9=E5=BC=8F=E5=92=8C=E7=B3=BB?= =?UTF-8?q?=E5=88=97=E5=90=8D=E4=BD=BF=E7=94=A8=E7=9A=84=E7=81=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chartx/AbstractVanSingleDataPane.java | 4 ++ .../AbstractCustomFieldComboBoxPane.java | 6 +- .../component/AbstractMultiComponentPane.java | 19 +++++- .../component/AbstractSingleFilterPane.java | 3 +- .../diff/MultiCategoryCellDataFieldsPane.java | 4 +- .../diff/MultiCategoryDataSetFieldsPane.java | 2 + .../fr/design/chartx/single/DataSetPane.java | 3 +- .../design/chartx/single/SingleDataPane.java | 4 ++ .../fr/extended/chart/UIComboBoxWithNone.java | 5 ++ .../AbstractMultiCategoryVanChartUI.java | 64 +++++++++++++++++++ 10 files changed, 103 insertions(+), 11 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 1db85d8c58..81d5e953c4 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,4 +34,8 @@ public abstract class AbstractVanSingleDataPane extends AbstractChartDataPane extends UIComboBoxPane< } public void checkBoxUse(boolean hasUse) { - jcb.setEnabled(hasUse); useFieldValuePane.checkBoxUse(hasUse); } @@ -171,7 +170,6 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< public void checkBoxUse(boolean hasUse) { series.setEnabled(hasUse); value.setEnabled(hasUse); - function.setEnabled(hasUse); } public void clearAllBoxList() { 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 f82e4b253c..7d49dfebbd 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 @@ -34,6 +34,7 @@ public abstract class AbstractMultiComponentPane extends J private List categoryComponentList = new ArrayList(); + private boolean isCategoryAxis = true; protected abstract T createFirstFieldComponent(); @@ -43,6 +44,10 @@ public abstract class AbstractMultiComponentPane extends J protected abstract void updateField(T component, ColumnField field); + public void setIsCategoryAxis(boolean isCategoryAxis) { + this.isCategoryAxis = isCategoryAxis; + } + public AbstractMultiComponentPane() { UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); @@ -126,7 +131,7 @@ public abstract class AbstractMultiComponentPane extends J } private boolean canAdd() { - return categoryComponentList.size() < 2; + return categoryComponentList.size() < 2 && isCategoryAxis; } public List componentList() { @@ -169,7 +174,15 @@ public abstract class AbstractMultiComponentPane extends J } } - public void checkEnable(boolean hasUse){ - addButton.setEnabled(hasUse); + public void checkEnable(boolean hasUse) { + //增加按钮是否灰化要根据是否选择了数据源,是否分类轴,分类数量是否超标三个判断 + boolean buttonUse = hasUse && isCategoryAxis && categoryComponentList.size() < 2; + //额外的分类是否灰化根据是否选择了数据源,是否分类轴判断 + boolean categoryUse = hasUse && isCategoryAxis; + + addButton.setEnabled(buttonUse); + for (JComponent component : categoryComponentList) { + component.setEnabled(categoryUse); + } } } 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 index 187dd25475..73a6351647 100644 --- 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 @@ -20,7 +20,6 @@ import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.awt.Label; /** * Created by shine on 2019/07/18. @@ -110,7 +109,7 @@ public abstract class AbstractSingleFilterPane extends AbstractChartTabPane { this.setLayout(new BorderLayout()); this.add(tableDataPane, BorderLayout.NORTH); this.add(dataSetFieldsPane, BorderLayout.CENTER); - checkBoxUse(); } /** @@ -108,6 +107,8 @@ public class DataSetPane extends FurtherBasicBeanPane { tableDataPane.populateBean(ob.getNameTableData()); dataSetFieldsPane.populateBean(ob.getColumnFieldCollection()); + + checkBoxUse(); } @Override 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 dc4dfc65ad..1049861b6a 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,4 +89,8 @@ 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/extended/chart/UIComboBoxWithNone.java b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java index 77347e0fd8..6df855cd70 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java @@ -14,6 +14,11 @@ public class UIComboBoxWithNone extends UIComboBox { return Toolkit.i18nText("Fine-Design_Chart_Use_None"); } + public UIComboBoxWithNone() { + super(); + addDefaultItem(); + } + @Override public void refreshBoxItems(List list) { super.refreshBoxItems(list); 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 6cd2743fef..ae924b4485 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 @@ -1,7 +1,13 @@ 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; @@ -14,7 +20,13 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.type.AxisType; +import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.data.VanChartMoreCateReportDataContentPane; import com.fr.van.chart.designer.data.VanChartMoreCateTableDataContentPane; import com.fr.van.chart.designer.other.VanChartInteractivePane; @@ -72,6 +84,58 @@ public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndependen protected SingleDataPane createSingleDataPane() { return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); } + + @Override + public void populate(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart vanChart = collection.getSelectedChartProvider(VanChart.class); + if (vanChart == null) { + return; + } + + VanChartRectanglePlot plot = vanChart.getPlot(); + VanChartAxis axis = plot.getDefaultXAxis(); + if (plot instanceof VanChartColumnPlot + && ((VanChartColumnPlot) plot).isBar()) { + 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); + } + } }; } }