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..5d7a9e67d7 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 @@ -1,6 +1,7 @@ package com.fr.design.module; import com.fr.base.ChartPreStyleConfig; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -8,11 +9,14 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; import com.fr.general.IOUtils; +import com.fr.module.ModuleContext; import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; +import com.fr.van.chart.designer.component.VanChartFillStylePane; import javax.swing.KeyStroke; +import java.util.concurrent.ExecutorService; import java.awt.event.ActionEvent; /** @@ -22,6 +26,9 @@ import java.awt.event.ActionEvent; */ public class ChartPreStyleAction extends UpdateAction { + private static ExecutorService refreshDesignPool = ModuleContext.getExecutor().newFixedThreadPool( + 10, new NamedThreadFactory("refreshChartStylePane")); + public ChartPreStyleAction() { this.setMenuKeySet(CHART_DEFAULT_STYLE); this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); @@ -54,6 +61,20 @@ public class ChartPreStyleAction extends UpdateAction { if (frame != null) { frame.repaint(); } + if (refreshDesignPool.isTerminated()) { + synchronized (refreshDesignPool) { + if (refreshDesignPool.isTerminated()) { + refreshDesignPool = ModuleContext.getExecutor().newFixedThreadPool( + 10, new NamedThreadFactory("refreshChartStylePane")); + } + } + } + refreshDesignPool.execute(new Runnable() { + @Override + public void run() { + DesignerContext.getDesignerBean(VanChartFillStylePane.name).refreshBeanElement(); + } + }); } })); } @@ -61,7 +82,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..7173f9678f 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,8 +35,9 @@ import java.awt.event.ActionListener; /** * Created by mengao on 2017/8/17. */ -public class VanChartFillStylePane extends BasicBeanPane { +public class VanChartFillStylePane extends BasicBeanPane implements DesignerBean { + public static final String name = "vanChartFillStyle"; protected ColorSchemeComboBox styleSelectBox; protected JPanel customPane; @@ -71,6 +76,8 @@ public class VanChartFillStylePane extends BasicBeanPane { customPane.add(changeColorSetPane, BorderLayout.CENTER); initListener(); initLayout(); + DesignerContext.setDesignerBean(name, this); + } private void initListener() { @@ -231,7 +238,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); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java index 8f6d3456f5..eb8bd0f16d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java @@ -35,7 +35,7 @@ public class VanChartTrendLinePane extends BasicPane{ private static final int PREFERRED_WIDTH = 100; private static final double LINE_WIDTH_MIN_VALUE = 0.5; private static final double LINE_WIDTH_DIERTA_VALUE = 0.5; - private static final double LINE_WIDTH_DEFAULT_VALUE = 2; + private static final double LINE_WIDTH_DEFAULT_VALUE = 1; private UITextField trendLineName; private ColorSelectBox trendLineColor; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java index 6f88e586ca..85aff83629 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java @@ -47,7 +47,7 @@ public class VanChartAlertValuePane extends BasicBeanPane { private static final int PREFERRED_WIDTH = 100; private static final double LINE_WIDTH_MIN_VALUE = 0.5; private static final double LINE_WIDTH_DIERTA_VALUE = 0.5; - private static final double LINE_WIDTH_DEFAULT_VALUE = 2; + private static final double LINE_WIDTH_DEFAULT_VALUE = 1; private UIButtonGroup alertAxis; protected TinyFormulaPane alertValue;