package cnp.ew.diagram;

import cnp.ew.scrolling.*;
import cnp.ew.text.*;
import cnp.ew.util.*;

import java.awt.*;
import java.util.*;

public class CpDiagramLc extends CpScrollingController
{
    CpDiagram diagram;

    public static CpDiagramLc example()
    {
        CpDiagram di;
        CpDiagrammableWrapperLc wrap, wrap2, wrap3;

        CpDiagramLc d = new CpDiagramLc(false, false, di = new CpDiagram());

        Vector v = new Vector();
        CpReadOnlyTextAreaLc text = new CpReadOnlyTextAreaLc("One");
        text.setBackground(new Color(255, 255, 204));
        text.setFont(CpFonts.dialogPlainTen());
        text.setBorderStyle(BORDER_LINE);
        text.setBorderMargin(3);
        wrap = new CpDiagrammableWrapperLc(text);
        wrap.move(5, 5);
        wrap.resize(text.preferredSize());
        v.addElement(wrap);

        CpReadOnlyTextAreaLc text2 = new CpReadOnlyTextAreaLc("Two");
        text2.setBackground(new Color(166, 202, 240));
        text2.setBorderStyle(BORDER_LINE);
        text2.setBorderMargin(3);
        text2.setFont(CpFonts.dialogPlainTen());
        wrap2 = new CpDiagrammableWrapperLc(text2);
        wrap2.move(40, 35);
        wrap2.resize(text2.preferredSize());
        v.addElement(wrap2);

        CpReadOnlyTextAreaLc text3 = new CpReadOnlyTextAreaLc("Three");
        text3.setBackground(new Color(153, 153, 255));
        text3.setBorderStyle(BORDER_LINE);
        text3.setBorderMargin(3);
        text3.setFont(CpFonts.dialogPlainTen());
        wrap3 = new CpDiagrammableWrapperLc(text3);
        wrap3.move(55, 10);
        wrap3.resize(text3.preferredSize());
        v.addElement(wrap3);

        di.setLcs(v);

        CpDependentConnector connector = new CpDependentConnector(new CpDependentLineLc(), false, false);
        connector.connect(wrap, wrap2);

        connector = new CpDependentConnector(new CpDependentLineLc(), false, false);
        connector.connect(wrap, wrap3);

        d.resize(100, 100);
        return d;
    }

    public CpDiagramLc(boolean hasHScroll, boolean hasVScroll, CpDiagram newDiagram)
    {
        super(hasHScroll, hasVScroll);
        scroller.setScrollable(diagram = newDiagram);
        diagram.setBackground(Color.white);
    }

    public CpDiagramLc(boolean hasHScroll, boolean hasVScroll)
    {
        this(hasHScroll, hasVScroll, new CpDiagram());
    }

    public CpDiagramLc(CpDiagram newDiagram)
    {
        this(true, true, newDiagram);
    }

    public CpDiagramLc()
    {
        this(new CpDiagram());
    }

    public CpDiagram getDiagram()
    {
        return diagram;
    }

	public Object getCopy()
	{
	    return example();
	}
}

