//*********************************************************************************************
//
// Author: 			Dackral Scott Phillips
//
// File: 			SWOGSplashScreen.java
//
//	Date:				August 5, 2K2
//
// Description:	This is a java program written to satisfy the requirements necessary to
//						fulfill my master's degree.  This program creates a Sematic Web Ontology
//						Generator (SWOG).  It's primary purpose is to give semantic web newbies
//						an introduction to the syntax.  It provides help menus for beginning
//						users as well as an advanced code viewer with highlighted syntax. 
//
//	Copyright © 2002 by Dackral Scott Phillips.  All Rights Reserved.
//
//*********************************************************************************************

	// Import necessary files

   import javax.swing.*;
   import javax.swing.border.*;
   import java.awt.*;
   import java.awt.event.*;

    public class SWOGSplashScreen extends JWindow
   {
      private int splashWidth;	//The width of the Splashscreen Window
      private int splashHeight;	//The height of the Splashscreen Window
      private int duration;		//Number of milliseconds the window should display
   
   // Creates a SplashScreen that displays an Image, and a text string
   // for a given number of milliseconds, it also sets the background and
   // foreground colors
   
       public SWOGSplashScreen(String text, String iconPath, int time, Color bkgd, Color frgd)
      {
         ImageIcon icon = new ImageIcon(iconPath); //Image to display
      
      // Get the screensize for later use
      
         Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
      
      // Create a new SplashScreen Panel
      
         JPanel panel = new JPanel(); 
      
      // Add the labels to be displayed
      
         JLabel iconLabel = new JLabel(icon, JLabel.CENTER);	//Image on top
         JLabel textLabel = new JLabel(text, JLabel.CENTER);	//Text on bottom
      
         textLabel.setFont(new Font("SanSerif", Font.BOLD, 12)); //Text font
         textLabel.setOpaque(true);			//Make it Opaque to change the bkgd color
         textLabel.setBackground(bkgd);	//Set the bkgd	
         textLabel.setForeground(frgd);	//Set the Foreground
      
      // Add a border
      
         Border border = BorderFactory.createLineBorder(frgd, 2);
      
      // Figure out the image dimensions
      
         splashWidth = icon.getIconWidth();
         splashHeight = icon.getIconHeight();
         duration = time;
      
      // Create the panel layout
      
         panel.setLayout(new BorderLayout());
         ((JPanel) panel).setBorder(border);
         panel.add("North", iconLabel);	//Image on top
         panel.add("South", textLabel);	//Text on bottom
         setContentPane(panel); 
      
      // Screen math to place the Splash in the center
      
         setLocation((dimension.width - splashWidth) / 2, (dimension.height - (splashHeight + 20)) / 2);
         setSize(splashWidth, splashHeight + 20);
         setVisible(true);
      
      // Display for the time requested, then get rid of it
      
         try 
         {
            Thread.sleep(duration);
         } 
             catch (InterruptedException e) 
            {
            }
         this.dispose();
      }
   }