diff --git a/designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java b/designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java index f534163b04..0abe78b34a 100644 --- a/designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java @@ -5,8 +5,10 @@ import com.fr.base.chart.BaseChartCollection; import com.fr.chartx.attr.ChartProvider; import com.fr.general.FRFont; import com.fr.report.cell.CellElement; +import com.fr.stable.collections.combination.Pair; import com.fr.stable.fun.mark.Selectable; +import java.awt.Color; import java.awt.Font; /** @@ -56,10 +58,19 @@ public interface DefaultValueAdjustProvider extends Selectable { /** * 修改设计可用字体默认列表 + * * @return */ default String[] getAvailableFontFamilyNames4Report() { return Utils.getAvailableFontFamilyNames4Report(); } + /** + * 修改配色方案默认值 + * @return + */ + default Pair adjustChartDefaultColorFill() { + + return new Pair<>(new Color[0], new Color[0]); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java index 823dd6ff3a..32b12f05a2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java @@ -9,6 +9,7 @@ import com.fr.config.predefined.PredefinedColorStyle; import com.fr.design.beans.BasicBeanPane; import com.fr.design.constants.LayoutConstants; import com.fr.design.event.UIObserverListener; +import com.fr.design.fun.DefaultValueAdjustProvider; import com.fr.design.gui.icombobox.ColorSchemeComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; @@ -17,7 +18,9 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.background.gradient.FixedGradientBarNoTheme; import com.fr.design.style.color.ColorAdjustPane; +import com.fr.design.utils.DesignUtils; import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; import javax.swing.JPanel; import java.util.Arrays; @@ -70,9 +73,20 @@ public class ColorFillStylePane extends BasicBeanPane { changeColorSetPane = new JPanel(cardLayout = new CardLayout()); changeColorSetPane.add(colorGradient = new FixedGradientBarNoTheme(4, 130), "gradient"); - gradientColors = new Color[]{Color.WHITE, FixedGradientBarNoTheme.NEW_CHARACTER}; - changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc"); - accColors = ColorAdjustPane.DEFAULT_COLORS; + DefaultValueAdjustProvider adjustProvider = DesignUtils.getValueAdjust(); + if (adjustProvider != null) { + Pair pair = adjustProvider.adjustChartDefaultColorFill(); + Color[] groupColors = pair.getFirst(); + colorAdjustPane = new ColorAdjustPane(groupColors); + gradientColors = pair.getSecond(); + accColors = groupColors; + } else { + colorAdjustPane = new ColorAdjustPane(); + gradientColors = new Color[]{Color.WHITE, FixedGradientBarNoTheme.NEW_CHARACTER}; + accColors = ColorAdjustPane.DEFAULT_COLORS; + } + changeColorSetPane.add(colorAdjustPane , "acc"); + cardLayout.show(changeColorSetPane, "acc"); customPane.add(changeColorSetPane, BorderLayout.CENTER); initListener(); diff --git a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java index e9c8b7a7d3..fd07f23932 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java @@ -4,6 +4,7 @@ import com.fr.base.FineColor; import com.fr.base.theme.FineColorDeriveState; import com.fr.base.theme.TemplateTheme; import com.fr.design.DesignerEnvManager; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; @@ -60,6 +61,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { private final JPanel menuColorPane; private ColorCell[][] themeColorCellGrid; + private ColorSelectorStyle colorSelector; + public static NewColorSelectPane createColorSelectPaneWithTheme(boolean supportTheme) { return new NewColorSelectPane(true, supportTheme); } @@ -156,6 +159,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { JPanel centerPane = new JPanel(new GridLayout(1, 8, DEFAULT_COLOR_HOR_INTERVAL, 0)); menuColorPane.add(northPane, BorderLayout.NORTH); menuColorPane.add(centerPane, BorderLayout.CENTER); + this.colorSelector = DesignModeContext.isDuchampMode() ? ColorSelectorStyle.FVS : ColorSelectorStyle.FR; Color[] colorArray = new Color[]{ // 8列主题色 @@ -177,11 +181,11 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { themeColorCellGrid = new ColorCell[colorArray.length][DEFAULT_DERIVE_COUNT]; for (int i = 0; i < colorArray.length; i++) { ColorCell[] colorCellColumn = new ColorCell[DEFAULT_DERIVE_COUNT]; - boolean isDefaultColor = (i == colorArray.length - 1 || i == colorArray.length - 2); + ColorConfig colorConfig = colorSelector.getColorConfig(i); Color color = colorArray[i]; - Color[] deriveColorArr = FineColorDeriveState.getDeriveColorArr(color, isDefaultColor, DEFAULT_DERIVE_COUNT); + Color[] deriveColorArr = colorConfig.getDeriveColorArr(color, DEFAULT_DERIVE_COUNT); for (int j = 0; j < deriveColorArr.length; j++) { - colorCellColumn[j] = createFineColorCell(deriveColorArr[j], isDefaultColor, i, j); + colorCellColumn[j] = createFineColorCell(deriveColorArr[j], !colorConfig.supportTheme, i, j); } themeColorCellGrid[i] = colorCellColumn; } @@ -215,13 +219,13 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { } } } - if (standardColors == null || standardColors.size() < 8) { + if (standardColors == null || standardColors.size() < 8 || standardColors.size() > 10) { return; } - - for (int i = 0; i < themeColorCellGrid.length - 2; i++) { - Color color = standardColors.get(i); - Color[] deriveColorArr = FineColorDeriveState.getDeriveColorArr(color, false, DEFAULT_DERIVE_COUNT); + for (int i = 0; i < standardColors.size(); i++) { + Color standardColor = standardColors.get(i); + ColorConfig colorConfig = colorSelector.getColorConfig(i); + Color[] deriveColorArr = colorConfig.getDeriveColorArr(standardColor, DEFAULT_DERIVE_COUNT); for (int j = 0; j < deriveColorArr.length; j++) { themeColorCellGrid[i][j].setColor(deriveColorArr[j]); } @@ -447,5 +451,90 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { } } + private enum DeriveAlgorithm { + PLAIN_ALGORITHM { + public Color[] getDeriveColorArr(Color color, int defaultDeriveCount) { + return FineColorDeriveState.getDeriveColorArr(color, false, defaultDeriveCount); + } + }, + + DEFAULT_DERIVE_ALGORITHM { + public Color[] getDeriveColorArr(Color color, int defaultDeriveCount) { + return FineColorDeriveState.getDeriveColorArr(color, true, defaultDeriveCount); + } + }; + + public abstract Color[] getDeriveColorArr(Color color, int defaultDeriveCount); + } + + private static class ColorConfig { + private boolean supportTheme; + private DeriveAlgorithm algorithm; + + private ColorConfig(boolean supportTheme, DeriveAlgorithm algorithm) { + this.supportTheme = supportTheme; + this.algorithm = algorithm; + } + + public static ColorConfig createThemeColorConfig(DeriveAlgorithm deriveAlgorithm) { + return new ColorConfig(true, deriveAlgorithm); + } + + public static ColorConfig createThemeColorConfig(boolean supportTheme, DeriveAlgorithm deriveAlgorithm) { + return new ColorConfig(supportTheme, deriveAlgorithm); + } + + + public Color[] getDeriveColorArr(Color color, int defaultDeriveCount){ + return algorithm.getDeriveColorArr(color, defaultDeriveCount); + } + } + + private enum ColorSelectorStyle { + FR, + FVS { + public List getColorConfigs() { + ArrayList colorConfigs = new ArrayList<>(); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.DEFAULT_DERIVE_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.DEFAULT_DERIVE_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + return colorConfigs; + } + }; + + public List getColorConfigs() { + ArrayList colorConfigs = new ArrayList<>(); + // 8列主题色 + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(DeriveAlgorithm.PLAIN_ALGORITHM)); + // 2列灰度色 + colorConfigs.add(ColorConfig.createThemeColorConfig(false, DeriveAlgorithm.DEFAULT_DERIVE_ALGORITHM)); + colorConfigs.add(ColorConfig.createThemeColorConfig(false, DeriveAlgorithm.DEFAULT_DERIVE_ALGORITHM)); + return colorConfigs; + } + + public ColorConfig getColorConfig(int i) { + List colorConfigs = getColorConfigs(); + if (i < 0 || i > colorConfigs.size()) { + return colorConfigs.get(0); + } + return colorConfigs.get(i); + } + + + } } 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 60f208f228..54ff15fab8 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 @@ -56,10 +56,11 @@ public class DefaultStyleHelper4Van { dealChartColor((VanChart) chartProvider); // //主题中没有的 根据主题深浅色自动 的属性 默认自动 // ((VanChart) chart4Update).setAutoThemeCustom(); - DefaultValueAdjustProvider adjustProvider = DesignUtils.getValueAdjust(); - if (adjustProvider != null) { - adjustProvider.adjustChart(chartProvider); - } + } + + DefaultValueAdjustProvider adjustProvider = DesignUtils.getValueAdjust(); + if (adjustProvider != null) { + adjustProvider.adjustChart(chartProvider); } }