From 92f454fb39d70489181093a71bf1756ea1555abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 12 May 2020 14:15:03 +0800 Subject: [PATCH] =?UTF-8?q?CHART-13535=20=E6=9B=B4=E6=94=B9=E9=A2=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A0=B7=E5=BC=8F=E4=B9=8B=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=85=8D=E8=89=B2=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../combobox/ColorSchemeComboBox.java | 5 +++ .../fr/design/module/ChartPreStyleAction.java | 8 ++++- .../component/VanChartFillStylePane.java | 34 +++++++++++++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java index 4358a728dd..db59179a31 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java @@ -82,6 +82,11 @@ public class ColorSchemeComboBox extends UIComboBox { return colorSchemes; } + public void refresh() { + this.colorSchemes = getColorSchemesFromConfig(); + this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray())); + } + public ColorInfo getSelectColorInfo() { String selectedItem = (String) getSelectedItem(); return colorSchemes.get(selectedItem); diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java index e0dbd8ba08..2efe12ca16 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java @@ -54,6 +54,12 @@ public class ChartPreStyleAction extends UpdateAction { if (frame != null) { frame.repaint(); } + new Thread() { + @Override + public void run() { + DesignerContext.getDesignerBean("vanChartFillStyle").refreshBeanElement(); + } + }.start(); } })); } @@ -61,7 +67,7 @@ public class ChartPreStyleAction extends UpdateAction { pane.populateBean(); dialog.setVisible(true); - + } public static final MenuKeySet CHART_DEFAULT_STYLE = new MenuKeySet() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java index 63c24a221b..be40fd59a9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java @@ -13,13 +13,17 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; +import com.fr.design.mainframe.DesignerBean; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane; import com.fr.design.style.background.gradient.FixedGradientBar; +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.BorderFactory; import javax.swing.JPanel; +import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -31,7 +35,7 @@ import java.awt.event.ActionListener; /** * Created by mengao on 2017/8/17. */ -public class VanChartFillStylePane extends BasicBeanPane { +public class VanChartFillStylePane extends BasicBeanPane implements DesignerBean { protected ColorSchemeComboBox styleSelectBox; @@ -124,6 +128,8 @@ public class VanChartFillStylePane extends BasicBeanPane { VanChartFillStylePane.this.revalidate(); } }); + + DesignerContext.setDesignerBean("vanChartFillStyle", this); } protected void initLayout() { @@ -231,7 +237,31 @@ public class VanChartFillStylePane extends BasicBeanPane { def.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem())); return def; } else { - return updateDefaultColor(); + return updateModifyColor(); } } + + private AttrFillStyle updateModifyColor() { + AttrFillStyle condition = new AttrFillStyle(); + condition.clearColors(); + ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo(); + boolean isGradient = selectColorInfo.isGradient(); + List colors = selectColorInfo.getColors(); + condition.setColorList(colors); + condition.setCustomFillStyle(true); + condition.setColorStyle(isGradient ? ChartConstants.COLOR_GRADIENT : ChartConstants.COLOR_ACC); + return condition; + } + + /** + * 刷新组件对象 + */ + public void refreshBeanElement() { + AttrFillStyle attrFillStyle = updateBean(); + + styleSelectBox.refresh(); + + populateBean(attrFillStyle); + GUICoreUtils.repaint(this); + } }