From 1a6d9db38d4f29f7bfbc8818bf49b451d28c7d73 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 19 Aug 2021 16:37:46 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-56548=20=20=E8=A7=86=E8=A7=89=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../background/gradient/GradientBar.java | 3 +- .../design/style/color/ColorAdjustPane.java | 3 +- .../fr/design/style/color/ColorButton.java | 3 +- .../fr/design/style/color/ColorFactory.java | 13 ++++ .../fr/design/style/color/FineColorCell.java | 4 ++ .../style/color/NewColorSelectPane.java | 72 +++++++++++++------ .../fr/design/module/ChartPreStyleAction.java | 11 ++- .../range/component/LegendGradientBar.java | 3 +- .../actions/server/WidgetManagerAction.java | 10 +++ 9 files changed, 97 insertions(+), 25 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index b088864c0..17b8b5dfd 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -107,7 +107,8 @@ public class GradientBar extends JComponent implements UIObserver, ColorSelectab if (select >= 0) { ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, GradientBar.this); + Color selectColor = list.get(select).getColorInner() == null ? Color.WHITE : list.get(select).getColorInner(); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, GradientBar.this); Color color = GradientBar.this.getColor(); if (color != null) { DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java index 2903df72f..fc7fdddba 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java @@ -6,6 +6,7 @@ import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.style.AbstractSelectBox; import javax.swing.JPanel; @@ -202,7 +203,7 @@ public class ColorAdjustPane extends JPanel implements UIObserver { public JPanel initWindowPane(double preferredWidth) { // 下拉的时候重新生成面板,刷新最近使用颜色 - NewColorSelectPane colorPane = new NewColorSelectPane(false) { + NewColorSelectPane colorPane = new NewColorSelectPane(false, !DesignerContext.getDesignerFrame().isServerConfig()) { protected boolean selectRealTime() { return false; diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java b/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java index 02e113b7a..d0fcaf0cc 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java @@ -2,6 +2,7 @@ package com.fr.design.style.color; import com.fr.base.BaseUtils; import com.fr.base.background.ColorBackground; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.style.AbstractSelectBox; import javax.swing.JPanel; @@ -121,7 +122,7 @@ public class ColorButton extends AbstractSelectBox { public JPanel initWindowPane(double preferredWidth) { // 下拉的时候重新生成面板,刷新最近使用颜色 - colorPane = new NewColorSelectPane(false) { + colorPane = new NewColorSelectPane(false, !DesignerContext.getDesignerFrame().isServerConfig()) { @Override protected boolean selectRealTime() { diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorFactory.java b/designer-base/src/main/java/com/fr/design/style/color/ColorFactory.java index b22104f28..b643752b3 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorFactory.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorFactory.java @@ -71,5 +71,18 @@ public interface ColorFactory { new Color(0, 0, 255) }; + public static final Color STANDARD_COLORS[] = { + new Color(166, 89, 66), + new Color(166, 123, 66), + new Color(166, 66, 66), + new Color(103, 166, 66), + new Color(66, 121, 166), + new Color(68, 66, 166), + new Color(98, 66, 166), + new Color(146, 66, 166), + new Color(75, 18, 89), + new Color(89, 18, 51) + }; + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java b/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java index 62cc4e340..ab1cb47cd 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java +++ b/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java @@ -8,6 +8,10 @@ public class FineColorCell extends ColorCell { private final int x; private final int y; + public FineColorCell(Color color, ColorSelectable colorSelectable) { + this(color, colorSelectable, -1, -1); + } + public FineColorCell(Color color, ColorSelectable colorSelectable, int x, int y) { super(color, colorSelectable); this.x = x; 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 96378e7fe..7630381a2 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 @@ -84,15 +84,22 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { initMenuColorPane(menuColorPane1); } + JPanel standardColorPane = new JPanel(new BorderLayout(0, 5)); + standardColorPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + standardColorPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Standard_Color")), BorderLayout.CENTER); + centerPane.add(standardColorPane); + JPanel colorSelectPane = createStandardColorPane(); + standardColorPane.add(colorSelectPane, BorderLayout.SOUTH); + // 增加最近使用 pane JPanel row1Pane = new JPanel(new BorderLayout(0, 5)); row1Pane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - row1Pane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Used")), BorderLayout.NORTH); + row1Pane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Used")), BorderLayout.CENTER); centerPane.add(row1Pane); // 最近使用 usedColorPane = new NewUsedColorPane(8, this, selectRealTime()); usedColorPane.setPreferredSize(new Dimension(168, 16)); - row1Pane.add(usedColorPane.getPane(), BorderLayout.CENTER); + row1Pane.add(usedColorPane.getPane(), BorderLayout.SOUTH); // mod by anchore 16/11/16 final UIButton customButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_More_Color")); @@ -116,23 +123,48 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { centerPane.add(centerPane1); } + private JPanel createStandardColorPane(){ + JPanel jPanel = new JPanel(new GridLayout(1, 10, 3, 0)); + Color[] colorArray = ColorFactory.STANDARD_COLORS; + for (int i = 0; i < colorArray.length; i++) { + jPanel.add(new ColorCell(colorArray[i], this)); + } + return jPanel; + } + private void initThemeColorPane(JPanel menuColorPane){ - menuColorPane.setLayout(new GridLayout(1, 8, 3, 0)); + menuColorPane.setLayout(new BorderLayout(0, 10)); + JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0)); + JPanel centerPane = new JPanel(new GridLayout(1, 8, 3, 0)); + menuColorPane.add(northPane, BorderLayout.NORTH); + menuColorPane.add(centerPane, BorderLayout.CENTER); //todo 暂时先写死,后续对接的时候从主体里面拿主题配色 Color[] colorArray = new Color[]{Color.decode("#FFFFFF"), Color.decode("#CCCCCC"), Color.decode("#E6A48A"), Color.decode("#E68A8A"), Color.gray, Color.green, Color.DARK_GRAY, Color.CYAN, Color.YELLOW, Color.lightGray}; + for (int i = 0; i < colorArray.length; i++) { Color color = colorArray[i]; - boolean isDefaultColor = (i == 0 || i ==1); - JPanel jPanel = new JPanel(new GridLayout(5, 1, 0, 3)); - jPanel.add(new FineColorCell(color, this, i, 0)); - jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 1)); - jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 2)); - jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 3)); - jPanel.add(new FineColorCell(saturationDown(color, isDefaultColor), this, i, 4)); - menuColorPane.add(jPanel); + boolean isDefaultColor = (i == 0 || i == 1); + northPane.add(createFineColorCell(color, isDefaultColor, i, 0)); } + for (int i = 0; i < colorArray.length; i++) { + Color color = colorArray[i]; + boolean isDefaultColor = (i == 0 || i == 1); + JPanel jPanel = new JPanel(new GridLayout(4, 1, 0, 3)); + jPanel.add(createFineColorCell(color = saturationDown(color, isDefaultColor, true), isDefaultColor, i, 1)); + jPanel.add(createFineColorCell(saturationDown(color, isDefaultColor, true), isDefaultColor, i, 2)); + color = colorArray[i]; + jPanel.add(createFineColorCell(color = saturationDown(color, isDefaultColor, false), isDefaultColor, i, 3)); + jPanel.add(createFineColorCell(saturationDown(color, isDefaultColor, false), isDefaultColor, i, 4)); + centerPane.add(jPanel); + } + + } + + + private FineColorCell createFineColorCell(Color color, boolean isDefaultColor, int x, int y) { + return isDefaultColor ? new FineColorCell(color, this) : new FineColorCell(color, this, x - 2, y); } /** @@ -141,18 +173,18 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { * @param isDefaultColor * @return */ - public static Color saturationDown(Color color, boolean isDefaultColor) { + public static Color saturationDown(Color color, boolean isDefaultColor, boolean isLight) { float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]); if (!isDefaultColor) { - hsb[1] += PURITY_VALUE; + hsb[1] = isLight ? Math.max(0, hsb[1] - PURITY_VALUE) : Math.min(1, hsb[1] + PURITY_VALUE); } - hsb[2] -= BRIGHTNESS_VALUE; - return Color.getHSBColor(hsb[0], hsb[1], hsb[2]); + hsb[2] = isLight ? Math.min(1, hsb[2] + BRIGHTNESS_VALUE) : Math.max(0, hsb[2] - BRIGHTNESS_VALUE); + Color color1 = Color.getHSBColor(hsb[0], hsb[1], hsb[2]); + return color1; } - private void initMenuColorPane(JPanel menuColorPane){ - menuColorPane.setLayout(new GridLayout(5, 8, 1, 1)); - menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); + private void initMenuColorPane(JPanel menuColorPane) { + menuColorPane.setLayout(new GridLayout(5, 8, 3, 3)); Color[] colorArray = this.getColorArray(); for (int i = 0; i < colorArray.length; i++) { Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i]; @@ -280,9 +312,9 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { @Override public Dimension getPreferredSize() { if (isSupportTransparent) { - return new Dimension(197, 207); + return new Dimension(197, 265); } - return new Dimension(197, 192); + return new Dimension(197, 250); } /** 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 61b9a8c4f..e989e1a36 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 @@ -16,6 +16,8 @@ import com.fr.transaction.WorkerFacade; import com.fr.van.chart.designer.component.VanChartFillStylePane; import javax.swing.KeyStroke; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.concurrent.ExecutorService; import java.awt.event.ActionEvent; @@ -43,6 +45,7 @@ public class ChartPreStyleAction extends UpdateAction { */ public void actionPerformed(ActionEvent e) { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + DesignerContext.getDesignerFrame().setServerConfig(true); final ChartPreStyleManagerPane pane = new ChartPreStyleManagerPane(); BasicDialog dialog = pane.showWindow(designerFrame); dialog.addDialogActionListener(new DialogActionAdapter() { @@ -79,7 +82,13 @@ public class ChartPreStyleAction extends UpdateAction { })); } }); - + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + super.windowClosed(e); + DesignerContext.getDesignerFrame().setServerConfig(false); + } + }); pane.populateBean(); dialog.setVisible(true); diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java index 8401f86a9..6096056a4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java @@ -274,7 +274,8 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI private void dealClick(SelectColorPointBtn selectColorPointBtn) { ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); this.setColor(selectColorPointBtn.getColorInner()); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, LegendGradientBar.this); + Color selectColor = selectColorPointBtn.getColorInner() == null ? Color.WHITE : selectColorPointBtn.getColorInner(); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, LegendGradientBar.this); Color color = this.getColor(); if (color != null) { DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); diff --git a/designer-realize/src/main/java/com/fr/design/actions/server/WidgetManagerAction.java b/designer-realize/src/main/java/com/fr/design/actions/server/WidgetManagerAction.java index 04a0cfa8e..ff8352e28 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/server/WidgetManagerAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/server/WidgetManagerAction.java @@ -17,6 +17,8 @@ import com.fr.transaction.WorkerFacade; import javax.swing.KeyStroke; import java.awt.event.ActionEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; public class WidgetManagerAction extends UpdateAction { public WidgetManagerAction() { @@ -33,6 +35,7 @@ public class WidgetManagerAction extends UpdateAction { */ public void actionPerformed(ActionEvent e) { final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + DesignerContext.getDesignerFrame().setServerConfig(true); final WidgetInfoConfig widgetManager = WidgetInfoConfig.getInstance(); final WidgetManagerPane widgetManagerPane = new WidgetManagerPane() { @Override @@ -63,6 +66,13 @@ public class WidgetManagerAction extends UpdateAction { })); } }); + widgetConfigDialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + super.windowClosed(e); + DesignerContext.getDesignerFrame().setServerConfig(false); + } + }); widgetConfigDialog.setVisible(true); }