Browse Source
* commit '458819a04648aa00ca7e47b569bfdcac0386370e': REPORT-25080 [10.0]英文操作系统启动设计器,启动画面鸣谢模块展示不全feature/big-screen
Hades
5 years ago
1 changed files with 120 additions and 120 deletions
@ -1,120 +1,120 @@ |
|||||||
package com.fr.start.common; |
package com.fr.start.common; |
||||||
|
|
||||||
import com.bulenkov.iconloader.IconLoader; |
import com.bulenkov.iconloader.IconLoader; |
||||||
import com.bulenkov.iconloader.util.JBUI; |
import com.bulenkov.iconloader.util.JBUI; |
||||||
import com.fr.base.GraphHelper; |
import com.fr.base.GraphHelper; |
||||||
import com.fr.design.ui.util.GraphicsConfig; |
import com.fr.design.ui.util.GraphicsConfig; |
||||||
import com.fr.stable.GraphDrawHelper; |
import com.fr.stable.GraphDrawHelper; |
||||||
import com.fr.stable.StringUtils; |
import com.fr.stable.StringUtils; |
||||||
import com.fr.stable.os.OperatingSystem; |
import com.fr.stable.os.OperatingSystem; |
||||||
import com.fr.value.NotNullLazyValue; |
import com.fr.value.NotNullLazyValue; |
||||||
import org.jetbrains.annotations.NotNull; |
import org.jetbrains.annotations.NotNull; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.util.Locale; |
import java.util.Locale; |
||||||
|
|
||||||
/** |
/** |
||||||
* 启动画面面板 |
* 启动画面面板 |
||||||
* |
* |
||||||
* @author vito |
* @author vito |
||||||
* @version 10.0 |
* @version 10.0 |
||||||
* Created by vito on 2019/09/12 |
* Created by vito on 2019/09/12 |
||||||
*/ |
*/ |
||||||
public class SplashPane extends JPanel { |
public class SplashPane extends JPanel { |
||||||
|
|
||||||
private static String OEM_PATH = "/com/fr/design/images/splash_10.png"; |
private static String OEM_PATH = "/com/fr/design/images/splash_10.png"; |
||||||
private static float JBUI_INIT_SCALE = JBUI.scale(1f); |
private static float JBUI_INIT_SCALE = JBUI.scale(1f); |
||||||
|
|
||||||
private static final Color MODULE_COLOR = new Color(255, 255, 255); |
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_X = uiScale(36); |
||||||
private static final int MODULE_INFO_Y = uiScale(300); |
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 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 THANK_INFO_Y = uiScale(340); |
||||||
private static final int FONT_SIZE = uiScale(12); |
private static final int FONT_SIZE = uiScale(12); |
||||||
|
|
||||||
private static final int MODULE_INFO_WIDTH = uiScale(150); |
private static final int MODULE_INFO_WIDTH = uiScale(170); |
||||||
private static final int MODULE_INFO_HEIGHT = uiScale(20); |
private static final int MODULE_INFO_HEIGHT = uiScale(20); |
||||||
|
|
||||||
private static final String ARIAL_FONT_NAME = "Arial"; |
private static final String ARIAL_FONT_NAME = "Arial"; |
||||||
private static final String YAHEI_FONT_NAME = "Microsoft YaHei"; |
private static final String YAHEI_FONT_NAME = "Microsoft YaHei"; |
||||||
|
|
||||||
private String thanksLog = StringUtils.EMPTY; |
private String thanksLog = StringUtils.EMPTY; |
||||||
private String moduleText = StringUtils.EMPTY; |
private String moduleText = StringUtils.EMPTY; |
||||||
|
|
||||||
private static int uiScale(int i) { |
private static int uiScale(int i) { |
||||||
return (int) (i * JBUI_INIT_SCALE); |
return (int) (i * JBUI_INIT_SCALE); |
||||||
} |
} |
||||||
|
|
||||||
private NotNullLazyValue<Font> fontValue = new NotNullLazyValue<Font>() { |
private NotNullLazyValue<Font> fontValue = new NotNullLazyValue<Font>() { |
||||||
@NotNull |
@NotNull |
||||||
@Override |
@Override |
||||||
protected Font compute() { |
protected Font compute() { |
||||||
Font font = null; |
Font font = null; |
||||||
if (OperatingSystem.isWindows()) { |
if (OperatingSystem.isWindows()) { |
||||||
font = createFont(YAHEI_FONT_NAME); |
font = createFont(YAHEI_FONT_NAME); |
||||||
} |
} |
||||||
if (font == null || isDialogFont(font)) { |
if (font == null || isDialogFont(font)) { |
||||||
font = createFont(ARIAL_FONT_NAME); |
font = createFont(ARIAL_FONT_NAME); |
||||||
} |
} |
||||||
return font; |
return font; |
||||||
} |
} |
||||||
}; |
}; |
||||||
|
|
||||||
@Override |
@Override |
||||||
protected void paintComponent(Graphics g) { |
protected void paintComponent(Graphics g) { |
||||||
super.paintComponent(g); |
super.paintComponent(g); |
||||||
Icon icon = IconLoader.getIcon(OEM_PATH); |
Icon icon = IconLoader.getIcon(OEM_PATH); |
||||||
icon.paintIcon(null, g, 0, 0); |
icon.paintIcon(null, g, 0, 0); |
||||||
paintShowText((Graphics2D) g); |
paintShowText((Graphics2D) g); |
||||||
g.dispose(); |
g.dispose(); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
protected void paintShowText(Graphics2D g) { |
protected void paintShowText(Graphics2D g) { |
||||||
GraphicsConfig config = new GraphicsConfig(g).setupAAPainting(); |
GraphicsConfig config = new GraphicsConfig(g).setupAAPainting(); |
||||||
|
|
||||||
g.setPaint(MODULE_COLOR); |
g.setPaint(MODULE_COLOR); |
||||||
g.setFont(fontValue.getValue()); |
g.setFont(fontValue.getValue()); |
||||||
|
|
||||||
//加载模块信息
|
//加载模块信息
|
||||||
GraphDrawHelper.drawString(g, moduleText, MODULE_INFO_X, MODULE_INFO_Y); |
GraphDrawHelper.drawString(g, moduleText, MODULE_INFO_X, MODULE_INFO_Y); |
||||||
|
|
||||||
//感谢用户信息
|
//感谢用户信息
|
||||||
if (StringUtils.isNotEmpty(thanksLog)) { |
if (StringUtils.isNotEmpty(thanksLog)) { |
||||||
g.setPaint(THANK_COLOR); |
g.setPaint(THANK_COLOR); |
||||||
GraphHelper.drawString(g, thanksLog, MODULE_INFO_X, THANK_INFO_Y); |
GraphHelper.drawString(g, thanksLog, MODULE_INFO_X, THANK_INFO_Y); |
||||||
} |
} |
||||||
config.restore(); |
config.restore(); |
||||||
} |
} |
||||||
|
|
||||||
Dimension getSplashDimension() { |
Dimension getSplashDimension() { |
||||||
Icon icon = IconLoader.getIcon(OEM_PATH); |
Icon icon = IconLoader.getIcon(OEM_PATH); |
||||||
return new Dimension(icon.getIconWidth(), icon.getIconHeight()); |
return new Dimension(icon.getIconWidth(), icon.getIconHeight()); |
||||||
} |
} |
||||||
|
|
||||||
private boolean isDialogFont(Font font) { |
private boolean isDialogFont(Font font) { |
||||||
return Font.DIALOG.equals(font.getFamily(Locale.US)); |
return Font.DIALOG.equals(font.getFamily(Locale.US)); |
||||||
} |
} |
||||||
|
|
||||||
private Font createFont(String fontName) { |
private Font createFont(String fontName) { |
||||||
return new Font(fontName, Font.PLAIN, FONT_SIZE); |
return new Font(fontName, Font.PLAIN, FONT_SIZE); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 设置在启动过程中, 动态改变的文本, 如 当前启动的模块信息 |
* 设置在启动过程中, 动态改变的文本, 如 当前启动的模块信息 |
||||||
* |
* |
||||||
* @param text 指定的文本 |
* @param text 指定的文本 |
||||||
*/ |
*/ |
||||||
void updateModuleLog(String text) { |
void updateModuleLog(String text) { |
||||||
moduleText = text; |
moduleText = text; |
||||||
repaint(MODULE_INFO_X, MODULE_INFO_Y - FONT_SIZE, MODULE_INFO_WIDTH, MODULE_INFO_HEIGHT); |
repaint(MODULE_INFO_X, MODULE_INFO_Y - FONT_SIZE, MODULE_INFO_WIDTH, MODULE_INFO_HEIGHT); |
||||||
} |
} |
||||||
|
|
||||||
void updateThanksLog(String text) { |
void updateThanksLog(String text) { |
||||||
thanksLog = text; |
thanksLog = text; |
||||||
repaint(MODULE_INFO_X, THANK_INFO_Y - FONT_SIZE, MODULE_INFO_WIDTH, MODULE_INFO_HEIGHT); |
repaint(MODULE_INFO_X, THANK_INFO_Y - FONT_SIZE, MODULE_INFO_WIDTH, MODULE_INFO_HEIGHT); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue