From 458819a04648aa00ca7e47b569bfdcac0386370e Mon Sep 17 00:00:00 2001 From: "Joe.Jiang" Date: Thu, 12 Dec 2019 10:59:20 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-25080=20[10.0]=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E7=B3=BB=E7=BB=9F=E5=90=AF=E5=8A=A8=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=EF=BC=8C=E5=90=AF=E5=8A=A8=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E9=B8=A3=E8=B0=A2=E6=A8=A1=E5=9D=97=E5=B1=95=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/start/common/SplashPane.java | 240 +++++++++--------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/start/common/SplashPane.java b/designer-realize/src/main/java/com/fr/start/common/SplashPane.java index bbd0cab0f..6220f13f2 100644 --- a/designer-realize/src/main/java/com/fr/start/common/SplashPane.java +++ b/designer-realize/src/main/java/com/fr/start/common/SplashPane.java @@ -1,120 +1,120 @@ -package com.fr.start.common; - -import com.bulenkov.iconloader.IconLoader; -import com.bulenkov.iconloader.util.JBUI; -import com.fr.base.GraphHelper; -import com.fr.design.ui.util.GraphicsConfig; -import com.fr.stable.GraphDrawHelper; -import com.fr.stable.StringUtils; -import com.fr.stable.os.OperatingSystem; -import com.fr.value.NotNullLazyValue; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.awt.*; -import java.util.Locale; - -/** - * 启动画面面板 - * - * @author vito - * @version 10.0 - * Created by vito on 2019/09/12 - */ -public class SplashPane extends JPanel { - - private static String OEM_PATH = "/com/fr/design/images/splash_10.png"; - private static float JBUI_INIT_SCALE = JBUI.scale(1f); - - private static final Color MODULE_COLOR = new Color(255, 255, 255); - private static final int MODULE_INFO_X = uiScale(36); - private static final int MODULE_INFO_Y = uiScale(300); - - private static final Color THANK_COLOR = new Color(255, 255, 255, (int) (0.6 * 255 + 0.5)); - private static final int THANK_INFO_Y = uiScale(340); - private static final int FONT_SIZE = uiScale(12); - - private static final int MODULE_INFO_WIDTH = uiScale(150); - private static final int MODULE_INFO_HEIGHT = uiScale(20); - - private static final String ARIAL_FONT_NAME = "Arial"; - private static final String YAHEI_FONT_NAME = "Microsoft YaHei"; - - private String thanksLog = StringUtils.EMPTY; - private String moduleText = StringUtils.EMPTY; - - private static int uiScale(int i) { - return (int) (i * JBUI_INIT_SCALE); - } - - private NotNullLazyValue fontValue = new NotNullLazyValue() { - @NotNull - @Override - protected Font compute() { - Font font = null; - if (OperatingSystem.isWindows()) { - font = createFont(YAHEI_FONT_NAME); - } - if (font == null || isDialogFont(font)) { - font = createFont(ARIAL_FONT_NAME); - } - return font; - } - }; - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - Icon icon = IconLoader.getIcon(OEM_PATH); - icon.paintIcon(null, g, 0, 0); - paintShowText((Graphics2D) g); - g.dispose(); - } - - - protected void paintShowText(Graphics2D g) { - GraphicsConfig config = new GraphicsConfig(g).setupAAPainting(); - - g.setPaint(MODULE_COLOR); - g.setFont(fontValue.getValue()); - - //加载模块信息 - GraphDrawHelper.drawString(g, moduleText, MODULE_INFO_X, MODULE_INFO_Y); - - //感谢用户信息 - if (StringUtils.isNotEmpty(thanksLog)) { - g.setPaint(THANK_COLOR); - GraphHelper.drawString(g, thanksLog, MODULE_INFO_X, THANK_INFO_Y); - } - config.restore(); - } - - Dimension getSplashDimension() { - Icon icon = IconLoader.getIcon(OEM_PATH); - return new Dimension(icon.getIconWidth(), icon.getIconHeight()); - } - - private boolean isDialogFont(Font font) { - return Font.DIALOG.equals(font.getFamily(Locale.US)); - } - - private Font createFont(String fontName) { - return new Font(fontName, Font.PLAIN, FONT_SIZE); - } - - /** - * 设置在启动过程中, 动态改变的文本, 如 当前启动的模块信息 - * - * @param text 指定的文本 - */ - void updateModuleLog(String text) { - moduleText = text; - repaint(MODULE_INFO_X, MODULE_INFO_Y - FONT_SIZE, MODULE_INFO_WIDTH, MODULE_INFO_HEIGHT); - } - - void updateThanksLog(String text) { - thanksLog = text; - repaint(MODULE_INFO_X, THANK_INFO_Y - FONT_SIZE, MODULE_INFO_WIDTH, MODULE_INFO_HEIGHT); - } - -} +package com.fr.start.common; + +import com.bulenkov.iconloader.IconLoader; +import com.bulenkov.iconloader.util.JBUI; +import com.fr.base.GraphHelper; +import com.fr.design.ui.util.GraphicsConfig; +import com.fr.stable.GraphDrawHelper; +import com.fr.stable.StringUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.value.NotNullLazyValue; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/** + * 启动画面面板 + * + * @author vito + * @version 10.0 + * Created by vito on 2019/09/12 + */ +public class SplashPane extends JPanel { + + private static String OEM_PATH = "/com/fr/design/images/splash_10.png"; + private static float JBUI_INIT_SCALE = JBUI.scale(1f); + + private static final Color MODULE_COLOR = new Color(255, 255, 255); + private static final int MODULE_INFO_X = uiScale(36); + private static final int MODULE_INFO_Y = uiScale(300); + + private static final Color THANK_COLOR = new Color(255, 255, 255, (int) (0.6 * 255 + 0.5)); + private static final int THANK_INFO_Y = uiScale(340); + private static final int FONT_SIZE = uiScale(12); + + private static final int MODULE_INFO_WIDTH = uiScale(170); + private static final int MODULE_INFO_HEIGHT = uiScale(20); + + private static final String ARIAL_FONT_NAME = "Arial"; + private static final String YAHEI_FONT_NAME = "Microsoft YaHei"; + + private String thanksLog = StringUtils.EMPTY; + private String moduleText = StringUtils.EMPTY; + + private static int uiScale(int i) { + return (int) (i * JBUI_INIT_SCALE); + } + + private NotNullLazyValue fontValue = new NotNullLazyValue() { + @NotNull + @Override + protected Font compute() { + Font font = null; + if (OperatingSystem.isWindows()) { + font = createFont(YAHEI_FONT_NAME); + } + if (font == null || isDialogFont(font)) { + font = createFont(ARIAL_FONT_NAME); + } + return font; + } + }; + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Icon icon = IconLoader.getIcon(OEM_PATH); + icon.paintIcon(null, g, 0, 0); + paintShowText((Graphics2D) g); + g.dispose(); + } + + + protected void paintShowText(Graphics2D g) { + GraphicsConfig config = new GraphicsConfig(g).setupAAPainting(); + + g.setPaint(MODULE_COLOR); + g.setFont(fontValue.getValue()); + + //加载模块信息 + GraphDrawHelper.drawString(g, moduleText, MODULE_INFO_X, MODULE_INFO_Y); + + //感谢用户信息 + if (StringUtils.isNotEmpty(thanksLog)) { + g.setPaint(THANK_COLOR); + GraphHelper.drawString(g, thanksLog, MODULE_INFO_X, THANK_INFO_Y); + } + config.restore(); + } + + Dimension getSplashDimension() { + Icon icon = IconLoader.getIcon(OEM_PATH); + return new Dimension(icon.getIconWidth(), icon.getIconHeight()); + } + + private boolean isDialogFont(Font font) { + return Font.DIALOG.equals(font.getFamily(Locale.US)); + } + + private Font createFont(String fontName) { + return new Font(fontName, Font.PLAIN, FONT_SIZE); + } + + /** + * 设置在启动过程中, 动态改变的文本, 如 当前启动的模块信息 + * + * @param text 指定的文本 + */ + void updateModuleLog(String text) { + moduleText = text; + repaint(MODULE_INFO_X, MODULE_INFO_Y - FONT_SIZE, MODULE_INFO_WIDTH, MODULE_INFO_HEIGHT); + } + + void updateThanksLog(String text) { + thanksLog = text; + repaint(MODULE_INFO_X, THANK_INFO_Y - FONT_SIZE, MODULE_INFO_WIDTH, MODULE_INFO_HEIGHT); + } + +}