From 922fa090ade9f0a7a0c074704e93de499aabfa9b Mon Sep 17 00:00:00 2001 From: shine Date: Wed, 1 Dec 2021 15:42:48 +0800 Subject: [PATCH] =?UTF-8?q?CHART-22060=20fix:fvs.cpt.chart=20=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E4=BD=BF=E7=94=A8=E7=9A=84=E9=BB=98=E8=AE=A4=E9=85=8D?= =?UTF-8?q?=E8=89=B2=E5=92=8C=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=8D=E5=90=8C=20=E5=90=8Cfvs.chart=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E9=85=8D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/chart/ChartTypePane.java | 10 +-- .../impl/ChartHyperPoplinkPane.java | 12 +--- .../chart/gui/ChartTypeButtonPane.java | 9 +-- .../chart/config/DefaultStyleConstants.java | 43 +++++++----- .../chart/config/DefaultStyleHelper4Van.java | 66 +++++++++++++++---- .../type/AbstractVanChartTypePane.java | 15 +---- 6 files changed, 90 insertions(+), 65 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index ffa1d5002c..1408b6a770 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -11,10 +11,9 @@ import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.info.ChartInfoCollector; -import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; -import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.van.chart.config.DefaultStyleHelper4Van; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; @@ -155,12 +154,7 @@ public class ChartTypePane extends ChartCommonWizardPane implements CallbackEven } } - if (!ChartEditContext.supportTheme() && chart4Update instanceof VanChart) { - //主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义 - ((VanChart) chart4Update).setThemeCustom(); -// //主题中没有的 根据主题深浅色自动 的属性 默认自动 -// ((VanChart) chart4Update).setAutoThemeCustom(); - } + DefaultStyleHelper4Van.checkChartDefaultStyle4Duchamp(chart4Update); update(chart4Update); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java index 855f4cbbc8..11d2e32e4d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java @@ -12,14 +12,13 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.hyperlink.AbstractHyperLinkPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.ChartHyperEditPane; -import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; -import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.van.chart.config.DefaultStyleHelper4Van; -import java.util.HashMap; import java.awt.BorderLayout; import java.awt.Dimension; +import java.util.HashMap; /** * 类说明: 图表超链 -- 弹出 悬浮窗. @@ -73,12 +72,7 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane implemen addButton.addActionListener((e) -> { String name = getNewChartName(); ChartProvider chart = getChangeStateNewChart(); - if (!ChartEditContext.supportTheme() && chart instanceof VanChart) { - //主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义 - ((VanChart) chart).setThemeCustom(); -// //主题中没有的 根据主题深浅色自动 的属性 默认自动 -// ((VanChart) chart4Update).setAutoThemeCustom(); - } + DefaultStyleHelper4Van.checkChartDefaultStyle4Duchamp(chart); checkInForm(chart); addNewChart(chart, name, editingCollection.getChartCount()); }); diff --git a/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java b/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java index 6d0de41cee..0e692f697a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java +++ b/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java @@ -64,28 +64,39 @@ public class DefaultStyleConstants { static final Background BACK = null; + //新特新 + public static String COLOR_NAME_1; + //经典高亮 + private static String COLOR_NAME_2; + + static { + try { + COLOR_NAME_1 = CodeUtils.cjkDecode("\u65b0\u7279\u6027"); + COLOR_NAME_2 = CodeUtils.cjkDecode("\u7ecf\u5178\u9ad8\u4eae"); + } catch (Exception e) { + e.printStackTrace(); + } + } + static String COLORS = null; static { ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); - try { - DefaultStyleConstants.COLORS = CodeUtils.cjkDecode("\u7ecf\u5178\u9ad8\u4eae"); - // 没有经典高亮, 用新特性 - if (config.getPreStyle(DefaultStyleConstants.COLORS) == null) { - DefaultStyleConstants.COLORS = CodeUtils.cjkDecode("\u65b0\u7279\u6027"); - } - // 没有新特性, 用第一个配色 - if (config.getPreStyle(DefaultStyleConstants.COLORS) == null) { - if (config.names().hasNext()) { - - String name = GeneralUtils.objectToString(config.names().next()); - if (config.getPreStyle(name) != null) { - DefaultStyleConstants.COLORS = name; - } + + COLORS = COLOR_NAME_2; + // 没有经典高亮, 用新特性 + if (config.getPreStyle(COLORS) == null) { + COLORS = COLOR_NAME_1; + } + // 没有新特性, 用第一个配色 + if (config.getPreStyle(COLORS) == null) { + if (config.names().hasNext()) { + + String name = GeneralUtils.objectToString(config.names().next()); + if (config.getPreStyle(name) != null) { + COLORS = name; } } - } catch (Exception e) { - e.printStackTrace(); } } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleHelper4Van.java b/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleHelper4Van.java index d6fc30bd5d..8421492fa8 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleHelper4Van.java +++ b/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleHelper4Van.java @@ -1,11 +1,14 @@ package com.fr.van.chart.config; +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; import com.fr.chart.base.AttrBorder; import com.fr.chart.base.AttrFillStyle; import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.DataSheet; +import com.fr.chartx.attr.ChartProvider; import com.fr.config.predefined.ColorFillStyle; import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.PiePlot4VanChart; @@ -19,6 +22,7 @@ import com.fr.plugin.chart.custom.type.CustomPlotType; import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.type.GaugeStyle; +import com.fr.plugin.chart.vanchart.VanChart; /** * @author shine @@ -28,8 +32,27 @@ import com.fr.plugin.chart.type.GaugeStyle; */ public class DefaultStyleHelper4Van { + private static boolean duchampMode() { + try { + return ChartEditContext.duchampMode(); + } catch (Throwable e) { + //tomcat预览 默认数据的图表 + return true; + } + } + + public static void checkChartDefaultStyle4Duchamp(ChartProvider chartProvider) { + if (!ChartEditContext.supportTheme() && chartProvider instanceof VanChart) { + //主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义 + ((VanChart) chartProvider).setThemeCustom(); + dealChartColor((VanChart) chartProvider); +// //主题中没有的 根据主题深浅色自动 的属性 默认自动 +// ((VanChart) chart4Update).setAutoThemeCustom(); + } + } + public static void dealVanPlot4Custom(VanChartPlot plot, CustomPlotType customPlotType) { - if (!ChartEditContext.duchampMode()) { + if (!duchampMode()) { return; } dealVanPlotCommonAttr(plot); @@ -60,7 +83,7 @@ public class DefaultStyleHelper4Van { } public static VanChartAxis dealAxisDefault(VanChartAxis axis) { - if (!ChartEditContext.duchampMode()) { + if (!duchampMode()) { return axis; } axis.getTitle().getTextAttr().setFRFont(DefaultStyleConstants.AXIS_TITLE); @@ -71,28 +94,20 @@ public class DefaultStyleHelper4Van { } public static void dealAxisAlert(VanChartAlertValue vanChartAlertValue) { - if (!ChartEditContext.duchampMode()) { + if (!duchampMode()) { return; } vanChartAlertValue.setAlertFont(DefaultStyleConstants.ALERT_FONT); } static void dealVanPlotCommonAttr(Plot plot) { - if (!ChartEditContext.duchampMode()) { + if (!duchampMode()) { return; } if (plot instanceof VanChartPlot) { VanChartPlot vanChartPlot = (VanChartPlot) plot; - ColorFillStyle colorFillStyle = new ColorFillStyle(); - colorFillStyle.setColorStyle(ChartConstants.COLOR_ACC); - colorFillStyle.setFillStyleName(DefaultStyleConstants.COLORS); - AttrFillStyle plotFillStyle = vanChartPlot.getPlotFillStyle(); - if (plotFillStyle == null) { - plotFillStyle = new AttrFillStyle(); - vanChartPlot.setPlotFillStyle(plotFillStyle); - } - plotFillStyle.setColorFillStyle(colorFillStyle); + dealChartColor(vanChartPlot); if (vanChartPlot.getLegend() != null) { vanChartPlot.getLegend().setFRFont(DefaultStyleConstants.LEGEND); @@ -118,6 +133,31 @@ public class DefaultStyleHelper4Van { } + private static void dealChartColor(VanChart vanChart) { + dealChartColor(vanChart.getPlot()); + } + + private static void dealChartColor(VanChartPlot vanChartPlot) { + ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); + Object preStyle = manager.getPreStyle(DefaultStyleConstants.COLORS); + if (preStyle instanceof ChartColorMatching) { + ColorFillStyle colorFillStyle = new ColorFillStyle(); + //default是默认的意思,为服务器默认配色方案 + //acc为多个颜色组合 + //gradient为渐变颜色 + colorFillStyle.setColorStyle(ChartConstants.COLOR_ACC); + colorFillStyle.setFillStyleName(DefaultStyleConstants.COLORS); + colorFillStyle.setColorList(((ChartColorMatching) preStyle).getColorList()); + + AttrFillStyle plotFillStyle = vanChartPlot.getPlotFillStyle(); + if (plotFillStyle == null) { + plotFillStyle = new AttrFillStyle(); + vanChartPlot.setPlotFillStyle(plotFillStyle); + } + plotFillStyle.setColorFillStyle(colorFillStyle); + } + } + private static void dealBorder(VanChartPlot vanChartPlot) { ConditionAttr defaultAttr = vanChartPlot.getConditionCollection().getDefaultAttr(); AttrBorder attrBorder = defaultAttr.getExisted(AttrBorder.class); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index 03faf95245..ef58809795 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java @@ -32,6 +32,7 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.base.VanChartZoom; import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.van.chart.config.DefaultStyleHelper4Van; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -145,12 +146,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane