コード例 #1
0
ファイル: CGEditor.java プロジェクト: raghunayak/mico
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());
    }
コード例 #2
0
ファイル: CGEditor.java プロジェクト: raghunayak/mico
public void actionPerformed( ActionEvent e )
    {
        String s = e.getActionCommand();
        if (s == null)
            return;

	String menuname = (String)menumap.get (curnode.GetType(true));
	Hashtable templates = (Hashtable)menus.get (menuname);

        ConceptualGraph cg = (ConceptualGraph)templates.get(s);
        AutoUpdateOff ();
        CGNode top = ConvertInput (cg);
        CGArrow arrow = new CGArrow (0, 0, 0, 0);
        Add (arrow);
        ToBottom (arrow);
        curnode.AddChild (top, arrow);
        top.SetParent (curnode, arrow);
        Layout (curnode);
        AutoUpdateOn ();

        NotifyViewers ();
  }
コード例 #3
0
ファイル: CGEditor.java プロジェクト: raghunayak/mico
private CGNode ConvertInput (ConceptualGraph cg)
    {
        StringBuffer ostr = new StringBuffer();
        cg.getNode().print (ostr);
        String s = ostr.toString();
        s = s.substring (1, s.length()-1);

        CGNode node = new CGNode (0, 0, s, getFontMetrics(getFont()),
                                  cg.getNode() instanceof ConceptNode);
        Add (node);

        ConceptualGraph cg2;
        for (cg2 = cg.getWidth(); cg2 != null; cg2 = cg2.getDepth()) {
            CGNode node2 = ConvertInput (cg2);
            CGArrow arrow2 = new CGArrow (0, 0, 0, 0);
            Add (arrow2);
            ToBottom (arrow2);

            node.AddChild (node2, arrow2);
            node2.SetParent (node, arrow2);
        }
        return node;
    }