Browse Source

多层饼图

research/10.0
zheng 5 years ago
parent
commit
a4bff1b769
  1. 21
      designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java
  2. 2
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java
  3. 150
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java
  4. 10
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java
  5. 40
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java
  6. 25
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java
  7. 6
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java
  8. 67
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java
  9. 94
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java
  10. 15
      designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java

21
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());
}
}

2
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.
* 一列组件<T extends JComponent> 可增可删
* 一列组件<T extends JComponent> 可增可删通过JComponent后面的加减button增删
*/
public abstract class AbstractMultiComponentPane<T extends JComponent> extends JPanel {
private static final int COM_W = 96;

150
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.
* 一列组件<T extends JComponent> 可增可删通过UISpinner增删
*/
public abstract class AbstractMultiComponentPaneWithUISpinner<T extends JComponent> extends JPanel {
private UISpinner levelNumSpinner;
private List<T> levelComponentList = new ArrayList<T>();
private JPanel levelPane;
private int currentNum = 3;
public AbstractMultiComponentPaneWithUISpinner() {
initComps();
}
public List<T> 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<T> newList = new ArrayList<T>();
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<ColumnField> 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<ColumnField> categoryList) {
categoryList.clear();
for (T comboBox : levelComponentList) {
ColumnField temp = new ColumnField();
categoryList.add(temp);
updateField(comboBox, temp);
}
}
}

10
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<UIComboBox> {
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<UIComboBox> {
@Override
protected UIComboBox createOtherFieldComponent() {
return new UIComboBox();
return new UIComboBox(currentBoxItems.toArray(new Object[currentBoxItems.size()]));
}
@Override

40
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<UIComboBox> {
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);
}
}

25
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<TinyFormulaPane> {
@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);
}
}

6
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<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList();

67
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<MultiPieColumnFieldCollection> {
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;
}
}

94
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<MultiPieColumnFieldCollection> {
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<UIComboBox> 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;
}
}

15
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<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot){

Loading…
Cancel
Save