Browse Source

Merging in latest from upstream (DESIGN/design:refs/heads/feature/10.0)

* commit '5a9c28c468bbd64cd993cd9d9545b5d25bd93414':
  无JIRA任务 开放API的一些遗留问题
  CHART-10229 单分类数据集数据源,单元格数据源面板&组合图面板&组合图类型选择update方法
research/11.0
Wim.Zhai 5 years ago
parent
commit
5e96aa2105
  1. 6
      designer-base/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptor.java
  2. 202
      designer-chart/src/main/java/com/fr/design/chartx/CustomChartDataPane.java
  3. 84
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryCellDataFieldsPane.java
  4. 88
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryDataSetFieldsPane.java
  5. 37
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java

6
designer-base/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptor.java

@ -4,7 +4,7 @@
package com.fr.design.designer.creator;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.stable.core.PropertyChangeListener;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
@ -17,7 +17,7 @@ public final class CRPropertyDescriptor extends PropertyDescriptor {
public static final String RENDERER = "renderer";
private boolean isSubProperty = false;
private PropertyChangeAdapter l;
private PropertyChangeListener l;
public CRPropertyDescriptor(String name, Class<?> beanClass) throws IntrospectionException {
super(name, beanClass);
@ -35,7 +35,7 @@ public final class CRPropertyDescriptor extends PropertyDescriptor {
return this;
}
public CRPropertyDescriptor setPropertyChangeListener(PropertyChangeAdapter l) {
public CRPropertyDescriptor setPropertyChangeListener(PropertyChangeListener l) {
this.l = l;
return this;
}

202
designer-chart/src/main/java/com/fr/design/chartx/CustomChartDataPane.java

@ -0,0 +1,202 @@
package com.fr.design.chartx;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.data.AbstractDataDefinition;
import com.fr.chartx.data.CustomChartDataDefinition;
import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane;
import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane;
import com.fr.design.chartx.fields.diff.SingleCategoryCellDataFieldsPane;
import com.fr.design.chartx.fields.diff.SingleCategoryDataSetFieldsPane;
import com.fr.design.chartx.single.SingleDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UITabGroup;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.custom.CustomPlotFactory;
import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.plugin.chart.custom.type.CustomPlotType;
import com.fr.plugin.chart.custom.type.CustomStyle;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.StringUtils;
import com.fr.van.chart.custom.component.VanChartCustomPlotUITabGroup;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-10-23
*/
public class CustomChartDataPane extends ChartDataPane {
public CustomChartDataPane(AttributeChangeListener listener) {
super(listener);
}
private VanChartCustomPlot customPlot;
private CardLayout cardLayout;
private JPanel centerPane;
private List<AbstractVanSingleDataPane> paneList;
private UITabGroup tabPane;
private String[] nameArray;
@Override
protected void initContentPane() {
if (customPlot == null) {
return;
}
cardLayout = new CardLayout();
initPaneList();
relayoutWhenListChange();
}
private void initPaneList() {
paneList = new ArrayList<>();
List<VanChartPlot> customPlotList = customPlot.getCustomPlotList();
for (int i = 0; i < customPlotList.size(); i++) {
//根据不同的plot创建不同的数据配置界面
final VanChartPlot vanChartPlot = customPlotList.get(i);
paneList.add(new AbstractVanSingleDataPane(listener) {
@Override
protected SingleDataPane createSingleDataPane() {
return createSingleDataPaneByPlot(vanChartPlot);
}
});
}
}
private SingleDataPane createSingleDataPaneByPlot(VanChartPlot plot) {
CustomPlotType customType = CustomPlotFactory.getCustomType(plot);
switch (customType) {
case RING:
case SLOT:
case CUVETTE:
//todo 仪表板没写好
return new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane());
case SCATTER:
case BUBBLE:
//todo 散点图没写好
return new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane());
default:
return StringUtils.equals(CustomStyle.CUSTOM.toString(), plot.getCustomType()) ?
new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane()) :
new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane());
}
}
private void relayoutWhenListChange() {
centerPane = new JPanel(cardLayout) {
@Override
public Dimension getPreferredSize() {
return paneList.get(tabPane.getSelectedIndex()).getPreferredSize();
}
};
//获取tab的标题
initTabTitle();
tabPane = new VanChartCustomPlotUITabGroup(nameArray) {
@Override
public void tabChanged(int index) {
dealWithTabChanged(index);
}
};
tabPane.setSelectedIndex(0);
tabPane.tabChanged(0);
initLayout();
}
private void initTabTitle() {
if (customPlot == null) {
return;
}
List<VanChartPlot> customPlotList = customPlot.getCustomPlotList();
nameArray = new String[Math.min(customPlotList.size(), paneList.size())];
for (int i = 0; i < nameArray.length; i++) {
JPanel pane = paneList.get(i);
VanChartPlot vanChartPlot = customPlotList.get(i);
CustomPlotType plotType = CustomPlotFactory.getCustomType(vanChartPlot);
nameArray[i] = CustomPlotFactory.getTitle(plotType);
centerPane.add(pane, nameArray[i]);
}
}
protected void dealWithTabChanged(int index) {
cardLayout.show(centerPane, nameArray[index]);
}
private void initLayout() {
JPanel tabPanel = new JPanel(new BorderLayout());
tabPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, getBackground()));
tabPanel.add(tabPane, BorderLayout.CENTER);
this.setLayout(new BorderLayout(0, 6));
this.add(tabPanel, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
}
@Override
public void populate(ChartCollection collection) {
if (collection == null) {
return;
}
VanChart chart = collection.getSelectedChart(VanChart.class);
if (chart == null) {
return;
}
customPlot = chart.getPlot();
this.removeAll();
initContentPane();
CustomChartDataDefinition dataSetCollection = (CustomChartDataDefinition) chart.getChartDataDefinition();
if (dataSetCollection != null) {
Map<CustomPlotType, AbstractDataDefinition> customDefinitions = dataSetCollection.getCustomDefinitions();
for (int i = 0; i < paneList.size(); i++) {
VanChartPlot vanChartPlot = customPlot.getCustomPlotList().get(i);
AbstractDataDefinition dataDefinition = customDefinitions.get(CustomPlotFactory.getCustomType(vanChartPlot));
if (dataDefinition != null) {
paneList.get(i).populate(dataDefinition);
}
}
}
this.initAllListeners();
this.validate();
}
@Override
public void update(ChartCollection collection) {
if (collection == null) {
return;
}
VanChart chart = collection.getSelectedChart(VanChart.class);
if (chart == null) {
return;
}
Map<CustomPlotType, AbstractDataDefinition> definitions = new HashMap<>();
for (int i = 0; i < paneList.size(); i++) {
definitions.put(CustomPlotFactory.getCustomType(customPlot.getCustomPlotList().get(i)), paneList.get(i).update());
}
CustomChartDataDefinition customDefinition = new CustomChartDataDefinition();
customDefinition.setCustomDefinitions(definitions);
chart.setChartDataDefinition(customDefinition);
}
}

84
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryCellDataFieldsPane.java

@ -0,0 +1,84 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection;
import com.fr.design.chartx.component.CategorySeriesFilterPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-10-24
*/
public class SingleCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> {
private TinyFormulaPane categoryPane;
private CategorySeriesFilterPane filterPane;
@Override
protected void initComponents() {
categoryPane = new TinyFormulaPane();
filterPane = new CategorySeriesFilterPane();
UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category"));
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT));
JPanel northPane = new JPanel(new BorderLayout(0, 6));
northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryPane, null, null, label, null}), BorderLayout.NORTH);
northPane.add(createCenterPane(), BorderLayout.CENTER);
northPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8));
this.setLayout(new BorderLayout(0, 6));
this.add(northPane, BorderLayout.NORTH);
this.add(filterPane, BorderLayout.CENTER);
}
@Override
protected String[] fieldLabels() {
return new String[0];
}
@Override
protected TinyFormulaPane[] formulaPanes() {
return new TinyFormulaPane[]{categoryPane};
}
@Override
public void populateBean(MultiCategoryColumnFieldCollection fieldCollection) {
if (fieldCollection.getCategoryList().size() > 0) {
populateField(categoryPane, fieldCollection.getCategoryList().get(0));
}
populateSeriesValuePane(fieldCollection);
filterPane.populateMultiCategoryFieldCollection(fieldCollection);
}
@Override
public MultiCategoryColumnFieldCollection updateBean() {
MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection();
fieldCollection.getCategoryList().add(new ColumnField());
updateField(categoryPane, fieldCollection.getCategoryList().get(0));
updateSeriesValuePane(fieldCollection);
filterPane.updateMultiCategoryFieldCollection(fieldCollection);
return fieldCollection;
}
}

88
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryDataSetFieldsPane.java

@ -0,0 +1,88 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection;
import com.fr.design.chartx.component.CategorySeriesFilterPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.extended.chart.UIComboBoxWithNone;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-10-24
*/
public class SingleCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> {
private UIComboBox categoryPane;
private CategorySeriesFilterPane filterPane;
@Override
protected void initComponents() {
categoryPane = new UIComboBoxWithNone();
filterPane = new CategorySeriesFilterPane();
UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category"));
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT));
JPanel northPane = new JPanel(new BorderLayout(0, 6));
northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryPane, null, null, label, null}), BorderLayout.NORTH);
northPane.add(new JSeparator(), BorderLayout.CENTER);
northPane.add(createCenterPane(), BorderLayout.SOUTH);
northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15));
this.setLayout(new BorderLayout(0, 6));
this.add(northPane, BorderLayout.NORTH);
this.add(filterPane, BorderLayout.CENTER);
}
@Override
protected String[] fieldLabels() {
return new String[0];
}
@Override
protected UIComboBox[] filedComboBoxes() {
return new UIComboBox[]{categoryPane};
}
@Override
public void populateBean(MultiCategoryColumnFieldCollection columnFieldCollection) {
if (columnFieldCollection.getCategoryList().size() > 0) {
populateField(categoryPane, columnFieldCollection.getCategoryList().get(0));
}
populateSeriesValuePane(columnFieldCollection);
filterPane.populateMultiCategoryFieldCollection(columnFieldCollection);
}
@Override
public MultiCategoryColumnFieldCollection updateBean() {
MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection();
columnFieldCollection.getCategoryList().add(new ColumnField());
updateField(categoryPane, columnFieldCollection.getCategoryList().get(0));
updateSeriesValuePane(columnFieldCollection);
filterPane.updateMultiCategoryFieldCollection(columnFieldCollection);
return columnFieldCollection;
}
}

37
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java

@ -6,6 +6,8 @@ import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.ConditionCollection;
import com.fr.chartx.data.AbstractDataDefinition;
import com.fr.chartx.data.CustomChartDataDefinition;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.type.ChartImagePane;
@ -24,11 +26,11 @@ import com.fr.van.chart.designer.type.AbstractVanChartTypePane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import java.util.HashMap;
import java.util.Map;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Mitisky on 16/2/16.
@ -123,6 +125,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
//如果上次的状态和这次的装填不在同一个页面,说明同一个图表內切换了,需要情況数据配置
if (lastState != chart.getPlot().getDetailType()) {
chart.setFilterDefinition(null);
((VanChart) chart).setChartDataDefinition(null);
}
Chart[] customChart = CustomIndependentVanChart.CustomVanChartTypes;
@ -137,6 +140,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
dealCustomDefinition(chart);
customSelectPane.updateBean(chart);
//更新新的数据配置
dealCustomChartDataDefinition(chart);
} else if (isSamePlot()) {//如果是同一个图表切换过来,则重置面板
customSelectPane.populateBean(chart);
}
@ -150,6 +156,27 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
}
private void dealCustomChartDataDefinition(Chart chart) {
CustomChartDataDefinition chartDataDefinition = (CustomChartDataDefinition) ((VanChart) chart).getChartDataDefinition();
if (chartDataDefinition == null) {
return;
}
Map<CustomPlotType, AbstractDataDefinition> customDefinitions = chartDataDefinition.getCustomDefinitions();
Map<CustomPlotType, AbstractDataDefinition> newCustomDefinitions = new HashMap<>();
VanChartCustomPlot customPlot = chart.getPlot();
for (int i = 0; i < customPlot.getCustomPlotList().size(); i++) {
CustomPlotType plotType = CustomPlotFactory.getCustomType(customPlot.getCustomPlotList().get(i));
AbstractDataDefinition definition = customDefinitions.get(plotType);
newCustomDefinitions.put(plotType, definition);
}
chartDataDefinition.setCustomDefinitions(newCustomDefinitions);
}
private void dealCustomDefinition(Chart chart) {
CustomDefinition definition = (CustomDefinition) chart.getFilterDefinition();
@ -229,9 +256,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
}
Plot cloned = null;
try {
if(newPlot != null) {
cloned = (Plot) newPlot.clone();
}
if (newPlot != null) {
cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ScatterChart");
}

Loading…
Cancel
Save