//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/god4j
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : god4j@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.god4j.editor.panels;
import java.awt.Dimension;

import org.huihoo.god4j.editor.XPDLCollection;
/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class JavaControlPanel extends JavaPanel
{
	protected JavaPanel controlledPanel;
	public JavaControlPanel(XPDLCollection myOwner, String title, boolean isVertical, boolean hasBorder)
	{
		super(myOwner, 0, title, JavaPanel.BOX_LAYOUT, isVertical, hasBorder);
	}
	public void setControlledPanel(JavaPanel controlledPanel)
	{
		this.controlledPanel = controlledPanel;
	}
	protected Dimension getPreferredDimension(String[] s)
	{
		double longest = 0;
		double w = 0;
		for (int i = 0; i < s.length; i++)
		{
			String n = s[i];
			try
			{
				w = getFontMetrics(getFont()).stringWidth(s[i]);
				if (w > longest)
				{
					longest = w;
				}
			}
			catch (Exception ex)
			{
			}
		}
		double h = getFontMetrics(getFont()).getHeight();
		w = longest + 25;
		if (w < 30)
		{
			w = 30;
		}
		return new Dimension((int) w, (int) h);
	}
}
