package org.avmdti.josast.demarage;

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.Window;

/*
 * 
 * <b>Description :</b>
 * 
 * 
 * <p>Projet : JCP <BR>
 * 
 * <br>
 * <b>JOSAST</b> : Java Open Source Amateur Satellite  Toolbox 
 * <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software.
 * <b>JOSAST</b> project is managed by AVMDTI (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
 * <br> This software is an open source software. Please read the <b><i>JOSAST licence</b></i><BR>(<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
 * <p>for more information contact <a href="mailto:josast@avmdti.org">josast@avmdti.org</a></p>
 * @author  <a href="mailto:mercier.josast@avmdti.org">mercier</a>
 * @version 1.0
 * <p><b>date </b>23 avr. 2003</p>
 * <p><b><i> Source Update </b></i></p>
 * <br> date : name : comments 
 * <br> V1 : mercier : create file
 * <p>
 * 
 */


/**
 * 
 * This class allow to display a Windows
 * <br>
 * @author Xtophe
 * @version 1.0
 */
public class FenetreDemarage {

	private Window _window = null;


	/**
	 * Constructor for FenetreDemarage.
	 * @param arg0 filename.
	 */
	public FenetreDemarage(String filename) {
		ImageIntroduction im = new ImageIntroduction(filename);
		_window = new Window(new Frame());

		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int largeur = screenSize.width * 2 / 3;
		im.setscale(largeur, -1);
		_window.add(im);
		_window.setSize(im.getIw(), im.getIh());
		Dimension windowSize = _window.getSize();
		if (windowSize.height > screenSize.height) {
			windowSize.height = screenSize.height;
		}
		if (windowSize.width > screenSize.width) {
			windowSize.width = screenSize.width;
		}
		_window.setLocation(
			(screenSize.width - windowSize.width) / 2,
			(screenSize.height - windowSize.height) / 2);
		_window.setVisible(true);

	}

	/**
	 * Set the window visible
	 * 
	 * @param b boolean true : visible
	 */
	public void setVisible(boolean b) {
		_window.setVisible(b);
	}
	
	/**
	 * Sample to demonstrate how to use this class. 
	 * <br> 
	 * <br> Fenetredemarage filename
	 * <br>
	 * 
	 * @param args image filename
	 */
	public static void main(String[] args) {
		if (args.length!=0)
		{
		 new FenetreDemarage(args[0]);
		}
		else
		{
			System.out.println("USAGE : il faut un argument : nom de l'image");
		}
		}
}
