Revision 8924
trunk/frameworks/_fwAndami/src/com/iver/andami/ui/splash/MultiSplashWindow.java | ||
---|---|---|
5 | 5 |
import java.awt.Dimension; |
6 | 6 |
import java.awt.Frame; |
7 | 7 |
import java.awt.Graphics; |
8 |
import java.awt.Image; |
|
8 | 9 |
import java.awt.Toolkit; |
9 |
import java.io.File; |
|
10 |
import java.io.FileFilter; |
|
11 |
import java.net.MalformedURLException; |
|
12 | 10 |
|
13 | 11 |
import javax.swing.BorderFactory; |
14 | 12 |
import javax.swing.ImageIcon; |
... | ... | |
17 | 15 |
import javax.swing.JWindow; |
18 | 16 |
|
19 | 17 |
import com.iver.andami.messages.Messages; |
18 |
import com.iver.andami.ui.theme.Theme; |
|
20 | 19 |
|
21 | 20 |
public class MultiSplashWindow extends JWindow implements TimerCallBack { |
22 | 21 |
|
... | ... | |
31 | 30 |
private int index = 0; |
32 | 31 |
private int current; |
33 | 32 |
private int lastIndex=-1; |
34 |
|
|
35 |
public MultiSplashWindow(Frame f) { |
|
33 |
private Theme theme; |
|
34 |
private long[] timers; |
|
35 |
public MultiSplashWindow(Frame f, Theme theme) { |
|
36 | 36 |
super(f); |
37 |
|
|
37 |
this.theme=theme; |
|
38 |
this.timers=theme.getTimers(); |
|
38 | 39 |
lblStatus = new JLabel(Messages.getString("SplashWindow.Iniciando")); |
39 | 40 |
lblStatus.setBorder(BorderFactory.createEtchedBorder()); |
40 | 41 |
lblStatus.setBackground(Color.WHITE); |
... | ... | |
56 | 57 |
} |
57 | 58 |
|
58 | 59 |
public void init(){ |
59 |
File dirLogos=new File("./logos"); |
|
60 |
File[] fileLogos=dirLogos.listFiles(new FileFilter() { |
|
61 |
|
|
62 |
public boolean accept(File arg0) { |
|
63 |
if (arg0.isDirectory()) |
|
64 |
return false; |
|
65 |
if (!(arg0.getName().toUpperCase().endsWith(".PNG")|| |
|
66 |
arg0.getName().toUpperCase().endsWith(".BMP")|| |
|
67 |
arg0.getName().toUpperCase().endsWith(".GIF")|| |
|
68 |
arg0.getName().toUpperCase().endsWith(".JPG")|| |
|
69 |
arg0.getName().toUpperCase().endsWith(".JPEG"))) |
|
70 |
return false; |
|
71 |
return true; |
|
72 |
}}); |
|
73 |
if (fileLogos!=null) { |
|
74 |
numLogos=fileLogos.length+1; |
|
75 |
}else { |
|
76 |
numLogos=1; |
|
60 |
img=theme.getSplashImages(); |
|
61 |
numLogos=img.length; |
|
62 |
if (numLogos==0) { |
|
63 |
numLogos=1; |
|
64 |
img=new ImageIcon[1]; |
|
65 |
img[0]=new ImageIcon(this.getClass().getClassLoader().getResource("images/logo_es.png")); |
|
66 |
timers=new long[1]; |
|
67 |
timers[0]=1000l; |
|
77 | 68 |
} |
78 | 69 |
|
79 |
img=new ImageIcon[numLogos]; |
|
80 |
img[0]=new ImageIcon(this.getClass().getClassLoader().getResource("images/logo_es.png")); |
|
81 | 70 |
int splashWidth = img[0].getIconWidth(); |
82 | 71 |
int splashHeight = img[0].getIconHeight(); |
83 | 72 |
|
84 |
for (int i=0;i<numLogos-1;i++){ |
|
85 |
try { |
|
86 |
img[i+1]=new ImageIcon(fileLogos[i].toURL()); |
|
87 |
splashWidth = Math.max(splashWidth, img[i+1].getIconWidth()); |
|
88 |
splashHeight = Math.max(splashHeight, img[i+1].getIconHeight()); |
|
89 |
} catch (MalformedURLException e) { |
|
90 |
} |
|
73 |
for (int i=1;i<numLogos;i++){ |
|
74 |
splashWidth = Math.max(splashWidth, img[i].getIconWidth()); |
|
75 |
splashHeight = Math.max(splashHeight, img[i].getIconHeight()); |
|
91 | 76 |
} |
92 | 77 |
splashDimension = new Dimension(splashWidth, splashHeight); |
93 | 78 |
setSize(splashDimension.width, splashDimension.height + 20); |
... | ... | |
102 | 87 |
|
103 | 88 |
if (img == null || img[current] == null) |
104 | 89 |
return; |
105 |
|
|
106 |
g.drawImage(img[current].getImage(), 0, 20, this);
|
|
90 |
ImageIcon image=img[current]; |
|
91 |
g.drawImage(image.getImage(), (getWidth()/2)-(image.getIconWidth()/2),(getHeight()/2-image.getIconHeight()/2), this);
|
|
107 | 92 |
lastIndex=current; |
108 | 93 |
} |
109 | 94 |
|
110 | 95 |
public void tick() { |
111 | 96 |
current = index; |
97 |
timer.setInterval(timers[current]); |
|
112 | 98 |
repaint(); |
113 | 99 |
index++; |
114 | 100 |
if (index >= numLogos) |
... | ... | |
131 | 117 |
|
132 | 118 |
public void stop() { |
133 | 119 |
timer.stop(); |
134 |
timer = null; |
|
120 |
//timer = null;
|
|
135 | 121 |
} |
136 | 122 |
|
137 | 123 |
public static void main(String[] args) { |
138 | 124 |
Frame frame = new Frame(); |
139 |
MultiSplashWindow ba = new MultiSplashWindow(frame); |
|
125 |
Theme theme=new Theme(); |
|
126 |
MultiSplashWindow ba = new MultiSplashWindow(frame,theme); |
|
140 | 127 |
ba.setVisible(true); |
141 | 128 |
ba.setSize(500, 500); |
142 | 129 |
ba.init(); |
... | ... | |
147 | 134 |
* @see com.iver.mdiApp.ui.AppLoadingListener#process(int) |
148 | 135 |
*/ |
149 | 136 |
public static void process(int p, String str) { |
150 |
|
|
151 | 137 |
lblStatus.setText(str); |
152 | 138 |
// System.out.println("Porcentaje :" + p); |
153 | 139 |
if (pb.getValue() != p) { |
Also available in: Unified diff