Exemple #1
0
private void Drop (MouseEvent ev)
    {
	switch (state) {
	case stateDrag:
	    state = stateIdle;
	    CheckResize ();
	    break;

	case stateCreate:
	    CGNode node = new CGNode (ev.getX(), ev.getY(), "something",
				      getFontMetrics (getFont()),
				      !curnode.IsConcept());
            curnode.AddChild (node, curarrow);
            node.SetParent (curnode, curarrow);
            ToBottom (curarrow);
            Add (node);

	    if (!node.IsConcept()) {
		int x = ev.getX() + node.Bbox().width + layoutXDist;
		CGNode node2 = new CGNode (x, ev.getY(), "something",
					   getFontMetrics (getFont()),
					   true);
		CGArrow arrow2 = new CGArrow (0, 0, 0, 0);
		node.AddChild (node2, arrow2);
		node2.SetParent (node, arrow2);
		Add (node2);
		Add (arrow2);
                ToBottom (arrow2);
	    }
            state = stateIdle;
            NotifyViewers();
            break;
	}
        ShowStatus (ev.getX(), ev.getY());
    }
Exemple #2
0
private void LayoutPass2 (CGNode root, int x, Vector vdist, int level)
    {
	Rectangle bbox = root.Bbox();
	int width = ((Integer)vdist.elementAt(level)).intValue();
	root.MoveTo (x + (width - bbox.width)/2, root.layout_y);

	int nchilds = root.NumChilds();
	for (int i = 0; i < nchilds; ++i) {
	    LayoutPass2 (root.ChildAt(i), x+width+layoutXDist, vdist, level+1);
	}
    }
Exemple #3
0
public void Layout (CGNode root)
    {
	int x, y;
	if (root == null) {
            if ((root = topnode) == null)
                return;
	    x = layoutXDist;
	    y = layoutYDist;
	} else {
	    x = root.Bbox().x;
	    y = root.Bbox().y;
	}
	AutoUpdateOff ();
	Vector vdist = new Vector();
	LayoutPass1 (root, y, vdist, 0);
	LayoutPass2 (root, x, vdist, 0);
	CheckResize ();
	AutoUpdateOn ();
    }
Exemple #4
0
private int LayoutPass1 (CGNode root, int y, Vector vdist, int level)
    {
	Rectangle bbox = root.Bbox();
	root.layout_y = y;
	root.SortChilds ();

	if (level >= vdist.size()) {
	    vdist.addElement (new Integer (bbox.width));
	} else {
	    int width = ((Integer)vdist.elementAt(level)).intValue();
	    if (width < bbox.width) {
		vdist.setElementAt (new Integer (bbox.width), level);
	    }
	}
	int nchilds = root.NumChilds(), y2 = y;
	for (int i = 0; i < nchilds; ++i) {
	    y2 = LayoutPass1 (root.ChildAt(i), y2, vdist, level+1);
	}
	return Math.max (y + bbox.height + layoutYDist, y2);
    }