Line | Hits | Source |
---|---|---|
1 | /******************************************************************************* | |
2 | * InternetCafe is a software solution that helps the management of Cybercafes | |
3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
5 | ||
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | ||
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | *******************************************************************************/ | |
20 | package ui.panel; | |
21 | ||
22 | import java.awt.Graphics; | |
23 | import java.awt.Image; | |
24 | import java.awt.MediaTracker; | |
25 | import java.awt.event.ComponentEvent; | |
26 | import java.awt.event.ComponentListener; | |
27 | import java.io.File; | |
28 | ||
29 | import javax.imageio.ImageIO; | |
30 | import javax.swing.JPanel; | |
31 | ||
32 | import org.apache.log4j.Logger; | |
33 | ||
34 | import ui.Messages; | |
35 | import base.ConfigurationManager; | |
36 | import base.InternetCafe; | |
37 | ||
38 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
39 | 0 | public class ICInfoPanel extends JPanel { |
40 | 0 | |
41 | 0 | private static final transient Logger logger = Logger |
42 | 0 | .getLogger(ICInfoPanel.class.getName()); |
43 | 0 | |
44 | 0 | private volatile Image backgroundImage = null; |
45 | 0 | |
46 | 0 | private boolean scaled = false; |
47 | 0 | |
48 | 0 | public ICInfoPanel() { |
49 | 0 | try { |
50 | 0 | final MediaTracker tracker = new MediaTracker(this); |
51 | 0 | new Thread() { |
52 | 0 | public void run() { |
53 | InternetCafe.setStatusBarMessage(Messages.getString("common.loading") //$NON-NLS-1$ | |
54 | + ConfigurationManager.getInstance() | |
55 | .getInternetCafeName() + " logo..."); //$NON-NLS-1$ | |
56 | InternetCafe.getStatusBar().getTimer().start(); | |
57 | ||
58 | Image originalImage = null; | |
59 | try { | |
60 | File logoFile = new File(ConfigurationManager | |
61 | .getInstance().getInternetCafeLogoPath()); | |
62 | if (logoFile.exists()) { | |
63 | tracker.addImage(originalImage = ImageIO | |
64 | .read(logoFile), 0); | |
65 | tracker.waitForID(0); | |
66 | tracker.addImage(backgroundImage = originalImage | |
67 | .getScaledInstance( | |
68 | getParent().getWidth() - 20, | |
69 | getParent().getHeight() - 20, | |
70 | Image.SCALE_FAST), 1); | |
71 | tracker.waitForID(1); | |
72 | scaled = true; | |
73 | updateUI(); | |
74 | InternetCafe.setStatusBarMessage(Messages.getString("common.ready")); //$NON-NLS-1$ | |
75 | InternetCafe.getStatusBar().setTaskDone(true); | |
76 | } | |
77 | } catch (Exception e) { | |
78 | // TODO Auto-generated catch block | |
79 | logger.error(e.getMessage()); | |
80 | e.printStackTrace(); | |
81 | } | |
82 | 0 | } |
83 | 0 | }.start(); |
84 | 0 | } catch (Exception ex) { |
85 | 0 | ex.printStackTrace(); |
86 | 0 | } |
87 | 0 | |
88 | 0 | this.addComponentListener(new ComponentListener() { |
89 | 0 | |
90 | public void componentResized(ComponentEvent arg0) { | |
91 | if (backgroundImage != null && getParent() != null) { | |
92 | ||
93 | backgroundImage = backgroundImage.getScaledInstance( | |
94 | getParent().getWidth() - 20, getParent() | |
95 | .getHeight() - 20, Image.SCALE_FAST); | |
96 | } | |
97 | ||
98 | } | |
99 | ||
100 | public void componentMoved(ComponentEvent arg0) { | |
101 | // TODO Auto-generated method stub | |
102 | ||
103 | } | |
104 | ||
105 | public void componentShown(ComponentEvent arg0) { | |
106 | // TODO Auto-generated method stub | |
107 | ||
108 | } | |
109 | ||
110 | public void componentHidden(ComponentEvent arg0) { | |
111 | // TODO Auto-generated method stub | |
112 | ||
113 | } | |
114 | ||
115 | }); | |
116 | 0 | |
117 | 0 | } |
118 | 0 | |
119 | 0 | public void paintComponent(Graphics graphics) { |
120 | 0 | super.paintComponent(graphics); |
121 | 0 | if (backgroundImage != null && scaled) |
122 | 0 | graphics.drawImage(backgroundImage, 0, 0, this); |
123 | 0 | } |
124 | 0 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |