Browse Source

代码质量

research/10.0
zheng 6 years ago
parent
commit
269272c280
  1. 59
      designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java
  2. 55
      designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java
  3. 24
      designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java
  4. 23
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java
  5. 19
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java
  6. 4
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java
  7. 15
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java
  8. 14
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java
  9. 8
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java
  10. 6
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java
  11. 6
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java

59
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<SeriesValueCorrelationDefinition> {
@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<Object[]> covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<Object[]> result = new ArrayList<Object[]>();
List<SeriesValueField> 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<Object[]> tableValues) {
List<SeriesValueField> seriesValueFieldList = new ArrayList<SeriesValueField>();
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;
}
}

55
designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java

@ -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<SeriesValueColumnFields> {
@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<Object[]> list = new ArrayList<Object[]>();
List<SeriesValueField> 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<Object[]> list = update();
List<SeriesValueField> seriesValueFieldList = new ArrayList<SeriesValueField>();
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);
}
}

24
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<SeriesValueColumnFields> {
public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane<SeriesValueCorrelationDefinition> {
@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<SeriesValueColumnFields> {
private class UseFieldValuePane extends AbstractUseFieldValuePane<SeriesValueCorrelationDefinition> {
@Override
public void populateBean(SeriesValueColumnFields ob) {
public void populateBean(SeriesValueCorrelationDefinition ob) {
List<SeriesValueField> 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<SeriesValueField> list = new ArrayList<SeriesValueField>();
SeriesValueField seriesValueField = new SeriesValueField();
ColumnField series = new ColumnField(updateSeries());
@ -73,12 +73,12 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan
}
}
private class CustomFieldNamePane extends AbstractCustomFieldNamePane<SeriesValueColumnFields> {
private class CustomFieldNamePane extends AbstractCustomFieldNamePane<SeriesValueCorrelationDefinition> {
@Override
public void populateBean(SeriesValueColumnFields ob) {
public void populateBean(SeriesValueCorrelationDefinition definition) {
List<Object[]> list = new ArrayList<Object[]>();
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<Object[]> list = update();
List<SeriesValueField> seriesValueFields = new ArrayList<SeriesValueField>();
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);
}
}

23
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java → 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<T> extends BasicBeanPane<T> {
public AbstractCorrelationPane() {
this.editorComponents = fieldEditorComponentWrappers();
this.editorComponents = createFieldEditorComponentWrappers();
String[] headers = new String[editorComponents.length];
@ -34,21 +34,22 @@ public abstract class AbstractCorrelationPane<T> extends BasicBeanPane<T> {
initComps(headers);
}
protected abstract FieldEditorComponentWrapper[] fieldEditorComponentWrappers();
protected abstract FieldEditorComponentWrapper[] createFieldEditorComponentWrappers();
protected List<Object[]> update() {
return correlationPane.updateBean();
}
protected void populate(List<Object[]> 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<Object[]> covertTBeanToTableModelList(T t);
protected abstract T covertTableModelListToTBean(List<Object[]> tableValues);
private void initComps(String[] headers) {
correlationPane = new UICorrelationPane(headers) {
public UITableEditor createUITableEditor() {
@ -79,7 +80,7 @@ public abstract class AbstractCorrelationPane<T> extends BasicBeanPane<T> {
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) {

19
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<T extends Component> implements FieldEditorComponentWrapper<T> {
private String header;
public AbstractEditorComponent(String header) {
this.header = header;
}
@Override
public String headerName() {
return this.header;
}
}

4
designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java → 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 extends Component> {
T createEditorComponent(UICorrelationPane parent);
Object value(T t);
Object getValue(T t);
void setValue(T t, Object o);
}

15
designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java → 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<TinyFormulaPane> {
private String header;
public class TinyFormulaPaneEditorComponent extends AbstractEditorComponent<TinyFormulaPane> {
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();
}

14
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<T extends AbstractColumnFieldCollectionWithSeriesValue>
extends AbstractCellDataFieldsPane<T> {
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<T extends Abstra
}
}
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) {
seriesValueFieldsPane.populateBean(t.getSeriesValueColumnFields());
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldsPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) {
seriesValueFieldsPane.updateBean(t.getSeriesValueColumnFields());
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldsPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
}

8
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java

@ -50,11 +50,11 @@ public abstract class AbstractDataSetFieldsWithSeriesValuePane<T extends Abstrac
seriesValueFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList);
}
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) {
seriesValueFieldComboBoxPane.populateBean(t.getSeriesValueColumnFields());
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldComboBoxPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) {
seriesValueFieldComboBoxPane.updateBean(t.getSeriesValueColumnFields());
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldComboBoxPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
}

6
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java

@ -44,13 +44,13 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS
}
@Override
public void populateBean(MultiCategoryColumnFieldCollection ob) {
public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) {
List<ColumnField> categoryList = ob.getCategoryList();
List<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList();
multiCategoryPane.populate(categoryList);
populateSeriesValuePane(ob);
populateSeriesValuePane(multiCategoryColumnFieldCollection);
}
@Override

6
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<ColumnField> categoryList = ob.getCategoryList();
public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) {
List<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList();
multiCategoryPane.populate(categoryList);
populateSeriesValuePane(ob);
populateSeriesValuePane(multiCategoryColumnFieldCollection);
}
@Override

Loading…
Cancel
Save