17 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
182 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
17 |
ilm |
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.ui;
|
|
|
15 |
|
|
|
16 |
import java.awt.Color;
|
|
|
17 |
import java.awt.Graphics;
|
|
|
18 |
import java.awt.Image;
|
|
|
19 |
import java.awt.Robot;
|
|
|
20 |
import java.awt.image.BufferedImage;
|
|
|
21 |
import java.io.File;
|
|
|
22 |
import java.net.URL;
|
|
|
23 |
|
|
|
24 |
import javax.swing.ImageIcon;
|
|
|
25 |
import javax.swing.JFrame;
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Un écran de démarrage qui affiche l'image passée.
|
|
|
29 |
*
|
|
|
30 |
* @author ILM Informatique 17 juin 2004
|
|
|
31 |
*/
|
|
|
32 |
public class Splash extends JFrame {
|
|
|
33 |
|
|
|
34 |
private BufferedImage screenShot;
|
|
|
35 |
private Image image;
|
|
|
36 |
|
|
|
37 |
public Splash(String imageName) {
|
|
|
38 |
super();
|
|
|
39 |
this.setUndecorated(true);
|
|
|
40 |
this.setBackground(Color.WHITE);
|
|
|
41 |
// load the image
|
|
|
42 |
// first try and load it from the classpath, / to not prepend org.openconcerto.ui
|
|
|
43 |
URL imageURL = getClass().getResource("/" + imageName);
|
|
|
44 |
// its ctor wait for the image to load
|
|
|
45 |
ImageIcon icon = null;
|
|
|
46 |
if (imageURL != null)
|
|
|
47 |
icon = new ImageIcon(imageURL);
|
|
|
48 |
else if (new File(imageName).exists()) // try and load it from a local drive
|
|
|
49 |
icon = new ImageIcon(imageName);
|
|
|
50 |
|
|
|
51 |
if (icon != null) {
|
|
|
52 |
this.image = icon.getImage();
|
|
|
53 |
|
|
|
54 |
int width = this.image.getWidth(null);
|
|
|
55 |
int height = this.image.getHeight(null);
|
|
|
56 |
|
|
|
57 |
this.setSize(width, height);
|
|
|
58 |
this.setLocationRelativeTo(null);
|
|
|
59 |
|
|
|
60 |
try {
|
|
|
61 |
this.screenShot = new Robot().createScreenCapture(this.getBounds());
|
|
|
62 |
} catch (Exception e) {
|
|
|
63 |
// on continue quand meme
|
|
|
64 |
e.printStackTrace();
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
public void paint(Graphics g) {
|
|
|
70 |
if (this.screenShot != null)
|
|
|
71 |
g.drawImage(this.screenShot, 0, 0, null);
|
|
|
72 |
g.drawImage(this.image, 0, 0, null);
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
}
|