Coverage details for ui.panel.ICInfoPanel

LineHitsSource
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  
380@SuppressWarnings("serial") //$NON-NLS-1$
390public class ICInfoPanel extends JPanel {
400 
410    private static final transient Logger logger = Logger
420            .getLogger(ICInfoPanel.class.getName());
430 
440    private volatile Image backgroundImage = null;
450 
460    private boolean scaled = false;
470 
480    public ICInfoPanel() {
490        try {
500            final MediaTracker tracker = new MediaTracker(this);
510            new Thread() {
520                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                     }
820                }
830            }.start();
840        } catch (Exception ex) {
850            ex.printStackTrace();
860        }
870 
880        this.addComponentListener(new ComponentListener() {
890 
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         });
1160 
1170    }
1180 
1190    public void paintComponent(Graphics graphics) {
1200        super.paintComponent(graphics);
1210        if (backgroundImage != null && scaled)
1220            graphics.drawImage(backgroundImage, 0, 0, this);
1230    }
1240}

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.