001: /*
002: * Created on 08/09/2005 Swing Components - visit http://sf.net/projects/gfd Copyright (C) 2005 Igor Regis da Silva
003: * Simões This program is free software; you can redistribute it and/or modify it under the terms of the GNU General
004: * Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any
005: * later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
006: * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
007: * more details. You should have received a copy of the GNU General Public License along with this program; if not,
008: * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
009: */
010: package br.com.gfp.windows;
011:
012: import java.awt.BorderLayout;
013: import java.awt.Color;
014: import java.awt.GridBagConstraints;
015: import java.awt.GridBagLayout;
016: import java.awt.Toolkit;
017: import java.util.Locale;
018:
019: import javax.swing.JLabel;
020: import javax.swing.JPanel;
021: import javax.swing.JProgressBar;
022: import javax.swing.JWindow;
023:
024: import br.com.gfpshare.beans.aplicativos.IconeFactory;
025:
026: /**
027: * SplashScreen do GFP
028: * @author Igor Regis da Silva Simoes
029: * @since 08/09/2005
030: */
031: public class SplashScreen extends JWindow {
032: private JLabel mensagens;
033:
034: private JProgressBar progressBar;
035:
036: /**
037: *
038: */
039: public SplashScreen() {
040: super ();
041: getContentPane().setLayout(new BorderLayout());
042:
043: JLabel imagem = new JLabel(IconeFactory.getIconeFactory()
044: .getImageIcon("/icones/Splash_Screen.jpeg")) {
045: @Override
046: public void paint(final java.awt.Graphics g) {
047: super .paint(g);
048: /*Não não mudamos a fonte que é usada para escrever a string
049: pois uma mudança de fonte atrazaria a carga da splash screen
050: em cerca de 200 milissegundos */
051: g.drawString(getLabel(), 400 / 2 - getLabelWidth() / 2,
052: 85);
053: g.setColor(new Color(150, 150, 250));
054: g.setFont(g.getFont().deriveFont(4));
055: g.drawString("http://gfd.sf.net", 400 / 2 - 126 / 2,
056: 295);
057: }
058: };
059: getContentPane().add(imagem, BorderLayout.CENTER);
060:
061: getContentPane().add(getPainelInfo(), BorderLayout.SOUTH);
062:
063: setSize(400, 330);
064: int x = Toolkit.getDefaultToolkit().getScreenSize().width;
065: int y = Toolkit.getDefaultToolkit().getScreenSize().height;
066: x = (x / 2) - (int) getSize().getWidth() / 2;
067: y = (y / 2) - (int) getSize().getHeight() / 2;
068: setLocation(x, y);
069: setVisible(true);
070: }
071:
072: /**
073: * Retorna o painel para exibir mensagens ao usuário
074: * @return
075: */
076: private JPanel getPainelInfo() {
077: JPanel p = new JPanel();
078: p.setLayout(new GridBagLayout());
079:
080: mensagens = new JLabel("Teste");
081: GridBagConstraints g = new GridBagConstraints();
082: g.gridx = 0;
083: g.gridy = 0;
084: g.weightx = 1;
085: g.fill = GridBagConstraints.HORIZONTAL;
086: p.add(mensagens, g);
087:
088: progressBar = new JProgressBar();
089: progressBar.setMinimum(0);
090: progressBar.setMaximum(100);
091: g.gridy = 1;
092: g.fill = GridBagConstraints.BOTH;
093: p.add(progressBar, g);
094:
095: return p;
096: }
097:
098: /**
099: * Exibe uma mensagen na tela de splash screen do GFP
100: */
101: public void setText(String msg) {
102: mensagens.setText(msg);
103: }
104:
105: /**
106: * Indica o prograsso na SplashScreen
107: * @param i
108: */
109: public void setProgresso(int i) {
110: progressBar.setValue(i);
111: }
112:
113: /**
114: * Retorna a frase a ser escrita na spalsh screen
115: * Usamos este método ao invés de properties files por razões de
116: * performace, pois isso economiza cerca de 250 milissegundos na
117: * carga da splassh screen.
118: * @return
119: */
120: private String getLabel() {
121: if (Locale.getDefault().getLanguage().equals("fr")) {
122: return "Gestionnaire de Finances Personnelles";
123: } else if (Locale.getDefault().getLanguage().equals("pt")) {
124: return "Gerenciador de Finan\u00E7as Pessoais";
125: } else if (Locale.getDefault().getLanguage().equals("de")) {
126: return "Persönlicher Finanzmanager";
127: } else if (Locale.getDefault().getLanguage().equals("es")) {
128: return "Gerente de Finanzas Personales";
129: } else if (Locale.getDefault().getLanguage().equals("it")) {
130: return "Gestore di Finanze Personali";
131: } else
132: return "Personal Finance Manager";
133: }
134:
135: /**
136: * Retorna o cumprimento da String retornada pelo método getLabel()
137: * Usamos este método ao invés de FontMetricis por razões de performace
138: * já que esta manobra econimiza cerca de 400 milessegundos da carga
139: * da splash screen
140: */
141: private int getLabelWidth() {
142: if (Locale.getDefault().getLanguage().equals("fr")) {
143: return 221;
144: } else if (Locale.getDefault().getLanguage().equals("pt")) {
145: return 197;
146: } else if (Locale.getDefault().getLanguage().equals("de")) {
147: return 163;
148: } else if (Locale.getDefault().getLanguage().equals("es")) {
149: return 183;
150: } else if (Locale.getDefault().getLanguage().equals("it")) {
151: return 161;
152: } else
153: return 151;
154: }
155: }
|