package j3deditor.bin.util.startup;


import j3deditor.bin.util.Utilities;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.RenderingHints;

import javax.swing.JLabel;
import javax.swing.JPanel;


/**
 * Splash screen panel.
 *
 * @author Risto Seene
 */
public class StartPanel extends JPanel{

	/** reference to the object representing logo image. */
	private Image logo = null;

	/** label that shows the information. */
	private JLabel info;


	/**
	 * Creates an instance of <code>StartPanel</code>.
	 */
	public StartPanel(){
	          logo = Utilities.image.getImage("logo1.png");
		
		setLayout(new BorderLayout());
		add(new JLabel(), BorderLayout.CENTER);

		JPanel p = new JPanel(new GridLayout(1, 2));
		p.setOpaque(false);
		add(p, BorderLayout.SOUTH);

		Font font = new Font(Font.SANS_SERIF, 0, 12);
		info = new JLabel(" Info", 2);
		info.setForeground(Color.black);
		info.setFont(font);
		p.add(info);
		JLabel proc = new JLabel(Runtime.getRuntime().availableProcessors() + " processor(s) detected ", 4);
		proc.setForeground(Color.black);
		proc.setFont(font);
		p.add(proc);
	}


	/**
	 * Draws the logo image on this panel.
	 * 
	 * @param g
	 * 	<code>Graphics</code> object sent by method caller
	 */
	@Override
	protected void paintComponent(Graphics g){
		Graphics2D g2 = (Graphics2D)g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		super.paintComponent(g2);

		g2.setColor(Color.white);
		g2.fillRect(0, 0, getWidth(), getHeight());
		g2.setColor(new Color(2, 150, 255));
		g2.drawRect(0, 0, getWidth() - 1, getHeight() - 1);

		g2.drawImage(logo, 0, 0, this);
	}


	/**
	 * Shows the given info on this panel.
	 *
	 * @param info
	 *	text to be shown
	 */
	public void setInfo(String info){
		this.info.setText(" " + info);
	}

}
