From 650fd5ccb4c69cd73801273ebeea34632c1d700b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 10 Jan 2022 15:39:35 +0800 Subject: [PATCH] =?UTF-8?q?CHART-22529=20=E5=88=87=E6=8D=A2=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E6=A0=87=E9=A2=98=E8=87=AA=E5=AE=9A=E4=B9=89=E2=80=94?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/chart/gui/ChangeConfigPane.java | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java index bed7c58c8..bbc923f4d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java @@ -71,7 +71,8 @@ public class ChangeConfigPane extends BasicBeanPane { private UIButtonGroup switchStyleGroup; private JPanel chartTypesPane; - private TinyFormulaPane switchTitlePane; + private List switchTitles = new ArrayList<>(); + private JPanel switchTitlePane = new JPanel(); private List changeChartButtons = new ArrayList<>(); private int selectedChart; // 设置面板里面选取的图表,不是真正切换的图表 @@ -87,10 +88,11 @@ public class ChangeConfigPane extends BasicBeanPane { 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 { 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 { 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 { } 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 { 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 { } private void updateSwitchTitle(ChartCollection collection) { - String titleString = switchTitlePane.updateBean(); - Object titleObj; - if (StableUtils.maybeFormula(titleString)) { - titleObj = BaseFormula.createFormulaBuilder().build(titleString); - } else { - titleObj = titleString; + 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(i, Chart.class).setSwitchTitle(titleObj); } - collection.getChart(selectedChart, Chart.class).setSwitchTitle(titleObj); } @Override @@ -330,6 +339,9 @@ public class ChangeConfigPane extends BasicBeanPane { } 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 { @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() {