Package de.axxeed.animosy.gui

Source Code of de.axxeed.animosy.gui.SplashScreen

/**
*
*/
package de.axxeed.animosy.gui;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

import javax.swing.JDialog;

import org.apache.log4j.Logger;

/**
* SplashScreen.java
* Created 14.01.2008 15:15:45
* @author Markus J. Luzius
*
*/
public class SplashScreen extends JDialog {
  private static final long serialVersionUID = -6111002767119011858L;
  private static Logger  log  = Logger.getLogger(SplashScreen.class);
  private static final int WIDTH = 400;
  private static final int HEIGHT = 280;
  private static final int WAITFOR = 4000;

  public SplashScreen() {
    this.setUndecorated(true);
    this.setSize(WIDTH, HEIGHT);
   
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (int j = 0; j < gs.length; j++) {
        GraphicsDevice gd = gs[j];
        GraphicsConfiguration[] gc = gd.getConfigurations();
        for (int i=0; i < gc.length; i++) {
            virtualBounds = virtualBounds.union(gc[i].getBounds());
        }
    }
    this.setLocation( (virtualBounds.width-WIDTH)/2, (virtualBounds.height-HEIGHT)/2);
    this.getContentPane().setBackground(new Color(180,180,255));
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

  }
 
  public void paint(Graphics g) {
    log.debug("Painting SplashScreen");
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;
   
    g2d.setFont(new Font("Verdana", Font.PLAIN, 12));
    g2d.drawString("Welcome to AnImOSY", 20, 30);
    g2d.drawString("- Another Implementation of Scotland Yard", 20, 50);
    g2d.setFont(new Font("Verdana", Font.PLAIN, 10));
    g2d.drawString("Copyright (c) 2007-2008, 2012-2013 Markus J. Luzius", 20, 200);
    g2d.drawString("This program comes with ABSOLUTELY NO WARRANTY.", 20, 220);
    g2d.drawString("This is free software, and you are welcome to", 20, 235);
    g2d.drawString("redistribute it under certain conditions", 20, 250);
    g2d.drawString("see \"license\" for details.", 20, 265);
    g2d.drawRect(0, 0, WIDTH-1, HEIGHT-1);
    g2d.drawRect(4, 4, WIDTH-9, HEIGHT-9);
    g2d.setColor(new Color(255,255,255));
    g2d.drawRect(1, 1, WIDTH-3, HEIGHT-3);
    g2d.drawRect(2, 2, WIDTH-5, HEIGHT-5);
    g2d.drawRect(3, 3, WIDTH-7, HEIGHT-7);
  }
 
  public void setVisible(boolean b) {
    log.debug(".setVisible("+b+")");
    super.setVisible(b);
    if(b) try {
      Thread.sleep(WAITFOR);
    }
    catch (InterruptedException e) {
      log.warn("SplashScreen interrupted...");
    }
    super.setVisible(false);
  }
 
}
TOP

Related Classes of de.axxeed.animosy.gui.SplashScreen

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.