KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > memoire > vainstall > gui > VABlueScreen


1 /**
2  * $RCSfile: VABlueScreen.java,v $
3  * @creation 01/02/00
4  * @modification $Date: 2005/03/30 19:42:12 $
5  */

6
7 package com.memoire.vainstall.gui;
8
9 import java.awt.*;
10 import java.awt.event.*;
11 import javax.swing.*;
12 import com.memoire.vainstall.*;
13
14 /**
15  * @version $Id: VABlueScreen.java,v 1.4 2005/03/30 19:42:12 deniger Exp $
16  * @author Axel von Arnim
17  */

18
19 public class VABlueScreen
20        extends JWindow
21 {
22   public VABlueScreen()
23   {
24     super();
25     // Escape listener
26
addKeyListener(new KeyAdapter() {
27       public void keyPressed(KeyEvent e)
28       {
29         if( e.getKeyCode()==KeyEvent.VK_ESCAPE ) {
30           dispose();
31           VAGlobals.printDebug("Blue screen killed");
32         }
33       }
34     });
35
36     if( VAGlobals.UI_BLUESCREEN_COLOR==null ) {
37       VAGlobals.UI_BLUESCREEN_COLOR=Color.blue;
38     }
39     getContentPane().setBackground(VAGlobals.UI_BLUESCREEN_COLOR);
40     Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
41     setBounds(0, 0, screen.width, screen.height);
42   }
43   
44   public void paint(Graphics _g)
45   {
46     // degrade
47
Color bg=getContentPane().getBackground();
48     int rapport=10;
49     int taille=5;
50     Color curbg=new Color(bg.getRed()/rapport,
51                           bg.getGreen()/rapport,
52                           bg.getBlue()/rapport);
53     int y=0;
54     Dimension size=getSize();
55     int n=size.height/taille;
56     int maxc=curbg.getRed();
57     if( curbg.getGreen()>maxc ) maxc=curbg.getGreen();
58     if( curbg.getBlue()>maxc ) maxc=curbg.getBlue();
59     double coef=Math.pow(255./maxc, 1./(n+1));
60     double r=curbg.getRed();
61     double g=curbg.getGreen();
62     double b=curbg.getBlue();
63     while( y<size.height ) {
64       _g.setColor(curbg);
65       _g.fillRect(0, y, size.width, taille);
66       y+=taille;
67       r*=coef; g*=coef; b*=coef;
68       curbg=new Color((int)r, (int)g, (int)b);
69     }
70
71     // deco texte
72
Font font=new Font("Serif", Font.BOLD|Font.ITALIC, 28);
73     _g.setColor(Color.white);
74     _g.setFont(font);
75     FontMetrics metrics=_g.getFontMetrics();
76     if (VAGlobals.APP_VERSION != null)
77         _g.drawString(VAGlobals.APP_NAME+" "+VAGlobals.APP_VERSION, 10, metrics.getHeight()+10);
78     else
79         _g.drawString(VAGlobals.APP_NAME+" (no version)", 10, metrics.getHeight()+10);
80     _g.setFont(font.deriveFont(22));
81     _g.drawString(VAGlobals.NAME+" "+VAGlobals.VERSION+VAGlobals.i18n("UI_Powered"), 10, size.height-10);
82   }
83 }
84
Popular Tags