|
|
@ -3,6 +3,7 @@ package com.fr.start.common; |
|
|
|
import com.bulenkov.iconloader.IconLoader; |
|
|
|
import com.bulenkov.iconloader.IconLoader; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.design.locale.impl.SplashMark; |
|
|
|
import com.fr.design.locale.impl.SplashMark; |
|
|
|
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.locale.LocaleCenter; |
|
|
|
import com.fr.general.locale.LocaleCenter; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.Icon; |
|
|
@ -10,7 +11,6 @@ import java.awt.Dimension; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author Yvan |
|
|
|
* @author Yvan |
|
|
@ -21,25 +21,37 @@ public class SplashPane4WinAndJDK11 extends SplashPane{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 启动画面图片路径 |
|
|
|
* 启动画面图片路径 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private String imagePath; |
|
|
|
private final String imagePath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 启动画面图片是否使用了两倍图 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean isDouble = false; |
|
|
|
|
|
|
|
|
|
|
|
public SplashPane4WinAndJDK11() { |
|
|
|
public SplashPane4WinAndJDK11() { |
|
|
|
this.imagePath = getSplashPath4WinAndJdk11(); |
|
|
|
this.imagePath = getSplashPath4WinAndJdk11(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String getSplashPath4WinAndJdk11() { |
|
|
|
private String getSplashPath4WinAndJdk11() { |
|
|
|
String path = "/com/fr/design/images/splash_10@2x.png"; |
|
|
|
String path = (String) LocaleCenter.getMark(SplashMark.class).getValue(); |
|
|
|
String filePath = this.getClass().getResource("/").getPath(); |
|
|
|
if (path.contains("splash_10.png")) { |
|
|
|
|
|
|
|
// 为图片加上"@2x"
|
|
|
|
|
|
|
|
String pathOfDouble = path.replace("splash_10.png", "splash_10@2x.png"); |
|
|
|
// 某些定制jar里面没有两倍图,判断一下,如果文件不存在,就返回一倍图的path
|
|
|
|
// 某些定制jar里面没有两倍图,判断一下,如果文件不存在,就返回一倍图的path
|
|
|
|
if (new File(filePath + path).exists()) { |
|
|
|
if (IOUtils.readResource(pathOfDouble) != null) { |
|
|
|
return path; |
|
|
|
this.isDouble = true; |
|
|
|
|
|
|
|
return pathOfDouble; |
|
|
|
} |
|
|
|
} |
|
|
|
return (String) LocaleCenter.getMark(SplashMark.class).getValue(); |
|
|
|
} |
|
|
|
|
|
|
|
return path; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void paintComponent(Graphics g) { |
|
|
|
protected void paintComponent(Graphics g) { |
|
|
|
super.paintJComponent(g); |
|
|
|
if (isDouble) { |
|
|
|
|
|
|
|
super.paintComponent(g); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
BufferedImage image = BaseUtils.readImage(imagePath); |
|
|
|
BufferedImage image = BaseUtils.readImage(imagePath); |
|
|
|
Graphics2D newG = (Graphics2D)g.create(0, 0, image.getWidth(), image.getHeight()); |
|
|
|
Graphics2D newG = (Graphics2D)g.create(0, 0, image.getWidth(), image.getHeight()); |
|
|
|
newG.scale(0.5D, 0.5D); |
|
|
|
newG.scale(0.5D, 0.5D); |
|
|
@ -53,6 +65,7 @@ public class SplashPane4WinAndJDK11 extends SplashPane{ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
Dimension getSplashDimension() { |
|
|
|
Dimension getSplashDimension() { |
|
|
|
Icon icon = IconLoader.getIcon(imagePath); |
|
|
|
Icon icon = IconLoader.getIcon(imagePath); |
|
|
|
return new Dimension(icon.getIconWidth() / 2, icon.getIconHeight() / 2); |
|
|
|
return isDouble ? new Dimension(icon.getIconWidth() / 2, icon.getIconHeight() / 2) : |
|
|
|
|
|
|
|
new Dimension(icon.getIconWidth(), icon.getIconHeight()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|