Browse Source
* commit '5ca412689276abc73124c3107fa3eab33e9b45da': CHART-9141 ChartRequestService新增+chart service move to chart module+chartdata remove from engine-cross xchart rename to chartProvider CHART-9141 se.cellCC && floatCC 调用图表统一接口 删除BaseChart 各resultProcessor 初步的流程走通 多层饼图research/10.0
Bjorn
6 years ago
28 changed files with 467 additions and 475 deletions
@ -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<Chart> { |
||||
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; |
||||
} |
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
Loading…
Reference in new issue