package cnp.ew.diagram;

import java.awt.*;
import java.util.*;

import cnp.ew.lightweight.*;

public class CpDiagrammableWrapperLc extends CpAbstractDiagrammableLc
{
    public CpLightweightComponent wrappedLc;

    public CpDiagrammableWrapperLc(CpLightweightComponent newWrappedLc)
    {
        super(0, 0, 0, 0);
        wrappedLc = newWrappedLc;
        add(wrappedLc);
    }

    public CpLightweightComponent getWrappedLc()
    {
        return wrappedLc;
    }

    public void layout()
    {
        wrappedLc.reshape(0, 0, size().width, size().height);
    }

    public Dimension preferredSize()
    {
        return wrappedLc.preferredSize();
    }

    // This should really be in CpInterfaceBuilderObjectLc or such
	public Vector getHandles()
	{
	    // If this is slow, we can cache them...
	    Vector v = new Vector();
		v.addElement(new CpSizingHandle(this, CpBasicLocator.rightBottomLocator, CpBasicLocator.leftTopLocator, getWantsXorSizing()));
		v.addElement(new CpSizingHandle(this, CpBasicLocator.leftTopLocator, CpBasicLocator.rightBottomLocator, getWantsXorSizing()));
		v.addElement(new CpSizingHandle(this, CpBasicLocator.leftBottomLocator, CpBasicLocator.rightTopLocator, getWantsXorSizing()));
		v.addElement(new CpSizingHandle(this, CpBasicLocator.rightTopLocator, CpBasicLocator.leftBottomLocator, getWantsXorSizing()));
	    CpDependentLineLc connectionLine = new CpDependentLineLc();
	    connectionLine.startDecoration = connectionLine.DOT;
	    connectionLine.endDecoration = connectionLine.DOT;
 		v.addElement(new CpConnectingHandle(this, CpBasicLocator.rightMiddleLocator, new CpDependentConnector(connectionLine, false, false), new CpConnectionPolicy()));
		return v;
	}
}