/*
 * Eine Klasse um eine SplashScreen zu generieren. 
 * 
 */
import javax.swing.JWindow;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

import sun.java2d.loops.ColorPaint;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import java.awt.Frame;

/**
 * @author Konstantin Kirsch
 */

public class SplashScreen extends Window{

	

	  
 	/**
	 * @param string
	 * @param connect
	 * @param i
	 */


	int width = 100, height = 100; 

		Image tile = null; 
		Toolkit toolkit = Toolkit.getDefaultToolkit() ; 

		String name    = "SplashScreen" ; 
		String version = "1.00" ; 
		String author  = "Konstantin Kirsch" ; 
		String web     = "http://www.k-kirsch.de/" ; 
		String mail    = "K.Kirsch@web.de" ; 

		SplashScreen() 
		{ 
		   super(new Frame()); 
		   setVisible(false) ; 

		   charge("SplashScreen.jpg") ; 
		} 

	public SplashScreen(String s) 
		{ 
		   super(new Frame()); 
		   setVisible(false) ; 

		   charge(s) ; 
		} 

		public void set(String name, String version, String author, String web, String mail) { 
		  this.name = name ; 
		  this.version = version ; 
		  this.author = author ; 
		  this.web = web ; 
		  this.mail = mail ; 
		} 

		private void charge(String s) 
		{ 
			  
			  MediaTracker trk = new MediaTracker(this) ; 
			  //tile = toolkit.getImage( s );
			  tile = getResourceImage(s); 
			  if (tile != null) { 
				  trk.addImage(tile, 0) ; 

				  try   {    trk.waitForID(0) ;  } 
				  catch ( InterruptedException e) {  } 

				  setSize(tile.getWidth(this), tile.getHeight(this)) ; 
			  } 
		} 
	   
	   public Image getResourceImage(String name){
	   	try{
		return Toolkit.getDefaultToolkit().getImage(java.net.URLClassLoader.getSystemResource(name));
	   	}catch(Exception e){
	   		e.printStackTrace();
	   		System.out.print("Error: Image Strukur nicht gefunden!!!");
	   		//System.exit(1);
	   		return null;
	   	}
	   }	
		public void run( ) { 
			  init() ; 
		} 
		public void init( ) 
		{ 
			Dimension dS = Toolkit.getDefaultToolkit().getScreenSize() ; 
			Dimension dL = getSize() ; 

			if (dL.width > dS.width) dL.width = dS.width ; 
			if (dL.height > dS.height) dL.height = dS.height ; 

			setLocation ( (dS.width - dL.width) / 2 , (dS.height - dL.height) / 2) ; 
			if(tile != null) 
				setVisible(true) ; 
		} 


		public void hide(int i) { 
			try { 
				Thread.sleep(i * 1000) ; 
			} 
			catch (Exception e) { } 

			setVisible(false) ; 
		} 

		public void paint(Graphics g) 
		{ 
			  int width = getSize().width, height = getSize().height, x = 0, y = 0; 

			  if(tile != null) 
				g.drawImage(tile, 0, 0, getBackground(), this); 
		      /*
		       //Unterer Code gedacht um im Logo was einzublenden 
			  g.setColor(new Color(0xD0D0D0)) ; 
			  g.fill3DRect(width-245, height-200, 225, 180, true); 
			  g.setColor(new Color(0x0)) ; 
			  g.draw3DRect(width-245, height-200, 225, 180, true); 
			
			  Font f = this.getFont() ; 

			  if (name != null) { 
				g.setFont(new Font("Arial",3, 18)) ; 
				g.drawString(name, width-230, height-175) ; 
			  } 

			  int Y = height-150 ; 
			  g.setFont(f) ; 
			  if (version != null) { 
				g.drawString("Version", width-235, Y) ; 
				g.drawString(version, width-165, Y) ; 
				Y += 22 ; 
			  } 
			  if (author != null) { 
				g.drawString("Author", width-235, Y) ; 
				g.drawString(author, width-165, Y) ; 
				Y += 22 ; 
			  } 
			  if (web != null) { 
				g.drawString("Url", width-235, Y) ; 
				g.drawString(web, width-165, Y) ; 
				Y += 22 ; 
			  } 
			  if (mail != null) { 
				g.drawString("E-Mail", width-235, Y) ; 
				g.drawString(mail, width-165, Y) ; 
				Y += 22 ; 
			  } 
	          */
		} 
	} 




