Browse Source

REPORT-134498 修复启动页的环境卡片边框问题

fbp/release
vito 3 months ago
parent
commit
f9b348b851
  1. 43
      designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
  2. 11
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 20
      designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java
  4. 6
      designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonStoryBoard.java
  5. 3
      designer-realize/src/main/java/com/fr/start/CarinaDesigner.java

43
designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java

@ -44,6 +44,9 @@ import static com.formdev.flatlaf.util.UIScale.scale;
*/ */
public class FineUIUtils { public class FineUIUtils {
public static final String LEFT = "LEFT";
public static final String RIGHT = "RIGHT";
public static final int RETINA_SCALE_FACTOR = 2; public static final int RETINA_SCALE_FACTOR = 2;
/** /**
@ -212,17 +215,48 @@ public class FineUIUtils {
*/ */
public static void paintPartRoundButtonBorder(Component c, Graphics2D g2, int x, int y, int width, int height, public static void paintPartRoundButtonBorder(Component c, Graphics2D g2, int x, int y, int width, int height,
float borderWidth, float arc) { float borderWidth, float arc) {
if (isLeftRoundButton(c)) {
paintPartRoundButtonBorder(g2, x, y, width, height, borderWidth, arc, LEFT, false);
} else {
paintPartRoundButtonBorder(g2, x, y, width, height, borderWidth, arc, RIGHT, false);
}
}
/**
* 绘制部分圆角矩形边框
*
* @param g2 Graphics2D
* @param x x坐标
* @param y y坐标
* @param width 宽度
* @param height 高度
* @param borderWidth 边框宽度
* @param arc 圆角
* @param roundPart 圆角的方位当前只能设置一侧
* @param closedPath 是否封闭非圆角那一侧是否有边框是为有边框
*/
public static void paintPartRoundButtonBorder(Graphics2D g2, int x, int y, int width, int height,
float borderWidth, float arc, String roundPart, boolean closedPath) {
FlatUIUtils.setRenderingHints(g2); FlatUIUtils.setRenderingHints(g2);
arc = scale(arc); arc = scale(arc);
float t = scale(borderWidth); float t = scale(borderWidth);
float t2x = t * 2; float t2x = t * 2;
Path2D path2D = new Path2D.Float(Path2D.WIND_EVEN_ODD); Path2D path2D = new Path2D.Float(Path2D.WIND_EVEN_ODD);
if (isLeftRoundButton(c)) { switch (roundPart) {
case LEFT: {
path2D.append(createLeftRoundRectangle(x, y, width, height, arc), false); path2D.append(createLeftRoundRectangle(x, y, width, height, arc), false);
path2D.append(createLeftRoundRectangle(x + t, y + t, width - t, height - t2x, arc - t), false); path2D.append(createLeftRoundRectangle(x + t, y + t,
} else { width - (closedPath ? t2x : t), height - t2x, arc - t), false);
break;
}
case RIGHT:
default: {
path2D.append(createRightRoundRectangle(x, y, width, height, arc), false); path2D.append(createRightRoundRectangle(x, y, width, height, arc), false);
path2D.append(createRightRoundRectangle(x, y + t, width - t, height - t2x, arc - t), false); path2D.append(createRightRoundRectangle(x + (closedPath ? t : 0), y + t,
width - (closedPath ? t2x : t), height - t2x, arc - t), false);
break;
}
} }
g2.fill(path2D); g2.fill(path2D);
} }
@ -452,6 +486,7 @@ public class FineUIUtils {
/** /**
* 创建一个支持自动换行的提示文本 * 创建一个支持自动换行的提示文本
*
* @param text 显示的文本内容 * @param text 显示的文本内容
* @return 自动换行提示文本 * @return 自动换行提示文本
*/ */

11
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -1713,7 +1713,16 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada
} }
} }
} }
Carina.config(LanguageConfigProvider.class).setLocale(CommonUtils.localeToString(designerEnvManager.getLanguage())); setLocale();
}
private static void setLocale() {
try {
Carina.config(LanguageConfigProvider.class)
.setLocale(CommonUtils.localeToString(designerEnvManager.getLanguage()));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} }

20
designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java

@ -23,7 +23,6 @@ import javax.swing.JPanel;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import javax.swing.JViewport; import javax.swing.JViewport;
import javax.swing.ScrollPaneConstants; import javax.swing.ScrollPaneConstants;
import java.awt.BasicStroke;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -311,11 +310,10 @@ public class StartupPageWorkspacePanel extends JPanel {
if (borderColor != null) { if (borderColor != null) {
g2d.setColor(borderColor); g2d.setColor(borderColor);
g2d.setStroke(new BasicStroke(BORDER_THIN)); FineUIUtils.paintPartRoundButtonBorder(g2d, 0, 0,
FlatUIUtils.setRenderingHints(g2d); this.getWidth(), this.getHeight(),
Path2D path2D = FineUIUtils.createLeftRoundRectangle(0, 0, BORDER_THIN, ARC_DIAMETER,
getWidth() - BORDER_THIN, getHeight() - BORDER_THIN, ARC_DIAMETER); FineUIUtils.LEFT, true);
g2d.draw(path2D);
} }
} }
}; };
@ -437,11 +435,11 @@ public class StartupPageWorkspacePanel extends JPanel {
Color borderColor = borderColorRef.get(); Color borderColor = borderColorRef.get();
if (borderColor != null) { if (borderColor != null) {
g2d.setColor(borderColor); g2d.setColor(borderColor);
g2d.setStroke(new BasicStroke(BORDER_THIN)); FineUIUtils.paintPartRoundButtonBorder(g2d, 0, 0,
FlatUIUtils.setRenderingHints(g2d); this.getWidth(), this.getHeight(),
Path2D path2D = FineUIUtils.createRightRoundRectangle(0, 0, BORDER_THIN, ARC_DIAMETER,
getWidth() - BORDER_THIN, getHeight() - BORDER_THIN, ARC_DIAMETER); FineUIUtils.RIGHT, true
g2d.draw(path2D); );
} }
} }

6
designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonStoryBoard.java

@ -3,9 +3,11 @@ package com.fr.design.gui.storybook.components;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UICombinationButton; import com.fr.design.gui.ibutton.UICombinationButton;
import com.fr.design.gui.ibutton.UISaveForbiddenButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.storybook.Story; import com.fr.design.gui.storybook.Story;
import com.fr.design.gui.storybook.StoryBoard; import com.fr.design.gui.storybook.StoryBoard;
import com.fr.design.i18n.Toolkit;
import com.fr.design.style.color.UIToolbarColorButton; import com.fr.design.style.color.UIToolbarColorButton;
import javax.swing.JButton; import javax.swing.JButton;
@ -177,7 +179,9 @@ public class ButtonStoryBoard extends StoryBoard {
.with(it -> setStyle(it, STYLE_PRIMARY)), .with(it -> setStyle(it, STYLE_PRIMARY)),
cell(new UICombinationButton("按钮2", new LazyIcon("triangle_down"))), cell(new UICombinationButton("按钮2", new LazyIcon("triangle_down"))),
cell(new JButton("按钮", new LazyIcon("add"))), cell(new JButton("按钮", new LazyIcon("add"))),
cell(new JButton(new LazyIcon("multi"))) cell(new UICombinationButton(
new UISaveForbiddenButton(Toolkit.i18nText("Fine-Design_Basic_Preview"), new LazyIcon("run").white()),
new UISaveForbiddenButton(new LazyIcon("triangle_down").white()))).with(UICombinationButton::setPrimary)
), ),
row(20, row(20,
cell(new UIToolbarColorButton(new LazyIcon("foreground"))), cell(new UIToolbarColorButton(new LazyIcon("foreground"))),

3
designer-realize/src/main/java/com/fr/start/CarinaDesigner.java

@ -41,6 +41,7 @@ public class CarinaDesigner extends MainDesigner{
* main * main
*/ */
public static void main(String[] args) { public static void main(String[] args) {
installUIDevModeTools();
DesignerStartupContext.getRecorder().start(); DesignerStartupContext.getRecorder().start();
PartitionManager manager = new PartitionManagerImpl(); PartitionManager manager = new PartitionManagerImpl();
StateHubContext.setReady(false); StateHubContext.setReady(false);
@ -66,8 +67,6 @@ public class CarinaDesigner extends MainDesigner{
DesignerStartupContext.getRecorder().stop(); DesignerStartupContext.getRecorder().stop();
SwitchForSwingChecker.initThreadMonitoring(); SwitchForSwingChecker.initThreadMonitoring();
DesignerLatencyMetric.getInstance().start(); DesignerLatencyMetric.getInstance().start();
installUIDevModeTools();
} }
/** /**

Loading…
Cancel
Save