diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java new file mode 100644 index 0000000000..3d5cdc9d99 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java @@ -0,0 +1,59 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.SeriesValueField; +import com.fr.design.chartx.component.correlation.AbstractCorrelationPane; +import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; +import com.fr.design.chartx.component.correlation.TinyFormulaPaneEditorComponent; +import com.fr.design.i18n.Toolkit; +import com.fr.general.GeneralUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/4. + */ +public class CellDataSeriesValueCorrelationPane extends AbstractCorrelationPane { + + @Override + protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { + return new FieldEditorComponentWrapper[]{ + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value")) + }; + } + + @Override + protected List covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { + List result = new ArrayList(); + + List seriesValueFieldList = seriesValueCorrelationDefinition.getSeriesValueFieldList(); + for (SeriesValueField seriesValueField : seriesValueFieldList) { + Object[] array = new Object[]{seriesValueField.getSeries().getFieldName(), seriesValueField.getValue().getFieldName()}; + result.add(array); + } + + return result; + } + + @Override + protected SeriesValueCorrelationDefinition covertTableModelListToTBean(List tableValues) { + List seriesValueFieldList = new ArrayList(); + + for (Object[] oneLine : tableValues) { + SeriesValueField seriesValueField = new SeriesValueField(); + ColumnField series = new ColumnField(GeneralUtils.objectToString(oneLine[0])); + ColumnField value = new ColumnField(GeneralUtils.objectToString(oneLine[1])); + seriesValueField.setSeries(series); + seriesValueField.setValue(value); + seriesValueFieldList.add(seriesValueField); + } + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = new SeriesValueCorrelationDefinition(); + seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFieldList); + + return seriesValueCorrelationDefinition; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java deleted file mode 100644 index 83a74f854d..0000000000 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java +++ /dev/null @@ -1,55 +0,0 @@ -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.design.i18n.Toolkit; -import com.fr.general.GeneralUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by shine on 2019/6/4. - */ -public class CellDataSeriesValueFieldsPane extends AbstractCorrelationPane { - - @Override - protected FieldEditorComponentWrapper[] fieldEditorComponentWrappers() { - return new FieldEditorComponentWrapper[]{ - new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), - new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value")) - }; - } - - @Override - public void populateBean(SeriesValueColumnFields ob) { - List list = new ArrayList(); - - List seriesValueFieldList = ob.getSeriesValueFieldList(); - for (SeriesValueField seriesValueField : seriesValueFieldList) { - Object[] array = new Object[]{seriesValueField.getSeries().getFieldName(), seriesValueField.getValue().getFieldName()}; - list.add(array); - } - - populate(list); - } - - @Override - public void updateBean(SeriesValueColumnFields ob) { - List list = update(); - - List seriesValueFieldList = new ArrayList(); - - for (Object[] objects : list) { - SeriesValueField seriesValueField = new SeriesValueField(); - ColumnField series = new ColumnField(GeneralUtils.objectToString(objects[0])); - ColumnField value = new ColumnField(GeneralUtils.objectToString(objects[1])); - seriesValueField.setSeries(series); - seriesValueField.setValue(value); - seriesValueFieldList.add(seriesValueField); - } - - ob.setSeriesValueFieldList(seriesValueFieldList); - } -} 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 index b6c080d523..82f0b7a886 100644 --- 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 @@ -1,7 +1,7 @@ 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.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.SeriesValueField; import com.fr.data.util.function.AbstractDataFunction; import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; @@ -13,7 +13,7 @@ import java.util.List; /** * Created by shine on 2019/5/17. */ -public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { +public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { @Override protected AbstractUseFieldValuePane createUseFieldValuePane() { @@ -26,7 +26,7 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } @Override - public void populateBean(SeriesValueColumnFields ob) { + public void populateBean(SeriesValueCorrelationDefinition ob) { if (ob.isCustomFieldValue()) { populateCustomFieldNamePane(ob); jcb.setSelectedIndex(1); @@ -37,7 +37,7 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } @Override - public void updateBean(SeriesValueColumnFields ob) { + public void updateBean(SeriesValueCorrelationDefinition ob) { if (jcb.getSelectedIndex() == 0) { ob.setCustomFieldValue(false); updateUseFieldValuePane(ob); @@ -47,10 +47,10 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } } - private class UseFieldValuePane extends AbstractUseFieldValuePane { + private class UseFieldValuePane extends AbstractUseFieldValuePane { @Override - public void populateBean(SeriesValueColumnFields ob) { + public void populateBean(SeriesValueCorrelationDefinition ob) { List list = ob.getSeriesValueFieldList(); if (list != null && list.size() > 0) { populateSeries(list.get(0).getSeries().getFieldName()); @@ -60,7 +60,7 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } @Override - public void updateBean(SeriesValueColumnFields ob) { + public void updateBean(SeriesValueCorrelationDefinition ob) { List list = new ArrayList(); SeriesValueField seriesValueField = new SeriesValueField(); ColumnField series = new ColumnField(updateSeries()); @@ -73,12 +73,12 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } } - private class CustomFieldNamePane extends AbstractCustomFieldNamePane { + private class CustomFieldNamePane extends AbstractCustomFieldNamePane { @Override - public void populateBean(SeriesValueColumnFields ob) { + public void populateBean(SeriesValueCorrelationDefinition definition) { List list = new ArrayList(); - for (SeriesValueField seriesValueField : ob.getSeriesValueFieldList()) { + for (SeriesValueField seriesValueField : definition.getSeriesValueFieldList()) { Object[] array = new Object[3]; array[0] = seriesValueField.getSeries().getFieldName(); array[1] = seriesValueField.getValue().getFieldName(); @@ -89,7 +89,7 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } @Override - public void updateBean(SeriesValueColumnFields ob) { + public void updateBean(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { List list = update(); List seriesValueFields = new ArrayList(); for (Object[] line : list) { @@ -101,7 +101,7 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan seriesValueField.setSeries(series); seriesValueFields.add(seriesValueField); } - ob.setSeriesValueFieldList(seriesValueFields); + seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFields); } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java similarity index 80% rename from designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java rename to designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java index e1f833b1fa..c7b459e49f 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java @@ -1,4 +1,4 @@ -package com.fr.design.chartx.component; +package com.fr.design.chartx.component.correlation; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.frpane.UICorrelationPane; @@ -23,7 +23,7 @@ public abstract class AbstractCorrelationPane extends BasicBeanPane { public AbstractCorrelationPane() { - this.editorComponents = fieldEditorComponentWrappers(); + this.editorComponents = createFieldEditorComponentWrappers(); String[] headers = new String[editorComponents.length]; @@ -34,21 +34,22 @@ public abstract class AbstractCorrelationPane extends BasicBeanPane { initComps(headers); } - protected abstract FieldEditorComponentWrapper[] fieldEditorComponentWrappers(); + protected abstract FieldEditorComponentWrapper[] createFieldEditorComponentWrappers(); - protected List update() { - return correlationPane.updateBean(); - } - - protected void populate(List list) { - correlationPane.populateBean(list); + @Override + public void populateBean(T ob) { + correlationPane.populateBean(covertTBeanToTableModelList(ob)); } @Override public T updateBean() { - return null; + return covertTableModelListToTBean(correlationPane.updateBean()); } + protected abstract List covertTBeanToTableModelList(T t); + + protected abstract T covertTableModelListToTBean(List tableValues); + private void initComps(String[] headers) { correlationPane = new UICorrelationPane(headers) { public UITableEditor createUITableEditor() { @@ -79,7 +80,7 @@ public abstract class AbstractCorrelationPane extends BasicBeanPane { private FieldEditorComponentWrapper currentEditorWrapper; public Object getCellEditorValue() { - return currentEditorWrapper.value(currentComponent); + return currentEditorWrapper.getValue(currentComponent); } public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java new file mode 100644 index 0000000000..d906058309 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java @@ -0,0 +1,19 @@ +package com.fr.design.chartx.component.correlation; + +import java.awt.Component; + +/** + * Created by shine on 2019/6/10. + */ +public abstract class AbstractEditorComponent implements FieldEditorComponentWrapper { + private String header; + + public AbstractEditorComponent(String header) { + this.header = header; + } + + @Override + public String headerName() { + return this.header; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java similarity index 79% rename from designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java rename to designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java index 9d8f1a0436..5181b466cc 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java @@ -1,4 +1,4 @@ -package com.fr.design.chartx.component; +package com.fr.design.chartx.component.correlation; import com.fr.design.gui.frpane.UICorrelationPane; @@ -13,7 +13,7 @@ public interface FieldEditorComponentWrapper { T createEditorComponent(UICorrelationPane parent); - Object value(T t); + Object getValue(T t); void setValue(T t, Object o); } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java similarity index 80% rename from designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java rename to designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java index 6234450731..71a0a59e51 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java @@ -1,4 +1,4 @@ -package com.fr.design.chartx.component; +package com.fr.design.chartx.component.correlation; import com.fr.base.BaseFormula; import com.fr.base.Utils; @@ -10,17 +10,10 @@ import com.fr.design.gui.frpane.UICorrelationPane; /** * Created by shine on 2019/6/4. */ -public class TinyFormulaPaneEditorComponent implements FieldEditorComponentWrapper { - - private String header; +public class TinyFormulaPaneEditorComponent extends AbstractEditorComponent { public TinyFormulaPaneEditorComponent(String header) { - this.header = header; - } - - @Override - public String headerName() { - return this.header; + super(header); } @Override @@ -50,7 +43,7 @@ public class TinyFormulaPaneEditorComponent implements FieldEditorComponentWrapp } @Override - public Object value(TinyFormulaPane formulaPane) { + public Object getValue(TinyFormulaPane formulaPane) { return formulaPane.getUITextField().getText(); } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java index a3693bf539..dc0ce33ec3 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java @@ -1,7 +1,7 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; -import com.fr.design.chartx.component.CellDataSeriesValueFieldsPane; +import com.fr.design.chartx.component.CellDataSeriesValueCorrelationPane; import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; import javax.swing.JPanel; @@ -13,12 +13,12 @@ import java.awt.BorderLayout; public abstract class AbstractCellDataFieldsWithSeriesValuePane extends AbstractCellDataFieldsPane { - private CellDataSeriesValueFieldsPane seriesValueFieldsPane; + private CellDataSeriesValueCorrelationPane seriesValueFieldsPane; @Override protected JPanel createCenterPane() { JPanel normalCenter = super.createCenterPane(); - seriesValueFieldsPane = new CellDataSeriesValueFieldsPane(); + seriesValueFieldsPane = new CellDataSeriesValueCorrelationPane(); if (normalCenter != null) { JPanel panel = new JPanel(new BorderLayout()); @@ -30,12 +30,12 @@ public abstract class AbstractCellDataFieldsWithSeriesValuePane categoryList = ob.getCategoryList(); + List categoryList = multiCategoryColumnFieldCollection.getCategoryList(); multiCategoryPane.populate(categoryList); - populateSeriesValuePane(ob); + populateSeriesValuePane(multiCategoryColumnFieldCollection); } @Override 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 f638cad223..0e61218120 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 @@ -41,12 +41,12 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer } @Override - public void populateBean(MultiCategoryColumnFieldCollection ob) { - List categoryList = ob.getCategoryList(); + public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) { + List categoryList = multiCategoryColumnFieldCollection.getCategoryList(); multiCategoryPane.populate(categoryList); - populateSeriesValuePane(ob); + populateSeriesValuePane(multiCategoryColumnFieldCollection); } @Override