Browse Source
Merge in DESIGN/design from ~PENGDA/design:feature/x to feature/x * commit 'a6238d0f61454d40b9affbcbe2794ff4fe052e72': REPORT-68363 条件属性系列间值的比较 REPORT-68363 条件属性系列间值的比较feature/x
ju
3 years ago
10 changed files with 247 additions and 59 deletions
@ -0,0 +1,70 @@ |
|||||||
|
package com.fr.design.data.datapane; |
||||||
|
|
||||||
|
import com.fr.data.util.function.AbstractDataFunction; |
||||||
|
import com.fr.data.util.function.AverageFunction; |
||||||
|
import com.fr.data.util.function.CountFunction; |
||||||
|
import com.fr.data.util.function.MaxFunction; |
||||||
|
import com.fr.data.util.function.MinFunction; |
||||||
|
import com.fr.data.util.function.NoneFunction; |
||||||
|
import com.fr.data.util.function.SumFunction; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.chart.base.FirstFunction; |
||||||
|
|
||||||
|
/** |
||||||
|
* 图表数据汇总方式下拉框 |
||||||
|
* |
||||||
|
* 支持首个,最后一个,求和,平均,最大值,最小值,个数 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public class SummaryMethodComboBox extends UIComboBox { |
||||||
|
public static final String[] CALCULATE_ARRAY = {Toolkit.i18nText("Fine-Design_Chart_Data_Function_First"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Last"), |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Data_Function_Sum"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Average"), |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Data_Function_Max"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Min"), |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Data_Function_Count")}; |
||||||
|
public static final Class[] CLASS_ARRAY = {FirstFunction.class, NoneFunction.class, SumFunction.class, AverageFunction.class, |
||||||
|
MaxFunction.class, MinFunction.class, CountFunction.class}; |
||||||
|
|
||||||
|
public SummaryMethodComboBox() { |
||||||
|
super(CALCULATE_ARRAY); |
||||||
|
setSelectedIndex(2); |
||||||
|
} |
||||||
|
|
||||||
|
public void reset() { |
||||||
|
this.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Data_Function_Sum")); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新公式选择. |
||||||
|
*/ |
||||||
|
public void populateBean(AbstractDataFunction function) { |
||||||
|
for (int i = 0; i < CLASS_ARRAY.length; i++) { |
||||||
|
if (function != null && ComparatorUtils.equals(function.getClass(), CLASS_ARRAY[i])) { |
||||||
|
setSelectedIndex(i); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 返回当前选择的公式 |
||||||
|
*/ |
||||||
|
public AbstractDataFunction updateBean() { |
||||||
|
try { |
||||||
|
int selectIndex = getSelectedIndex(); |
||||||
|
if (selectIndex >= 0 && selectIndex < CLASS_ARRAY.length) { |
||||||
|
return (AbstractDataFunction) CLASS_ARRAY[selectIndex].newInstance(); |
||||||
|
} |
||||||
|
} catch (InstantiationException e) { |
||||||
|
FineLoggerFactory.getLogger().error("Function Error"); |
||||||
|
return null; |
||||||
|
} catch (IllegalAccessException e) { |
||||||
|
FineLoggerFactory.getLogger().error("Function Error"); |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 356 B |
@ -0,0 +1,69 @@ |
|||||||
|
package com.fr.design.chart; |
||||||
|
|
||||||
|
import com.fr.base.TableData; |
||||||
|
import com.fr.base.chart.chartdata.TopDefinitionProvider; |
||||||
|
import com.fr.chart.chartattr.Chart; |
||||||
|
import com.fr.chart.chartattr.Plot; |
||||||
|
import com.fr.chart.chartdata.MoreNameCDDefinition; |
||||||
|
import com.fr.chart.chartdata.OneValueCDDefinition; |
||||||
|
import com.fr.data.TableDataSource; |
||||||
|
import com.fr.design.DesignModelAdapter; |
||||||
|
import com.fr.design.data.DesignTableDataManager; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.plugin.chart.custom.CustomDefinition; |
||||||
|
import com.fr.plugin.chart.custom.type.CustomPlotType; |
||||||
|
import com.fr.van.chart.designer.PlotFactory; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class ChartDataHelper { |
||||||
|
public static String[] getCommonChartFieldNames(Chart chart) { |
||||||
|
if (chart == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
Plot plot = chart.getPlot(); |
||||||
|
if (plot == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
if (!PlotFactory.plotSupportAddTableField(plot)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
TopDefinitionProvider definition = chart.getFilterDefinition(); |
||||||
|
return getFieldNames(definition); |
||||||
|
} |
||||||
|
|
||||||
|
public static String[] getCustomChartTableFieldNames(Chart chart, CustomPlotType plotType) { |
||||||
|
if (chart == null || plotType == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
TopDefinitionProvider filterDefinition = chart.getFilterDefinition(); |
||||||
|
if (filterDefinition instanceof CustomDefinition) { |
||||||
|
CustomDefinition customDefinition = (CustomDefinition) filterDefinition; |
||||||
|
Map<CustomPlotType, TopDefinitionProvider> definitionProviderMap = customDefinition.getDefinitionProviderMap(); |
||||||
|
return getFieldNames(definitionProviderMap.get(plotType)); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
private static String[] getFieldNames(TopDefinitionProvider definition) { |
||||||
|
if (definition == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); |
||||||
|
TableDataSource tableDataSource = adapter == null ? null : adapter.getBook(); |
||||||
|
TableData tableData = null; |
||||||
|
if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) { |
||||||
|
OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition; |
||||||
|
tableData = oneValueCDDefinition.getTableData(); |
||||||
|
} else if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) { |
||||||
|
MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition; |
||||||
|
tableData = moreNameCDDefinition.getTableData(); |
||||||
|
} |
||||||
|
if (tableData == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return DesignTableDataManager.getSelectedColumnNames(tableDataSource, tableData.getName()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,89 @@ |
|||||||
|
package com.fr.design.chart.series.SeriesCondition; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.Chart; |
||||||
|
import com.fr.data.DSColumnWithSummaryMethod; |
||||||
|
import com.fr.design.chart.ChartDataHelper; |
||||||
|
import com.fr.design.data.datapane.SummaryMethodComboBox; |
||||||
|
import com.fr.design.editor.editor.Editor; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.plugin.chart.custom.type.CustomPlotType; |
||||||
|
import java.awt.Dimension; |
||||||
|
import javax.swing.DefaultComboBoxModel; |
||||||
|
|
||||||
|
public class ColSelectedWithSummaryMethodEditor extends Editor<DSColumnWithSummaryMethod> { |
||||||
|
private UIComboBox columnNameComboBox = new UIComboBox(); |
||||||
|
private SummaryMethodComboBox summaryMethodComboBox; |
||||||
|
private static DefaultComboBoxModel<String> columnNameComboBoxModel = new DefaultComboBoxModel<>(); |
||||||
|
private static DefaultComboBoxModel<String> summaryMethodComboBoxModel = new DefaultComboBoxModel<>(SummaryMethodComboBox.CALCULATE_ARRAY); |
||||||
|
|
||||||
|
public ColSelectedWithSummaryMethodEditor() { |
||||||
|
this.setName(Toolkit.i18nText("Fine-Design_Chart_Summary_Array")); |
||||||
|
this.setLayout(FRGUIPaneFactory.createLeftZeroLayout()); |
||||||
|
if (columnNameComboBox == null) { |
||||||
|
columnNameComboBox = new UIComboBox(); |
||||||
|
} |
||||||
|
columnNameComboBox.setPreferredSize(new Dimension(82, 20)); |
||||||
|
this.add(columnNameComboBox); |
||||||
|
summaryMethodComboBox = new SummaryMethodComboBox(); |
||||||
|
summaryMethodComboBox.setModel(summaryMethodComboBoxModel); |
||||||
|
summaryMethodComboBox.setPreferredSize(new Dimension(82, 20)); |
||||||
|
this.add(summaryMethodComboBox); |
||||||
|
columnNameComboBox.setModel(columnNameComboBoxModel); |
||||||
|
} |
||||||
|
|
||||||
|
public static void refreshCommonChartFieldNames(Chart chart) { |
||||||
|
String[] columnNames = ChartDataHelper.getCommonChartFieldNames(chart); |
||||||
|
refreshComboBoxModel(columnNames); |
||||||
|
} |
||||||
|
|
||||||
|
public static void refreshCustomChartTableFieldNames(Chart chart, CustomPlotType plotType) { |
||||||
|
String[] columnNames = ChartDataHelper.getCustomChartTableFieldNames(chart, plotType); |
||||||
|
refreshComboBoxModel(columnNames); |
||||||
|
} |
||||||
|
|
||||||
|
private static void refreshComboBoxModel(String[] columnNames) { |
||||||
|
if (columnNames != null) { |
||||||
|
columnNameComboBoxModel.removeAllElements(); |
||||||
|
for (String columnName : columnNames) { |
||||||
|
columnNameComboBoxModel.addElement(columnName); |
||||||
|
} |
||||||
|
for (String method : SummaryMethodComboBox.CALCULATE_ARRAY) { |
||||||
|
summaryMethodComboBoxModel.addElement(method); |
||||||
|
} |
||||||
|
} else { |
||||||
|
columnNameComboBoxModel.removeAllElements(); |
||||||
|
summaryMethodComboBoxModel.removeAllElements(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public String getIconName() { |
||||||
|
return "ds_column_summary"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DSColumnWithSummaryMethod getValue() { |
||||||
|
if (columnNameComboBox.getSelectedItem() == null || summaryMethodComboBox.getSelectedItem() == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
DSColumnWithSummaryMethod dsColumnWithSummaryMethod = new DSColumnWithSummaryMethod(); |
||||||
|
dsColumnWithSummaryMethod.setFieldName(columnNameComboBox.getSelectedItem().toString()); |
||||||
|
dsColumnWithSummaryMethod.setDataFunction(summaryMethodComboBox.updateBean()); |
||||||
|
return dsColumnWithSummaryMethod; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setValue(DSColumnWithSummaryMethod value) { |
||||||
|
if (value != null) { |
||||||
|
columnNameComboBox.setSelectedItem(value.getFieldName()); |
||||||
|
summaryMethodComboBox.setSelectedItem(value.getDataFunction()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean accept(Object object) { |
||||||
|
return object instanceof DSColumnWithSummaryMethod; |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue