From d8659e6b51e8822fd41747ec709dd578ecc570bd Mon Sep 17 00:00:00 2001 From: zheng Date: Wed, 22 May 2019 14:44:35 +0800 Subject: [PATCH 01/17] =?UTF-8?q?CHART-4027=20=E5=9B=BE=E8=A1=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/chartx/AbstractChartDataPane.java | 58 +++ .../fr/design/chartx/GanttChartDataPane.java | 39 ++ .../chartx/MultiCategoryChartDataPane.java | 43 ++ .../chartx/WordCloundChartDataPane.java | 20 + .../AbstractCustomFieldComboBoxPane.java | 368 ++++++++++++++++++ .../component/AbstractMultiComponentPane.java | 168 ++++++++ .../component/CustomFieldComboBoxPane.java | 58 +++ .../chartx/component/MultiComboBoxPane.java | 32 ++ .../component/MultiTinyFormulaPane.java | 31 ++ .../fields/AbstractCellDataFieldsPane.java | 93 +++++ .../fields/AbstractDataSetFieldsPane.java | 142 +++++++ ...tractDataSetFieldsWithCustomFieldPane.java | 60 +++ .../diff/MultiCategoryCellDataFieldsPane.java | 65 ++++ .../diff/MultiCategoryDataSetFieldsPane.java | 69 ++++ .../fr/design/chartx/single/CellDataPane.java | 56 +++ .../fr/design/chartx/single/DataSetPane.java | 121 ++++++ .../design/chartx/single/SingleDataPane.java | 90 +++++ .../ExtendedCustomFieldComboBoxPane.java | 322 +-------------- .../ColumnIndependentVanChartInterface.java | 8 + 19 files changed, 1542 insertions(+), 301 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java new file mode 100644 index 0000000000..61359d91b7 --- /dev/null +++ b/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 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()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java new file mode 100644 index 0000000000..e418e0c300 --- /dev/null +++ b/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 { + + 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; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java new file mode 100644 index 0000000000..721fc8480e --- /dev/null +++ b/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 { + + 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()); + } + + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java new file mode 100644 index 0000000000..2f3bd39a00 --- /dev/null +++ b/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()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java new file mode 100644 index 0000000000..8453452d25 --- /dev/null +++ b/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 extends UIComboBoxPane { + 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 fieldList = new ArrayList(); + + @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> initPaneList() { + useFieldValuePane = createUseFieldValuePane(); + customFieldNamePane = createCustomFieldNamePane(); + List> list = new ArrayList>(); + 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 extends FurtherBasicBeanPane { + 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 extends FurtherBasicBeanPane { + + 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 list) { + correlationPane.populateBean(list); + } + + protected List 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; + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java new file mode 100644 index 0000000000..008a7d91cb --- /dev/null +++ b/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. + * 一列组件 可增可删 + */ +public abstract class AbstractMultiComponentPane 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 categoryComponentList = new ArrayList(); + + + 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 componentList() { + List list = new ArrayList<>(categoryComponentList); + list.add(firstFieldComponent); + return list; + } + + public void populate(List 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 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); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java new file mode 100644 index 0000000000..8e6b98577d --- /dev/null +++ b/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 { + + @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 { + + @Override + public void populateBean(CustomFieldValueColumnFields ob) { + + } + } + + private class CustomFieldNamePane extends AbstractCustomFieldNamePane { + + @Override + public void populateBean(CustomFieldValueColumnFields ob) { + + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java new file mode 100644 index 0000000000..37a110b7d4 --- /dev/null +++ b/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 { + + @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); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java new file mode 100644 index 0000000000..5e56b967c4 --- /dev/null +++ b/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 { + @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); + + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java new file mode 100644 index 0000000000..98400ed7ae --- /dev/null +++ b/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 extends BasicBeanPane { + + 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; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java new file mode 100644 index 0000000000..84c8401c10 --- /dev/null +++ b/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 extends BasicBeanPane { + + 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); + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java new file mode 100644 index 0000000000..9b0418c306 --- /dev/null +++ b/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 + extends AbstractDataSetFieldsPane { + + 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()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java new file mode 100644 index 0000000000..755f4a8c53 --- /dev/null +++ b/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 { + + 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 list = multiCategoryPane.componentList(); + return list.toArray(new TinyFormulaPane[list.size()]); + } + + @Override + public void populateBean(MultiCategoryColumnFieldCollection ob) { + + List categoryList = ob.getCategoryList(); + + multiCategoryPane.populate(categoryList); + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection(); + List categoryList = fieldCollection.getCategoryList(); + + multiCategoryPane.update(categoryList); + + return fieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java new file mode 100644 index 0000000000..f3828361b3 --- /dev/null +++ b/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 { + + private MultiComboBoxPane multiCategoryPane; + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + List 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 categoryList = ob.getCategoryList(); + + multiCategoryPane.populate(categoryList); + + populateCustomPane(ob); + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection(); + List categoryList = columnFieldCollection.getCategoryList(); + + multiCategoryPane.update(categoryList); + + updateCustomPane(columnFieldCollection); + + return columnFieldCollection; + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java new file mode 100644 index 0000000000..f0a4ef0afd --- /dev/null +++ b/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 { + + 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; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java new file mode 100644 index 0000000000..98394c31a0 --- /dev/null +++ b/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 { + 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 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; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java new file mode 100644 index 0000000000..a4e6949983 --- /dev/null +++ b/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 { + + private UIComboBoxPane 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() { + @Override + protected List> initPaneList() { + List> list = new ArrayList>(); + 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; + } +} diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java index ceeea71c2d..cc28497658 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java +++ b/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 { - 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 fieldList = new ArrayList(); - +public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { @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> initPaneList() { - useFieldValuePane = new UseFieldValuePane(); - customFieldNamePane = new CustomFieldNamePane(); - List> list = new ArrayList>(); - 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 { - 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 { @Override public void populateBean(AbstractDataConfig ob) { List 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 list = new ArrayList(); - 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 { - - 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 { @Override public void populateBean(AbstractDataConfig ob) { @@ -248,13 +83,12 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane list = correlationPane.updateBean(); + List list = update(); List customFields = new ArrayList(); for (Object[] line : list) { @@ -267,120 +101,6 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane Date: Tue, 4 Jun 2019 14:20:13 +0800 Subject: [PATCH 02/17] =?UTF-8?q?CHART-4027=20=E7=B3=BB=E5=88=97+=E5=80=BC?= =?UTF-8?q?=20=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9B=B8=E5=85=B3=20design?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/CustomFieldComboBoxPane.java | 58 ---------- .../SeriesValueFieldComboBoxPane.java | 108 ++++++++++++++++++ ...ractDataSetFieldsWithSeriesValuePane.java} | 28 ++--- .../diff/MultiCategoryDataSetFieldsPane.java | 2 +- 4 files changed, 123 insertions(+), 73 deletions(-) delete mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java rename designer-chart/src/main/java/com/fr/design/chartx/fields/diff/{AbstractDataSetFieldsWithCustomFieldPane.java => AbstractDataSetFieldsWithSeriesValuePane.java} (60%) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java deleted file mode 100644 index 8e6b98577d..0000000000 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java +++ /dev/null @@ -1,58 +0,0 @@ -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 { - - @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 { - - @Override - public void populateBean(CustomFieldValueColumnFields ob) { - - } - } - - private class CustomFieldNamePane extends AbstractCustomFieldNamePane { - - @Override - public void populateBean(CustomFieldValueColumnFields ob) { - - } - } - -} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java new file mode 100644 index 0000000000..b6c080d523 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java @@ -0,0 +1,108 @@ +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.data.util.function.AbstractDataFunction; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; +import com.fr.general.GeneralUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/5/17. + */ +public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { + + @Override + protected AbstractUseFieldValuePane createUseFieldValuePane() { + return new UseFieldValuePane(); + } + + @Override + protected AbstractCustomFieldNamePane createCustomFieldNamePane() { + return new CustomFieldNamePane(); + } + + @Override + public void populateBean(SeriesValueColumnFields ob) { + if (ob.isCustomFieldValue()) { + populateCustomFieldNamePane(ob); + jcb.setSelectedIndex(1); + } else { + populateUseFieldValuePane(ob); + jcb.setSelectedIndex(0); + } + } + + @Override + public void updateBean(SeriesValueColumnFields ob) { + if (jcb.getSelectedIndex() == 0) { + ob.setCustomFieldValue(false); + updateUseFieldValuePane(ob); + } else { + ob.setCustomFieldValue(true); + updateCustomFieldNamePane(ob); + } + } + + private class UseFieldValuePane extends AbstractUseFieldValuePane { + + @Override + public void populateBean(SeriesValueColumnFields ob) { + List list = ob.getSeriesValueFieldList(); + if (list != null && list.size() > 0) { + populateSeries(list.get(0).getSeries().getFieldName()); + populateValue(list.get(0).getValue().getFieldName()); + populateFunction((AbstractDataFunction) list.get(0).getValue().getDataFunction()); + } + } + + @Override + public void updateBean(SeriesValueColumnFields ob) { + List list = new ArrayList(); + SeriesValueField seriesValueField = new SeriesValueField(); + ColumnField series = new ColumnField(updateSeries()); + ColumnField value = new ColumnField(updateValue()); + value.setDataFunction(updateFunction()); + seriesValueField.setValue(value); + seriesValueField.setSeries(series); + list.add(seriesValueField); + ob.setSeriesValueFieldList(list); + } + } + + private class CustomFieldNamePane extends AbstractCustomFieldNamePane { + + @Override + public void populateBean(SeriesValueColumnFields ob) { + List list = new ArrayList(); + for (SeriesValueField seriesValueField : ob.getSeriesValueFieldList()) { + Object[] array = new Object[3]; + array[0] = seriesValueField.getSeries().getFieldName(); + array[1] = seriesValueField.getValue().getFieldName(); + array[2] = DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction()); + list.add(array); + } + populate(list); + } + + @Override + public void updateBean(SeriesValueColumnFields ob) { + List list = update(); + List seriesValueFields = new ArrayList(); + for (Object[] line : list) { + ColumnField series = new ColumnField(GeneralUtils.objectToString(line[0])); + ColumnField value = new ColumnField(GeneralUtils.objectToString(line[1])); + value.setDataFunction(DataPaneHelper.getFunctionByName(GeneralUtils.objectToString(line[2]))); + SeriesValueField seriesValueField = new SeriesValueField(); + seriesValueField.setValue(value); + seriesValueField.setSeries(series); + seriesValueFields.add(seriesValueField); + } + ob.setSeriesValueFieldList(seriesValueFields); + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java similarity index 60% rename from designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java rename to designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java index 9b0418c306..7c4f0f083f 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java @@ -1,7 +1,7 @@ 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.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; +import com.fr.design.chartx.component.SeriesValueFieldComboBoxPane; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import javax.swing.JPanel; @@ -12,49 +12,49 @@ import java.util.List; * Created by shine on 2019/5/16. * 带有 自定义系列名(fr表现为 系列名使用字段名) 的字段集合 的一个pane */ -public abstract class AbstractDataSetFieldsWithCustomFieldPane +public abstract class AbstractDataSetFieldsWithSeriesValuePane extends AbstractDataSetFieldsPane { - private CustomFieldComboBoxPane customFieldComboBoxPane; + private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane; @Override protected JPanel createCenterPane() { JPanel normalCenter = super.createCenterPane(); - customFieldComboBoxPane = new CustomFieldComboBoxPane(); + seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane(); if (normalCenter != null) { JPanel panel = new JPanel(new BorderLayout()); panel.add(normalCenter, BorderLayout.CENTER); - panel.add(customFieldComboBoxPane, BorderLayout.SOUTH); + panel.add(seriesValueFieldComboBoxPane, BorderLayout.SOUTH); return panel; } else { - return customFieldComboBoxPane; + return seriesValueFieldComboBoxPane; } } @Override public void checkBoxUse(boolean hasUse) { super.checkBoxUse(hasUse); - customFieldComboBoxPane.checkBoxUse(hasUse); + seriesValueFieldComboBoxPane.checkBoxUse(hasUse); } @Override public void clearAllBoxList() { super.clearAllBoxList(); - customFieldComboBoxPane.clearAllBoxList(); + seriesValueFieldComboBoxPane.clearAllBoxList(); } @Override public void refreshBoxListWithSelectTableData(List columnNameList) { super.refreshBoxListWithSelectTableData(columnNameList); - customFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList); + seriesValueFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList); } - protected void populateCustomPane(AbstractColumnFieldCollectionWithCustomField t) { - customFieldComboBoxPane.populateBean(t.getCustomFieldValueColumnFields()); + protected void populateCustomPane(AbstractColumnFieldCollectionWithSeriesValue t) { + seriesValueFieldComboBoxPane.populateBean(t.getSeriesValueColumnFields()); } - protected void updateCustomPane(AbstractColumnFieldCollectionWithCustomField t) { - customFieldComboBoxPane.updateBean(t.getCustomFieldValueColumnFields()); + protected void updateCustomPane(AbstractColumnFieldCollectionWithSeriesValue t) { + seriesValueFieldComboBoxPane.updateBean(t.getSeriesValueColumnFields()); } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java index f3828361b3..6a6983fc1d 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -13,7 +13,7 @@ import java.util.List; /** * Created by shine on 2019/4/10. */ -public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithCustomFieldPane { +public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane { private MultiComboBoxPane multiCategoryPane; From 5c113a8dbb63ee07f559d3d14ea440dd1da40285 Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 4 Jun 2019 16:11:47 +0800 Subject: [PATCH 03/17] =?UTF-8?q?CHART-4027=20=E7=B3=BB=E5=88=97+=E5=80=BC?= =?UTF-8?q?=20=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9B=B8=E5=85=B3celldata=20desi?= =?UTF-8?q?gn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractChartDataCorrelationPane.java | 106 ++++++++++++++++++ .../CellDataSeriesValueFieldsPane.java | 55 +++++++++ .../FieldEditorComponentWrapper.java | 19 ++++ .../TinyFormulaPaneEditorComponent.java | 61 ++++++++++ .../fields/AbstractCellDataFieldsPane.java | 16 ++- ...ractCellDataFieldsWithSeriesValuePane.java | 41 +++++++ ...tractDataSetFieldsWithSeriesValuePane.java | 4 +- .../diff/MultiCategoryCellDataFieldsPane.java | 9 +- .../diff/MultiCategoryDataSetFieldsPane.java | 4 +- 9 files changed, 302 insertions(+), 13 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java new file mode 100644 index 0000000000..1e29a818e8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java @@ -0,0 +1,106 @@ +package com.fr.design.chartx.component; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.frpane.UICorrelationPane; +import com.fr.design.gui.itable.UITable; +import com.fr.design.gui.itable.UITableEditor; +import com.fr.stable.StringUtils; + +import javax.swing.JTable; +import javax.swing.event.ChangeEvent; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.List; + +/** + * Created by shine on 2019/6/4. + */ +public abstract class AbstractChartDataCorrelationPane extends BasicBeanPane { + private FieldEditorComponentWrapper[] editorComponents; + + private UICorrelationPane correlationPane; + + public AbstractChartDataCorrelationPane() { + + this.editorComponents = fieldEditorComponentWrappers(); + + String[] headers = new String[editorComponents.length]; + + for (int i = 0, len = editorComponents.length; i < len; i++) { + headers[i] = editorComponents[i].headerName(); + } + + initComps(headers); + } + + protected abstract FieldEditorComponentWrapper[] fieldEditorComponentWrappers(); + + protected List update() { + return correlationPane.updateBean(); + } + + protected void populate(List list) { + correlationPane.populateBean(list); + } + + @Override + public T updateBean() { + return null; + } + + private void initComps(String[] headers) { + correlationPane = new UICorrelationPane(headers) { + public UITableEditor createUITableEditor() { + return new Editor(); + } + + protected UITable initUITable() { + return new UITable(columnCount) { + + public UITableEditor createTableEditor() { + return createUITableEditor(); + } + + public void tableCellEditingStopped(ChangeEvent e) { + stopPaneEditing(e); + } + }; + } + }; + + this.setLayout(new BorderLayout()); + this.add(correlationPane, BorderLayout.CENTER); + } + + private class Editor extends UITableEditor { + + private Component currentComponent; + private FieldEditorComponentWrapper currentEditorWrapper; + + public Object getCellEditorValue() { + return currentEditorWrapper.value(currentComponent); + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (column == table.getModel().getColumnCount()) { + return null; + } + + correlationPane.stopCellEditing(); + + currentEditorWrapper = AbstractChartDataCorrelationPane.this.editorComponents[column]; + + currentComponent = currentEditorWrapper.createEditorComponent(correlationPane); + currentEditorWrapper.setValue(currentComponent, value); + + return currentComponent; + } + + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java new file mode 100644 index 0000000000..21d4280124 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java @@ -0,0 +1,55 @@ +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 AbstractChartDataCorrelationPane { + + @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 list = new ArrayList(); + + List 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 list = update(); + + List seriesValueFieldList = new ArrayList(); + + 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); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java b/designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java new file mode 100644 index 0000000000..9d8f1a0436 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java @@ -0,0 +1,19 @@ +package com.fr.design.chartx.component; + +import com.fr.design.gui.frpane.UICorrelationPane; + +import java.awt.Component; + +/** + * Created by shine on 2019/6/4. + */ +public interface FieldEditorComponentWrapper { + + String headerName(); + + T createEditorComponent(UICorrelationPane parent); + + Object value(T t); + + void setValue(T t, Object o); +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java new file mode 100644 index 0000000000..6234450731 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java @@ -0,0 +1,61 @@ +package com.fr.design.chartx.component; + +import com.fr.base.BaseFormula; +import com.fr.base.Utils; +import com.fr.design.constants.UIConstants; +import com.fr.design.event.UIObserverListener; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.frpane.UICorrelationPane; + +/** + * Created by shine on 2019/6/4. + */ +public class TinyFormulaPaneEditorComponent implements FieldEditorComponentWrapper { + + private String header; + + public TinyFormulaPaneEditorComponent(String header) { + this.header = header; + } + + @Override + public String headerName() { + return this.header; + } + + @Override + public TinyFormulaPane createEditorComponent(final UICorrelationPane parent) { + TinyFormulaPane editorComponent = new TinyFormulaPane() { + @Override + public void okEvent() { + parent.stopCellEditing(); + parent.fireTargetChanged(); + } + + @Override + protected void populateTextField(BaseFormula fm) { + formulaTextField.setText(fm.getContent()); + } + }; + editorComponent.setBackground(UIConstants.FLESH_BLUE); + + editorComponent.getUITextField().registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + parent.fireTargetChanged(); + } + }); + + return editorComponent; + } + + @Override + public Object value(TinyFormulaPane formulaPane) { + return formulaPane.getUITextField().getText(); + } + + @Override + public void setValue(TinyFormulaPane formulaPane, Object o) { + formulaPane.getUITextField().setText(Utils.objectToString(o)); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java index 98400ed7ae..6b6408d937 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java @@ -31,19 +31,23 @@ public abstract class AbstractCellDataFieldsPane + extends AbstractCellDataFieldsPane { + + private CellDataSeriesValueFieldsPane seriesValueFieldsPane; + + @Override + protected JPanel createCenterPane() { + JPanel normalCenter = super.createCenterPane(); + seriesValueFieldsPane = new CellDataSeriesValueFieldsPane(); + + if (normalCenter != null) { + JPanel panel = new JPanel(new BorderLayout()); + panel.add(normalCenter, BorderLayout.CENTER); + panel.add(seriesValueFieldsPane, BorderLayout.SOUTH); + return panel; + } else { + return seriesValueFieldsPane; + } + } + + protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) { + seriesValueFieldsPane.populateBean(t.getSeriesValueColumnFields()); + } + + protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) { + seriesValueFieldsPane.updateBean(t.getSeriesValueColumnFields()); + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java index 7c4f0f083f..c62a7deaa2 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java @@ -50,11 +50,11 @@ public abstract class AbstractDataSetFieldsWithSeriesValuePane { +public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane { private MultiTinyFormulaPane multiCategoryPane; @@ -23,7 +22,7 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane< } @Override - protected JPanel addNorthPane() { + protected JPanel createNorthPane() { createMultiFormulaPane(); @@ -50,6 +49,8 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane< List categoryList = ob.getCategoryList(); multiCategoryPane.populate(categoryList); + + populateSeriesValuePane(ob); } @Override @@ -60,6 +61,8 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane< multiCategoryPane.update(categoryList); + updateSeriesValuePane(fieldCollection); + return fieldCollection; } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java index 6a6983fc1d..f638cad223 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -46,7 +46,7 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer multiCategoryPane.populate(categoryList); - populateCustomPane(ob); + populateSeriesValuePane(ob); } @Override @@ -57,7 +57,7 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer multiCategoryPane.update(categoryList); - updateCustomPane(columnFieldCollection); + updateSeriesValuePane(columnFieldCollection); return columnFieldCollection; } From 4b357edbc8212e3891b39738bae413f758f776cb Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 4 Jun 2019 16:34:12 +0800 Subject: [PATCH 04/17] update --- ...taCorrelationPane.java => AbstractCorrelationPane.java} | 7 ++++--- .../chartx/component/CellDataSeriesValueFieldsPane.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) rename designer-chart/src/main/java/com/fr/design/chartx/component/{AbstractChartDataCorrelationPane.java => AbstractCorrelationPane.java} (91%) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java similarity index 91% rename from designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java rename to designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java index 1e29a818e8..e1f833b1fa 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java @@ -14,13 +14,14 @@ import java.util.List; /** * Created by shine on 2019/6/4. + * 自定义editorComponent + 支持多种数据格式 */ -public abstract class AbstractChartDataCorrelationPane extends BasicBeanPane { +public abstract class AbstractCorrelationPane extends BasicBeanPane { private FieldEditorComponentWrapper[] editorComponents; private UICorrelationPane correlationPane; - public AbstractChartDataCorrelationPane() { + public AbstractCorrelationPane() { this.editorComponents = fieldEditorComponentWrappers(); @@ -88,7 +89,7 @@ public abstract class AbstractChartDataCorrelationPane extends BasicBeanPane< correlationPane.stopCellEditing(); - currentEditorWrapper = AbstractChartDataCorrelationPane.this.editorComponents[column]; + currentEditorWrapper = AbstractCorrelationPane.this.editorComponents[column]; currentComponent = currentEditorWrapper.createEditorComponent(correlationPane); currentEditorWrapper.setValue(currentComponent, value); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java index 21d4280124..83a74f854d 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java @@ -12,7 +12,7 @@ import java.util.List; /** * Created by shine on 2019/6/4. */ -public class CellDataSeriesValueFieldsPane extends AbstractChartDataCorrelationPane { +public class CellDataSeriesValueFieldsPane extends AbstractCorrelationPane { @Override protected FieldEditorComponentWrapper[] fieldEditorComponentWrappers() { From 269272c280ffed502a24880f6f8355b6d2c53a65 Mon Sep 17 00:00:00 2001 From: zheng Date: Mon, 10 Jun 2019 17:15:22 +0800 Subject: [PATCH 05/17] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CellDataSeriesValueCorrelationPane.java | 59 +++++++++++++++++++ .../CellDataSeriesValueFieldsPane.java | 55 ----------------- .../SeriesValueFieldComboBoxPane.java | 24 ++++---- .../AbstractCorrelationPane.java | 23 ++++---- .../correlation/AbstractEditorComponent.java | 19 ++++++ .../FieldEditorComponentWrapper.java | 4 +- .../TinyFormulaPaneEditorComponent.java | 15 ++--- ...ractCellDataFieldsWithSeriesValuePane.java | 14 ++--- ...tractDataSetFieldsWithSeriesValuePane.java | 8 +-- .../diff/MultiCategoryCellDataFieldsPane.java | 6 +- .../diff/MultiCategoryDataSetFieldsPane.java | 6 +- 11 files changed, 125 insertions(+), 108 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java delete mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java rename designer-chart/src/main/java/com/fr/design/chartx/component/{ => correlation}/AbstractCorrelationPane.java (80%) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java rename designer-chart/src/main/java/com/fr/design/chartx/component/{ => correlation}/FieldEditorComponentWrapper.java (79%) rename designer-chart/src/main/java/com/fr/design/chartx/component/{ => correlation}/TinyFormulaPaneEditorComponent.java (80%) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java new file mode 100644 index 0000000000..3d5cdc9d99 --- /dev/null +++ b/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 { + + @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 covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { + List result = new ArrayList(); + + List 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 tableValues) { + List seriesValueFieldList = new ArrayList(); + + 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; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java deleted file mode 100644 index 83a74f854d..0000000000 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java +++ /dev/null @@ -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 { - - @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 list = new ArrayList(); - - List 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 list = update(); - - List seriesValueFieldList = new ArrayList(); - - 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); - } -} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java index b6c080d523..82f0b7a886 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java +++ b/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 { +public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { @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 { + private class UseFieldValuePane extends AbstractUseFieldValuePane { @Override - public void populateBean(SeriesValueColumnFields ob) { + public void populateBean(SeriesValueCorrelationDefinition ob) { List 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 list = new ArrayList(); SeriesValueField seriesValueField = new SeriesValueField(); ColumnField series = new ColumnField(updateSeries()); @@ -73,12 +73,12 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } } - private class CustomFieldNamePane extends AbstractCustomFieldNamePane { + private class CustomFieldNamePane extends AbstractCustomFieldNamePane { @Override - public void populateBean(SeriesValueColumnFields ob) { + public void populateBean(SeriesValueCorrelationDefinition definition) { List list = new ArrayList(); - 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 list = update(); List seriesValueFields = new ArrayList(); 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); } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java similarity index 80% rename from designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java rename to designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java index e1f833b1fa..c7b459e49f 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCorrelationPane.java +++ b/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 extends BasicBeanPane { public AbstractCorrelationPane() { - this.editorComponents = fieldEditorComponentWrappers(); + this.editorComponents = createFieldEditorComponentWrappers(); String[] headers = new String[editorComponents.length]; @@ -34,21 +34,22 @@ public abstract class AbstractCorrelationPane extends BasicBeanPane { initComps(headers); } - protected abstract FieldEditorComponentWrapper[] fieldEditorComponentWrappers(); + protected abstract FieldEditorComponentWrapper[] createFieldEditorComponentWrappers(); - protected List update() { - return correlationPane.updateBean(); - } - - protected void populate(List 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 covertTBeanToTableModelList(T t); + + protected abstract T covertTableModelListToTBean(List tableValues); + private void initComps(String[] headers) { correlationPane = new UICorrelationPane(headers) { public UITableEditor createUITableEditor() { @@ -79,7 +80,7 @@ public abstract class AbstractCorrelationPane extends BasicBeanPane { 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) { diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java new file mode 100644 index 0000000000..d906058309 --- /dev/null +++ b/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 implements FieldEditorComponentWrapper { + private String header; + + public AbstractEditorComponent(String header) { + this.header = header; + } + + @Override + public String headerName() { + return this.header; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java similarity index 79% rename from designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java rename to designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java index 9d8f1a0436..5181b466cc 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java +++ b/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 createEditorComponent(UICorrelationPane parent); - Object value(T t); + Object getValue(T t); void setValue(T t, Object o); } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java similarity index 80% rename from designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java rename to designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java index 6234450731..71a0a59e51 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java +++ b/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 { - - private String header; +public class TinyFormulaPaneEditorComponent extends AbstractEditorComponent { 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(); } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java index a3693bf539..dc0ce33ec3 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java +++ b/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 extends AbstractCellDataFieldsPane { - 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 categoryList = ob.getCategoryList(); + List categoryList = multiCategoryColumnFieldCollection.getCategoryList(); multiCategoryPane.populate(categoryList); - populateSeriesValuePane(ob); + populateSeriesValuePane(multiCategoryColumnFieldCollection); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java index f638cad223..0e61218120 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java +++ b/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 categoryList = ob.getCategoryList(); + public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) { + List categoryList = multiCategoryColumnFieldCollection.getCategoryList(); multiCategoryPane.populate(categoryList); - populateSeriesValuePane(ob); + populateSeriesValuePane(multiCategoryColumnFieldCollection); } @Override From 852907a1cc06640363389355a32f580135c7ea01 Mon Sep 17 00:00:00 2001 From: zheng Date: Mon, 10 Jun 2019 19:35:41 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCustomFieldComboBoxPane.java | 214 ++++-------------- .../CellDataSeriesValueCorrelationPane.java | 5 +- .../SeriesValueFieldComboBoxPane.java | 21 +- .../correlation/AbstractCorrelationPane.java | 28 ++- .../CalculateComboBoxEditorComponent.java | 45 ++++ .../FieldEditorComponentWrapper.java | 3 +- .../TinyFormulaPaneEditorComponent.java | 4 +- .../UIComboBoxEditorComponent.java | 55 +++++ .../UITextFieldEditorComponent.java | 41 ++++ .../ExtendedCustomFieldComboBoxPane.java | 15 +- 10 files changed, 235 insertions(+), 196 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UIComboBoxEditorComponent.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java index 8453452d25..6f6172bc39 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -2,14 +2,15 @@ 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.chartx.component.correlation.AbstractCorrelationPane; +import com.fr.design.chartx.component.correlation.CalculateComboBoxEditorComponent; +import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; +import com.fr.design.chartx.component.correlation.UIComboBoxEditorComponent; +import com.fr.design.chartx.component.correlation.UITextFieldEditorComponent; 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.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartDataPane; @@ -19,17 +20,11 @@ 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; @@ -38,7 +33,6 @@ import java.util.List; * 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取 */ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane { - 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; @@ -64,7 +58,31 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< customFieldNamePane = createCustomFieldNamePane(); List> list = new ArrayList>(); list.add(useFieldValuePane); - list.add(customFieldNamePane); + FurtherBasicBeanPane pane = new FurtherBasicBeanPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name"); + } + + @Override + public boolean accept(Object ob) { + return false; + } + + @Override + public void reset() { + } + + @Override + public void populateBean(Object ob) { + } + + @Override + public Object updateBean() { + return null; + } + }; + list.add(pane); return list; } @@ -129,9 +147,9 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< 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}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), SwingConstants.LEFT), series}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), function}, }; double p = TableLayout.PREFERRED; @@ -204,165 +222,25 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< } } - protected abstract class AbstractCustomFieldNamePane extends FurtherBasicBeanPane { - - 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(); - } - }; - } + protected abstract class AbstractCustomFieldNamePane extends AbstractCorrelationPane { - public UITableEditor createUITableEditor() { - return new Editor() { + @Override + protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { + return new FieldEditorComponentWrapper[]{ + new UIComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Field_Name")) { @Override - protected UICorrelationPane getParent() { - return correlationPane; + protected List items() { + return fieldList; } - }; - } + }, + new UITextFieldEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), + new CalculateComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Summary_Method")) }; - - this.setLayout(new BorderLayout()); - this.add(correlationPane, BorderLayout.CENTER); - - } - - - protected void populate(List list) { - correlationPane.populateBean(list); - } - - protected List 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; + protected Object[] createLine() { + return new String[]{StringUtils.EMPTY, StringUtils.EMPTY, Toolkit.i18nText("Fine-Design_Chart_Use_None")}; } } - - 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; - } - } - } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java index 3d5cdc9d99..fe6d7db76c 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java @@ -39,7 +39,7 @@ public class CellDataSeriesValueCorrelationPane extends AbstractCorrelationPane< } @Override - protected SeriesValueCorrelationDefinition covertTableModelListToTBean(List tableValues) { + protected void setTableModelListToTBean(List tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { List seriesValueFieldList = new ArrayList(); for (Object[] oneLine : tableValues) { @@ -51,9 +51,6 @@ public class CellDataSeriesValueCorrelationPane extends AbstractCorrelationPane< seriesValueFieldList.add(seriesValueField); } - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = new SeriesValueCorrelationDefinition(); seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFieldList); - - return seriesValueCorrelationDefinition; } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java index 82f0b7a886..4d5fbd3b40 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java @@ -74,25 +74,24 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } private class CustomFieldNamePane extends AbstractCustomFieldNamePane { - @Override - public void populateBean(SeriesValueCorrelationDefinition definition) { + protected List covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { List list = new ArrayList(); - for (SeriesValueField seriesValueField : definition.getSeriesValueFieldList()) { - Object[] array = new Object[3]; - array[0] = seriesValueField.getSeries().getFieldName(); - array[1] = seriesValueField.getValue().getFieldName(); - array[2] = DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction()); + for (SeriesValueField seriesValueField : seriesValueCorrelationDefinition.getSeriesValueFieldList()) { + Object[] array = new Object[]{ + seriesValueField.getSeries().getFieldName(), + seriesValueField.getValue().getFieldName(), + DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction()) + }; list.add(array); } - populate(list); + return list; } @Override - public void updateBean(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { - List list = update(); + protected void setTableModelListToTBean(List tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { List seriesValueFields = new ArrayList(); - for (Object[] line : list) { + for (Object[] line : tableValues) { ColumnField series = new ColumnField(GeneralUtils.objectToString(line[0])); ColumnField value = new ColumnField(GeneralUtils.objectToString(line[1])); value.setDataFunction(DataPaneHelper.getFunctionByName(GeneralUtils.objectToString(line[2]))); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java index c7b459e49f..5c468c424a 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java @@ -10,6 +10,8 @@ import javax.swing.JTable; import javax.swing.event.ChangeEvent; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.List; /** @@ -41,14 +43,19 @@ public abstract class AbstractCorrelationPane extends BasicBeanPane { correlationPane.populateBean(covertTBeanToTableModelList(ob)); } + @Override + public void updateBean(T ob) { + setTableModelListToTBean(correlationPane.updateBean(), ob); + } + @Override public T updateBean() { - return covertTableModelListToTBean(correlationPane.updateBean()); + return null; } protected abstract List covertTBeanToTableModelList(T t); - protected abstract T covertTableModelListToTBean(List tableValues); + protected abstract void setTableModelListToTBean(List tableValues, T t); private void initComps(String[] headers) { correlationPane = new UICorrelationPane(headers) { @@ -68,12 +75,27 @@ public abstract class AbstractCorrelationPane extends BasicBeanPane { } }; } + + protected ActionListener getAddButtonListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + tablePane.addLine(createLine()); + fireTargetChanged(); + } + }; + } }; this.setLayout(new BorderLayout()); this.add(correlationPane, BorderLayout.CENTER); } + protected Object[] createLine() { + return new Object[this.editorComponents.length]; + } + + private class Editor extends UITableEditor { private Component currentComponent; @@ -92,7 +114,7 @@ public abstract class AbstractCorrelationPane extends BasicBeanPane { currentEditorWrapper = AbstractCorrelationPane.this.editorComponents[column]; - currentComponent = currentEditorWrapper.createEditorComponent(correlationPane); + currentComponent = currentEditorWrapper.getTableCellEditorComponent(correlationPane, table, isSelected, row, column); currentEditorWrapper.setValue(currentComponent, value); return currentComponent; diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java new file mode 100644 index 0000000000..9b14fdf4d7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java @@ -0,0 +1,45 @@ +package com.fr.design.chartx.component.correlation; + +import com.fr.design.gui.frpane.UICorrelationPane; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; + +import javax.swing.JTable; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * Created by shine on 2019/6/10. + */ +public class CalculateComboBoxEditorComponent extends AbstractEditorComponent { + + public CalculateComboBoxEditorComponent(String header) { + super(header); + } + + @Override + public CalculateComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) { + + CalculateComboBox calculateComboBox = new CalculateComboBox(); + + calculateComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + parent.stopCellEditing(); + parent.fireTargetChanged(); + } + }); + return calculateComboBox; + } + + @Override + public Object getValue(CalculateComboBox calculateComboBox) { + return calculateComboBox.getSelectedItem(); + } + + @Override + public void setValue(CalculateComboBox calculateComboBox, Object o) { + + if (o != null) { + calculateComboBox.setSelectedItem(o); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java index 5181b466cc..af934c3256 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java @@ -2,6 +2,7 @@ package com.fr.design.chartx.component.correlation; import com.fr.design.gui.frpane.UICorrelationPane; +import javax.swing.JTable; import java.awt.Component; /** @@ -11,7 +12,7 @@ public interface FieldEditorComponentWrapper { String headerName(); - T createEditorComponent(UICorrelationPane parent); + T getTableCellEditorComponent(UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column); Object getValue(T t); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java index 71a0a59e51..7470ef62d2 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java @@ -7,6 +7,8 @@ import com.fr.design.event.UIObserverListener; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.frpane.UICorrelationPane; +import javax.swing.JTable; + /** * Created by shine on 2019/6/4. */ @@ -17,7 +19,7 @@ public class TinyFormulaPaneEditorComponent extends AbstractEditorComponent { + + public UIComboBoxEditorComponent(String header) { + super(header); + } + + protected List items() { + return new ArrayList(); + } + + @Override + public UIComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) { + UIComboBox uiComboBox = new UIComboBox(items().toArray()); + + uiComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + parent.stopCellEditing(); + parent.fireTargetChanged(); + UITable table = parent.getTable(); + Object object = table.getValueAt(row, 0); + if (object != null) { + table.setValueAt(object, row, 1); + } + } + }); + + return uiComboBox; + } + + + @Override + public Object getValue(UIComboBox uiComboBox) { + return uiComboBox.getSelectedItem(); + } + + @Override + public void setValue(UIComboBox uiComboBox, Object o) { + uiComboBox.getModel().setSelectedItem(o); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java new file mode 100644 index 0000000000..142cfb12b7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java @@ -0,0 +1,41 @@ +package com.fr.design.chartx.component.correlation; + +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.UICorrelationPane; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.general.GeneralUtils; + +import javax.swing.JTable; + +/** + * Created by shine on 2019/6/10. + */ +public class UITextFieldEditorComponent extends AbstractEditorComponent { + public UITextFieldEditorComponent(String header) { + super(header); + } + + @Override + public UITextField getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) { + UITextField uiTextField = new UITextField(); + + uiTextField.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + parent.fireTargetChanged(); + } + }); + + return uiTextField; + } + + @Override + public Object getValue(UITextField uiTextField) { + return uiTextField.getText(); + } + + @Override + public void setValue(UITextField uiTextField, Object o) { + uiTextField.setText(GeneralUtils.objectToString(o)); + } +} diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java index cc28497658..f918011dbd 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java @@ -75,23 +75,21 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane { @Override - public void populateBean(AbstractDataConfig ob) { - List customFields = ob.getCustomFields(); + protected List covertTBeanToTableModelList(AbstractDataConfig dataConfig) { + List customFields = dataConfig.getCustomFields(); List list = new ArrayList(); for (ExtendedField field : customFields) { String[] array = {field.getFieldName(), field.getCustomName(), DataPaneHelper.getFunctionString(field.getDataFunction())}; list.add(array); } - populate(list); + return list; } @Override - public void updateBean(AbstractDataConfig ob) { - List list = update(); - + protected void setTableModelListToTBean(List tableValues, AbstractDataConfig dataConfig) { List customFields = new ArrayList(); - for (Object[] line : list) { + for (Object[] line : tableValues) { ExtendedField field = new ExtendedField(Utils.objectToString(line[0])); field.setCustomName(Utils.objectToString(line[1])); if (line.length > 2) { @@ -100,8 +98,9 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox customFields.add(field); } - ob.setCustomFields(customFields); + dataConfig.setCustomFields(customFields); } + } } From 0dce6dd580fdc3deca9328f8290fc1f9663f8fac Mon Sep 17 00:00:00 2001 From: zheng Date: Mon, 10 Jun 2019 20:00:01 +0800 Subject: [PATCH 07/17] update --- .../chartx/component/AbstractCustomFieldComboBoxPane.java | 4 ++-- .../design/chartx/component/SeriesValueFieldComboBoxPane.java | 4 ++-- .../fr/extended/chart/ExtendedCustomFieldComboBoxPane.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java index 6f6172bc39..3376bd1930 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -130,7 +130,7 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< useFieldValuePane.updateBean(t); } - protected abstract class AbstractUseFieldValuePane extends FurtherBasicBeanPane { + protected abstract class AbstractUseFieldValuePane extends FurtherBasicBeanPane { private UIComboBox series; private UIComboBox value; private CalculateComboBox function; @@ -222,7 +222,7 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< } } - protected abstract class AbstractCustomFieldNamePane extends AbstractCorrelationPane { + protected abstract class AbstractCustomFieldNamePane extends AbstractCorrelationPane { @Override protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java index 4d5fbd3b40..30ae364b74 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java @@ -47,7 +47,7 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } } - private class UseFieldValuePane extends AbstractUseFieldValuePane { + private class UseFieldValuePane extends AbstractUseFieldValuePane { @Override public void populateBean(SeriesValueCorrelationDefinition ob) { @@ -73,7 +73,7 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan } } - private class CustomFieldNamePane extends AbstractCustomFieldNamePane { + private class CustomFieldNamePane extends AbstractCustomFieldNamePane { @Override protected List covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { List list = new ArrayList(); diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java index f918011dbd..108d4b605e 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java @@ -45,7 +45,7 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox } } - private class ExtendedUseFieldValuePane extends AbstractUseFieldValuePane { + private class ExtendedUseFieldValuePane extends AbstractUseFieldValuePane { @Override public void populateBean(AbstractDataConfig ob) { @@ -72,7 +72,7 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox } - private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane { + private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane { @Override protected List covertTBeanToTableModelList(AbstractDataConfig dataConfig) { From fff1a460b28bee2274cc8fd6c8c46186894fe036 Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 18 Jun 2019 15:08:17 +0800 Subject: [PATCH 08/17] =?UTF-8?q?=E6=9F=B1=E5=BD=A2=E5=9B=BE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=E5=B0=91=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E7=82=B9=20=E4=B8=8A=E6=AC=A1=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F=E5=87=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/AbstractCustomFieldComboBoxPane.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java index 3376bd1930..443fea07a7 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -58,6 +58,11 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< customFieldNamePane = createCustomFieldNamePane(); List> list = new ArrayList>(); list.add(useFieldValuePane); + list.add(paneWrapper()); + return list; + } + + private FurtherBasicBeanPane paneWrapper() { FurtherBasicBeanPane pane = new FurtherBasicBeanPane() { @Override public String title4PopupWindow() { @@ -82,8 +87,9 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< return null; } }; - list.add(pane); - return list; + pane.setLayout(new BorderLayout(0, 6)); + pane.add(customFieldNamePane, BorderLayout.CENTER); + return pane; } protected abstract AbstractUseFieldValuePane createUseFieldValuePane(); From b9fcc636b6cdf8ebdecedf959caee8fb714f7d0e Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 18 Jun 2019 15:38:35 +0800 Subject: [PATCH 09/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=8D=E4=BA=91?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E9=85=8D=E7=BD=AE=20=E6=9C=89?= =?UTF-8?q?=E5=8A=A9=E4=BA=8E=E7=90=86=E8=A7=A3=E8=AE=A1=E7=AE=97=E7=9A=84?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/chartx/WordCloudChartDataPane.java | 20 +++++ .../chartx/WordCloundChartDataPane.java | 20 ----- .../fields/AbstractDataSetFieldsPane.java | 7 ++ .../diff/MultiCategoryDataSetFieldsPane.java | 6 -- .../diff/WordCloudCellDataFieldsPane.java | 70 ++++++++++++++++++ .../diff/WordCloudDataSetFieldsPane.java | 74 +++++++++++++++++++ ...WordCloudIndependentVanChartInterface.java | 21 ++---- 7 files changed, 177 insertions(+), 41 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java delete mode 100644 designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudCellDataFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java new file mode 100644 index 0000000000..6773081527 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java @@ -0,0 +1,20 @@ +package com.fr.design.chartx; + +import com.fr.design.chartx.fields.diff.WordCloudCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.WordCloudDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +/** + * Created by shine on 2019/5/22. + */ +public class WordCloudChartDataPane extends MultiCategoryChartDataPane { + public WordCloudChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new WordCloudDataSetFieldsPane(), new WordCloudCellDataFieldsPane()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java deleted file mode 100644 index 2f3bd39a00..0000000000 --- a/designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java +++ /dev/null @@ -1,20 +0,0 @@ -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()); - } -} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java index 84c8401c10..1b0efcd5c4 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java @@ -12,6 +12,7 @@ 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 com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -139,4 +140,10 @@ public abstract class AbstractDataSetFieldsPane { + + private UITextField name; + private TinyFormulaPane wordName; + private TinyFormulaPane wordValue; + + @Override + protected void initComponents() { + name = new UITextField(); + wordName = new TinyFormulaPane(); + wordValue = new TinyFormulaPane(); + + super.initComponents(); + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Value") + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{ + wordName, + wordValue + }; + } + + @Override + protected Component[] fieldComponents() { + return new Component[]{ + name, + wordName, + wordValue + }; + } + + @Override + public void populateBean(WordCloudColumnFieldCollection ob) { + name.setText(ob.getTargetName()); + populateField(wordName, ob.getWordName()); + populateField(wordValue, ob.getWordValue()); + } + + @Override + public WordCloudColumnFieldCollection updateBean() { + WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection(); + result.setTargetName(name.getText()); + updateField(wordName, result.getWordName()); + populateField(wordValue, result.getWordValue()); + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java new file mode 100644 index 0000000000..77c529ea5a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java @@ -0,0 +1,74 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.WordCloudColumnFieldCollection; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; + +import java.awt.Component; + +/** + * Created by shine on 2019/6/18. + */ +public class WordCloudDataSetFieldsPane extends AbstractDataSetFieldsPane { + private UITextField name; + private UIComboBox wordName; + private UIComboBox wordValue; + private CalculateComboBox calculateCombox; + + @Override + protected void initComponents() { + name = new UITextField(); + wordName = new UIComboBox(); + wordValue = new UIComboBox(); + calculateCombox = new CalculateComboBox(); + + super.initComponents(); + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Value"), + Toolkit.i18nText("Fine-Design_Chart_Summary_Method") + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{ + wordName, + wordValue + }; + } + + @Override + protected Component[] fieldComponents() { + return new Component[]{ + name, + wordName, + wordValue, + calculateCombox + }; + } + + @Override + public void populateBean(WordCloudColumnFieldCollection ob) { + name.setText(ob.getTargetName()); + populateField(wordName, ob.getWordName()); + populateFunctionField(wordValue, calculateCombox, ob.getWordValue()); + } + + @Override + public WordCloudColumnFieldCollection updateBean() { + WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection(); + result.setTargetName(name.getText()); + updateField(wordName, result.getWordName()); + updateFunctionField(wordValue, calculateCombox, result.getWordValue()); + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java index e6e89c0d93..1b270b90b7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java @@ -3,23 +3,19 @@ package com.fr.van.chart.wordcloud.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.WordCloudChartDataPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; -import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; -import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; - import com.fr.plugin.chart.base.VanChartConstants; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; -import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotReportDataContentPane; -import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotTableDataContentPane; import com.fr.van.chart.wordcloud.designer.other.VanChartWordCloudConditionPane; import com.fr.van.chart.wordcloud.designer.style.VanChartWordCloudSeriesPane; import com.fr.van.chart.wordcloud.designer.type.VanChartWordCloudTypePane; @@ -50,16 +46,6 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa return "com/fr/design/images/form/toolbar/wordcloud.png"; } - @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { - return new WordCloudPlotReportDataContentPane(); - } - - @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { - return new WordCloudPlotTableDataContentPane(); - } - @Override public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartWordCloudSeriesPane(parent, plot); @@ -104,4 +90,9 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa public String getPlotTypeTitle4PopupWindow(){ return VanChartWordCloudTypePane.TITLE; } + + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new WordCloudChartDataPane(listener); + } } From a4bff1b769c788264855fb619a1562fb2c71a39f Mon Sep 17 00:00:00 2001 From: zheng Date: Wed, 19 Jun 2019 13:29:11 +0800 Subject: [PATCH 10/17] =?UTF-8?q?=E5=A4=9A=E5=B1=82=E9=A5=BC=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/chartx/MultiPieChartDataPane.java | 21 +++ .../component/AbstractMultiComponentPane.java | 2 +- ...stractMultiComponentPaneWithUISpinner.java | 150 ++++++++++++++++++ .../chartx/component/MultiComboBoxPane.java | 10 +- .../MultiComboBoxPaneWithUISpinner.java | 40 +++++ .../MultiTinyFormulaPaneWithUISpinner.java | 25 +++ .../diff/MultiCategoryDataSetFieldsPane.java | 6 + .../diff/MultiPieCellDataFieldsPane.java | 67 ++++++++ .../diff/MultiPieDataSetFieldsPane.java | 94 +++++++++++ .../MultiPieIndependentVanChartInterface.java | 15 +- 10 files changed, 417 insertions(+), 13 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java new file mode 100644 index 0000000000..952bca3cdc --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java @@ -0,0 +1,21 @@ +package com.fr.design.chartx; + +import com.fr.design.chartx.fields.diff.MultiPieCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.MultiPieDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieChartDataPane extends MultiCategoryChartDataPane { + + public MultiPieChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new MultiPieDataSetFieldsPane(), new MultiPieCellDataFieldsPane()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java index 008a7d91cb..2a8154d7bb 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java @@ -21,7 +21,7 @@ import java.util.List; /** * Created by shine on 2019/4/10. - * 一列组件 可增可删 + * 一列组件 可增可删,通过JComponent后面的加减button增删。 */ public abstract class AbstractMultiComponentPane extends JPanel { private static final int COM_W = 96; diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java new file mode 100644 index 0000000000..b24743c762 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java @@ -0,0 +1,150 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + * 一列组件 可增可删,通过UISpinner增删。 + */ +public abstract class AbstractMultiComponentPaneWithUISpinner extends JPanel { + + private UISpinner levelNumSpinner; + + private List levelComponentList = new ArrayList(); + + private JPanel levelPane; + + private int currentNum = 3; + + public AbstractMultiComponentPaneWithUISpinner() { + initComps(); + } + + public List getComponentList() { + return levelComponentList; + } + + protected abstract T createJComponent(); + + protected abstract void populateField(T component, ColumnField field); + + protected abstract void updateField(T component, ColumnField field); + + protected void initComps() { + + this.setLayout(new BorderLayout(0, 6)); + + levelNumSpinner = new UISpinner(1, 15, 1, currentNum) { + @Override + protected void fireStateChanged() { + //先处理自身的空间布局 + refreshLevelPane(); + //然后更新数据 + super.fireStateChanged(); + } + + @Override + public void setTextFieldValue(double value) { + //如果为0,则没有改变值 + if (value == 0) { + return; + } + super.setTextFieldValue(value); + } + }; + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level_Number")), levelNumSpinner}, + }; + + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(components, new double[]{TableLayout.PREFERRED}, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6); + + this.add(northPane, BorderLayout.NORTH); + + initLevelPane(); + } + + private void initLevelPane() { + double[] rows = new double[currentNum]; + + Component[][] components = new Component[currentNum][2]; + + List newList = new ArrayList(); + + int maxSize = levelComponentList.size(); + for (int i = 0; i < currentNum; i++) { + rows[i] = TableLayout.PREFERRED; + T component = i < maxSize ? levelComponentList.get(i) : createJComponent(); + newList.add(component); + + components[i] = new Component[]{ + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level") + String.valueOf(i + 1)), + component + }; + } + + levelComponentList = newList; + + levelPane = TableLayoutHelper.createGapTableLayoutPane(components, rows, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6); + + this.add(levelPane, BorderLayout.CENTER); + } + + private void refreshLevelPane() { + if (levelNumSpinner == null) { + return; + } + + int newNum = (int) levelNumSpinner.getValue(); + + if (newNum != currentNum) { + currentNum = newNum; + this.remove(levelPane); + this.initLevelPane(); + } + + refreshPane(); + } + + private void refreshPane() { + this.validate(); + this.repaint(); + this.revalidate(); + } + + public void populate(List categoryList) { + int len = categoryList.size(); + levelNumSpinner.setValue(len); + + refreshLevelPane(); + + for (int i = 0; i < len; i++) { + ColumnField columnField = categoryList.get(i); + T component = levelComponentList.get(i); + populateField(component, columnField); + } + } + + public void update(List categoryList) { + categoryList.clear(); + + for (T comboBox : levelComponentList) { + ColumnField temp = new ColumnField(); + categoryList.add(temp); + updateField(comboBox, temp); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java index 37a110b7d4..f1716a0ae0 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java @@ -5,10 +5,18 @@ import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.extended.chart.UIComboBoxWithNone; +import java.util.ArrayList; +import java.util.List; + /** * Created by shine on 2019/4/12. */ public class MultiComboBoxPane extends AbstractMultiComponentPane { + private List currentBoxItems = new ArrayList(); + + public void setCurrentBoxItems(List currentBoxItems) { + this.currentBoxItems = currentBoxItems; + } @Override protected UIComboBox createFirstFieldComponent() { @@ -17,7 +25,7 @@ public class MultiComboBoxPane extends AbstractMultiComponentPane { @Override protected UIComboBox createOtherFieldComponent() { - return new UIComboBox(); + return new UIComboBox(currentBoxItems.toArray(new Object[currentBoxItems.size()])); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java new file mode 100644 index 0000000000..8b20768e2d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java @@ -0,0 +1,40 @@ +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 java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiComboBoxPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner { + private List currentBoxList = new ArrayList(); + + @Override + protected void initComps() { + currentBoxList = new ArrayList(); + super.initComps(); + } + + public void setCurrentBoxList(List currentBoxList) { + this.currentBoxList = currentBoxList; + } + + @Override + protected UIComboBox createJComponent() { + return new UIComboBox(currentBoxList.toArray(new Object[currentBoxList.size()])); + } + + @Override + protected void populateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.updateField(component, field); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java new file mode 100644 index 0000000000..e3bbf4b848 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java @@ -0,0 +1,25 @@ +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/6/19. + */ +public class MultiTinyFormulaPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner { + @Override + protected TinyFormulaPane createJComponent() { + 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); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java index 17fcfb2ba3..1abe2b1849 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -39,6 +39,12 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer return initMultiCategoryPane(); } + @Override + public void refreshBoxListWithSelectTableData(List columnNameList) { + super.refreshBoxListWithSelectTableData(columnNameList); + multiCategoryPane.setCurrentBoxItems(columnNameList); + } + @Override public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) { List categoryList = multiCategoryColumnFieldCollection.getCategoryList(); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java new file mode 100644 index 0000000000..950f49401a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java @@ -0,0 +1,67 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; +import com.fr.design.chartx.component.MultiTinyFormulaPaneWithUISpinner; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private UITextField nameField;//指标名称 + + private MultiTinyFormulaPaneWithUISpinner levelPane; + + private TinyFormulaPane value; + + @Override + protected void initComponents() { + nameField = new UITextField(); + levelPane = new MultiTinyFormulaPaneWithUISpinner(); + value = new TinyFormulaPane(); + super.initComponents(); + } + + @Override + protected JPanel createNorthPane() { + return levelPane; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{ + value + }; + } + + @Override + public void populateBean(MultiPieColumnFieldCollection ob) { + nameField.setText(ob.getTargetName()); + levelPane.populate(ob.getLevels()); + populateField(value, ob.getValue()); + } + + @Override + public MultiPieColumnFieldCollection updateBean() { + MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection(); + + result.setTargetName(nameField.getText()); + levelPane.update(result.getLevels()); + updateField(value, result.getValue()); + + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java new file mode 100644 index 0000000000..2a299ba6e9 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java @@ -0,0 +1,94 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; +import com.fr.design.chartx.component.MultiComboBoxPaneWithUISpinner; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; + +import javax.swing.JPanel; +import java.awt.Component; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieDataSetFieldsPane extends AbstractDataSetFieldsPane { + private UITextField nameField; + + private MultiComboBoxPaneWithUISpinner levelComboBoxPane; + + private UIComboBox value; + + private CalculateComboBox function; + + @Override + protected void initComponents() { + nameField = new UITextField(); + levelComboBoxPane = new MultiComboBoxPaneWithUISpinner(); + value = new UIComboBox(); + function = new CalculateComboBox(); + super.initComponents(); + } + + @Override + protected JPanel createNorthPane() { + return levelComboBoxPane; + } + + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + Toolkit.i18nText("Fine-Design_Chart_Summary_Method") + }; + } + + @Override + protected Component[] fieldComponents() { + return new UIComboBox[]{ + value, + function + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + List list = levelComboBoxPane.getComponentList(); + + int len = list.size(); + UIComboBox[] result = new UIComboBox[len + 1]; + for (int i = 0; i < len; i++) { + result[i] = list.get(i); + } + result[len] = value; + + return result; + } + + @Override + public void refreshBoxListWithSelectTableData(List columnNameList) { + super.refreshBoxListWithSelectTableData(columnNameList); + levelComboBoxPane.setCurrentBoxList(columnNameList); + } + + @Override + public void populateBean(MultiPieColumnFieldCollection ob) { + levelComboBoxPane.populate(ob.getLevels()); + populateFunctionField(value, function, ob.getValue()); + } + + @Override + public MultiPieColumnFieldCollection updateBean() { + MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection(); + + levelComboBoxPane.update(result.getLevels()); + + updateFunctionField(value, function, result.getValue()); + + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java index e25e55b064..06f0b0f75f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java @@ -2,14 +2,12 @@ package com.fr.van.chart.multilayer; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.MultiPieChartDataPane; 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.data.report.AbstractReportDataContentPane; -import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; -import com.fr.van.chart.multilayer.data.MultiPiePlotReportDataContentPane; -import com.fr.van.chart.multilayer.data.MultiPiePlotTableDataContentPane; import com.fr.van.chart.multilayer.other.VanChartMultiPieConditionPane; import com.fr.van.chart.multilayer.style.VanChartMultiPieSeriesPane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; @@ -29,13 +27,8 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan } @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ - return new MultiPiePlotTableDataContentPane(parent); - } - - @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ - return new MultiPiePlotReportDataContentPane(parent); + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new MultiPieChartDataPane(listener); } public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ From bbe4791fae69aeba83d72c93cd382bde27a8b48b Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 25 Jun 2019 15:29:48 +0800 Subject: [PATCH 11/17] =?UTF-8?q?CHART-9141=20se.cellCC=20&&=20floatCC=20?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=9B=BE=E8=A1=A8=E7=BB=9F=E4=B8=80=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20=E5=88=A0=E9=99=A4BaseChart=20=E5=90=84resultProces?= =?UTF-8?q?sor=20=E5=88=9D=E6=AD=A5=E7=9A=84=E6=B5=81=E7=A8=8B=E8=B5=B0?= =?UTF-8?q?=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/chart/MiddleChartComponent.java | 15 +- .../fr/design/ChartTypeInterfaceManager.java | 3 +- .../com/fr/design/chart/ChartTypePane.java | 12 +- .../fr/design/chart/gui/ChartComponent.java | 4 +- .../design/chart/gui/ChartWidgetOption.java | 6 +- .../active/action/ChartComponentAction.java | 7 +- .../impl/ChartHyperPoplinkPane.java | 5 +- .../chart/gui/ChartTypeButtonPane.java | 6 +- .../mainframe/chart/gui/ChartTypePane.java | 41 +----- .../chart/gui/type/AbstractChartTypePane.java | 3 +- .../fr/design/module/ChartPreStylePane.java | 13 +- .../fr/extended/chart/ExtendedTypePane.java | 3 +- .../java/com/fr/poly/PolyComponentsBar.java | 9 +- .../src/main/java/com/fr/poly/PolyUtils.java | 24 +--- .../com/fr/poly/creator/ChartBlockEditor.java | 133 ------------------ .../poly/hanlder/PolyDesignerDropTarget.java | 6 +- 16 files changed, 50 insertions(+), 240 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java b/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java index 9d16d6787a..025c669bc5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java +++ b/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java @@ -1,12 +1,11 @@ package com.fr.design.gui.chart; -import javax.swing.JComponent; - -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; -import com.fr.stable.core.PropertyChangeAdapter; +import com.fr.chartx.attr.XChart; import com.fr.stable.core.PropertyChangeListener; +import javax.swing.JComponent; + /** * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-7-10 上午09:19:36 @@ -18,8 +17,8 @@ public abstract class MiddleChartComponent extends JComponent { public abstract BaseChartCollection update(); public abstract void reset(); - - public abstract BaseChart getEditingChart(); - - public abstract void addStopEditingListener(PropertyChangeListener list); + + public abstract XChart getEditingChart(); + + public abstract void addStopEditingListener(PropertyChangeListener list); } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index 1255d87d5a..a188737c0a 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -5,6 +5,7 @@ import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.XChart; import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.IndependentChartUIProvider; @@ -161,7 +162,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr int index = 0; for (ChartInternationalNameContentBean bean : typeName) { String plotID = bean.getPlotID(); - Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); + XChart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(plotID)) { continue; } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index d914a81e8b..ed1e2656e0 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -11,6 +11,7 @@ import com.fr.chart.chartattr.ChartIcon; import com.fr.chart.chartattr.MapPlot; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.XChart; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; @@ -36,12 +37,13 @@ public class ChartTypePane extends ChartCommonWizardPane { private static final long serialVersionUID = -1175602484968520546L; private ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstanceWithCheck().getAllChartBaseNames(); + //todo@shinerefactor 这个页面所有强转Chart的地方都要处理一下 private Chart[][] charts4Icon = null; { charts4Icon = new Chart[this.typeName.length][]; for (int i = 0; i < this.typeName.length; i++) { - Chart[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getPlotID()); + XChart[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getPlotID()); int rowChartsCount = rowCharts.length; charts4Icon[i] = new Chart[rowChartsCount]; for (int j = 0; j < rowChartsCount; j++) { @@ -145,9 +147,9 @@ public class ChartTypePane extends ChartCommonWizardPane { int subIndex = 0; for (int i = 0; i < typeName.length; i++) { - Chart[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(typeName[i].getPlotID()); + XChart[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(typeName[i].getPlotID()); for (int j = 0; j < charts.length; j++) { - if (charts[j].getPlot().match4GUI(plot)) { + if (((Chart) charts[j]).getPlot().match4GUI(plot)) { mainIndex = i; subIndex = j; // 一旦匹配 立马中断 @@ -162,7 +164,7 @@ public class ChartTypePane extends ChartCommonWizardPane { public void update(Chart oldChart) { String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID(); - Chart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; + Chart chart = (Chart) ChartTypeManager.getInstanceWithCheck().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; if(chart.getPlot() != null){ if(chart.getPlot() instanceof MapPlot && !supportMap()){ JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Not_Supported")); @@ -191,7 +193,7 @@ public class ChartTypePane extends ChartCommonWizardPane { Chart chart4Update = cc.getSelectedChart(); if (chart4Update == null) { String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID(); - Chart chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; + Chart chart = (Chart) ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; try{ chart4Update = (Chart)chart.clone(); cc.addChart(chart4Update); diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index 769218c7fa..85fcaaeff4 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -1,7 +1,6 @@ package com.fr.design.chart.gui; import com.fr.base.ScreenResolution; -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartGlyph; import com.fr.base.chart.chartdata.CallbackEvent; @@ -10,6 +9,7 @@ import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartglyph.AxisGlyph; +import com.fr.chartx.attr.XChart; import com.fr.design.chart.gui.active.ActiveGlyph; import com.fr.design.chart.gui.active.ChartActiveGlyph; import com.fr.design.file.HistoryTemplateListPane; @@ -162,7 +162,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene return (this.chartCollection4Design == null) ? 0 : this.chartCollection4Design.getChartCount(); } - public BaseChart getEditingChart() { + public XChart getEditingChart() { return editingChart; } diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java index f621c545f5..d52dcbfde9 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java @@ -1,7 +1,7 @@ package com.fr.design.chart.gui; -import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.XChart; import com.fr.design.gui.core.WidgetOption; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.Widget; @@ -38,8 +38,8 @@ public class ChartWidgetOption extends WidgetOption { Class clz = widgetClass(); try { ChartEditor widget = clz.newInstance(); - Chart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.chartID)[0]; - widget.addChart((Chart) chart.clone()); + XChart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.chartID)[0]; + widget.addChart((XChart) chart.clone()); return widget; } catch (InstantiationException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java index a27d2387a1..9bedc637d3 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java @@ -1,11 +1,10 @@ package com.fr.design.chart.gui.active.action; -import com.fr.base.chart.BaseChart; import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartglyph.AxisGlyph; -import com.fr.design.chart.gui.ChartComponent; import com.fr.design.actions.UpdateAction; +import com.fr.design.chart.gui.ChartComponent; /** * Created by IntelliJ IDEA. @@ -29,10 +28,6 @@ public abstract class ChartComponentAction extends UpdateAction { chartComponent.repaint(); } - public BaseChart getEditingChart() { - return chartComponent.getEditingChart(); - } - public ChartCollection getChartCollection() { return chartComponent.getChartCollection(); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java index c3db9b7ef3..01c5a156e5 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java @@ -6,6 +6,7 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.web.ChartHyperPoplink; +import com.fr.chartx.attr.XChart; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.hyperlink.AbstractHyperLinkPane; @@ -66,10 +67,10 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane implemen if (editingCollection != null) { //点击添加按钮,则会触发切换状态 - Chart chart = editingCollection.getChangeStateNewChart(); + XChart chart = editingCollection.getChangeStateNewChart(); try { - Chart newChart = (Chart) chart.clone(); + XChart newChart = (XChart) chart.clone(); editingCollection.addNamedChart(name, newChart); } catch (CloneNotSupportedException e1) { FineLoggerFactory.getLogger().error("Error in Clone"); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 33c9a41dcc..56547842cf 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -41,30 +41,6 @@ public class ChartTypePane extends AbstractChartAttrPane{ private ChartTypeButtonPane buttonPane; private ChartEditPane editPane; private ChartCollection editingCollection; - private PaneState paneState = new PaneState(); - - private class PaneState{ - //记录面板所处状态 - private SwitchState paneState = SwitchState.DEFAULT; - //记录当前面板是谁在使用切换状态 - private String chartID = StringUtils.EMPTY; - - public SwitchState getPaneState() { - return paneState; - } - - public void setPaneState(SwitchState paneState) { - this.paneState = paneState; - } - - public String getChartID() { - return chartID; - } - - public void setChartID(String chartID) { - this.chartID = chartID; - } - } @Override protected JPanel createContentPane() { @@ -337,22 +313,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void relayoutChartTypePane(ChartCollection collection){ - if (needRelayout(collection)) { - chartTypeComBox.relayout(collection); - //设置面板切换状态 - updatePaneState(collection); - } - } - - private void updatePaneState(ChartCollection collection) { - paneState.setChartID(collection.getRepresentChartID()); - paneState.setPaneState(collection.getState()); - } - - // TODO: 2016/11/17 因为现在populate面板时会重新构造面板,所以每次都需要重构 - private boolean needRelayout(ChartCollection collection) { - /*return paneState.getChartID() != collection.getRepresentChartID() || paneState.getPaneState() != collection.getState();*/ - return true; + chartTypeComBox.relayout(collection); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java index 27f4266820..46447495d8 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java @@ -17,6 +17,7 @@ import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Title; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.charttypes.BarIndependentChart; +import com.fr.chartx.attr.XChart; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane; import com.fr.design.gui.ilable.BoldFontTextLabel; @@ -616,7 +617,7 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ return typePane; } - public Chart getDefaultChart() { + public XChart getDefaultChart() { return BarIndependentChart.barChartTypes[0]; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java index 2b8f6ea321..5bd4c38978 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java @@ -5,7 +5,6 @@ import com.fr.chart.base.ChartUtils; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.event.UIObserver; @@ -13,7 +12,6 @@ import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.layout.FRGUIPaneFactory; - import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; @@ -30,7 +28,8 @@ public class ChartPreStylePane extends BasicBeanPane { private ChartPreFillStylePane fillStylePane; private ChartComponent chartComponent; - + private Bar2DPlot demoPlot; + public ChartPreStylePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -50,8 +49,9 @@ public class ChartPreStylePane extends BasicBeanPane { this.add(boxPane, BorderLayout.CENTER); ChartCollection cc = new ChartCollection(); - cc.addChart(new Chart(new Bar2DPlot())); - + demoPlot = new Bar2DPlot(); + cc.addChart(new Chart(demoPlot)); + chartComponent = new ChartComponent(); chartComponent.populate(cc); chartComponent.setPreferredSize(new Dimension(400, 300)); @@ -82,8 +82,7 @@ public class ChartPreStylePane extends BasicBeanPane { private void refreshWhenStyleChange(ChartColorMatching preStyle) { if(chartComponent != null) { - Plot plot = (Plot) chartComponent.getEditingChart().getBasePlot(); - plot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle)); + demoPlot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle)); chartComponent.reset(); } } diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java index 9e5ddd7b48..331e511640 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java @@ -2,6 +2,7 @@ package com.fr.extended.chart; import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.XChart; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; @@ -65,7 +66,7 @@ public class ExtendedTypePane extends AbstractChartType } @Override - public Chart getDefaultChart() { + public XChart getDefaultChart() { return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0]; } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java b/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java index 564a3ae6a2..097528c685 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java @@ -1,7 +1,7 @@ package com.fr.poly; import com.fr.base.BaseUtils; -import com.fr.base.chart.BaseChart; +import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartGetter; import com.fr.base.chart.BaseChartNameID; import com.fr.base.vcs.DesignerMode; @@ -64,9 +64,10 @@ public class PolyComponentsBar extends JToolBar { ); this.add(serIcons[0]); for (int i = 0; i < typeLen; i++) { - BaseChart[] rowChart = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID()); - String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(typeName[i].getPlotID()); - serIcons[i + 1] = new SerIcon(rowChart[0], InterProviderFactory.getProvider().getLocText(typeName[i].getName()), iconPath); + String chartID = typeName[i].getPlotID(); + String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID); + BaseChartCollection chartCollection = BaseChartGetter.getStaticChartCollection(chartID); + serIcons[i + 1] = new SerIcon(chartCollection, InterProviderFactory.getProvider().getLocText(typeName[i].getName()), iconPath); this.add(serIcons[i + 1]); } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyUtils.java b/designer-realize/src/main/java/com/fr/poly/PolyUtils.java index 330949fb34..e297a69ad4 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyUtils.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyUtils.java @@ -4,9 +4,7 @@ package com.fr.poly; import com.fr.base.ScreenResolution; -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; -import com.fr.base.chart.BasePlot; import com.fr.log.FineLoggerFactory; import com.fr.poly.creator.BlockCreator; import com.fr.poly.creator.ChartBlockCreator; @@ -15,7 +13,6 @@ import com.fr.poly.model.AddedData; import com.fr.report.poly.PolyChartBlock; import com.fr.report.poly.PolyECBlock; import com.fr.report.poly.TemplateBlock; -import com.fr.stable.bridge.StableFactory; import java.awt.Point; import java.lang.reflect.Constructor; @@ -53,10 +50,8 @@ public class PolyUtils { public static BlockCreator createCreator(Class clazz) { return createCreator(blockGenerate(clazz)); } - - public static BlockCreator createCreator(BaseChart chart) { - BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG); - cc.addChart(chart); + + public static BlockCreator createCreator(BaseChartCollection cc) { TemplateBlock block = new PolyChartBlock(cc); return createCreator(block); } @@ -66,20 +61,7 @@ public class PolyUtils { try { block = (TemplateBlock) clazz.newInstance(); } catch (Exception e) { - try { - BasePlot plot = (BasePlot)clazz.newInstance(); - BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG); - - BaseChart chart = (BaseChart)StableFactory.createXmlObject(BaseChart.XML_TAG); - chart.initChart(plot); - cc.addChart(chart); - - block = new PolyChartBlock(cc); - } catch (InstantiationException e1) { - FineLoggerFactory.getLogger().error(e1.getMessage(), e1); - } catch (IllegalAccessException e1) { - FineLoggerFactory.getLogger().error(e1.getMessage(), e1); - } + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return block; } diff --git a/designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java b/designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java index 006c7e48db..bf72884bcb 100644 --- a/designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java +++ b/designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java @@ -3,25 +3,15 @@ */ package com.fr.poly.creator; -import com.fr.base.BaseUtils; -import com.fr.base.ScreenResolution; -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; -import com.fr.base.chart.BaseChartGetter; -import com.fr.base.chart.BaseChartNameID; import com.fr.base.vcs.DesignerMode; -import com.fr.design.border.UIRoundedBorder; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.mainframe.EastRegionContainerPane; -import com.fr.design.mainframe.JSliderPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.module.DesignModuleFactory; -import com.fr.design.utils.gui.LayoutUtils; -import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.poly.PolyConstants; import com.fr.poly.PolyDesigner; import com.fr.poly.PolyDesigner.SelectionType; @@ -31,13 +21,8 @@ import com.fr.report.poly.PolyChartBlock; import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JPanel; -import javax.swing.JToggleButton; -import javax.swing.border.Border; import java.awt.Color; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Rectangle; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -48,31 +33,10 @@ import java.awt.event.MouseEvent; */ // 图片的命名必须符合下面的代码规范(chart类别+序号的方式) 不然读取不到指定图片 public class ChartBlockEditor extends BlockEditor { - private static final int BOUND_OFF = 21; - private static Border buttonBorder; - private static String[][] chartsNames; - private static BaseChartNameID[] typeName = BaseChartGetter.getStaticAllChartBaseNames(); - private int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes); - - static { - buttonBorder = new UIRoundedBorder(new Color(149, 149, 149), 1, 5); - chartsNames = new String[typeName.length][]; - for (int i = 0; i < typeName.length; i++) { - BaseChart[] rowCharts = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID()); - chartsNames[i] = new String[rowCharts.length]; - for (int j = 0; j < rowCharts.length; j++) { - chartsNames[i][j] = rowCharts[j].getChartName(); - } - } - } - - private ChartButton[] chartButtons = null; public ChartBlockEditor(PolyDesigner designer, ChartBlockCreator creator) { super(designer, creator); this.resolution = creator.resolution; - //shine:和产品商量后决定把最上面一排切换按钮去掉 -// this.initNorthBarComponent(); } @@ -80,33 +44,6 @@ public class ChartBlockEditor extends BlockEditor Date: Tue, 25 Jun 2019 19:42:41 +0800 Subject: [PATCH 12/17] xchart rename to chartProvider --- .../java/com/fr/design/gui/chart/MiddleChartComponent.java | 4 ++-- .../main/java/com/fr/design/ChartTypeInterfaceManager.java | 4 ++-- .../src/main/java/com/fr/design/chart/ChartTypePane.java | 6 +++--- .../main/java/com/fr/design/chart/gui/ChartComponent.java | 4 ++-- .../java/com/fr/design/chart/gui/ChartWidgetOption.java | 6 +++--- .../series/SeriesCondition/impl/ChartHyperPoplinkPane.java | 6 +++--- .../fr/design/mainframe/chart/gui/ChartTypeButtonPane.java | 6 +++--- .../mainframe/chart/gui/type/AbstractChartTypePane.java | 4 ++-- .../main/java/com/fr/extended/chart/ExtendedTypePane.java | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java b/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java index 025c669bc5..01d9e7dd32 100644 --- a/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java +++ b/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java @@ -1,7 +1,7 @@ package com.fr.design.gui.chart; import com.fr.base.chart.BaseChartCollection; -import com.fr.chartx.attr.XChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.stable.core.PropertyChangeListener; import javax.swing.JComponent; @@ -18,7 +18,7 @@ public abstract class MiddleChartComponent extends JComponent { public abstract void reset(); - public abstract XChart getEditingChart(); + public abstract ChartProvider getEditingChart(); public abstract void addStopEditingListener(PropertyChangeListener list); } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index a188737c0a..72585ade8e 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -5,7 +5,7 @@ import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; -import com.fr.chartx.attr.XChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.IndependentChartUIProvider; @@ -162,7 +162,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr int index = 0; for (ChartInternationalNameContentBean bean : typeName) { String plotID = bean.getPlotID(); - XChart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); + ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(plotID)) { continue; } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index ed1e2656e0..2a19072e08 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -11,7 +11,7 @@ import com.fr.chart.chartattr.ChartIcon; import com.fr.chart.chartattr.MapPlot; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; -import com.fr.chartx.attr.XChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; @@ -43,7 +43,7 @@ public class ChartTypePane extends ChartCommonWizardPane { { charts4Icon = new Chart[this.typeName.length][]; for (int i = 0; i < this.typeName.length; i++) { - XChart[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getPlotID()); + ChartProvider[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getPlotID()); int rowChartsCount = rowCharts.length; charts4Icon[i] = new Chart[rowChartsCount]; for (int j = 0; j < rowChartsCount; j++) { @@ -147,7 +147,7 @@ public class ChartTypePane extends ChartCommonWizardPane { int subIndex = 0; for (int i = 0; i < typeName.length; i++) { - XChart[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(typeName[i].getPlotID()); + ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(typeName[i].getPlotID()); for (int j = 0; j < charts.length; j++) { if (((Chart) charts[j]).getPlot().match4GUI(plot)) { mainIndex = i; diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index 85fcaaeff4..31baca0715 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -9,7 +9,7 @@ import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartglyph.AxisGlyph; -import com.fr.chartx.attr.XChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.chart.gui.active.ActiveGlyph; import com.fr.design.chart.gui.active.ChartActiveGlyph; import com.fr.design.file.HistoryTemplateListPane; @@ -162,7 +162,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene return (this.chartCollection4Design == null) ? 0 : this.chartCollection4Design.getChartCount(); } - public XChart getEditingChart() { + public ChartProvider getEditingChart() { return editingChart; } diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java index d52dcbfde9..eb36aadea1 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java @@ -1,7 +1,7 @@ package com.fr.design.chart.gui; import com.fr.chart.charttypes.ChartTypeManager; -import com.fr.chartx.attr.XChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.gui.core.WidgetOption; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.Widget; @@ -38,8 +38,8 @@ public class ChartWidgetOption extends WidgetOption { Class clz = widgetClass(); try { ChartEditor widget = clz.newInstance(); - XChart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.chartID)[0]; - widget.addChart((XChart) chart.clone()); + ChartProvider chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.chartID)[0]; + widget.addChart((ChartProvider) chart.clone()); return widget; } catch (InstantiationException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java index 01c5a156e5..74c78ff2d8 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java @@ -6,7 +6,7 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.web.ChartHyperPoplink; -import com.fr.chartx.attr.XChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.hyperlink.AbstractHyperLinkPane; @@ -67,10 +67,10 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane implemen if (editingCollection != null) { //点击添加按钮,则会触发切换状态 - XChart chart = editingCollection.getChangeStateNewChart(); + ChartProvider chart = editingCollection.getChangeStateNewChart(); try { - XChart newChart = (XChart) chart.clone(); + ChartProvider newChart = (ChartProvider) chart.clone(); editingCollection.addNamedChart(name, newChart); } catch (CloneNotSupportedException e1) { FineLoggerFactory.getLogger().error("Error in Clone"); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java index 46447495d8..47de03b569 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java @@ -17,7 +17,7 @@ import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Title; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.charttypes.BarIndependentChart; -import com.fr.chartx.attr.XChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane; import com.fr.design.gui.ilable.BoldFontTextLabel; @@ -617,7 +617,7 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ return typePane; } - public XChart getDefaultChart() { + public ChartProvider getDefaultChart() { return BarIndependentChart.barChartTypes[0]; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java index 331e511640..ccc39b525e 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java @@ -2,7 +2,7 @@ package com.fr.extended.chart; import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.ChartTypeManager; -import com.fr.chartx.attr.XChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; @@ -66,7 +66,7 @@ public class ExtendedTypePane extends AbstractChartType } @Override - public XChart getDefaultChart() { + public ChartProvider getDefaultChart() { return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0]; } From eba5d13d8fc2410224e9b3e6856c1856d29f4efb Mon Sep 17 00:00:00 2001 From: zheng Date: Thu, 27 Jun 2019 13:50:02 +0800 Subject: [PATCH 13/17] =?UTF-8?q?CHART-9141=20ChartRequestService=E6=96=B0?= =?UTF-8?q?=E5=A2=9E+chart=20service=20move=20to=20chart=20module+chartdat?= =?UTF-8?q?a=20remove=20from=20engine-cross?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/chart/ChartControlPane.java | 128 ------------------ .../chart/gui/other/ChartSwitchPane.java | 94 ------------- 2 files changed, 222 deletions(-) delete mode 100644 designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java delete mode 100644 designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java deleted file mode 100644 index e0493cc70d..0000000000 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.fr.design.chart; - -import com.fr.chart.chartattr.Chart; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.gui.controlpane.JListControlPane; -import com.fr.design.gui.controlpane.NameObjectCreator; -import com.fr.design.gui.controlpane.NameableCreator; -import com.fr.design.layout.FRGUIPaneFactory; - -import com.fr.general.NameObject; -import com.fr.stable.Nameable; - -import java.awt.*; -import java.util.HashMap; - -/** - * 管理图表类型Pane - * @author kunsnat: ChartComponent移出. - */ -public class ChartControlPane extends JListControlPane { - private static final long serialVersionUID = 7336270815128413184L; - - public ChartControlPane() { - super(); - // 重新设定大小. 因为JControlPane默认的(450,450) 不适合图表这边 @ChartSize -// this.setPreferredSize(new Dimension(770, 520)); - } - - @Override - public NameableCreator[] createNameableCreators() { - return new NameableCreator[] { - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Chart"), Chart.class, ChartTypeUpdatePane.class) - }; - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Manage_Chart_Type"); - } - - public void populate(ChartCollection cc) { - if(cc == null)return; - - NameObject[] nameObjects = new NameObject[cc.getChartCount()]; - for (int i = 0; i < nameObjects.length; i++) { - nameObjects[i] = new NameObject(cc.getChartName(i), cc.getChart(i)); - } - - populate(nameObjects); - // kunsnat: 选中当前图表选中的name - String chartSelectedName = cc.getChartName(cc.getSelectedIndex() < cc.getChartCount() ? cc.getSelectedIndex() : 0); - setSelectedName(chartSelectedName); - } - - public void update(ChartCollection cc) { - HashMap namesChart = new HashMap();// 暂存判断是否有必要更新 - for(int i = 0; i < cc.getChartCount(); i++) { - try { - namesChart.put(cc.getChartName(i), cc.getChart(i).clone()); - } catch (CloneNotSupportedException e) { - - } - } - - Nameable[] nameables = update(); - if (nameables.length == 0 || cc == null) { - return; - } - - cc.removeAllNameObject(); - String select = getSelectedName(); - for (int i = 0; i < nameables.length; i++) { - if (nameables[i] instanceof NameObject && ((NameObject)nameables[i]).getObject() instanceof Chart) { - NameObject no = (NameObject)nameables[i]; - - String name = no.getName(); - Chart chart = (Chart)no.getObject(); - if(namesChart.containsKey(name)) { - Chart tmpChart = (Chart)namesChart.get(name); - if(chart.getPlot() != null && tmpChart.getPlot() != null - && chart.getPlot().match4GUI(tmpChart.getPlot())) { - chart = tmpChart;// 代替之前做过编辑的Chart - } - } - cc.addNamedChart(name, chart); - if(no.getName().equals(select)) { - cc.setSelectedIndex(i); - } - } - } - } - - /* - * alex:继承UpdatePane的ChartTypePane - */ - public static class ChartTypeUpdatePane extends BasicBeanPane { - private static final long serialVersionUID = -7058348930816218415L; - private Chart editing; - - private ChartTypePane typePane; - - public ChartTypeUpdatePane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - typePane = new ChartTypePane(); - this.add(typePane, BorderLayout.CENTER); - } - - @Override - protected String title4PopupWindow() { - return "Chart Type"; - } - - @Override - public void populateBean(Chart ob) { - editing = ob; - typePane.populate(ob); - } - - @Override - public Chart updateBean() { - typePane.update(editing); - - return editing; - } - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java deleted file mode 100644 index 6288b7ecf4..0000000000 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.fr.design.mainframe.chart.gui.other; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -import com.fr.design.chart.ChartControlPane; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.mainframe.chart.ChartEditPane; -import com.fr.design.mainframe.chart.PaneTitleConstants; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; - - -public class ChartSwitchPane extends AbstractAttrNoScrollPane{ - - private UIButton changeButton; - - private ChartCollection editingChartCollection; - - private ChartEditPane currentChartEditPane; - - public ChartSwitchPane() { - - } - - @Override - protected JPanel createContentPane() { - JPanel pane = new JPanel(); - pane.setLayout(new BorderLayout()); - - changeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch")); - - pane.add(changeButton, BorderLayout.NORTH); - - changeButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final ChartControlPane chartTypeManager = new ChartControlPane(); - chartTypeManager.populate(editingChartCollection); - - BasicDialog dlg = chartTypeManager.showWindow4ChartType(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionAdapter() { - public void doOk() { - chartTypeManager.update(editingChartCollection);//kunsnat: 确定刷新"chartSelectIndex" - - if(currentChartEditPane != null) { - currentChartEditPane.populate(editingChartCollection);// 选中新Plot之后 刷新对应界面, 比如超级链接等, 然后才能update. - currentChartEditPane.gotoPane(PaneTitleConstants.CHART_TYPE_TITLE); - currentChartEditPane.gotoPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE); - currentChartEditPane.fire(); - } - } - }); - - dlg.setVisible(true); - } - }); - - return pane; - } - - /** - * 注册 切换事件的改变 和超链不同. - * @param listener - */ - public void registerChartEditPane(ChartEditPane currentChartEditPane) { - this.currentChartEditPane = currentChartEditPane; - } - - public void populateBean(ChartCollection c) { - this.editingChartCollection = c; - } - - public void updateBean(ChartCollection c) { - - } - - /** - * 界面标题 - * @param 返回标题 - */ - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch_Chart"); - } - - @Override - public String getIconPath() { - return null; - } -} \ No newline at end of file From 838d8faf3356e791debe97796456793ef7cbbcd9 Mon Sep 17 00:00:00 2001 From: zheng Date: Wed, 10 Jul 2019 18:37:27 +0800 Subject: [PATCH 14/17] =?UTF-8?q?CHART-9141=20replace=20chart=20with=20cha?= =?UTF-8?q?rtProvider(eg:typePane)=20&&=20=E5=9B=BE=E8=A1=A8=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=20&&=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=9B=BE=E8=A1=A8=E5=86=85=E9=83=A8=E5=AF=B9datamodel?= =?UTF-8?q?=E7=9A=84cache(=E5=92=8Cengine=E7=A1=AE=E8=AE=A4=E8=BF=87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 16 +- .../design/chart/ChartCommonWizardPane.java | 14 +- .../com/fr/design/chart/ChartTypePane.java | 86 +--- .../design/chart/gui/ChartWidgetOption.java | 10 +- .../active/action/ChartComponentAction.java | 5 - .../impl/ChartHyperPoplinkPane.java | 3 +- .../design/mainframe/chart/ChartEditPane.java | 43 +- .../chart/gui/ChartTypeButtonPane.java | 68 ++- .../mainframe/chart/gui/ChartTypePane.java | 69 +-- .../mainframe/chart/gui/StylePane4Chart.java | 33 -- .../chart/gui/type/AbstractBarPane.java | 6 +- .../chart/gui/type/AbstractChartTypePane.java | 394 +---------------- .../type/AbstractDeprecatedChartTypePane.java | 409 ++++++++++++++++++ .../chart/gui/type/AreaPlotPane.java | 2 +- .../chart/gui/type/BubblePlotPane.java | 4 +- .../chart/gui/type/CustomPlotPane.java | 2 +- .../chart/gui/type/DonutPlotPane.java | 8 +- .../chart/gui/type/FunnelPlotPane.java | 2 +- .../chart/gui/type/GanttPlotPane.java | 2 +- .../chart/gui/type/GisMapPlotPane.java | 6 +- .../chart/gui/type/LinePlotPane.java | 2 +- .../mainframe/chart/gui/type/MapPlotPane.java | 2 +- .../chart/gui/type/MeterPlotPane.java | 6 +- .../mainframe/chart/gui/type/PiePlotPane.java | 4 +- .../chart/gui/type/RadarPlotPane.java | 2 +- .../chart/gui/type/RangePlotPane.java | 2 +- .../chart/gui/type/StockPlotPane.java | 4 +- .../gui/type/UserDefinedChartTypePane.java | 4 +- .../chart/gui/type/XYScatterPlotPane.java | 2 +- .../fr/extended/chart/ExtendedTypePane.java | 7 +- .../type/AbstractVanChartTypePane.java | 5 +- .../java/com/fr/poly/PolyComponentsBar.java | 4 +- 32 files changed, 602 insertions(+), 624 deletions(-) delete mode 100644 designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java create mode 100644 designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index 72585ade8e..8c3f56ae01 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -2,7 +2,6 @@ package com.fr.design; import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartInternationalNameContentBean; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; @@ -161,7 +160,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; int index = 0; for (ChartInternationalNameContentBean bean : typeName) { - String plotID = bean.getPlotID(); + String plotID = bean.getChartID(); ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(plotID)) { continue; @@ -254,7 +253,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr * * @param paneList pane容器 */ - public void addPlotTypePaneList(List> paneList, Map>> allChartTypePane) { + public void addPlotTypePaneList(List> paneList, Map>> allChartTypePane) { List priorityList = getPriorityInOrder(); for (Integer aPriorityList : priorityList) { @@ -264,7 +263,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr } - public void addPlotTypePaneList(String priority, List> paneList, Map>> allChartTypePane) { + public void addPlotTypePaneList(String priority, List> paneList, Map>> allChartTypePane) { if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { @@ -283,7 +282,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr paneList.add(pane); if (allChartTypePane.get(priority) == null) { - allChartTypePane.put(priority, new LinkedHashMap>()); + allChartTypePane.put(priority, new LinkedHashMap>()); } allChartTypePane.get(priority).put(plotID, pane); } @@ -450,9 +449,10 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr return true; } - public boolean needChartChangePane(Chart chart) { - if (chart != null && chart.getPlot() != null) { - IndependentChartUIProvider provider = getChartTypeInterface(chart.getPlot().getPlotID()); + public boolean needChartChangePane(ChartProvider chart) { + if (chart != null) { + String chartID = chart.getID(); + IndependentChartUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { return provider.needChartChangePane(); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java index 7fefabd3e3..6ff6e0639d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java @@ -1,7 +1,7 @@ package com.fr.design.chart; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chartx.attr.ChartProvider; public abstract class ChartCommonWizardPane extends ChartWizardPane { private static final long serialVersionUID = 2467967841657570498L; @@ -11,12 +11,12 @@ public abstract class ChartCommonWizardPane extends ChartWizardPane { if (cc == null) { return; } - - populate(cc.getSelectedChart()); + + populate(cc.getSelectedChartProvider()); } - - public abstract void populate(Chart chart); - - public abstract void update(Chart oldChart); + + public abstract void populate(ChartProvider chart); + + public abstract void update(ChartProvider oldChart); } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index 2a19072e08..257fb8826e 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -5,18 +5,13 @@ package com.fr.design.chart; */ import com.fr.chart.base.ChartInternationalNameContentBean; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartIcon; -import com.fr.chart.chartattr.MapPlot; -import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.license.exception.RegistEditionException; -import com.fr.license.function.VT4FR; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; @@ -24,7 +19,6 @@ import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.JList; -import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.ListCellRenderer; @@ -37,22 +31,22 @@ public class ChartTypePane extends ChartCommonWizardPane { private static final long serialVersionUID = -1175602484968520546L; private ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstanceWithCheck().getAllChartBaseNames(); - //todo@shinerefactor 这个页面所有强转Chart的地方都要处理一下 - private Chart[][] charts4Icon = null; + private ChartProvider[][] charts4Icon = null; { - charts4Icon = new Chart[this.typeName.length][]; + charts4Icon = new ChartProvider[this.typeName.length][]; for (int i = 0; i < this.typeName.length; i++) { - ChartProvider[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getPlotID()); + ChartProvider[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getChartID()); int rowChartsCount = rowCharts.length; - charts4Icon[i] = new Chart[rowChartsCount]; + charts4Icon[i] = new ChartProvider[rowChartsCount]; for (int j = 0; j < rowChartsCount; j++) { try { - charts4Icon[i][j] = (Chart) rowCharts[j].clone(); - charts4Icon[i][j].setTitle(null); - if(charts4Icon[i][j].getPlot() != null){ - charts4Icon[i][j].getPlot().setLegend(null); - } + charts4Icon[i][j] = (ChartProvider) rowCharts[j].clone(); + //todo@shinerefactor 老图表也是提供一张图片 这边就不用setTitle(null) 然后实时去画 +// charts4Icon[i][j].setTitle(null); +// if(charts4Icon[i][j].getPlot() != null){ +// charts4Icon[i][j].getPlot().setLegend(null); +// } } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -123,7 +117,7 @@ public class ChartTypePane extends ChartCommonWizardPane { protected ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int main_index = mainTypeList.getSelectedIndex(); - Chart[] sub_charts = ChartTypePane.this.charts4Icon[main_index]; + ChartProvider[] sub_charts = ChartTypePane.this.charts4Icon[main_index]; ChartTypePane.this.iconListModel.clear(); for (int i = 0; i < sub_charts.length; i++) { ChartTypePane.this.iconListModel.addElement(new ChartIcon(sub_charts[i])); @@ -133,56 +127,14 @@ public class ChartTypePane extends ChartCommonWizardPane { }; public String getChartName(ChartIcon chartIcon) { - Chart chart = (Chart)chartIcon.getChart(); - return chart.getChartName(); + ChartProvider chart = chartIcon.getChart(); + return ChartTypeManager.getInstanceWithCheck().getChartName(chart.getID()); } - public void populate(Chart chart) { - if (chart == null) { - return; - } - Plot plot = chart.getPlot(); - - int mainIndex = 0; - int subIndex = 0; - - for (int i = 0; i < typeName.length; i++) { - ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(typeName[i].getPlotID()); - for (int j = 0; j < charts.length; j++) { - if (((Chart) charts[j]).getPlot().match4GUI(plot)) { - mainIndex = i; - subIndex = j; - // 一旦匹配 立马中断 - break; - } - } - } - - mainTypeList.setSelectedIndex(mainIndex); - iconViewList.setSelectedIndex(subIndex); - } - - public void update(Chart oldChart) { - String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID(); - Chart chart = (Chart) ChartTypeManager.getInstanceWithCheck().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; - if(chart.getPlot() != null){ - if(chart.getPlot() instanceof MapPlot && !supportMap()){ - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Not_Supported")); - throw new RegistEditionException(VT4FR.ChartMap); - } - - if (chart.getPlot() != null) { - try { - oldChart.changePlotInNewType((Plot) chart.getPlot().clone()); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - } + public void populate(ChartProvider chart) { } - private boolean supportMap() { - return VT4FR.ChartMap.isSupport(); + public void update(ChartProvider oldChart) { } public void update(ChartCollection cc) { @@ -190,12 +142,12 @@ public class ChartTypePane extends ChartCommonWizardPane { return; } - Chart chart4Update = cc.getSelectedChart(); + ChartProvider chart4Update = cc.getSelectedChartProvider(); if (chart4Update == null) { - String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID(); - Chart chart = (Chart) ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; + String plotID = typeName[mainTypeList.getSelectedIndex()].getChartID(); + ChartProvider chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; try{ - chart4Update = (Chart)chart.clone(); + chart4Update = (ChartProvider) chart.clone(); cc.addChart(chart4Update); }catch (CloneNotSupportedException ex){ FineLoggerFactory.getLogger().error(ex.getMessage(), ex); diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java index eb36aadea1..753bb47cd3 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java @@ -1,7 +1,6 @@ package com.fr.design.chart.gui; -import com.fr.chart.charttypes.ChartTypeManager; -import com.fr.chartx.attr.ChartProvider; +import com.fr.base.chart.BaseChartGetter; import com.fr.design.gui.core.WidgetOption; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.Widget; @@ -38,14 +37,11 @@ public class ChartWidgetOption extends WidgetOption { Class clz = widgetClass(); try { ChartEditor widget = clz.newInstance(); - ChartProvider chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.chartID)[0]; - widget.addChart((ChartProvider) chart.clone()); + widget.setChartCollection(BaseChartGetter.createChartCollection(this.chartID)); return widget; } catch (InstantiationException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (IllegalAccessException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java index 9bedc637d3..83d471068d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java @@ -1,6 +1,5 @@ package com.fr.design.chart.gui.active.action; -import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartglyph.AxisGlyph; import com.fr.design.actions.UpdateAction; @@ -32,10 +31,6 @@ public abstract class ChartComponentAction extends UpdateAction { return chartComponent.getChartCollection(); } - public Axis getActiveAxis() { - return chartComponent.getActiveAxis(); - } - public AxisGlyph getActiveAxisGlyph() { return chartComponent.getActiveAxisGlyph(); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java index 74c78ff2d8..7083da6818 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java @@ -1,6 +1,5 @@ package com.fr.design.chart.series.SeriesCondition.impl; -import com.fr.base.chart.BaseChartCollection; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; @@ -92,7 +91,7 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane(); addTypePane(); - boolean isDefault = true; - String plotID = ""; - if(currentChart.getPlot() != null){ - plotID = currentChart.getPlot().getPlotID(); - isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); - } + String chartID = currentChart.getID(); + boolean isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); if(isDefault){ paneList.add(dataPane4SupportCell); @@ -152,11 +151,11 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 paneList.add(otherPane); this.isDefaultPane = true; }else{ - ChartDataPane chartDataPane = createChartDataPane(plotID); + ChartDataPane chartDataPane = createChartDataPane(chartID); if (chartDataPane != null) { paneList.add(chartDataPane); } - AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(plotID, listener); + AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(chartID, listener); for(int i = 0; i < otherPaneList.length; i++){ otherPaneList[i].addAttributeChangeListener(listener); paneList.add(otherPaneList[i]); @@ -226,8 +225,8 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 return; } - if(checkNeedsReLayout(collection.getSelectedChart())){ - reLayout(collection.getSelectedChart()); + if (checkNeedsReLayout(collection.getSelectedChartProvider())) { + reLayout(collection.getSelectedChartProvider()); } this.collection = collection; @@ -253,7 +252,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } } - public int getSelectedChartIndex(Chart chart){ + public int getSelectedChartIndex(ChartProvider chart) { int index = 0; if(typePane != null){ FurtherBasicBeanPane[] paneList = typePane.getPaneList(); @@ -267,15 +266,13 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } //populate的时候看看要不要重构面板 - private boolean checkNeedsReLayout(Chart chart){ + private boolean checkNeedsReLayout(ChartProvider chart) { if(chart != null){ int lastIndex = typePane.getSelectedIndex(); int currentIndex = getSelectedChartIndex(chart); - boolean currentPane = true; - if(chart.getPlot() != null){ - String plotID = chart.getPlot().getPlotID(); - currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); - } + String chartID = chart.getID(); + boolean currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); + return (currentPane != isDefaultPane) || (!currentPane && lastIndex != currentIndex); } return false; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index ef5f8e1d41..4d72211134 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -19,6 +19,7 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.vanchart.VanChart; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; @@ -42,6 +43,8 @@ import java.awt.event.MouseListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; /** * 图表 类型 增删 控制按钮界面. @@ -56,6 +59,12 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private static final int P_W = 300; private static final int P_H = 400; + private static Set> supportChangeConfigChartClassSet = new HashSet>(); + + static { + registerSupportChangeConfigChartClass(VanChart.class); + } + private UIButton addButton; private UIButton configButton; private ArrayList indexList = new ArrayList(); @@ -109,6 +118,10 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen // Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); } + public static void registerSupportChangeConfigChartClass(Class cls) { + supportChangeConfigChartClassSet.add(cls); + } + private void initConfigCreator() { configCreator = new UIMenuNameableCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"), new AttrChangeConfig(), ChangeConfigPane.class); } @@ -135,7 +148,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (editingCollection != null) { //点击添加按钮,则会触发切换状态 - ChartProvider chart = editingCollection.getChangeStateNewChart(); + ChartProvider chart = getChangeStateNewChart(); try { ChartProvider newChart = (ChartProvider) chart.clone(); editingCollection.addNamedChart(name, newChart); @@ -150,12 +163,51 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen //获取图表收集器的状态 private void checkoutChange(){ - editingCollection.calculateMultiChartMode(); + calculateMultiChartMode(); if (parent != null){ parent.relayoutChartTypePane(editingCollection); } //检查是否可以配置切换 - configButton.setEnabled(editingCollection.changeEnable()); + configButton.setEnabled(changeEnable()); + } + + /** + * 获取切花状态下的图表 + * + * @return + */ + public ChartProvider getChangeStateNewChart() { + ChartProvider chart = editingCollection.getSelectedChartProvider(); + String priority = ChartTypeManager.VAN_CHART_PRIORITY; + //todo@shinerefactor + // chart.getPriority(); + return ChartTypeManager.getInstanceWithCheck().getFirstChart(priority); + } + + //图表收集器模式状态改变 + private void calculateMultiChartMode() { + //设置切换功能是否可用 + editingCollection.getChangeConfigAttr().setEnable(changeEnable()); + //多图表切换模式 + if (editingCollection.getChartCount() > 1) { + editingCollection.setState(SwitchState.CHANGE); + } else { + editingCollection.setState(SwitchState.DEFAULT); + } + } + + /** + * 是否支持图表切换的配置 + * + * @return + */ + private boolean changeEnable() { + return editingCollection.getChartCount() > 1 + && supportChange(); + } + + private boolean supportChange() { + return supportChangeConfigChartClassSet.contains(editingCollection.getSelectedChartProvider().getClass()); } ActionListener configListener = new ActionListener() { @@ -310,11 +362,11 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } private void checkConfigButtonVisible() { - addButton.setVisible(ChartTypeManager.enabledChart(editingCollection.getSelectedChart().getPlot().getPlotID())); + addButton.setVisible(ChartTypeManager.enabledChart(editingCollection.getSelectedChartProvider().getID())); //新建一个collection - if(editingCollection.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChart() != null){ + if (editingCollection.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChartProvider() != null) { //Chart 不支持图表切换 - configButton.setVisible(editingCollection.getSelectedChart().supportChange()); + configButton.setVisible(supportChange()); } } @@ -440,7 +492,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void deleteAButton() { //先重构属性,在重构面板,否则面板在重构过程中,会重新将属性中的切换图表加到indexList中,导致面板无法删除 //记录改变前的plotID - String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID(); + String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider().getID(); if (editingCollection != null) { int count = editingCollection.getChartCount(); for (int i = 0; i < count; i++) { @@ -520,7 +572,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (isEnabled()) { noSelected(); //记录改变前的plotID - String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID(); + String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider().getID(); changeCollectionSelected(getButtonName()); setSelectedWithFireListener(true); fireSelectedChanged(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 56547842cf..8ac031f754 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -2,9 +2,9 @@ package com.fr.design.mainframe.chart.gui; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.SwitchState; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.dialog.BasicScrollPane; @@ -98,14 +98,14 @@ public class ChartTypePane extends AbstractChartAttrPane{ public String title4PopupWindow() { return PaneTitleConstants.CHART_TYPE_TITLE; } - - class ComboBoxPane extends UIComboBoxPane{ - private Map>> allChartTypePane; + + class ComboBoxPane extends UIComboBoxPane { + private Map>> allChartTypePane; @Override - protected List> initPaneList() { - List> paneList = new ArrayList>(); - allChartTypePane = new LinkedHashMap>>(); + protected List> initPaneList() { + List> paneList = new ArrayList>(); + allChartTypePane = new LinkedHashMap>>(); ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane); return paneList; } @@ -121,13 +121,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ * 如果是切换图表的不同图表之间切换,则collection的选择下标会改变 * @param chart */ - public void updateBean(Chart chart) { + public void updateBean(ChartProvider chart) { - Plot oldPlot = chart.getPlot(); - String lastPlotID = oldPlot == null ? StringUtils.EMPTY : oldPlot.getPlotID(); + String lastPlotID = chart.getID(); try{ - Chart newDefaultChart = (Chart)((AbstractChartTypePane)getSelectedPane()).getDefaultChart().clone(); + ChartProvider newDefaultChart = (ChartProvider) ((AbstractChartTypePane) getSelectedPane()).getDefaultChart().clone(); if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) { //vanChart 和 chart 之间切换 //不同chart之间切换 @@ -142,20 +141,20 @@ public class ChartTypePane extends AbstractChartAttrPane{ //这一步会替换plot ((AbstractChartTypePane)getSelectedPane()).updateBean(chart); - Plot plot = chart.getPlot(); - - if(plot != null){ - String plotID = plot.getPlotID(); + String chartID = chart.getID(); - //plot改变的话图表类型就算改变了 + //chartID改变的话图表类型就算改变了 + if (StringUtils.isNotEmpty(chartID)) { - chart.setWrapperName(ChartTypeManager.getInstanceWithCheck().getWrapperName(plotID)); - - chart.setChartImagePath(ChartTypeManager.getInstanceWithCheck().getChartImagePath(plotID)); + if (chart instanceof Chart) { + //todo@shinerefactor: 这边看下是否可以删除 + ((Chart) chart).setWrapperName(ChartTypeManager.getInstanceWithCheck().getWrapperName(chartID)); + ((Chart) chart).setChartImagePath(ChartTypeManager.getInstanceWithCheck().getChartImagePath(chartID)); + } - boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); + boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); - if(editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ + if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, chartID))) { editPane.reLayout(chart); } } @@ -195,12 +194,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ private void addOnePriorityCards(String priority, boolean ignore) { - Map> map = allChartTypePane.get(priority); + Map> map = allChartTypePane.get(priority); - Iterator>> iterator = map.entrySet().iterator(); + Iterator>> iterator = map.entrySet().iterator(); while (iterator.hasNext()) { - Map.Entry> entry = iterator.next(); + Map.Entry> entry = iterator.next(); String plotID = entry.getKey(); if (ignore || ChartTypeManager.enabledChart(plotID)) { cards.add(entry.getValue()); @@ -217,9 +216,11 @@ public class ChartTypePane extends AbstractChartAttrPane{ //处理办法:这边除了重构 下拉项选项和cardNames 还需要把cards重构下(不需要init pane,只需要我需要的拿出来就好了) private void relayout(ChartCollection collection){ //重构需要重构下拉框选项和cardNames - Chart chart = collection.getSelectedChart(); - String priority = chart.getPriority(); - String plotID = chart.getPlot().getPlotID(); + ChartProvider chart = collection.getSelectedChartProvider(); + String priority = ChartTypeManager.VAN_CHART_PRIORITY; + //TODO@shinerefactor + // chart.getPriority(); + String plotID = chart.getID(); boolean enabledChart = ChartTypeManager.enabledChart(plotID); String item = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(priority, plotID); @@ -262,7 +263,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ } @Override - public void populateBean(Chart ob) { + public void populateBean(ChartProvider ob) { for (int i = 0; i < this.cards.size(); i++) { FurtherBasicBeanPane pane = cards.get(i); if (pane.accept(ob)) { @@ -279,12 +280,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ } @Override - public Chart updateBean() { + public ChartProvider updateBean() { return getSelectedPane().updateBean(); } @Override - public FurtherBasicBeanPane getSelectedPane(){ + public FurtherBasicBeanPane getSelectedPane() { Object item = jcb.getSelectedItem(); for (int i = 0; i < cards.size(); i++){ if (ComparatorUtils.equals(item, cards.get(i).title4PopupWindow())){ @@ -303,8 +304,8 @@ public class ChartTypePane extends AbstractChartAttrPane{ * @param collection */ public void reLayoutEditPane(String lastPlotID, ChartCollection collection){ - Chart chart = collection.getSelectedChart(); - String plotID = chart.getPlot().getPlotID(); + ChartProvider chart = collection.getSelectedChartProvider(); + String plotID = chart.getID(); boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); if (editPane != null && editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ editPane.reLayout(chart); @@ -322,7 +323,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void populate(ChartCollection collection) { editingCollection = collection; - Chart chart = collection.getSelectedChart(); + ChartProvider chart = collection.getSelectedChartProvider(); this.remove(leftContentPane); initContentPane(); @@ -340,7 +341,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void update(ChartCollection collection) { editingCollection = collection; buttonPane.update(collection);// 内部操作时 已经做过处理. - Chart chart = collection.getSelectedChart(); + ChartProvider chart = collection.getSelectedChartProvider(); chartTypeComBox.updateBean(chart); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java deleted file mode 100644 index 9ce3afd91d..0000000000 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.fr.design.mainframe.chart.gui; - -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; -import com.fr.design.mainframe.chart.gui.style.series.SeriesPane4ChartDesigner; - -/** - * 图表设计器的样式面板 - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-25 - * Time: 下午6:56 - */ -public class StylePane4Chart extends ChartStylePane { - - public StylePane4Chart(AttributeChangeListener listener, boolean isNeedFormula) { - super(listener, isNeedFormula); - } - - public void update(ChartCollection collection) { - int selectIndex = collection.getSelectedIndex(); - super.update(collection); - collection.getSelectedChart().setStyleGlobal(false); - collection.setChartName(selectIndex, collection.getSelectedChart().getTitle().getTextObject().toString()); - } - - protected ChartSeriesPane createChartSeriesPane(){ - return new SeriesPane4ChartDesigner(StylePane4Chart.this); - } - -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java index 4561549d41..639a41e429 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java @@ -9,9 +9,9 @@ import com.fr.chart.chartattr.Chart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午04:55:05 */ -public abstract class AbstractBarPane extends AbstractChartTypePane { - - protected static final int COLOMN_CHART = 0; +public abstract class AbstractBarPane extends AbstractDeprecatedChartTypePane { + + protected static final int COLOMN_CHART = 0; protected static final int STACK_COLOMN_CHART = 1; protected static final int PERCENT_STACK_COLOMN_CHART = 2; protected static final int THREE_D_COLOMN_CHART = 3; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java index 47de03b569..2634247623 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java @@ -1,21 +1,9 @@ package com.fr.design.mainframe.chart.gui.type; -import com.fr.base.ChartColorMatching; -import com.fr.base.ChartPreStyleConfig; -import com.fr.base.background.ColorBackground; -import com.fr.chart.base.AttrContents; -import com.fr.chart.base.AttrFillStyle; import com.fr.chart.base.ChartConstants; -import com.fr.chart.base.ChartUtils; -import com.fr.chart.base.DataSeriesCondition; -import com.fr.chart.base.TextAttr; -import com.fr.chart.chartattr.Axis; -import com.fr.chart.chartattr.CategoryPlot; import com.fr.chart.chartattr.Chart; -import com.fr.chart.chartattr.Legend; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Title; -import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.charttypes.BarIndependentChart; import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.FurtherBasicBeanPane; @@ -25,9 +13,6 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.ComparatorUtils; -import com.fr.general.FRFont; -import com.fr.js.NameJavaScriptGroup; -import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import javax.swing.JPanel; @@ -35,12 +20,11 @@ import javax.swing.JSeparator; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Font; import java.util.ArrayList; import java.util.List; -public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ +public abstract class AbstractChartTypePane extends FurtherBasicBeanPane { private static final int ONE_LINE_NUM = 4; @@ -163,50 +147,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ } } } - /** - * 更新界面属性 - */ - public void populateBean(Chart chart) { - for(ChartImagePane imagePane : typeDemo) { - imagePane.isPressing = false; - } - for(ChartImagePane imagePane : styleList) { - imagePane.isPressing = false; - } - - if(styleList != null && !styleList.isEmpty()){ - int plotStyle = chart.getPlot().getPlotStyle(); - String styleName = chart.getPlot().getPlotFillStyle().getFillStyleName(); - - switch (plotStyle){ - case ChartConstants.STYLE_SHADE: if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"), styleName)){ - styleList.get(STYLE_SHADE).isPressing = true; - lastStyleIndex = STYLE_SHADE; - } - break; - case ChartConstants.STYLE_TRANSPARENT:if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"), styleName)){ - styleList.get(STYLE_TRANSPARENT).isPressing = true; - lastStyleIndex = STYLE_TRANSPARENT; - } - break; - case ChartConstants.STYLE_3D: if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)){ - styleList.get(STYLE_PLANE3D).isPressing = true; - lastStyleIndex = STYLE_PLANE3D; - } - break; - case ChartConstants.STYLE_OUTER:if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)){ - styleList.get(STYLE_HIGHLIGHT).isPressing = true; - lastStyleIndex = STYLE_HIGHLIGHT; - } - break; - default: - lastStyleIndex = -1; - break; - } - stylePane.setVisible(!(chart.getPlot().isSupport3D())); - this.repaint(); - } - } protected void checkDemosBackground() { if(this.styleList != null && !styleList.isEmpty()){ @@ -222,119 +162,10 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ } } - private void setPlotFillStyle(Chart chart){ - ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); - Plot plot = chart.getPlot(); - Object preStyle = null; - String name = ""; - if(styleList.get(STYLE_SHADE).isPressing){ - name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"); - preStyle = manager.getPreStyle(name); - }else if(styleList.get(STYLE_TRANSPARENT).isPressing){ - name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"); - preStyle = manager.getPreStyle(name); - }else if(styleList.get(STYLE_PLANE3D).isPressing){ - name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); - preStyle = manager.getPreStyle(name); - }else if(styleList.get(STYLE_HIGHLIGHT).isPressing){ - name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); - preStyle = manager.getPreStyle(name); - } - if(preStyle == null){ - plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT); - }else{ - AttrFillStyle fillStyle = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle); - fillStyle.setFillStyleName(name); - plot.setPlotFillStyle(fillStyle); - } - } - - /** - * 保存风格,对选中的风格做设置 - */ - public void updateBean(Chart chart) { - Plot oldPlot = chart.getPlot(); - Plot newPlot = this.setSelectedClonedPlotWithCondition(oldPlot); - checkTypeChange(oldPlot);//判断图表的类型是否发生变化 - if(styleList != null && !styleList.isEmpty()){ - if(styleList.get(STYLE_SHADE).isPressing && lastStyleIndex != STYLE_SHADE){ - lastStyleIndex = STYLE_SHADE; - chart.setPlot(newPlot); - chart.getPlot().setPlotStyle(ChartConstants.STYLE_SHADE); - resetChart(chart); - createCondition4Shade(chart); - setPlotFillStyle(chart); - }else if(styleList.get(STYLE_TRANSPARENT).isPressing && lastStyleIndex != STYLE_TRANSPARENT){ - lastStyleIndex = STYLE_TRANSPARENT; - chart.setPlot(newPlot); - chart.getPlot().setPlotStyle(ChartConstants.STYLE_TRANSPARENT); - resetChart(chart); - createCondition4Transparent(chart); - setPlotFillStyle(chart); - }else if(styleList.get(STYLE_PLANE3D).isPressing && lastStyleIndex != STYLE_PLANE3D){ - lastStyleIndex = STYLE_PLANE3D; - chart.setPlot(newPlot); - chart.getPlot().setPlotStyle(ChartConstants.STYLE_3D); - resetChart(chart); - createCondition4Plane3D(chart); - setPlotFillStyle(chart); - }else if(styleList.get(STYLE_HIGHLIGHT).isPressing && lastStyleIndex != STYLE_HIGHLIGHT){ - lastStyleIndex = STYLE_HIGHLIGHT; - chart.setPlot(newPlot); - chart.getPlot().setPlotStyle(ChartConstants.STYLE_OUTER); - resetChart(chart); - createCondition4HighLight(chart); - setPlotFillStyle(chart); - }else if(lastStyleIndex >= STYLE_SHADE && lastStyleIndex <= STYLE_HIGHLIGHT){ - if(styleList.get(lastStyleIndex).isDoubleClicked || typeChanged){ - chart.setPlot(newPlot); - resetChart(chart); - styleList.get(lastStyleIndex).isPressing = false; - checkDemosBackground(); - lastStyleIndex = -1; - } - } - - stylePane.setVisible(!(chart.getPlot().isSupport3D())); - this.repaint(); - } - } - - private Plot setSelectedClonedPlotWithCondition(Plot oldPlot){ - Plot newPlot = getSelectedClonedPlot(); - if(oldPlot != null && ComparatorUtils.equals(newPlot.getClass(), oldPlot.getClass())){ - if(oldPlot.getHotHyperLink() != null){ - NameJavaScriptGroup hotHyper = oldPlot.getHotHyperLink(); - try { - newPlot.setHotHyperLink((NameJavaScriptGroup)hotHyper.clone()); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error("Error in Hyperlink, Please Check it.", e); - } - } - newPlot.setConditionCollection(oldPlot.getConditionCollection()); - newPlot.setSeriesDragEnable(oldPlot.isSeriesDragEnable()); - if(newPlot.isSupportZoomCategoryAxis() && newPlot.getxAxis() != null) { - newPlot.getxAxis().setZoom(oldPlot.getxAxis().isZoom()); - } - if(newPlot.isSupportTooltipInInteractivePane()) { - newPlot.setHotTooltipStyle(oldPlot.getHotTooltipStyle()); - } - - if(newPlot.isSupportAutoRefresh()) { - newPlot.setAutoRefreshPerSecond(oldPlot.getAutoRefreshPerSecond()); - } - - if (newPlot.isSupportAxisTip()) { - newPlot.setInteractiveAxisTooltip(oldPlot.isInteractiveAxisTooltip()); - } - } - return newPlot; - } - /** * 更新整个新的Chart类型 */ - public Chart updateBean() { + public T updateBean() { return null; } @@ -346,14 +177,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ chart.setBackground(null); } - protected void changePlotWithClone(Chart chart, Plot plot) { - try { - chart.switchPlot((Plot)plot.clone()); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error("Error in change plot"); - } - } - /** * 重置 */ @@ -394,219 +217,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ return false; } - //高光渐变的默认属性设置 - private void createCondition4HighLight(Chart chart){ - if(chart != null){ - //标题 - Title title = new Title(chart.getTitle().getTextObject()); - chart.setTitle(title); - title.setTitleVisible(true); - TextAttr textAttr = title.getTextAttr(); - if (textAttr == null) { - textAttr = new TextAttr(); - title.setTextAttr(textAttr); - } - title.setPosition(Constants.LEFT); - textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(51, 51, 51))); - - //图例 - Legend legend = new Legend(); - legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138,140,139))); - legend.setPosition(Constants.RIGHT_TOP); - chart.getPlot().setLegend(legend); - - //分类轴,现在只有柱形图,条形图,面积图 - if(chart.getPlot() instanceof CategoryPlot){ - CategoryPlot plot = (CategoryPlot)chart.getPlot(); - - //分类轴设置 - Axis cateAxis = plot.getxAxis(); - cateAxis.setAxisStyle(Constants.LINE_THICK); - cateAxis.setAxisColor(new Color(204, 220, 228)); - cateAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); - cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setShowAxisLabel(true); - cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(138,140,139))); - - //值轴 - Axis valueAxis = plot.getyAxis(); - valueAxis.setAxisStyle(Constants.NONE); - valueAxis.setAxisColor(null); - valueAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); - valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - valueAxis.setShowAxisLabel(true); - valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(138,140,139))); - - //绘图区 - plot.setBorderStyle(Constants.LINE_THIN); - plot.setBorderColor(new Color(204, 220, 228)); - plot.setBackground(ColorBackground.getInstance(new Color(248, 247, 245))); - plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); - plot.getyAxis().setMainGridColor(new Color(192,192,192)); - } - - } - } - - //平面3D的默认属性设置 - private void createCondition4Plane3D(Chart chart){ - if(chart != null){ - //标题 - Title title = new Title(chart.getTitle().getTextObject()); - chart.setTitle(title); - title.setTitleVisible(true); - TextAttr textAttr = title.getTextAttr(); - if (textAttr == null) { - textAttr = new TextAttr(); - title.setTextAttr(textAttr); - } - title.setPosition(Constants.CENTER); - textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 16f, new Color(51,51,51))); - - //图例 - Legend legend = new Legend(); - legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128,128,128))); - legend.setPosition(Constants.TOP); - chart.getPlot().setLegend(legend); - - //分类轴,现在只有柱形图,条形图,面积图 - if(chart.getPlot() instanceof CategoryPlot){ - CategoryPlot plot = (CategoryPlot)chart.getPlot(); - //分类轴设置 - Axis cateAxis = plot.getxAxis(); - cateAxis.setAxisStyle(Constants.LINE_THICK); - cateAxis.setAxisColor(new Color(57, 57, 57)); - cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setShowAxisLabel(true); - cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(57,57,57))); - - //值轴设置 - Axis valueAxis = plot.getyAxis(); - valueAxis.setAxisStyle(Constants.LINE_NONE); - valueAxis.setTickMarkType(Constants.TICK_MARK_NONE); - valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - valueAxis.setShowAxisLabel(false); - - //绘图区 - plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); - plot.getyAxis().setMainGridColor(new Color(192,192,192)); - chart.setBorderStyle(Constants.LINE_NONE); - - //数据标签 - ConditionAttr attrList = plot.getConditionCollection().getDefaultAttr(); - DataSeriesCondition attr = attrList.getExisted(AttrContents.class); - if(attr != null) { - attrList.remove(attr); - } - AttrContents attrContents = new AttrContents(); - attrContents.setPosition(Constants.OUTSIDE); - attrContents.setSeriesLabel(ChartConstants.VALUE_PARA); - attrContents.setTextAttr(new TextAttr(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(51,51,51)))); - attrList.addDataSeriesCondition(attrContents); - } - } - } - - //透明风格的默认属性设置 - private void createCondition4Transparent(Chart chart){ - if(chart != null){ - //标题 - Title title = new Title(chart.getTitle().getTextObject()); - chart.setTitle(title); - title.setTitleVisible(true); - TextAttr textAttr = title.getTextAttr(); - if (textAttr == null) { - textAttr = new TextAttr(); - title.setTextAttr(textAttr); - } - title.setPosition(Constants.LEFT); - textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(192,192,192))); - - //图例 - Legend legend = new Legend(); - legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138,140,139))); - legend.setPosition(Constants.RIGHT_TOP); - chart.getPlot().setLegend(legend); - - Plot plot = chart.getPlot(); - //绘图区 - chart.setBackground(ColorBackground.getInstance(new Color(51,51,51))); - - //分类轴,现在只有柱形图,条形图,面积图 - if(plot instanceof CategoryPlot){ - //边框 - plot.setBorderStyle(Constants.LINE_THIN); - plot.setBorderColor(new Color(65,65,65)); - - //分类轴设置 - Axis cateAxis = plot.getxAxis(); - cateAxis.setAxisStyle(Constants.LINE_THICK); - cateAxis.setAxisColor(new Color(192,192,192)); - cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setShowAxisLabel(true); - cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(150,150,150))); - - //值轴 - Axis valueAxis = plot.getyAxis(); - valueAxis.setShowAxisLabel(true); - valueAxis.setAxisStyle(Constants.LINE_NONE); - valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(150,150,150))); - valueAxis.setMainGridStyle(Constants.LINE_THIN); - valueAxis.setMainGridColor(new Color(63, 62, 62)); - } - } - } - - //渐变的默认属性设置 - private void createCondition4Shade(Chart chart){ - if(chart != null){ - //标题 - Title title = new Title(chart.getTitle().getTextObject()); - chart.setTitle(title); - title.setTitleVisible(true); - TextAttr textAttr = title.getTextAttr(); - if (textAttr == null) { - textAttr = new TextAttr(); - title.setTextAttr(textAttr); - } - title.setPosition(Constants.CENTER); - textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(0,51,102))); - - //图例 - Legend legend = new Legend(); - legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128,128,128))); - legend.setPosition(Constants.BOTTOM); - chart.getPlot().setLegend(legend); - - //分类轴,现在只有柱形图,条形图,面积图 - if(chart.getPlot() instanceof CategoryPlot){ - CategoryPlot plot = (CategoryPlot)chart.getPlot(); - - //分类轴设置 - Axis cateAxis = plot.getxAxis(); - cateAxis.setAxisStyle(Constants.LINE_THICK); - cateAxis.setAxisColor(new Color(73, 100, 117)); - cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setShowAxisLabel(true); - cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(128,128,128))); - - //值轴 - Axis valueAxis = plot.getyAxis(); - valueAxis.setShowAxisLabel(true); - valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(128,128,128))); - valueAxis.setAxisStyle(Constants.LINE_NONE); - - //绘图区 - plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); - plot.getyAxis().setMainGridColor(new Color(192,192,192)); - plot.setHorizontalIntervalBackgroundColor(new Color(243,243,243)); - } - } - } - protected boolean needsResetChart(Chart chart){ return chart != null &&chart.getPlot() != null diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java new file mode 100644 index 0000000000..81578ded56 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java @@ -0,0 +1,409 @@ +package com.fr.design.mainframe.chart.gui.type; + +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; +import com.fr.base.background.ColorBackground; +import com.fr.chart.base.AttrContents; +import com.fr.chart.base.AttrFillStyle; +import com.fr.chart.base.ChartConstants; +import com.fr.chart.base.ChartUtils; +import com.fr.chart.base.DataSeriesCondition; +import com.fr.chart.base.TextAttr; +import com.fr.chart.chartattr.Axis; +import com.fr.chart.chartattr.CategoryPlot; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.Legend; +import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartattr.Title; +import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRFont; +import com.fr.js.NameJavaScriptGroup; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.Constants; + +import java.awt.Color; +import java.awt.Font; + +/** + * Created by shine on 2019/7/1. + */ +public abstract class AbstractDeprecatedChartTypePane extends AbstractChartTypePane { + + protected void changePlotWithClone(Chart chart, Plot plot) { + try { + chart.switchPlot((Plot) plot.clone()); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error("Error in change plot"); + } + } + + /** + * 更新界面属性 + */ + public void populateBean(Chart chart) { + for (ChartImagePane imagePane : typeDemo) { + imagePane.isPressing = false; + } + for (ChartImagePane imagePane : styleList) { + imagePane.isPressing = false; + } + + if (styleList != null && !styleList.isEmpty()) { + int plotStyle = chart.getPlot().getPlotStyle(); + String styleName = chart.getPlot().getPlotFillStyle().getFillStyleName(); + + switch (plotStyle) { + case ChartConstants.STYLE_SHADE: + if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"), styleName)) { + styleList.get(STYLE_SHADE).isPressing = true; + lastStyleIndex = STYLE_SHADE; + } + break; + case ChartConstants.STYLE_TRANSPARENT: + if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"), styleName)) { + styleList.get(STYLE_TRANSPARENT).isPressing = true; + lastStyleIndex = STYLE_TRANSPARENT; + } + break; + case ChartConstants.STYLE_3D: + if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)) { + styleList.get(STYLE_PLANE3D).isPressing = true; + lastStyleIndex = STYLE_PLANE3D; + } + break; + case ChartConstants.STYLE_OUTER: + if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)) { + styleList.get(STYLE_HIGHLIGHT).isPressing = true; + lastStyleIndex = STYLE_HIGHLIGHT; + } + break; + default: + lastStyleIndex = -1; + break; + } + stylePane.setVisible(!(chart.getPlot().isSupport3D())); + this.repaint(); + } + } + + public void updateBean(Chart chart) { + Plot oldPlot = chart.getPlot(); + Plot newPlot = this.setSelectedClonedPlotWithCondition(oldPlot); + checkTypeChange(oldPlot);//判断图表的类型是否发生变化 + if (styleList != null && !styleList.isEmpty()) { + if (styleList.get(STYLE_SHADE).isPressing && lastStyleIndex != STYLE_SHADE) { + lastStyleIndex = STYLE_SHADE; + chart.setPlot(newPlot); + chart.getPlot().setPlotStyle(ChartConstants.STYLE_SHADE); + resetChart(chart); + createCondition4Shade(chart); + setPlotFillStyle(chart); + } else if (styleList.get(STYLE_TRANSPARENT).isPressing && lastStyleIndex != STYLE_TRANSPARENT) { + lastStyleIndex = STYLE_TRANSPARENT; + chart.setPlot(newPlot); + chart.getPlot().setPlotStyle(ChartConstants.STYLE_TRANSPARENT); + resetChart(chart); + createCondition4Transparent(chart); + setPlotFillStyle(chart); + } else if (styleList.get(STYLE_PLANE3D).isPressing && lastStyleIndex != STYLE_PLANE3D) { + lastStyleIndex = STYLE_PLANE3D; + chart.setPlot(newPlot); + chart.getPlot().setPlotStyle(ChartConstants.STYLE_3D); + resetChart(chart); + createCondition4Plane3D(chart); + setPlotFillStyle(chart); + } else if (styleList.get(STYLE_HIGHLIGHT).isPressing && lastStyleIndex != STYLE_HIGHLIGHT) { + lastStyleIndex = STYLE_HIGHLIGHT; + chart.setPlot(newPlot); + chart.getPlot().setPlotStyle(ChartConstants.STYLE_OUTER); + resetChart(chart); + createCondition4HighLight(chart); + setPlotFillStyle(chart); + } else if (lastStyleIndex >= STYLE_SHADE && lastStyleIndex <= STYLE_HIGHLIGHT) { + if (styleList.get(lastStyleIndex).isDoubleClicked || typeChanged) { + chart.setPlot(newPlot); + resetChart(chart); + styleList.get(lastStyleIndex).isPressing = false; + checkDemosBackground(); + lastStyleIndex = -1; + } + } + + stylePane.setVisible(!(chart.getPlot().isSupport3D())); + this.repaint(); + } + } + + private Plot setSelectedClonedPlotWithCondition(Plot oldPlot) { + Plot newPlot = getSelectedClonedPlot(); + if (oldPlot != null && ComparatorUtils.equals(newPlot.getClass(), oldPlot.getClass())) { + if (oldPlot.getHotHyperLink() != null) { + NameJavaScriptGroup hotHyper = oldPlot.getHotHyperLink(); + try { + newPlot.setHotHyperLink((NameJavaScriptGroup) hotHyper.clone()); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error("Error in Hyperlink, Please Check it.", e); + } + } + newPlot.setConditionCollection(oldPlot.getConditionCollection()); + newPlot.setSeriesDragEnable(oldPlot.isSeriesDragEnable()); + if (newPlot.isSupportZoomCategoryAxis() && newPlot.getxAxis() != null) { + newPlot.getxAxis().setZoom(oldPlot.getxAxis().isZoom()); + } + if (newPlot.isSupportTooltipInInteractivePane()) { + newPlot.setHotTooltipStyle(oldPlot.getHotTooltipStyle()); + } + + if (newPlot.isSupportAutoRefresh()) { + newPlot.setAutoRefreshPerSecond(oldPlot.getAutoRefreshPerSecond()); + } + + if (newPlot.isSupportAxisTip()) { + newPlot.setInteractiveAxisTooltip(oldPlot.isInteractiveAxisTooltip()); + } + } + return newPlot; + } + + //平面3D的默认属性设置 + private void createCondition4Plane3D(Chart chart) { + if (chart != null) { + //标题 + Title title = new Title(chart.getTitle().getTextObject()); + chart.setTitle(title); + title.setTitleVisible(true); + TextAttr textAttr = title.getTextAttr(); + if (textAttr == null) { + textAttr = new TextAttr(); + title.setTextAttr(textAttr); + } + title.setPosition(Constants.CENTER); + textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 16f, new Color(51, 51, 51))); + + //图例 + Legend legend = new Legend(); + legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128))); + legend.setPosition(Constants.TOP); + chart.getPlot().setLegend(legend); + + //分类轴,现在只有柱形图,条形图,面积图 + if (chart.getPlot() instanceof CategoryPlot) { + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + //分类轴设置 + Axis cateAxis = plot.getxAxis(); + cateAxis.setAxisStyle(Constants.LINE_THICK); + cateAxis.setAxisColor(new Color(57, 57, 57)); + cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setShowAxisLabel(true); + cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(57, 57, 57))); + + //值轴设置 + Axis valueAxis = plot.getyAxis(); + valueAxis.setAxisStyle(Constants.LINE_NONE); + valueAxis.setTickMarkType(Constants.TICK_MARK_NONE); + valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + valueAxis.setShowAxisLabel(false); + + //绘图区 + plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); + plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); + chart.setBorderStyle(Constants.LINE_NONE); + + //数据标签 + ConditionAttr attrList = plot.getConditionCollection().getDefaultAttr(); + DataSeriesCondition attr = attrList.getExisted(AttrContents.class); + if (attr != null) { + attrList.remove(attr); + } + AttrContents attrContents = new AttrContents(); + attrContents.setPosition(Constants.OUTSIDE); + attrContents.setSeriesLabel(ChartConstants.VALUE_PARA); + attrContents.setTextAttr(new TextAttr(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(51, 51, 51)))); + attrList.addDataSeriesCondition(attrContents); + } + } + } + + //透明风格的默认属性设置 + private void createCondition4Transparent(Chart chart) { + if (chart != null) { + //标题 + Title title = new Title(chart.getTitle().getTextObject()); + chart.setTitle(title); + title.setTitleVisible(true); + TextAttr textAttr = title.getTextAttr(); + if (textAttr == null) { + textAttr = new TextAttr(); + title.setTextAttr(textAttr); + } + title.setPosition(Constants.LEFT); + textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(192, 192, 192))); + + //图例 + Legend legend = new Legend(); + legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139))); + legend.setPosition(Constants.RIGHT_TOP); + chart.getPlot().setLegend(legend); + + Plot plot = chart.getPlot(); + //绘图区 + chart.setBackground(ColorBackground.getInstance(new Color(51, 51, 51))); + + //分类轴,现在只有柱形图,条形图,面积图 + if (plot instanceof CategoryPlot) { + //边框 + plot.setBorderStyle(Constants.LINE_THIN); + plot.setBorderColor(new Color(65, 65, 65)); + + //分类轴设置 + Axis cateAxis = plot.getxAxis(); + cateAxis.setAxisStyle(Constants.LINE_THICK); + cateAxis.setAxisColor(new Color(192, 192, 192)); + cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setShowAxisLabel(true); + cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(150, 150, 150))); + + //值轴 + Axis valueAxis = plot.getyAxis(); + valueAxis.setShowAxisLabel(true); + valueAxis.setAxisStyle(Constants.LINE_NONE); + valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(150, 150, 150))); + valueAxis.setMainGridStyle(Constants.LINE_THIN); + valueAxis.setMainGridColor(new Color(63, 62, 62)); + } + } + } + + //渐变的默认属性设置 + private void createCondition4Shade(Chart chart) { + if (chart != null) { + //标题 + Title title = new Title(chart.getTitle().getTextObject()); + chart.setTitle(title); + title.setTitleVisible(true); + TextAttr textAttr = title.getTextAttr(); + if (textAttr == null) { + textAttr = new TextAttr(); + title.setTextAttr(textAttr); + } + title.setPosition(Constants.CENTER); + textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(0, 51, 102))); + + //图例 + Legend legend = new Legend(); + legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128))); + legend.setPosition(Constants.BOTTOM); + chart.getPlot().setLegend(legend); + + //分类轴,现在只有柱形图,条形图,面积图 + if (chart.getPlot() instanceof CategoryPlot) { + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + + //分类轴设置 + Axis cateAxis = plot.getxAxis(); + cateAxis.setAxisStyle(Constants.LINE_THICK); + cateAxis.setAxisColor(new Color(73, 100, 117)); + cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setShowAxisLabel(true); + cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(128, 128, 128))); + + //值轴 + Axis valueAxis = plot.getyAxis(); + valueAxis.setShowAxisLabel(true); + valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(128, 128, 128))); + valueAxis.setAxisStyle(Constants.LINE_NONE); + + //绘图区 + plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); + plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); + plot.setHorizontalIntervalBackgroundColor(new Color(243, 243, 243)); + } + } + } + + //高光渐变的默认属性设置 + private void createCondition4HighLight(Chart chart) { + if (chart != null) { + //标题 + Title title = new Title(chart.getTitle().getTextObject()); + chart.setTitle(title); + title.setTitleVisible(true); + TextAttr textAttr = title.getTextAttr(); + if (textAttr == null) { + textAttr = new TextAttr(); + title.setTextAttr(textAttr); + } + title.setPosition(Constants.LEFT); + textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(51, 51, 51))); + + //图例 + Legend legend = new Legend(); + legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139))); + legend.setPosition(Constants.RIGHT_TOP); + chart.getPlot().setLegend(legend); + + //分类轴,现在只有柱形图,条形图,面积图 + if (chart.getPlot() instanceof CategoryPlot) { + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + + //分类轴设置 + Axis cateAxis = plot.getxAxis(); + cateAxis.setAxisStyle(Constants.LINE_THICK); + cateAxis.setAxisColor(new Color(204, 220, 228)); + cateAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); + cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setShowAxisLabel(true); + cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(138, 140, 139))); + + //值轴 + Axis valueAxis = plot.getyAxis(); + valueAxis.setAxisStyle(Constants.NONE); + valueAxis.setAxisColor(null); + valueAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); + valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + valueAxis.setShowAxisLabel(true); + valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(138, 140, 139))); + + //绘图区 + plot.setBorderStyle(Constants.LINE_THIN); + plot.setBorderColor(new Color(204, 220, 228)); + plot.setBackground(ColorBackground.getInstance(new Color(248, 247, 245))); + plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); + plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); + } + + } + } + + private void setPlotFillStyle(Chart chart) { + ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); + Plot plot = chart.getPlot(); + Object preStyle = null; + String name = ""; + if (styleList.get(STYLE_SHADE).isPressing) { + name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"); + preStyle = manager.getPreStyle(name); + } else if (styleList.get(STYLE_TRANSPARENT).isPressing) { + name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"); + preStyle = manager.getPreStyle(name); + } else if (styleList.get(STYLE_PLANE3D).isPressing) { + name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); + preStyle = manager.getPreStyle(name); + } else if (styleList.get(STYLE_HIGHLIGHT).isPressing) { + name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); + preStyle = manager.getPreStyle(name); + } + if (preStyle == null) { + plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT); + } else { + AttrFillStyle fillStyle = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle); + fillStyle.setFillStyleName(name); + plot.setPlotFillStyle(fillStyle); + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java index 425f508070..a50bc52b5e 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java @@ -17,7 +17,7 @@ import com.fr.locale.InterProviderFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午06:57:36 */ -public class AreaPlotPane extends AbstractChartTypePane{ +public class AreaPlotPane extends AbstractDeprecatedChartTypePane { private static final int STACK_AREA_CHART = 0; private static final int PERCENT_AREA_LINE_CHART = 1; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java index b3e7cd34ae..551a975235 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java @@ -13,8 +13,8 @@ import com.fr.locale.InterProviderFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午06:56:47 */ -public class BubblePlotPane extends AbstractChartTypePane { - private static final long serialVersionUID = -601566194238908115L; +public class BubblePlotPane extends AbstractDeprecatedChartTypePane { + private static final long serialVersionUID = -601566194238908115L; private static final int BUBBLE_CHART = 0; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java index 8e367444f3..f81b1168ce 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java @@ -11,7 +11,7 @@ import com.fr.locale.InterProviderFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-21 下午06:17:40 */ -public class CustomPlotPane extends AbstractChartTypePane { +public class CustomPlotPane extends AbstractDeprecatedChartTypePane { @Override protected String getPlotTypeID() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java index c1cd47d78f..0b57d225df 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java @@ -22,10 +22,10 @@ import java.text.DecimalFormat; * @author eason * */ -public class DonutPlotPane extends AbstractChartTypePane{ - private static final long serialVersionUID = -7084314809934346710L; - private static final int DONUT_CHART = 0; //2d圆环图 - private static final int THREE_D_DONUT_CHART = 1; //3D圆环图 +public class DonutPlotPane extends AbstractDeprecatedChartTypePane { + private static final long serialVersionUID = -7084314809934346710L; + private static final int DONUT_CHART = 0; //2d圆环图 + private static final int THREE_D_DONUT_CHART = 1; //3D圆环图 @Override protected String[] getTypeIconPath() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java index 2de685cb82..1b00f7a2aa 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java @@ -18,7 +18,7 @@ import java.text.DecimalFormat; * Time: 下午2:50 * To change this template use File | Settings | File Templates. */ -public class FunnelPlotPane extends AbstractChartTypePane{ +public class FunnelPlotPane extends AbstractDeprecatedChartTypePane { private static final int FUNNEL_CHART = 0; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java index b1845bfe4c..1bae398b52 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java @@ -11,7 +11,7 @@ import com.fr.locale.InterProviderFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午10:38:18 */ -public class GanttPlotPane extends AbstractChartTypePane{ +public class GanttPlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = -601566194238908115L; private static final int GANTT = 0; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java index 9911ce4fbf..e62f2e5c51 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java @@ -19,10 +19,10 @@ import java.awt.BorderLayout; import java.awt.Component; -public class GisMapPlotPane extends AbstractChartTypePane{ - +public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { + private static final long serialVersionUID = 2595221900000305396L; - + private static final int GISMAP = 0; private UITextField keyInput; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java index 0f93938bb0..e5e23d2bcf 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java @@ -9,7 +9,7 @@ import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; -public class LinePlotPane extends AbstractChartTypePane{ +public class LinePlotPane extends AbstractDeprecatedChartTypePane { private static final int LINE_CHART = 0; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java index d761be3712..2b606fc064 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java @@ -16,7 +16,7 @@ import com.fr.log.FineLoggerFactory; import javax.swing.JPanel; import java.awt.BorderLayout; -public class MapPlotPane extends AbstractChartTypePane { +public class MapPlotPane extends AbstractDeprecatedChartTypePane { private boolean isSvgMap = true; // 默认是svg地图 diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java index 10293b68c7..a02bcf5d10 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java @@ -16,9 +16,9 @@ import com.fr.log.FineLoggerFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午10:48:57 */ -public class MeterPlotPane extends AbstractChartTypePane { - - private static final int METER = 0; +public class MeterPlotPane extends AbstractDeprecatedChartTypePane { + + private static final int METER = 0; private static final int BLUE_METER =1; private static final int SIMPLE_METER = 2; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java index eeccd2246e..4212d76c48 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java @@ -21,8 +21,8 @@ import java.text.DecimalFormat; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午06:55:33 */ -public class PiePlotPane extends AbstractChartTypePane{ - private static final long serialVersionUID = -601566194238908115L; +public class PiePlotPane extends AbstractDeprecatedChartTypePane { + private static final long serialVersionUID = -601566194238908115L; private static final int PIE_CHART = 0; private static final int THREE_D_PIE_CHART = 1; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java index 50e4a756eb..e3e55cb853 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java @@ -11,7 +11,7 @@ import com.fr.locale.InterProviderFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午09:55:01 */ -public class RadarPlotPane extends AbstractChartTypePane{ +public class RadarPlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = -601566194238908115L; private static final int RADAR = 0; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java index f87c6074d4..c685b4c3be 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java @@ -12,7 +12,7 @@ import com.fr.locale.InterProviderFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午10:43:50 */ -public class RangePlotPane extends AbstractChartTypePane{ +public class RangePlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = -601566194238908115L; private static final int RANGE = 0; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java index 63f4ead335..c8c88fae1b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java @@ -11,8 +11,8 @@ import com.fr.locale.InterProviderFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午10:52:36 */ -public class StockPlotPane extends AbstractChartTypePane { - +public class StockPlotPane extends AbstractDeprecatedChartTypePane { + private static final int STOCK = 0; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java index 1f40de8be2..473c16c370 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java @@ -1,12 +1,14 @@ package com.fr.design.mainframe.chart.gui.type; import com.fr.chart.chartattr.Chart; +import com.fr.common.annotations.Compatible; /** * Created by mengao on 2017/8/30. * 不能删掉这个类,echarts插件中用到 */ -public abstract class UserDefinedChartTypePane extends AbstractChartTypePane { +@Compatible +public abstract class UserDefinedChartTypePane extends AbstractDeprecatedChartTypePane { protected String[] getTypeLayoutPath() { return new String[0]; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java index 46a5b13c07..eab3a98378 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java @@ -14,7 +14,7 @@ import com.fr.stable.Constants; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午08:33:55 */ -public class XYScatterPlotPane extends AbstractChartTypePane{ +public class XYScatterPlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = -601566194238908115L; private static final int XYSCATTER_CHART = 0; diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java index ccc39b525e..affc3a611a 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java @@ -1,6 +1,5 @@ package com.fr.extended.chart; -import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; @@ -9,7 +8,7 @@ import com.fr.design.mainframe.chart.gui.type.ChartImagePane; /** * Created by shine on 2018/3/5. */ -public class ExtendedTypePane extends AbstractChartTypePane { +public class ExtendedTypePane extends AbstractChartTypePane { @Override protected String[] getTypeIconPath() { @@ -35,7 +34,7 @@ public class ExtendedTypePane extends AbstractChartType } @Override - public void populateBean(Chart chart) { + public void populateBean(AbstractChart chart) { if (getTypeIconPath().length > 0) { for (ChartImagePane imagePane : typeDemo) { imagePane.isPressing = false; @@ -47,7 +46,7 @@ public class ExtendedTypePane extends AbstractChartType } @Override - public void updateBean(Chart chart) { + public void updateBean(AbstractChart chart) { update((T) chart); if (getTypeIconPath().length > 0) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index b16c9237e1..9ae650d97f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java @@ -12,9 +12,8 @@ import com.fr.design.gui.ilable.MultilineLabel; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; import com.fr.general.Background; -import com.fr.log.FineLoggerFactory; - import com.fr.js.NameJavaScriptGroup; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.base.VanChartZoom; @@ -25,7 +24,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -public abstract class AbstractVanChartTypePane extends AbstractChartTypePane{ +public abstract class AbstractVanChartTypePane extends AbstractChartTypePane { private static final long serialVersionUID = 7743244512351499265L; private UICheckBox largeModelCheckBox; diff --git a/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java b/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java index 097528c685..d06f77af41 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java @@ -64,9 +64,9 @@ public class PolyComponentsBar extends JToolBar { ); this.add(serIcons[0]); for (int i = 0; i < typeLen; i++) { - String chartID = typeName[i].getPlotID(); + String chartID = typeName[i].getChartID(); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID); - BaseChartCollection chartCollection = BaseChartGetter.getStaticChartCollection(chartID); + BaseChartCollection chartCollection = BaseChartGetter.createChartCollection(chartID); serIcons[i + 1] = new SerIcon(chartCollection, InterProviderFactory.getProvider().getLocText(typeName[i].getName()), iconPath); this.add(serIcons[i + 1]); } From a8993872e22b49fd7e857a83d34c4f4a69b27ca9 Mon Sep 17 00:00:00 2001 From: zheng Date: Wed, 10 Jul 2019 19:19:21 +0800 Subject: [PATCH 15/17] =?UTF-8?q?CHART-9141=20=E5=88=A0=E9=99=A4=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/gui/ChartDesignerOtherPane.java | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java deleted file mode 100644 index 4f109bd557..0000000000 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.chart.gui; - -import com.fr.design.mainframe.chart.gui.other.ChartDesignerConditionAttrPane; -import com.fr.design.mainframe.chart.gui.other.ChartDesignerInteractivePane; -import com.fr.design.dialog.BasicPane; - - -import javax.swing.*; -import java.awt.*; -import java.util.*; - -/** - * 图表设计器的图标属性表高级tab - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-16 - * Time: 下午2:04 - */ -public class ChartDesignerOtherPane extends ChartOtherPane { - - @Override - protected JPanel createContentPane() { - JPanel content = new JPanel(new BorderLayout()); - otherPane = new ChartTabPane(); - content.add(otherPane, BorderLayout.CENTER); - return content; - } - - /** - * 界面标题 - * - * @return 返回标题. - */ - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced"); - } - - private boolean isHaveCondition() { - return hasCondition; - } - - - private class ChartTabPane extends TabPane { - - @Override - protected java.util.List initPaneList() { - java.util.List paneList = new ArrayList(); - interactivePane = new ChartDesignerInteractivePane(ChartDesignerOtherPane.this); - - paneList.add(interactivePane); - - if (ChartDesignerOtherPane.this.isHaveCondition()) { - conditionAttrPane = new ChartDesignerConditionAttrPane(); - paneList.add(conditionAttrPane); - } - return paneList; - } - - } -} \ No newline at end of file From 7c76b1e46323e216467734712141381b0884c84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Wed, 17 Jul 2019 17:25:55 +0800 Subject: [PATCH 16/17] =?UTF-8?q?CHART-4798=20=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 分类系列使用字段名时,value和series的fieldName放反了 --- .../chartx/component/SeriesValueFieldComboBoxPane.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java index 30ae364b74..4372cf0db1 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java @@ -79,8 +79,8 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan List list = new ArrayList(); for (SeriesValueField seriesValueField : seriesValueCorrelationDefinition.getSeriesValueFieldList()) { Object[] array = new Object[]{ - seriesValueField.getSeries().getFieldName(), seriesValueField.getValue().getFieldName(), + seriesValueField.getSeries().getFieldName(), DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction()) }; list.add(array); @@ -92,8 +92,8 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan protected void setTableModelListToTBean(List tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { List seriesValueFields = new ArrayList(); for (Object[] line : tableValues) { - ColumnField series = new ColumnField(GeneralUtils.objectToString(line[0])); - ColumnField value = new ColumnField(GeneralUtils.objectToString(line[1])); + ColumnField value = new ColumnField(GeneralUtils.objectToString(line[0])); + ColumnField series = new ColumnField(GeneralUtils.objectToString(line[1])); value.setDataFunction(DataPaneHelper.getFunctionByName(GeneralUtils.objectToString(line[2]))); SeriesValueField seriesValueField = new SeriesValueField(); seriesValueField.setValue(value); From e191c65c9ca7afec2c14851c416f522a923a6f31 Mon Sep 17 00:00:00 2001 From: zheng Date: Thu, 18 Jul 2019 17:49:03 +0800 Subject: [PATCH 17/17] =?UTF-8?q?CHART-9141=20filter=E7=95=8C=E9=9D=A2&xml?= =?UTF-8?q?=E3=80=81processor=E4=B8=8D=E5=90=88=E7=90=86=E6=94=B9=E6=88=90?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E3=80=81result=E6=B5=81=E7=A8=8B=E4=B8=80?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/AbstractSingleFilterPane.java | 171 ++++++++++++++++++ .../diff/MultiCategoryCellDataFieldsPane.java | 47 +++++ .../diff/MultiCategoryDataSetFieldsPane.java | 47 +++++ .../actions/insert/flot/ChartFloatAction.java | 8 +- 4 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java new file mode 100644 index 0000000000..7c494aac1e --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java @@ -0,0 +1,171 @@ +package com.fr.design.chartx.component; + +import com.fr.base.Utils; +import com.fr.chartx.data.field.DataFilterProperties; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.TableLayout; +import com.fr.design.mainframe.chart.gui.data.PresentComboBox; +import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by shine on 2019/07/18. + */ +public abstract class AbstractSingleFilterPane extends AbstractChartTabPane { + + private static final int FIL_HEIGHT = 150; + + private UICheckBox useTopCheckBox; + + private UITextField topNumTextField; + private UICheckBox hideNullCheckBox; + private UICheckBox mergeOtherCheckBox; + + private PresentComboBox present; + + private AbstractAttrNoScrollPane parent; + + private JPanel topPane; + + public AbstractSingleFilterPane() { + super(true); + //todo@shinerefactor present的时候这边可以整理下 + // this.parent = parent; + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + dim.height = FIL_HEIGHT; + return dim; + } + + + protected void layoutContentPane() { + super.layoutContentPane(); + leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); + } + + public void reloaPane(JPanel pane) { + super.reloaPane(pane); + leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); + } + + @Override + protected JPanel createContentPane() { + this.setLayout(new BorderLayout()); + JPanel pane = initPane(); + this.add(pane, BorderLayout.NORTH); + return pane; + } + + + private JPanel initPane() { + useTopCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); + JPanel panel1 = new JPanel(new BorderLayout()); + JPanel panel2 = new JPanel(new BorderLayout()); + panel1.add(useTopCheckBox, BorderLayout.NORTH); + topNumTextField = new UITextField(); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Records_Num")); + mergeOtherCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); + mergeOtherCheckBox.setSelected(true); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + new Component[]{label, topNumTextField}, + new Component[]{mergeOtherCheckBox, null} + }; + + topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + topPane.setBorder(BorderFactory.createEmptyBorder(10, 15, 0, 0)); + //默认不显示 + topPane.setVisible(false); + panel1.add(topPane, BorderLayout.CENTER); + hideNullCheckBox = new UICheckBox(title4PopupWindow() + " is null, hidden"); + panel2.add(hideNullCheckBox, BorderLayout.NORTH); + + useTopCheckBox.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + checkBoxUse(); + } + }); + + present = new PresentComboBox() { + protected void fireChange() { + fire(); + } + }; + JPanel presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present"), present); + panel2.add(presentPane, BorderLayout.SOUTH); + + double[] column = {f}; + double[] row = {p, p}; + Component[][] coms = new Component[][]{ + new Component[]{panel1}, + new Component[]{panel2} + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(coms, row, column); + } + + + private void fire() { + if (this.parent != null) { + parent.attributeChanged(); + } + } + + /** + * 检查Box是否可用 + */ + public void checkBoxUse() { + topPane.setVisible(useTopCheckBox.isSelected()); + } + + @Override + public void populateBean(DataFilterProperties ob) { + useTopCheckBox.setSelected(ob.isUseTop()); + + topNumTextField.setText(String.valueOf(ob.getTop())); + + hideNullCheckBox.setSelected(ob.isHideNull()); + + mergeOtherCheckBox.setSelected(ob.isMerge()); + + present.populate(ob.getPresent()); + + checkBoxUse(); + } + + @Override + public DataFilterProperties updateBean() { + DataFilterProperties dataFilterProperties = new DataFilterProperties(); + + dataFilterProperties.setUseTop(useTopCheckBox.isSelected()); + + Number number = Utils.objectToNumber(topNumTextField.getText(), true); + if (number != null) { + dataFilterProperties.setTop(number.intValue()); + } + dataFilterProperties.setHideNull(hideNullCheckBox.isSelected()); + + dataFilterProperties.setMerge(mergeOtherCheckBox.isSelected()); + + dataFilterProperties.setPresent(present.update()); + + return dataFilterProperties; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java index 76588271e4..3645a08db7 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java @@ -1,9 +1,12 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; import com.fr.design.chartx.component.MultiTinyFormulaPane; import com.fr.design.formula.TinyFormulaPane; +import com.fr.van.chart.map.designer.VanChartGroupPane; import javax.swing.JPanel; import java.util.List; @@ -15,6 +18,9 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS private MultiTinyFormulaPane multiCategoryPane; + private AbstractSingleFilterPane seriesFilterPane; + private AbstractSingleFilterPane categoryFilterPane; + private void createMultiFormulaPane() { if (multiCategoryPane == null) { multiCategoryPane = new MultiTinyFormulaPane(); @@ -29,6 +35,28 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS return multiCategoryPane; } + @Override + protected JPanel createSouthPane() { + if (seriesFilterPane == null) { + seriesFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + //todo@shinerefactor + return "series"; + } + }; + categoryFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return "category"; + } + }; + } + return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} + , new JPanel[]{seriesFilterPane, categoryFilterPane}) { + }; + } + @Override protected String[] fieldLabels() { return new String[0]; @@ -51,6 +79,16 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS multiCategoryPane.populate(categoryList); populateSeriesValuePane(multiCategoryColumnFieldCollection); + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); + } } @Override @@ -63,6 +101,15 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS updateSeriesValuePane(fieldCollection); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); + } + return fieldCollection; } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java index 1abe2b1849..5b18d8ae83 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -1,9 +1,12 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; import com.fr.design.chartx.component.MultiComboBoxPane; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.van.chart.map.designer.VanChartGroupPane; import javax.swing.JPanel; import java.util.List; @@ -16,6 +19,9 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer private MultiComboBoxPane multiCategoryPane; + private AbstractSingleFilterPane seriesFilterPane; + private AbstractSingleFilterPane categoryFilterPane; + @Override protected String[] fieldLabels() { return new String[0]; @@ -39,6 +45,28 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer return initMultiCategoryPane(); } + @Override + protected JPanel createSouthPane() { + if (seriesFilterPane == null) { + seriesFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + //todo@shinerefactor + return "series"; + } + }; + categoryFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return "category"; + } + }; + } + return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} + , new JPanel[]{seriesFilterPane, categoryFilterPane}) { + }; + } + @Override public void refreshBoxListWithSelectTableData(List columnNameList) { super.refreshBoxListWithSelectTableData(columnNameList); @@ -52,6 +80,16 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer multiCategoryPane.populate(categoryList); populateSeriesValuePane(multiCategoryColumnFieldCollection); + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); + } } @Override @@ -64,6 +102,15 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer updateSeriesValuePane(columnFieldCollection); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = columnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); + } + return columnFieldCollection; } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java index d7ab0f9b15..b8f05c2e4a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java @@ -15,10 +15,9 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; import com.fr.design.module.DesignModuleFactory; -import com.fr.log.FineLoggerFactory; - import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; +import com.fr.log.FineLoggerFactory; import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; import com.fr.report.elementcase.TemplateElementCase; @@ -27,8 +26,8 @@ import com.fr.stable.bridge.StableFactory; import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; -import javax.swing.*; -import java.awt.*; +import javax.swing.KeyStroke; +import java.awt.Color; /** * 图表插入悬浮元素的操作. @@ -80,7 +79,6 @@ public class ChartFloatAction extends ElementCaseAction { reportPane.stopEditing(); final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG); - cc.removeAllNameObject(); final MiddleChartDialog chartDialog = DesignModuleFactory.getChartDialog(DesignerContext.getDesignerFrame()); chartDialog.populate(cc); chartDialog.addDialogActionListener(new DialogActionAdapter() {