mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
rework splash screen
This commit is contained in:
@@ -11,5 +11,5 @@
|
|||||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;Library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;DIYLC&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;diylc-core&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;diylc-library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;Library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;DIYLC&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;diylc-core&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;diylc-library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.diylc.DIYLCStarter"/>
|
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.diylc.DIYLCStarter"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="diylc-swing"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="diylc-swing"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-splash:splash.png -Xms256m -Xmx512m -Dorg.diylc.scriptRun=true -Ddorg.diylc.debugContinuityAreas=true -Ddorg.diylc.WriteStaticVariants=true -Ddorg.diylc.debugComponentAreas=true"/>
|
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx512m -Dorg.diylc.scriptRun=true -Ddorg.diylc.debugContinuityAreas=true -Ddorg.diylc.WriteStaticVariants=true -Ddorg.diylc.debugComponentAreas=true"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|||||||
Binary file not shown.
@@ -1,115 +1,131 @@
|
|||||||
package org.diylc;
|
package org.diylc;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.SplashScreen;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JDialog;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.diylc.images.IconLoader;
|
import org.diylc.images.IconLoader;
|
||||||
|
|
||||||
public class DIYLCSplash {
|
/**
|
||||||
|
* Custom splash screen with animated components. Does not use standard SplashScreen because of issues with OS X and Java 8.
|
||||||
private Thread t;
|
*
|
||||||
|
* @author bancika
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DIYLCSplash extends JDialog {
|
||||||
|
|
||||||
public DIYLCSplash(final SplashScreen splash) {
|
private static final long serialVersionUID = 1L;
|
||||||
if (splash == null)
|
private Thread t;
|
||||||
return;
|
|
||||||
final Graphics2D g = splash.createGraphics();
|
private int frameNumber = 90;
|
||||||
if (g == null)
|
|
||||||
return;
|
private Point resistorTarget = new Point(112, 114);
|
||||||
|
private Point filmTarget = new Point(233, 113);
|
||||||
t = new Thread(new Runnable() {
|
private Point electrolyticTarget = new Point(261, 23);
|
||||||
|
private Point ceramicTarget = new Point(352, 22);
|
||||||
|
|
||||||
@Override
|
private int pxPerFrame = 3;
|
||||||
public void run() {
|
|
||||||
for (int i = 90; i >= 0; i--) {
|
|
||||||
if (!splash.isVisible())
|
|
||||||
return;
|
|
||||||
final int frame = i;
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
public DIYLCSplash() {
|
||||||
public void run() {
|
setPreferredSize(new Dimension(getSplash().getIconWidth(), getSplash().getIconHeight()));
|
||||||
renderSplashFrame(splash, g, frame);
|
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
||||||
splash.update();
|
setUndecorated(true);
|
||||||
}
|
pack();
|
||||||
});
|
setLocationRelativeTo(null);
|
||||||
try {
|
setVisible(true);
|
||||||
Thread.sleep(10);
|
setAlwaysOnTop(true);
|
||||||
} catch (InterruptedException e) {
|
repaint();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start() {
|
|
||||||
if (t != null)
|
|
||||||
t.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ImageIcon resistor = null;
|
t = new Thread(new Runnable() {
|
||||||
|
|
||||||
public ImageIcon getResistor() {
|
@Override
|
||||||
if (resistor == null) {
|
public void run() {
|
||||||
resistor = (ImageIcon) IconLoader.SplashResistor.getIcon();
|
for (int i = 90; i >= 0; i--) {
|
||||||
}
|
if (!isVisible())
|
||||||
return resistor;
|
return;
|
||||||
}
|
frameNumber = i;
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
|
||||||
private ImageIcon film = null;
|
@Override
|
||||||
|
public void run() {
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
|
g2d.setComposite(AlphaComposite.SrcOver);
|
||||||
|
getSplash().paintIcon(null, g, 0, 0);
|
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f - frameNumber * 0.007f));
|
||||||
|
getResistor().paintIcon(null, g, resistorTarget.x - pxPerFrame * frameNumber, resistorTarget.y);
|
||||||
|
getFilm().paintIcon(null, g, filmTarget.x, filmTarget.y + pxPerFrame * frameNumber);
|
||||||
|
getElectrolytic().paintIcon(null, g, electrolyticTarget.x, electrolyticTarget.y - pxPerFrame * frameNumber);
|
||||||
|
getCeramic().paintIcon(null, g, ceramicTarget.x + pxPerFrame * frameNumber, ceramicTarget.y);
|
||||||
|
}
|
||||||
|
|
||||||
public ImageIcon getFilm() {
|
public void start() {
|
||||||
if (film == null) {
|
if (t != null)
|
||||||
film = (ImageIcon) IconLoader.SplashFilm.getIcon();
|
t.start();
|
||||||
}
|
}
|
||||||
return film;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ImageIcon ceramic = null;
|
private ImageIcon resistor = null;
|
||||||
|
|
||||||
public ImageIcon getCeramic() {
|
public ImageIcon getResistor() {
|
||||||
if (ceramic == null) {
|
if (resistor == null) {
|
||||||
ceramic = (ImageIcon) IconLoader.SplashCeramic.getIcon();
|
resistor = (ImageIcon) IconLoader.SplashResistor.getIcon();
|
||||||
}
|
}
|
||||||
return ceramic;
|
return resistor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageIcon electrolytic = null;
|
private ImageIcon film = null;
|
||||||
|
|
||||||
public ImageIcon getElectrolytic() {
|
public ImageIcon getFilm() {
|
||||||
if (electrolytic == null) {
|
if (film == null) {
|
||||||
electrolytic = (ImageIcon) IconLoader.SplashElectrolytic.getIcon();
|
film = (ImageIcon) IconLoader.SplashFilm.getIcon();
|
||||||
}
|
}
|
||||||
return electrolytic;
|
return film;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageIcon splash = null;
|
private ImageIcon ceramic = null;
|
||||||
|
|
||||||
public ImageIcon getSplash() {
|
public ImageIcon getCeramic() {
|
||||||
if (splash == null) {
|
if (ceramic == null) {
|
||||||
splash = (ImageIcon) IconLoader.Splash.getIcon();
|
ceramic = (ImageIcon) IconLoader.SplashCeramic.getIcon();
|
||||||
}
|
}
|
||||||
return splash;
|
return ceramic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point resistorTarget = new Point(112, 114);
|
private ImageIcon electrolytic = null;
|
||||||
private Point filmTarget = new Point(233, 113);
|
|
||||||
private Point electrolyticTarget = new Point(261, 23);
|
|
||||||
private Point ceramicTarget = new Point(352, 22);
|
|
||||||
|
|
||||||
private int pxPerFrame = 3;
|
public ImageIcon getElectrolytic() {
|
||||||
|
if (electrolytic == null) {
|
||||||
|
electrolytic = (ImageIcon) IconLoader.SplashElectrolytic.getIcon();
|
||||||
|
}
|
||||||
|
return electrolytic;
|
||||||
|
}
|
||||||
|
|
||||||
public void renderSplashFrame(SplashScreen splash, Graphics2D g, int frame) {
|
private ImageIcon splash = null;
|
||||||
g.setComposite(AlphaComposite.Clear);
|
|
||||||
getSplash().paintIcon(null, g, 0, 0);
|
public ImageIcon getSplash() {
|
||||||
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f - frame * 0.007f));
|
if (splash == null) {
|
||||||
getResistor().paintIcon(null, g, resistorTarget.x - pxPerFrame * frame, resistorTarget.y);
|
splash = (ImageIcon) IconLoader.Splash.getIcon();
|
||||||
getFilm().paintIcon(null, g, filmTarget.x, filmTarget.y + pxPerFrame * frame);
|
}
|
||||||
getElectrolytic().paintIcon(null, g, electrolyticTarget.x, electrolyticTarget.y - pxPerFrame * frame);
|
return splash;
|
||||||
getCeramic().paintIcon(null, g, ceramicTarget.x + pxPerFrame * frame, ceramicTarget.y);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ package org.diylc;
|
|||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.FontFormatException;
|
import java.awt.FontFormatException;
|
||||||
import java.awt.GraphicsEnvironment;
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.SplashScreen;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@@ -60,16 +58,7 @@ public class DIYLCStarter {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Initialize splash screen
|
// Initialize splash screen
|
||||||
final SplashScreen splash = SplashScreen.getSplashScreen();
|
DIYLCSplash splash = new DIYLCSplash();
|
||||||
URL splashUrl = Presenter.class.getClassLoader().getResource("org/diylc/splash.png");
|
|
||||||
if (splash != null) {
|
|
||||||
try {
|
|
||||||
splash.setImageURL(splashUrl);
|
|
||||||
new DIYLCSplash(splash).start();
|
|
||||||
} catch (NullPointerException | IllegalStateException | IOException e1) {
|
|
||||||
LOG.error("Could not initialize splash screen", e1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
URL url = DIYLCStarter.class.getResource("log4j.properties");
|
URL url = DIYLCStarter.class.getResource("log4j.properties");
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
@@ -140,6 +129,10 @@ public class DIYLCStarter {
|
|||||||
|
|
||||||
MainFrame mainFrame = new MainFrame();
|
MainFrame mainFrame = new MainFrame();
|
||||||
mainFrame.setLocationRelativeTo(null);
|
mainFrame.setLocationRelativeTo(null);
|
||||||
|
|
||||||
|
splash.setVisible(false);
|
||||||
|
splash.dispose();
|
||||||
|
|
||||||
mainFrame.setVisible(true);
|
mainFrame.setVisible(true);
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
mainFrame.getPresenter().loadProjectFromFile(args[0]);
|
mainFrame.getPresenter().loadProjectFromFile(args[0]);
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user