zheng
6 years ago
11 changed files with 125 additions and 108 deletions
@ -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; |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
Loading…
Reference in new issue