package j3deditor.bin.editor.util;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;


/**
 * The <code>SELayout</code> class is a layout manager
 * for <code>SceneEditor</code>.
 *
 * @author Risto Seene
 * 
 * @see j3deditor.bin.editor.SceneEditor
 */
public class SELayout implements LayoutManager{

	/** width of the top left component */
	private int width;

	/** height of the top left component */
	private int height;


	/**
	 * Creates an instance of <code>SELayout</code>.
	 *
	 * @param width
	 *	width of the top left component
	 * @param height
	 *	height of the top left component
	 */
	public SELayout(int width, int height){
		this.width = width;
		this.height = height;
	}

	/**
	 * Required by LayoutManager.
	 * 
	 * @param name
	 * 	doesn't do anything
	 * @param comp
	 * 	doesn't do anything
	 */
	public void addLayoutComponent(String name, Component comp){
	}

	/**
	 * Required by LayoutManager.
	 * 
	 * @param comp
	 * 	doesn't do anything
	 */
	public void removeLayoutComponent(Component comp){
	}

	/**
	 * Required by LayoutManager.
	 * 
	 * @param parent
	 * 	doesn't do anything
	 * @return (0, 0)
	 */
	public Dimension preferredLayoutSize(Container parent){
		return new Dimension(0, 0);
	}

	/**
	 * Required by LayoutManager.
	 * 
	 * @param parent
	 * 	doesn't do anything
	 * @return (0, 0)
	 */
	public Dimension minimumLayoutSize(Container parent){
		return new Dimension(0, 0);
	}

	/**
	 * Required by LayoutManager.
	 * Lays out the component into the given container.
	 *
	 * @param parent
	 *	container which components will be layd out
	 */
	public void layoutContainer(Container parent){
		int maxWidth = parent.getWidth();
		int maxHeight = parent.getHeight();

		try{
			int bottomHeight = (int)(0.2 * maxHeight);

			parent.getComponent(0).setBounds(0, 0, width, height);
			parent.getComponent(1).setBounds(width, 0, maxWidth - width, height);
			parent.getComponent(2).setBounds(0, height, width, maxHeight - bottomHeight - height);
			parent.getComponent(3).setBounds(width, height, maxWidth - width - 1, maxHeight - bottomHeight - height);
			parent.getComponent(4).setBounds(0, maxHeight - bottomHeight, maxWidth, bottomHeight);
		} catch(Throwable t){
		}

	}
}

