本文整理汇总了Java中org.abego.treelayout.util.DefaultTreeForTreeLayout.addChild方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeForTreeLayout.addChild方法的具体用法?Java DefaultTreeForTreeLayout.addChild怎么用?Java DefaultTreeForTreeLayout.addChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.abego.treelayout.util.DefaultTreeForTreeLayout
的用法示例。
在下文中一共展示了DefaultTreeForTreeLayout.addChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSampleTree
import org.abego.treelayout.util.DefaultTreeForTreeLayout; //导入方法依赖的package包/类
/**
* @return a "Sample" tree with {@link TextInBox} items as nodes.
*/
public static TreeForTreeLayout<TextInBox> createSampleTree() {
TextInBox root = new TextInBox("root", 40, 20);
TextInBox n1 = new TextInBox("n1", 30, 20);
TextInBox n1_1 = new TextInBox("n1.1\n(first node)", 80, 36);
TextInBox n1_2 = new TextInBox("n1.2", 40, 20);
TextInBox n1_3 = new TextInBox("n1.3\n(last node)", 80, 36);
TextInBox n2 = new TextInBox("n2", 30, 20);
TextInBox n2_1 = new TextInBox("n2", 30, 20);
DefaultTreeForTreeLayout<TextInBox> tree = new DefaultTreeForTreeLayout<TextInBox>(
root);
tree.addChild(root, n1);
tree.addChild(n1, n1_1);
tree.addChild(n1, n1_2);
tree.addChild(n1, n1_3);
tree.addChild(root, n2);
tree.addChild(n2, n2_1);
return tree;
}
示例2: createSampleTree2
import org.abego.treelayout.util.DefaultTreeForTreeLayout; //导入方法依赖的package包/类
/**
* @return a "Sample" tree with {@link TextInBox} items as nodes.
*/
public static TreeForTreeLayout<TextInBox> createSampleTree2() {
TextInBox root = new TextInBox("prog", 40, 20);
TextInBox n1 = new TextInBox("classDef", 65, 20);
TextInBox n1_1 = new TextInBox("class", 50, 20);
TextInBox n1_2 = new TextInBox("T", 20, 20);
TextInBox n1_3 = new TextInBox("{", 20, 20);
TextInBox n1_4 = new TextInBox("member", 60, 20);
TextInBox n1_5 = new TextInBox("member", 60, 20);
TextInBox n1_5_1 = new TextInBox("<ERROR:int>", 90, 20);
TextInBox n1_6 = new TextInBox("member", 60, 20);
TextInBox n1_6_1 = new TextInBox("int", 30, 20);
TextInBox n1_6_2 = new TextInBox("i", 20, 20);
TextInBox n1_6_3 = new TextInBox(";", 20, 20);
TextInBox n1_7 = new TextInBox("}", 20, 20);
DefaultTreeForTreeLayout<TextInBox> tree = new DefaultTreeForTreeLayout<TextInBox>(
root);
tree.addChild(root, n1);
tree.addChild(n1, n1_1);
tree.addChild(n1, n1_2);
tree.addChild(n1, n1_3);
tree.addChild(n1, n1_4);
tree.addChild(n1, n1_5);
tree.addChild(n1_5, n1_5_1);
tree.addChild(n1, n1_6);
tree.addChild(n1_6,n1_6_1);
tree.addChild(n1_6,n1_6_2);
tree.addChild(n1_6,n1_6_3);
tree.addChild(n1, n1_7);
return tree;
}
示例3: testAddChild
import org.abego.treelayout.util.DefaultTreeForTreeLayout; //导入方法依赖的package包/类
@Test
public void testAddChild() throws Exception {
DefaultTreeForTreeLayout<String> tree = new DefaultTreeForTreeLayout<String>(
"ROOT");
tree.addChild("ROOT", "N1");
tree.addChild("ROOT", "N2");
tree.addChild("N1", "N1.1");
assertEquals("N1", tree.getChildrenList("ROOT").get(0));
assertEquals("N1.1", tree.getChildrenList("N1").get(0));
assertEquals("N2", tree.getChildrenList("ROOT").get(1));
}
示例4: testAddChild_parentNotInTree
import org.abego.treelayout.util.DefaultTreeForTreeLayout; //导入方法依赖的package包/类
@Test
public void testAddChild_parentNotInTree() throws Exception {
DefaultTreeForTreeLayout<String> tree = new DefaultTreeForTreeLayout<String>(
"ROOT");
try {
tree.addChild("N1", "N1.1");
fail("exception expected");
} catch (Exception ex) {
assertEquals("parentNode is not in the tree", ex.getMessage());
}
}