From d7d95ef78abbd69ca4c13d6d5cdd1398264e91f4 Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 4 Jun 2019 14:20:13 +0800 Subject: [PATCH] =?UTF-8?q?CHART-4027=20=E7=B3=BB=E5=88=97+=E5=80=BC=20?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9B=B8=E5=85=B3=20design?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/CustomFieldComboBoxPane.java | 58 ---------- .../SeriesValueFieldComboBoxPane.java | 108 ++++++++++++++++++ ...ractDataSetFieldsWithSeriesValuePane.java} | 28 ++--- .../diff/MultiCategoryDataSetFieldsPane.java | 2 +- 4 files changed, 123 insertions(+), 73 deletions(-) delete mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java rename designer-chart/src/main/java/com/fr/design/chartx/fields/diff/{AbstractDataSetFieldsWithCustomFieldPane.java => AbstractDataSetFieldsWithSeriesValuePane.java} (60%) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java deleted file mode 100644 index 8e6b98577..000000000 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.fr.design.chartx.component; - -import com.fr.chartx.data.field.CustomFieldValueColumnFields; - -/** - * Created by shine on 2019/5/17. - */ -public class CustomFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { - - @Override - protected AbstractUseFieldValuePane createUseFieldValuePane() { - return new UseFieldValuePane(); - } - - @Override - protected AbstractCustomFieldNamePane createCustomFieldNamePane() { - return new CustomFieldNamePane(); - } - - @Override - public void populateBean(CustomFieldValueColumnFields ob) { - if (ob.isCustomFieldValue()) { - populateCustomFieldNamePane(ob); - jcb.setSelectedIndex(1); - } else { - populateUseFieldValuePane(ob); - jcb.setSelectedIndex(0); - } - } - - @Override - public void updateBean(CustomFieldValueColumnFields ob) { - if (jcb.getSelectedIndex() == 0) { - ob.setCustomFieldValue(false); - updateUseFieldValuePane(ob); - } else { - ob.setCustomFieldValue(true); - updateCustomFieldNamePane(ob); - } - } - - private class UseFieldValuePane extends AbstractUseFieldValuePane { - - @Override - public void populateBean(CustomFieldValueColumnFields ob) { - - } - } - - private class CustomFieldNamePane extends AbstractCustomFieldNamePane { - - @Override - public void populateBean(CustomFieldValueColumnFields ob) { - - } - } - -} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java new file mode 100644 index 000000000..b6c080d52 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java @@ -0,0 +1,108 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueColumnFields; +import com.fr.chartx.data.field.SeriesValueField; +import com.fr.data.util.function.AbstractDataFunction; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; +import com.fr.general.GeneralUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/5/17. + */ +public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { + + @Override + protected AbstractUseFieldValuePane createUseFieldValuePane() { + return new UseFieldValuePane(); + } + + @Override + protected AbstractCustomFieldNamePane createCustomFieldNamePane() { + return new CustomFieldNamePane(); + } + + @Override + public void populateBean(SeriesValueColumnFields ob) { + if (ob.isCustomFieldValue()) { + populateCustomFieldNamePane(ob); + jcb.setSelectedIndex(1); + } else { + populateUseFieldValuePane(ob); + jcb.setSelectedIndex(0); + } + } + + @Override + public void updateBean(SeriesValueColumnFields ob) { + if (jcb.getSelectedIndex() == 0) { + ob.setCustomFieldValue(false); + updateUseFieldValuePane(ob); + } else { + ob.setCustomFieldValue(true); + updateCustomFieldNamePane(ob); + } + } + + private class UseFieldValuePane extends AbstractUseFieldValuePane { + + @Override + public void populateBean(SeriesValueColumnFields ob) { + List list = ob.getSeriesValueFieldList(); + if (list != null && list.size() > 0) { + populateSeries(list.get(0).getSeries().getFieldName()); + populateValue(list.get(0).getValue().getFieldName()); + populateFunction((AbstractDataFunction) list.get(0).getValue().getDataFunction()); + } + } + + @Override + public void updateBean(SeriesValueColumnFields ob) { + List list = new ArrayList(); + SeriesValueField seriesValueField = new SeriesValueField(); + ColumnField series = new ColumnField(updateSeries()); + ColumnField value = new ColumnField(updateValue()); + value.setDataFunction(updateFunction()); + seriesValueField.setValue(value); + seriesValueField.setSeries(series); + list.add(seriesValueField); + ob.setSeriesValueFieldList(list); + } + } + + private class CustomFieldNamePane extends AbstractCustomFieldNamePane { + + @Override + public void populateBean(SeriesValueColumnFields ob) { + List list = new ArrayList(); + for (SeriesValueField seriesValueField : ob.getSeriesValueFieldList()) { + Object[] array = new Object[3]; + array[0] = seriesValueField.getSeries().getFieldName(); + array[1] = seriesValueField.getValue().getFieldName(); + array[2] = DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction()); + list.add(array); + } + populate(list); + } + + @Override + public void updateBean(SeriesValueColumnFields ob) { + List list = update(); + List seriesValueFields = new ArrayList(); + for (Object[] line : list) { + ColumnField series = new ColumnField(GeneralUtils.objectToString(line[0])); + ColumnField value = new ColumnField(GeneralUtils.objectToString(line[1])); + value.setDataFunction(DataPaneHelper.getFunctionByName(GeneralUtils.objectToString(line[2]))); + SeriesValueField seriesValueField = new SeriesValueField(); + seriesValueField.setValue(value); + seriesValueField.setSeries(series); + seriesValueFields.add(seriesValueField); + } + ob.setSeriesValueFieldList(seriesValueFields); + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java similarity index 60% rename from designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java rename to designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java index 9b0418c30..7c4f0f083 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java @@ -1,7 +1,7 @@ package com.fr.design.chartx.fields.diff; -import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithCustomField; -import com.fr.design.chartx.component.CustomFieldComboBoxPane; +import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; +import com.fr.design.chartx.component.SeriesValueFieldComboBoxPane; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import javax.swing.JPanel; @@ -12,49 +12,49 @@ import java.util.List; * Created by shine on 2019/5/16. * 带有 自定义系列名(fr表现为 系列名使用字段名) 的字段集合 的一个pane */ -public abstract class AbstractDataSetFieldsWithCustomFieldPane +public abstract class AbstractDataSetFieldsWithSeriesValuePane extends AbstractDataSetFieldsPane { - private CustomFieldComboBoxPane customFieldComboBoxPane; + private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane; @Override protected JPanel createCenterPane() { JPanel normalCenter = super.createCenterPane(); - customFieldComboBoxPane = new CustomFieldComboBoxPane(); + seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane(); if (normalCenter != null) { JPanel panel = new JPanel(new BorderLayout()); panel.add(normalCenter, BorderLayout.CENTER); - panel.add(customFieldComboBoxPane, BorderLayout.SOUTH); + panel.add(seriesValueFieldComboBoxPane, BorderLayout.SOUTH); return panel; } else { - return customFieldComboBoxPane; + return seriesValueFieldComboBoxPane; } } @Override public void checkBoxUse(boolean hasUse) { super.checkBoxUse(hasUse); - customFieldComboBoxPane.checkBoxUse(hasUse); + seriesValueFieldComboBoxPane.checkBoxUse(hasUse); } @Override public void clearAllBoxList() { super.clearAllBoxList(); - customFieldComboBoxPane.clearAllBoxList(); + seriesValueFieldComboBoxPane.clearAllBoxList(); } @Override public void refreshBoxListWithSelectTableData(List columnNameList) { super.refreshBoxListWithSelectTableData(columnNameList); - customFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList); + seriesValueFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList); } - protected void populateCustomPane(AbstractColumnFieldCollectionWithCustomField t) { - customFieldComboBoxPane.populateBean(t.getCustomFieldValueColumnFields()); + protected void populateCustomPane(AbstractColumnFieldCollectionWithSeriesValue t) { + seriesValueFieldComboBoxPane.populateBean(t.getSeriesValueColumnFields()); } - protected void updateCustomPane(AbstractColumnFieldCollectionWithCustomField t) { - customFieldComboBoxPane.updateBean(t.getCustomFieldValueColumnFields()); + protected void updateCustomPane(AbstractColumnFieldCollectionWithSeriesValue t) { + seriesValueFieldComboBoxPane.updateBean(t.getSeriesValueColumnFields()); } } 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 f3828361b..6a6983fc1 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 @@ -13,7 +13,7 @@ import java.util.List; /** * Created by shine on 2019/4/10. */ -public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithCustomFieldPane { +public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane { private MultiComboBoxPane multiCategoryPane;