Browse Source

CHART-22529 切换控件标题自定义—设计器面板

feature/x
方磊 3 years ago
parent
commit
650fd5ccb4
  1. 39
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java

39
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java

@ -71,7 +71,8 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
private UIButtonGroup switchStyleGroup;
private JPanel chartTypesPane;
private TinyFormulaPane switchTitlePane;
private List<TinyFormulaPane> switchTitles = new ArrayList<>();
private JPanel switchTitlePane = new JPanel();
private List<ChangeChartButton> changeChartButtons = new ArrayList<>();
private int selectedChart; // 设置面板里面选取的图表,不是真正切换的图表
@ -87,10 +88,11 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p,p};
double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Change_Style")),configStyleButton},
new Component[]{configPane, null},
new Component[]{createButtonContentPane(), null}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
@ -170,7 +172,7 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
chartTypesPane = new JPanel();
chartTypesPane.setLayout(new BoxLayout(chartTypesPane, BoxLayout.Y_AXIS));
switchTitlePane = new TinyFormulaPane();
switchTitlePane.setLayout(new CardLayout());
buttonContentPane.add(chartTypesPane, BorderLayout.NORTH);
buttonContentPane.add(
@ -206,15 +208,16 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
changeChartButtons.add(button);
button.setSelected(i == select);
pane.add(button);
populateSwitchTitlePane(i, collection);
}
chartTypesPane.revalidate();
switchTitlePane.revalidate();
selectedChart = select;
populateSwitchTitlePane(collection, select);
}
private void populateSwitchTitlePane(ChartCollection collection, int chartIndex) {
private void populateSwitchTitlePane(int chartIndex, ChartCollection collection) {
Chart chart = collection.getChart(chartIndex, Chart.class);
Object switchTitle = chart.getSwitchTitle();
String result;
@ -227,7 +230,11 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
} else {
result = collection.getChartName(chartIndex);
}
switchTitlePane.populateBean(result);
TinyFormulaPane title = new TinyFormulaPane();
title.populateBean(result);
switchTitles.add(title);
switchTitlePane.add(title, collection.getChartName(chartIndex));
}
private JPanel createButtonConfigPane() {
@ -238,7 +245,6 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
Component[][] components = new Component[][]{
new Component[]{createTitleStylePane(), null},
new Component[]{createButtonBackgroundColorPane(), null},
new Component[]{createButtonContentPane(), null}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
@ -314,14 +320,17 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
}
private void updateSwitchTitle(ChartCollection collection) {
String titleString = switchTitlePane.updateBean();
int count = collection.getChartCount();
for (int i = 0; i < count; i++) {
String titleString = switchTitles.get(i).updateBean();
Object titleObj;
if (StableUtils.maybeFormula(titleString)) {
titleObj = BaseFormula.createFormulaBuilder().build(titleString);
} else {
titleObj = titleString;
}
collection.getChart(selectedChart, Chart.class).setSwitchTitle(titleObj);
collection.getChart(i, Chart.class).setSwitchTitle(titleObj);
}
}
@Override
@ -330,6 +339,9 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
}
private class ChangeChartButton extends UIToggleButton {
private static final int BUTTON_WIDTH = 52;
private static final int BUTTON_HEIGHT = 20;
private ChartCollection collection;
private int buttonIndex;
@ -345,12 +357,17 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
@Override
public void mouseClicked(MouseEvent e) {
resetChangeChartButtons();
populateSwitchTitlePane(collection, buttonIndex);
CardLayout cardLayout = (CardLayout) switchTitlePane.getLayout();
cardLayout.show(switchTitlePane, collection.getChartName(buttonIndex));
ChangeChartButton.this.setSelected(true);
selectedChart = buttonIndex;
}
};
}
public Dimension getPreferredSize() {
return new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT);
}
}
private void resetChangeChartButtons() {

Loading…
Cancel
Save