2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: ImageScreen.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.4 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/04/20 18:49:15 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.util.awt; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.BorderLayout; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.MouseAdapter; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.MouseEvent; |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
22 |
import javax.swing.ImageIcon; |
2 |
26 Feb 07 |
jari |
23 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
24 |
import javax.swing.JWindow; |
2 |
26 Feb 07 |
jari |
25 |
|
2 |
26 Feb 07 |
jari |
26 |
public class ImageScreen extends JWindow { |
2 |
26 Feb 07 |
jari |
27 |
|
2 |
26 Feb 07 |
jari |
28 |
public ImageScreen() { |
2 |
26 Feb 07 |
jari |
29 |
super(); |
2 |
26 Feb 07 |
jari |
30 |
addMouseListener(new Listener()); |
2 |
26 Feb 07 |
jari |
31 |
|
2 |
26 Feb 07 |
jari |
32 |
ImageIcon image = new ImageIcon(ImageScreen.class.getResource("/org/tigr/images/mev_splash.gif")); |
2 |
26 Feb 07 |
jari |
33 |
ImageCanvas canvas = new ImageCanvas(image); |
2 |
26 Feb 07 |
jari |
34 |
canvas.setPreferredSize(new Dimension(image.getIconWidth()+4, image.getIconHeight()+5)); |
2 |
26 Feb 07 |
jari |
35 |
getContentPane().add(canvas, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
36 |
pack(); |
2 |
26 Feb 07 |
jari |
37 |
} |
2 |
26 Feb 07 |
jari |
38 |
|
2 |
26 Feb 07 |
jari |
39 |
public void showImageScreen() { |
2 |
26 Feb 07 |
jari |
40 |
Dimension screenSize = getToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
41 |
setLocation(screenSize.width/2 - getSize().width/2, screenSize.height/2 - getSize().height/2); |
2 |
26 Feb 07 |
jari |
42 |
show(); |
2 |
26 Feb 07 |
jari |
43 |
} |
2 |
26 Feb 07 |
jari |
44 |
|
2 |
26 Feb 07 |
jari |
45 |
public void showImageScreen(long millis) { |
2 |
26 Feb 07 |
jari |
46 |
try { |
2 |
26 Feb 07 |
jari |
47 |
showImageScreen(); |
2 |
26 Feb 07 |
jari |
48 |
Thread.sleep(millis); |
2 |
26 Feb 07 |
jari |
49 |
dispose(); |
2 |
26 Feb 07 |
jari |
50 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
51 |
} |
2 |
26 Feb 07 |
jari |
52 |
} |
2 |
26 Feb 07 |
jari |
53 |
|
2 |
26 Feb 07 |
jari |
54 |
private void setImageIcon(ImageIcon icon) { |
2 |
26 Feb 07 |
jari |
55 |
} |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
class ImageCanvas extends JPanel { |
2 |
26 Feb 07 |
jari |
58 |
|
2 |
26 Feb 07 |
jari |
59 |
private ImageIcon image; |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
public ImageCanvas(ImageIcon image) { |
2 |
26 Feb 07 |
jari |
62 |
this.image = image; |
2 |
26 Feb 07 |
jari |
63 |
setBackground(Color.blue); |
2 |
26 Feb 07 |
jari |
64 |
setBorder(BorderFactory.createLineBorder(Color.black, 1)); |
2 |
26 Feb 07 |
jari |
65 |
} |
2 |
26 Feb 07 |
jari |
66 |
|
2 |
26 Feb 07 |
jari |
67 |
public void paint(Graphics g) { |
2 |
26 Feb 07 |
jari |
68 |
super.paint(g); |
2 |
26 Feb 07 |
jari |
69 |
g.drawImage(image.getImage(), 2, 2, this); |
2 |
26 Feb 07 |
jari |
70 |
} |
2 |
26 Feb 07 |
jari |
71 |
} |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
public static void main(String [] args) { |
2 |
26 Feb 07 |
jari |
74 |
ImageScreen is = new ImageScreen(); |
2 |
26 Feb 07 |
jari |
75 |
is.showImageScreen(); |
2 |
26 Feb 07 |
jari |
76 |
} |
2 |
26 Feb 07 |
jari |
77 |
|
2 |
26 Feb 07 |
jari |
78 |
class Listener extends MouseAdapter { |
2 |
26 Feb 07 |
jari |
79 |
public void mousePressed(MouseEvent me) { |
2 |
26 Feb 07 |
jari |
80 |
ImageScreen.this.dispose(); |
2 |
26 Feb 07 |
jari |
81 |
} |
2 |
26 Feb 07 |
jari |
82 |
} |
2 |
26 Feb 07 |
jari |
83 |
} |