Browse Source

CHART-4027 图表数据设计器界面

research/10.0
zheng 6 years ago
parent
commit
d8659e6b51
  1. 58
      designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java
  2. 39
      designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java
  3. 43
      designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java
  4. 20
      designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java
  5. 368
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java
  6. 168
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java
  7. 58
      designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java
  8. 32
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java
  9. 31
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java
  10. 93
      designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java
  11. 142
      designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java
  12. 60
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java
  13. 65
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java
  14. 69
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java
  15. 56
      designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java
  16. 121
      designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java
  17. 90
      designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java
  18. 322
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java
  19. 8
      designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java

58
designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java

@ -0,0 +1,58 @@
package com.fr.design.chartx;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.data.ChartDataDefinitionProvider;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.plugin.chart.vanchart.VanChart;
import java.awt.BorderLayout;
/**
* Created by shine on 2019/4/15.
*/
public abstract class AbstractChartDataPane<T extends ChartDataDefinitionProvider> extends ChartDataPane {
public AbstractChartDataPane(AttributeChangeListener listener) {
super(listener);
}
protected abstract void populate(T t);
protected abstract T update();
@Override
public void populate(ChartCollection collection) {
if (collection == null) {
return;
}
VanChart chart = collection.getSelectedChart(VanChart.class);
if (chart == null) {
return;
}
this.removeAll();
this.add(createContentPane(), BorderLayout.CENTER);
ChartDataDefinitionProvider dataSetCollection = chart.getChartDataDefinition();
populate((T) dataSetCollection);
this.initAllListeners();
this.validate();
}
@Override
public void update(ChartCollection collection) {
if (collection == null) {
return;
}
VanChart chart = collection.getSelectedChart(VanChart.class);
if (chart == null) {
return;
}
chart.setChartDataDefinition(update());
}
}

39
designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java

@ -0,0 +1,39 @@
package com.fr.design.chartx;
import com.fr.chartx.data.GanttChartDataDefinition;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.van.chart.map.designer.VanChartGroupPane;
import javax.swing.JPanel;
/**
* Created by shine on 2019/5/22.
*/
public class GanttChartDataPane extends AbstractChartDataPane<GanttChartDataDefinition> {
private MultiCategoryChartDataPane dataPane;
private MultiCategoryChartDataPane linkPane;
@Override
protected JPanel createContentPane() {
dataPane = new MultiCategoryChartDataPane(listener);
linkPane = new MultiCategoryChartDataPane(listener);
return new VanChartGroupPane(new String[]{"data", "link"}, new JPanel[]{dataPane, linkPane}) {
};
}
public GanttChartDataPane(AttributeChangeListener listener) {
super(listener);
}
@Override
protected void populate(GanttChartDataDefinition ganttChartDataDefinition) {
dataPane.populate(ganttChartDataDefinition.getDataDefinition());
linkPane.populate(ganttChartDataDefinition.getLinkDefinition());
}
@Override
protected GanttChartDataDefinition update() {
return null;
}
}

43
designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java

@ -0,0 +1,43 @@
package com.fr.design.chartx;
import com.fr.chartx.data.AbstractDataDefinition;
import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane;
import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane;
import com.fr.design.chartx.single.SingleDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import javax.swing.JPanel;
/**
* Created by shine on 2019/5/22.
*/
public class MultiCategoryChartDataPane extends AbstractChartDataPane<AbstractDataDefinition> {
private SingleDataPane singleDataPane;
public MultiCategoryChartDataPane(AttributeChangeListener listener) {
super(listener);
}
@Override
protected void populate(AbstractDataDefinition dataDefinition) {
singleDataPane.populateBean(dataDefinition);
}
@Override
protected AbstractDataDefinition update() {
return singleDataPane.updateBean();
}
@Override
protected JPanel createContentPane() {
singleDataPane = createSingleDataPane();
return singleDataPane;
}
protected SingleDataPane createSingleDataPane() {
return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane());
}
}

20
designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java

@ -0,0 +1,20 @@
package com.fr.design.chartx;
import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane;
import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane;
import com.fr.design.chartx.single.SingleDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
/**
* Created by shine on 2019/5/22.
*/
public class WordCloundChartDataPane extends MultiCategoryChartDataPane {
public WordCloundChartDataPane(AttributeChangeListener listener) {
super(listener);
}
@Override
protected SingleDataPane createSingleDataPane() {
return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane());
}
}

368
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java

@ -0,0 +1,368 @@
package com.fr.design.chartx.component;
import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.UITable;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.extended.chart.UIComboBoxWithNone;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2018/9/12.
* 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取
*/
public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<T> {
private static final String[] HEADS = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")};
private AbstractUseFieldValuePane useFieldValuePane;
private AbstractCustomFieldNamePane customFieldNamePane;
private List<String> fieldList = new ArrayList<String>();
@Override
protected void initLayout() {
this.setLayout(new BorderLayout(0, 6));
JPanel northPane = new JPanel(new BorderLayout());
northPane.add(jcb, BorderLayout.CENTER);
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"));
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20));
northPane.add(label, BorderLayout.WEST);
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
}
@Override
protected List<FurtherBasicBeanPane<? extends T>> initPaneList() {
useFieldValuePane = createUseFieldValuePane();
customFieldNamePane = createCustomFieldNamePane();
List<FurtherBasicBeanPane<? extends T>> list = new ArrayList<FurtherBasicBeanPane<? extends T>>();
list.add(useFieldValuePane);
list.add(customFieldNamePane);
return list;
}
protected abstract AbstractUseFieldValuePane createUseFieldValuePane();
protected abstract AbstractCustomFieldNamePane createCustomFieldNamePane();
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
protected boolean valueComboBoxHasNone() {
return false;
}
public void checkBoxUse(boolean hasUse) {
jcb.setEnabled(hasUse);
useFieldValuePane.checkBoxUse(hasUse);
}
public void clearAllBoxList() {
useFieldValuePane.clearAllBoxList();
fieldList.clear();
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList);
fieldList = columnNameList;
}
protected void populateCustomFieldNamePane(T t) {
customFieldNamePane.populateBean(t);
}
protected void updateCustomFieldNamePane(T t) {
customFieldNamePane.updateBean(t);
}
protected void populateUseFieldValuePane(T t) {
useFieldValuePane.populateBean(t);
}
protected void updateUseFieldValuePane(T t) {
useFieldValuePane.updateBean(t);
}
protected abstract class AbstractUseFieldValuePane<T> extends FurtherBasicBeanPane<T> {
private UIComboBox series;
private UIComboBox value;
private CalculateComboBox function;
public AbstractUseFieldValuePane() {
initComponents();
}
private void initComponents() {
series = new UIComboBox();
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
function = new CalculateComboBox();
Component[][] components = new Component[][]{
new Component[]{new UILabel(HEADS[1], SwingConstants.LEFT), series},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value},
new Component[]{new UILabel(HEADS[2], SwingConstants.LEFT), function},
};
double p = TableLayout.PREFERRED;
double[] columnSize = {78, 122};
double[] rowSize = {p, p, p};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout(0, 6));
this.add(panel, BorderLayout.CENTER);
}
public void checkBoxUse(boolean hasUse) {
series.setEnabled(hasUse);
value.setEnabled(hasUse);
function.setEnabled(hasUse);
}
public void clearAllBoxList() {
DataPaneHelper.clearBoxItems(series);
DataPaneHelper.clearBoxItems(value);
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
DataPaneHelper.refreshBoxItems(series, columnNameList);
DataPaneHelper.refreshBoxItems(value, columnNameList);
}
protected void populateSeries(String item) {
series.setSelectedItem(item);
}
protected void populateValue(String item) {
value.setSelectedItem(item);
}
protected void populateFunction(AbstractDataFunction _function) {
function.populateBean(_function);
}
protected String updateSeries() {
return GeneralUtils.objectToString(series.getSelectedItem());
}
protected String updateValue() {
return GeneralUtils.objectToString(value.getSelectedItem());
}
protected AbstractDataFunction updateFunction() {
return function.updateBean();
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value");
}
@Override
public T updateBean() {
return null;
}
}
protected abstract class AbstractCustomFieldNamePane<T> extends FurtherBasicBeanPane<T> {
private UICorrelationPane correlationPane;
public AbstractCustomFieldNamePane() {
initComponents();
}
private void initComponents() {
correlationPane = new UICorrelationPane(HEADS) {
@Override
protected ActionListener getAddButtonListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tablePane.addLine(new String[]{StringUtils.EMPTY, StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")});
fireTargetChanged();
}
};
}
public UITableEditor createUITableEditor() {
return new Editor() {
@Override
protected UICorrelationPane getParent() {
return correlationPane;
}
};
}
};
this.setLayout(new BorderLayout());
this.add(correlationPane, BorderLayout.CENTER);
}
protected void populate(List<Object[]> list) {
correlationPane.populateBean(list);
}
protected List<Object[]> update() {
return correlationPane.updateBean();
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name");
}
@Override
public T updateBean() {
return null;
}
}
private abstract class Editor extends UITableEditor {
private JComponent editorComponent;
protected abstract UICorrelationPane getParent();
@Override
public Object getCellEditorValue() {
if (editorComponent instanceof UIComboBox) {
return ((UIComboBox) editorComponent).getSelectedItem();
} else if (editorComponent instanceof UITextField) {
return ((UITextField) editorComponent).getText();
} else if (editorComponent instanceof CalculateComboBox) {
return ((CalculateComboBox) editorComponent).getSelectedItem();
}
return super.getCellEditorValue();
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, final int row, int column) {
switch (column) {
case 0:
editorComponent = createComboBoxEdit(row, value);
break;
case 1:
editorComponent = createTextEdit(value);
break;
default:
editorComponent = createCalculateComboBox(value);
break;
}
return editorComponent;
}
private void setDefaultName(int row) {
UITable table = getParent().getTable();
Object object = table.getValueAt(row, 0);
if (object != null) {
table.setValueAt(object, row, 1);
}
}
private UIComboBox createComboBoxEdit(final int row, Object value) {
UIComboBox uiComboBox = new UIComboBox(fieldList.toArray());
uiComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
getParent().stopCellEditing();
getParent().fireTargetChanged();
setDefaultName(row);
}
});
if (value != null && StringUtils.isNotEmpty(value.toString())) {
uiComboBox.getModel().setSelectedItem(value);
} else {
uiComboBox.getModel().setSelectedItem(value);
}
return uiComboBox;
}
private UITextField createTextEdit(Object value) {
UITextField uiTextField = new UITextField();
if (value != null) {
uiTextField.setText(value.toString());
}
uiTextField.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
getParent().fireTargetChanged();
}
});
return uiTextField;
}
private CalculateComboBox createCalculateComboBox(Object value) {
CalculateComboBox calculateComboBox = new CalculateComboBox();
if (value != null) {
calculateComboBox.setSelectedItem(value);
}
calculateComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
getParent().stopCellEditing();
getParent().fireTargetChanged();
}
});
return calculateComboBox;
}
}
}

168
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java

@ -0,0 +1,168 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.general.IOUtils;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/4/10.
* 一列组件<T extends JComponent> 可增可删
*/
public abstract class AbstractMultiComponentPane<T extends JComponent> extends JPanel {
private static final int COM_W = 96;
private static final int H = 20;
private static final int ICON_W = 20;
private JPanel boxPane;
private UIButton addButton;
private T firstFieldComponent;
private List<T> categoryComponentList = new ArrayList<T>();
protected abstract T createFirstFieldComponent();
protected abstract T createOtherFieldComponent();
protected abstract void populateField(T component, ColumnField field);
protected abstract void updateField(T component, ColumnField field);
public AbstractMultiComponentPane() {
UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category"));
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT));
firstFieldComponent = createFirstFieldComponent();
firstFieldComponent.setPreferredSize(new Dimension(COM_W, H));
addButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
addButton.setPreferredSize(new Dimension(ICON_W, H));
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (canAdd()) {
addNewComboBox();
}
}
});
final JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2));
panel.add(label);
panel.add(firstFieldComponent);
panel.add(addButton);
boxPane = new JPanel();
boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS));
this.setLayout(new BorderLayout(4, 0));
this.add(panel, BorderLayout.NORTH);
this.add(boxPane, BorderLayout.CENTER);
}
private JPanel addComboBoxAndButtonToBox(T uiComboBox, UIButton uiButton) {
final JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2));
panel.add(uiComboBox);
panel.add(uiButton);
boxPane.add(panel);
categoryComponentList.add(uiComboBox);
return panel;
}
private void addNewComboBox() {
final T comboBox = createOtherFieldComponent();
comboBox.setPreferredSize(new Dimension(COM_W, H));
UIButton delButton = new UIButton(IOUtils.readIcon("com/fr/design/images/toolbarbtn/close.png"));
delButton.setPreferredSize(new Dimension(ICON_W, H));
final JPanel panel = addComboBoxAndButtonToBox(comboBox, delButton);
delButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boxPane.remove(panel);
categoryComponentList.remove(comboBox);
checkAddButton();
relayoutPane();
}
});
relayoutPane();
checkAddButton();
}
private void relayoutPane() {
this.revalidate();
}
private void checkAddButton() {
addButton.setEnabled(canAdd());
}
private boolean canAdd() {
return categoryComponentList.size() < 3;
}
public List<T> componentList() {
List<T> list = new ArrayList<>(categoryComponentList);
list.add(firstFieldComponent);
return list;
}
public void populate(List<ColumnField> categoryList) {
int comboBoxSize = categoryComponentList.size(),
len = categoryList.size();
if (len > 0) {
populateField(firstFieldComponent, categoryList.get(0));
}
for (int i = 1; i < len; i++) {
if (i > comboBoxSize) {
addNewComboBox();
}
T comboBox = categoryComponentList.get(i - 1);
populateField(comboBox, categoryList.get(i));
}
checkAddButton();
relayoutPane();
}
public void update(List<ColumnField> categoryList) {
categoryList.clear();
ColumnField temp1 = new ColumnField();
categoryList.add(temp1);
updateField(firstFieldComponent, temp1);
for (T comboBox : categoryComponentList) {
ColumnField temp = new ColumnField();
categoryList.add(temp);
updateField(comboBox, temp);
}
}
}

58
designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java

@ -0,0 +1,58 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.CustomFieldValueColumnFields;
/**
* Created by shine on 2019/5/17.
*/
public class CustomFieldComboBoxPane extends AbstractCustomFieldComboBoxPane<CustomFieldValueColumnFields> {
@Override
protected AbstractUseFieldValuePane createUseFieldValuePane() {
return new UseFieldValuePane();
}
@Override
protected AbstractCustomFieldNamePane createCustomFieldNamePane() {
return new CustomFieldNamePane();
}
@Override
public void populateBean(CustomFieldValueColumnFields ob) {
if (ob.isCustomFieldValue()) {
populateCustomFieldNamePane(ob);
jcb.setSelectedIndex(1);
} else {
populateUseFieldValuePane(ob);
jcb.setSelectedIndex(0);
}
}
@Override
public void updateBean(CustomFieldValueColumnFields ob) {
if (jcb.getSelectedIndex() == 0) {
ob.setCustomFieldValue(false);
updateUseFieldValuePane(ob);
} else {
ob.setCustomFieldValue(true);
updateCustomFieldNamePane(ob);
}
}
private class UseFieldValuePane extends AbstractUseFieldValuePane<CustomFieldValueColumnFields> {
@Override
public void populateBean(CustomFieldValueColumnFields ob) {
}
}
private class CustomFieldNamePane extends AbstractCustomFieldNamePane<CustomFieldValueColumnFields> {
@Override
public void populateBean(CustomFieldValueColumnFields ob) {
}
}
}

32
designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java

@ -0,0 +1,32 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.extended.chart.UIComboBoxWithNone;
/**
* Created by shine on 2019/4/12.
*/
public class MultiComboBoxPane extends AbstractMultiComponentPane<UIComboBox> {
@Override
protected UIComboBox createFirstFieldComponent() {
return new UIComboBoxWithNone();
}
@Override
protected UIComboBox createOtherFieldComponent() {
return new UIComboBox();
}
@Override
protected void populateField(UIComboBox component, ColumnField field) {
AbstractDataSetFieldsPane.populateField(component, field);
}
@Override
protected void updateField(UIComboBox component, ColumnField field) {
AbstractDataSetFieldsPane.updateField(component, field);
}
}

31
designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java

@ -0,0 +1,31 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane;
/**
* Created by shine on 2019/4/12.
*/
public class MultiTinyFormulaPane extends AbstractMultiComponentPane<TinyFormulaPane> {
@Override
protected TinyFormulaPane createFirstFieldComponent() {
return new TinyFormulaPane();
}
@Override
protected TinyFormulaPane createOtherFieldComponent() {
return new TinyFormulaPane();
}
@Override
protected void populateField(TinyFormulaPane component, ColumnField field) {
AbstractCellDataFieldsPane.populateField(component, field);
}
@Override
protected void updateField(TinyFormulaPane component, ColumnField field) {
AbstractCellDataFieldsPane.updateField(component, field);
}
}

93
designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java

@ -0,0 +1,93 @@
package com.fr.design.chartx.fields;
import com.fr.chartx.data.field.AbstractColumnFieldCollection;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.Arrays;
/**
* Created by shine on 2019/5/16.
* 单元格数据源 具体有哪些字段的一个抽象pane
*/
public abstract class AbstractCellDataFieldsPane<T extends AbstractColumnFieldCollection> extends BasicBeanPane<T> {
public AbstractCellDataFieldsPane() {
initComponents();
}
protected void initComponents() {
this.setLayout(new BorderLayout(0, 6));
this.add(addNorthPane(), BorderLayout.NORTH);
this.add(addCenterPane(), BorderLayout.CENTER);
this.add(addSouthPane(), BorderLayout.SOUTH);
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8));
}
protected JPanel addCenterPane() {
String[] labels = fieldLabels();
Component[] formulaPanes = fieldComponents();
int len = Math.min(labels.length, formulaPanes.length);
Component[][] components = new Component[len][2];
for (int i = 0; i < len; i++) {
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]};
}
double p = TableLayout.PREFERRED;
double[] columnSize = {ChartDataPane.LABEL_WIDTH, 124};
double[] rowSize = new double[len];
Arrays.fill(rowSize, p);
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6);
}
protected JPanel addNorthPane() {
return new JPanel();
}
protected JPanel addSouthPane() {
return new JPanel();
}
protected Component[] fieldComponents() {
return formulaPanes();
}
protected abstract String[] fieldLabels();
protected abstract TinyFormulaPane[] formulaPanes();
@Override
public abstract T updateBean();
public static void populateField(TinyFormulaPane formulaPane, ColumnField field) {
formulaPane.populateBean(field.getFieldName());
}
public static void updateField(TinyFormulaPane formulaPane, ColumnField field) {
field.setFieldName(formulaPane.updateBean());
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
}

142
designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java

@ -0,0 +1,142 @@
package com.fr.design.chartx.fields;
import com.fr.chartx.data.field.AbstractColumnFieldCollection;
import com.fr.chartx.data.field.ColumnField;
import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.general.GeneralUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.Arrays;
import java.util.List;
import static com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper.refreshBoxItems;
/**
* Created by shine on 2019/5/16.
* 数据集数据源 具体有哪些字段的一个抽象pane
*/
public abstract class AbstractDataSetFieldsPane<T extends AbstractColumnFieldCollection> extends BasicBeanPane<T> {
public AbstractDataSetFieldsPane() {
initComponents();
}
protected void initComponents() {
this.setLayout(new BorderLayout(0, 4));
this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15));
JPanel north = createNorthPane(),
center = createCenterPane(),
south = createSouthPane();
if (north != null) {
this.add(north, BorderLayout.NORTH);
}
if (center != null) {
this.add(center, BorderLayout.CENTER);
}
if (south != null) {
this.add(south, BorderLayout.SOUTH);
}
}
protected JPanel createNorthPane() {
return null;
}
protected JPanel createCenterPane() {
String[] labels = fieldLabels();
Component[] fieldComponents = fieldComponents();
int len = Math.min(labels.length, fieldComponents.length);
if (len == 0) {
return null;
}
Component[][] components = new Component[len][2];
for (int i = 0; i < len; i++) {
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponents[i]};
}
double p = TableLayout.PREFERRED;
double[] columnSize = {ChartDataPane.LABEL_WIDTH, 122};
double[] rowSize = new double[len];
Arrays.fill(rowSize, p);
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6);
}
protected JPanel createSouthPane() {
return null;
}
protected Component[] fieldComponents() {
return filedComboBoxes();
}
protected abstract String[] fieldLabels();
protected abstract UIComboBox[] filedComboBoxes();
public void checkBoxUse(boolean hasUse) {
for (Component component : fieldComponents()) {
component.setEnabled(hasUse);
}
}
public void clearAllBoxList() {
for (UIComboBox comboBox : filedComboBoxes()) {
DataPaneHelper.clearBoxItems(comboBox);
}
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
for (UIComboBox comboBox : filedComboBoxes()) {
refreshBoxItems(comboBox, columnNameList);
}
}
@Override
public abstract T updateBean();
public static void populateField(UIComboBox comboBox, ColumnField field) {
populateFunctionField(comboBox, null, field);
}
public static void updateField(UIComboBox comboBox, ColumnField field) {
updateFunctionField(comboBox, null, field);
}
protected static void populateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) {
comboBox.setSelectedItem(field.getFieldName());
if (calculateComboBox != null) {
calculateComboBox.populateBean((AbstractDataFunction) field.getDataFunction());
}
}
protected static void updateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) {
field.setFieldName(GeneralUtils.objectToString(comboBox.getSelectedItem()));
if (calculateComboBox != null) {
field.setDataFunction(calculateComboBox.updateBean());
} else {
field.setDataFunction(null);
}
}
}

60
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java

@ -0,0 +1,60 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithCustomField;
import com.fr.design.chartx.component.CustomFieldComboBoxPane;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.util.List;
/**
* Created by shine on 2019/5/16.
* 带有 自定义系列名fr表现为 系列名使用字段名 的字段集合 的一个pane
*/
public abstract class AbstractDataSetFieldsWithCustomFieldPane<T extends AbstractColumnFieldCollectionWithCustomField>
extends AbstractDataSetFieldsPane<T> {
private CustomFieldComboBoxPane customFieldComboBoxPane;
@Override
protected JPanel createCenterPane() {
JPanel normalCenter = super.createCenterPane();
customFieldComboBoxPane = new CustomFieldComboBoxPane();
if (normalCenter != null) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(normalCenter, BorderLayout.CENTER);
panel.add(customFieldComboBoxPane, BorderLayout.SOUTH);
return panel;
} else {
return customFieldComboBoxPane;
}
}
@Override
public void checkBoxUse(boolean hasUse) {
super.checkBoxUse(hasUse);
customFieldComboBoxPane.checkBoxUse(hasUse);
}
@Override
public void clearAllBoxList() {
super.clearAllBoxList();
customFieldComboBoxPane.clearAllBoxList();
}
@Override
public void refreshBoxListWithSelectTableData(List columnNameList) {
super.refreshBoxListWithSelectTableData(columnNameList);
customFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList);
}
protected void populateCustomPane(AbstractColumnFieldCollectionWithCustomField t) {
customFieldComboBoxPane.populateBean(t.getCustomFieldValueColumnFields());
}
protected void updateCustomPane(AbstractColumnFieldCollectionWithCustomField t) {
customFieldComboBoxPane.updateBean(t.getCustomFieldValueColumnFields());
}
}

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

@ -0,0 +1,65 @@
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.MultiTinyFormulaPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane;
import javax.swing.JPanel;
import java.util.List;
/**
* Created by shine on 2019/4/12.
*/
public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<MultiCategoryColumnFieldCollection> {
private MultiTinyFormulaPane multiCategoryPane;
private void createMultiFormulaPane() {
if (multiCategoryPane == null) {
multiCategoryPane = new MultiTinyFormulaPane();
}
}
@Override
protected JPanel addNorthPane() {
createMultiFormulaPane();
return multiCategoryPane;
}
@Override
protected String[] fieldLabels() {
return new String[0];
}
@Override
protected TinyFormulaPane[] formulaPanes() {
createMultiFormulaPane();
List<TinyFormulaPane> list = multiCategoryPane.componentList();
return list.toArray(new TinyFormulaPane[list.size()]);
}
@Override
public void populateBean(MultiCategoryColumnFieldCollection ob) {
List<ColumnField> categoryList = ob.getCategoryList();
multiCategoryPane.populate(categoryList);
}
@Override
public MultiCategoryColumnFieldCollection updateBean() {
MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection();
List<ColumnField> categoryList = fieldCollection.getCategoryList();
multiCategoryPane.update(categoryList);
return fieldCollection;
}
}

69
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java

@ -0,0 +1,69 @@
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.MultiComboBoxPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import java.util.List;
/**
* Created by shine on 2019/4/10.
*/
public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithCustomFieldPane<MultiCategoryColumnFieldCollection> {
private MultiComboBoxPane multiCategoryPane;
@Override
protected String[] fieldLabels() {
return new String[0];
}
@Override
protected UIComboBox[] filedComboBoxes() {
List<UIComboBox> list = initMultiCategoryPane().componentList();
return list.toArray(new UIComboBox[list.size()]);
}
private MultiComboBoxPane initMultiCategoryPane() {
if (multiCategoryPane == null) {
multiCategoryPane = new MultiComboBoxPane();
}
return multiCategoryPane;
}
@Override
protected JPanel createNorthPane() {
return initMultiCategoryPane();
}
@Override
public void populateBean(MultiCategoryColumnFieldCollection ob) {
List<ColumnField> categoryList = ob.getCategoryList();
multiCategoryPane.populate(categoryList);
populateCustomPane(ob);
}
@Override
public MultiCategoryColumnFieldCollection updateBean() {
MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection();
List<ColumnField> categoryList = columnFieldCollection.getCategoryList();
multiCategoryPane.update(categoryList);
updateCustomPane(columnFieldCollection);
return columnFieldCollection;
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
}

56
designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java

@ -0,0 +1,56 @@
package com.fr.design.chartx.single;
import com.fr.chartx.data.CellDataDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.i18n.Toolkit;
import java.awt.BorderLayout;
/**
* Created by shine on 2019/5/21.
*/
public class CellDataPane extends FurtherBasicBeanPane<CellDataDefinition> {
private AbstractCellDataFieldsPane cellDataFieldsPane;
public CellDataPane(AbstractCellDataFieldsPane cellDataFieldsPane) {
initComps(cellDataFieldsPane);
}
private void initComps(AbstractCellDataFieldsPane cellDataFieldsPane) {
this.cellDataFieldsPane = cellDataFieldsPane;
this.setLayout(new BorderLayout());
this.add(cellDataFieldsPane, BorderLayout.CENTER);
}
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_Cell_Data");
}
@Override
public boolean accept(Object ob) {
return ob instanceof CellDataDefinition;
}
@Override
public void reset() {
this.removeAll();
}
@Override
public void populateBean(CellDataDefinition ob) {
cellDataFieldsPane.populateBean(ob.getColumnFieldCollection());
}
@Override
public CellDataDefinition updateBean() {
CellDataDefinition cellDataDefinition = new CellDataDefinition();
cellDataDefinition.setColumnFieldCollection(cellDataFieldsPane.updateBean());
return cellDataDefinition;
}
}

121
designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java

@ -0,0 +1,121 @@
package com.fr.design.chartx.single;
import com.fr.chartx.data.DataSetDefinition;
import com.fr.data.impl.NameTableData;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
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.mainframe.chart.gui.data.DatabaseTableDataPane;
import com.fr.design.utils.gui.UIComponentUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.List;
/**
* Created by shine on 2019/5/21.
*/
public class DataSetPane extends FurtherBasicBeanPane<DataSetDefinition> {
private static final int TABLE_DATA_LABEL_LINE_WRAP_WIDTH = 65;
private static final int TABLE_DATA_PANE_WIDTH = 246;
private DatabaseTableDataPane tableDataPane;
private AbstractDataSetFieldsPane dataSetFieldsPane;
public DataSetPane(AbstractDataSetFieldsPane dataSetFieldsPane) {
initComps(dataSetFieldsPane);
}
private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane) {
UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data"));
UIComponentUtils.setLineWrap(label, TABLE_DATA_LABEL_LINE_WRAP_WIDTH);
UIComponentUtils.setPreferedWidth(label, ChartDataPane.LABEL_WIDTH);
tableDataPane = new DatabaseTableDataPane(label) {
@Override
protected void userEvent() {
refreshBoxList();
checkBoxUse();
}
};
tableDataPane.setPreferredSize(new Dimension(TABLE_DATA_PANE_WIDTH, tableDataPane.getPreferredSize().height));
this.dataSetFieldsPane = dataSetFieldsPane;
this.setLayout(new BorderLayout());
this.add(tableDataPane, BorderLayout.NORTH);
this.add(dataSetFieldsPane, BorderLayout.CENTER);
}
/**
* 检查box是否可用.
*/
public void checkBoxUse() {
TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper();
if (dataSetFieldsPane != null) {
dataSetFieldsPane.checkBoxUse(dataWrap != null);
}
}
/**
* 刷新字段下拉列表
*/
private void refreshBoxList() {
TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper();
if (dataWrap == null) {
return;
}
List<String> columnNameList = dataWrap.calculateColumnNameList();
if (dataSetFieldsPane != null) {
dataSetFieldsPane.refreshBoxListWithSelectTableData(columnNameList);
}
}
@Override
public boolean accept(Object ob) {
return ob instanceof DataSetDefinition;
}
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_TableData");
}
@Override
public void reset() {
this.removeAll();
}
@Override
public void populateBean(DataSetDefinition ob) {
refreshBoxList();
checkBoxUse();
tableDataPane.populateBean(ob.getNameTableData());
dataSetFieldsPane.populateBean(ob.getColumnFieldCollection());
}
@Override
public DataSetDefinition updateBean() {
DataSetDefinition dataSetDefinition = new DataSetDefinition();
TableDataWrapper tableDataWrapper = tableDataPane.getTableDataWrapper();
if (tableDataWrapper != null) {
dataSetDefinition.setNameTableData(new NameTableData(tableDataWrapper.getTableDataName()));
}
dataSetDefinition.setColumnFieldCollection(dataSetFieldsPane.updateBean());
return dataSetDefinition;
}
}

90
designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java

@ -0,0 +1,90 @@
package com.fr.design.chartx.single;
import com.fr.chartx.data.AbstractDataDefinition;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ilable.UILabel;
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;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/5/21.
*/
public class SingleDataPane extends BasicBeanPane<AbstractDataDefinition> {
private UIComboBoxPane<AbstractDataDefinition> comboBoxPane;
private DataSetPane dataSetPane;
private CellDataPane cellDataPane;
public SingleDataPane(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) {
initComps(dataSetFieldsPane, cellDataFieldsPane);
}
private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) {
cellDataPane = new CellDataPane(cellDataFieldsPane);
dataSetPane = new DataSetPane(dataSetFieldsPane);
comboBoxPane = new UIComboBoxPane<AbstractDataDefinition>() {
@Override
protected List<FurtherBasicBeanPane<? extends AbstractDataDefinition>> initPaneList() {
List<FurtherBasicBeanPane<? extends AbstractDataDefinition>> list = new ArrayList<FurtherBasicBeanPane<? extends AbstractDataDefinition>>();
list.add(dataSetPane);
list.add(cellDataPane);
return list;
}
protected void initLayout() {
this.setLayout(new BorderLayout(LayoutConstants.HGAP_LARGE, 6));
JPanel northPane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0));
northPane.add(jcb, BorderLayout.CENTER);
UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Source"));
label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT));
northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null}));
northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8));
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return null;
}
};
this.setLayout(new BorderLayout());
this.add(comboBoxPane, BorderLayout.CENTER);
}
@Override
public void populateBean(AbstractDataDefinition ob) {
comboBoxPane.populateBean(ob);
}
@Override
public AbstractDataDefinition updateBean() {
return comboBoxPane.updateBean();
}
@Override
protected String title4PopupWindow() {
return null;
}
}

322
designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

@ -2,101 +2,34 @@ package com.fr.extended.chart;
import com.fr.base.Utils;
import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.UITable;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.chartx.component.AbstractCustomFieldComboBoxPane;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.stable.StringUtils;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2018/9/12.
* Created by shine on 2019/5/16.
*/
public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractDataConfig> {
private static final String[] HEADS = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")};
private UseFieldValuePane useFieldValuePane;
private CustomFieldNamePane customFieldNamePane;
private List<String> fieldList = new ArrayList<String>();
public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBoxPane<AbstractDataConfig> {
@Override
protected void initLayout() {
this.setLayout(new BorderLayout(0, 6));
JPanel northPane = new JPanel(new BorderLayout());
northPane.add(jcb, BorderLayout.CENTER);
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"));
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20));
northPane.add(label, BorderLayout.WEST);
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
protected AbstractUseFieldValuePane createUseFieldValuePane() {
return new ExtendedUseFieldValuePane();
}
@Override
protected List<FurtherBasicBeanPane<? extends AbstractDataConfig>> initPaneList() {
useFieldValuePane = new UseFieldValuePane();
customFieldNamePane = new CustomFieldNamePane();
List<FurtherBasicBeanPane<? extends AbstractDataConfig>> list = new ArrayList<FurtherBasicBeanPane<? extends AbstractDataConfig>>();
list.add(useFieldValuePane);
list.add(customFieldNamePane);
return list;
protected AbstractCustomFieldNamePane createCustomFieldNamePane() {
return new ExtendedCustomFieldNamePane();
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
protected boolean valueComboBoxHasNone() {
return false;
}
public void checkBoxUse(boolean hasUse) {
jcb.setEnabled(hasUse);
useFieldValuePane.checkBoxUse(hasUse);
}
public void clearAllBoxList() {
useFieldValuePane.clearAllBoxList();
fieldList.clear();
}
protected void refreshBoxListWithSelectTableData(List columnNameList) {
useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList);
fieldList = columnNameList;
}
@Override
public void populateBean(AbstractDataConfig ob) {
if (ob.isCustomName()) {
customFieldNamePane.populateBean(ob);
populateCustomFieldNamePane(ob);
jcb.setSelectedIndex(1);
} else {
useFieldValuePane.populateBean(ob);
populateUseFieldValuePane(ob);
jcb.setSelectedIndex(0);
}
}
@ -105,68 +38,22 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
public void updateBean(AbstractDataConfig ob) {
if (jcb.getSelectedIndex() == 0) {
ob.setCustomName(false);
useFieldValuePane.updateBean(ob);
updateUseFieldValuePane(ob);
} else {
ob.setCustomName(true);
customFieldNamePane.updateBean(ob);
updateCustomFieldNamePane(ob);
}
}
private class UseFieldValuePane extends FurtherBasicBeanPane<AbstractDataConfig> {
private UIComboBox series;
private UIComboBox value;
private CalculateComboBox function;
private UseFieldValuePane() {
initComponents();
}
private void initComponents() {
series = new UIComboBox();
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
function = new CalculateComboBox();
Component[][] components = new Component[][]{
new Component[]{new UILabel(HEADS[1], SwingConstants.LEFT), series},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value},
new Component[]{new UILabel(HEADS[2], SwingConstants.LEFT), function},
};
double p = TableLayout.PREFERRED;
double[] columnSize = {78, 122};
double[] rowSize = {p, p, p};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout(0, 6));
this.add(panel, BorderLayout.CENTER);
}
public void checkBoxUse(boolean hasUse) {
series.setEnabled(hasUse);
value.setEnabled(hasUse);
function.setEnabled(hasUse);
}
public void clearAllBoxList() {
DataPaneHelper.clearBoxItems(series);
DataPaneHelper.clearBoxItems(value);
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
DataPaneHelper.refreshBoxItems(series, columnNameList);
DataPaneHelper.refreshBoxItems(value, columnNameList);
}
private class ExtendedUseFieldValuePane extends AbstractUseFieldValuePane<AbstractDataConfig> {
@Override
public void populateBean(AbstractDataConfig ob) {
List<ExtendedField> list = ob.getCustomFields();
if (list.size() == 2) {
series.setSelectedItem(list.get(0).getFieldName());
value.setSelectedItem(list.get(1).getFieldName());
function.populateBean((AbstractDataFunction) list.get(1).getDataFunction());
populateSeries(list.get(0).getFieldName());
populateValue(list.get(1).getFieldName());
populateFunction((AbstractDataFunction) list.get(1).getDataFunction());
}
}
@ -174,70 +61,18 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
public void updateBean(AbstractDataConfig ob) {
List<ExtendedField> list = new ArrayList<ExtendedField>();
list.add(new ExtendedField(Utils.objectToString(series.getSelectedItem())));
ExtendedField field = new ExtendedField(Utils.objectToString(value.getSelectedItem()));
field.setDataFunction(function.updateBean());
list.add(new ExtendedField(updateSeries()));
ExtendedField field = new ExtendedField(updateValue());
field.setDataFunction(updateFunction());
list.add(field);
ob.setCustomFields(list);
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value");
}
@Override
public AbstractDataConfig updateBean() {
return null;
}
}
private class CustomFieldNamePane extends FurtherBasicBeanPane<AbstractDataConfig> {
private UICorrelationPane correlationPane;
public CustomFieldNamePane() {
initComponents();
}
private void initComponents() {
correlationPane = new UICorrelationPane(HEADS) {
@Override
protected ActionListener getAddButtonListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tablePane.addLine(new String[]{StringUtils.EMPTY, StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")});
fireTargetChanged();
}
};
}
public UITableEditor createUITableEditor() {
return new Editor() {
@Override
protected UICorrelationPane getParent() {
return correlationPane;
}
};
}
};
this.setLayout(new BorderLayout());
this.add(correlationPane, BorderLayout.CENTER);
}
private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane<AbstractDataConfig> {
@Override
public void populateBean(AbstractDataConfig ob) {
@ -248,13 +83,12 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
String[] array = {field.getFieldName(), field.getCustomName(), DataPaneHelper.getFunctionString(field.getDataFunction())};
list.add(array);
}
correlationPane.populateBean(list);
populate(list);
}
@Override
public void updateBean(AbstractDataConfig ob) {
List<Object[]> list = correlationPane.updateBean();
List<Object[]> list = update();
List<ExtendedField> customFields = new ArrayList<ExtendedField>();
for (Object[] line : list) {
@ -267,120 +101,6 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
}
ob.setCustomFields(customFields);
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name");
}
@Override
public AbstractDataConfig updateBean() {
return null;
}
}
private abstract class Editor extends UITableEditor {
private JComponent editorComponent;
protected abstract UICorrelationPane getParent();
@Override
public Object getCellEditorValue() {
if (editorComponent instanceof UIComboBox) {
return ((UIComboBox) editorComponent).getSelectedItem();
} else if (editorComponent instanceof UITextField) {
return ((UITextField) editorComponent).getText();
} else if (editorComponent instanceof CalculateComboBox) {
return ((CalculateComboBox) editorComponent).getSelectedItem();
}
return super.getCellEditorValue();
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, final int row, int column) {
switch (column) {
case 0:
editorComponent = createComboBoxEdit(row, value);
break;
case 1:
editorComponent = createTextEdit(value);
break;
default:
editorComponent = createCalculateComboBox(value);
break;
}
return editorComponent;
}
private void setDefaultName(int row) {
UITable table = getParent().getTable();
Object object = table.getValueAt(row, 0);
if (object != null) {
table.setValueAt(object, row, 1);
}
}
private UIComboBox createComboBoxEdit(final int row, Object value) {
UIComboBox uiComboBox = new UIComboBox(fieldList.toArray());
uiComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
getParent().stopCellEditing();
getParent().fireTargetChanged();
setDefaultName(row);
}
});
if (value != null && StringUtils.isNotEmpty(value.toString())) {
uiComboBox.getModel().setSelectedItem(value);
} else {
uiComboBox.getModel().setSelectedItem(value);
}
return uiComboBox;
}
private UITextField createTextEdit(Object value) {
UITextField uiTextField = new UITextField();
if (value != null) {
uiTextField.setText(value.toString());
}
uiTextField.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
getParent().fireTargetChanged();
}
});
return uiTextField;
}
private CalculateComboBox createCalculateComboBox(Object value) {
CalculateComboBox calculateComboBox = new CalculateComboBox();
if (value != null) {
calculateComboBox.setSelectedItem(value);
}
calculateComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
getParent().stopCellEditing();
getParent().fireTargetChanged();
}
});
return calculateComboBox;
}
}

8
designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java

@ -2,7 +2,10 @@ package com.fr.van.chart.column;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chartx.MultiCategoryChartDataPane;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI;
@ -33,4 +36,9 @@ public class ColumnIndependentVanChartInterface extends AbstractMultiCategoryVan
public String getPlotTypeTitle4PopupWindow(){
return VanChartColumnPlotPane.TITLE;
}
@Override
public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new MultiCategoryChartDataPane(listener);
}
}
Loading…
Cancel
Save