com.badlogic.gdx.scenes.scene2d.ui.Tree Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Tree. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestTree.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
private void addNormalWidgets () {
	Skin skin = VisUI.getSkin();

	Tree tree = new Tree(skin);
	TestNode item1 = new TestNode(new Label("item 1", skin));
	TestNode item2 = new TestNode(new Label("item 2", skin));
	TestNode item3 = new TestNode(new Label("item 3", skin));

	item1.add(new TestNode(new Label("item 1.1", skin)));
	item1.add(new TestNode(new Label("item 1.2", skin)));
	item1.add(new TestNode(new Label("item 1.3", skin)));

	item2.add(new TestNode(new Label("item 2.1", skin)));
	item2.add(new TestNode(new Label("item 2.2", skin)));
	item2.add(new TestNode(new Label("item 2.3", skin)));

	item3.add(new TestNode(new Label("item 3.1", skin)));
	item3.add(new TestNode(new Label("item 3.2", skin)));
	item3.add(new TestNode(new Label("item 3.3", skin)));

	item1.setExpanded(true);

	tree.add(item1);
	tree.add(item2);
	tree.add(item3);

	add(tree).expand().fill();
}
 
Example #2
Source File: BehaviorTreeViewer.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
private int addToTree (Tree displayTree, TaskNode parentNode, Task<E> task, IntArray taskSteps, int taskStepIndex) {
	TaskNode node = new TaskNode(task, this, taskSteps == null ? step - 1 : taskSteps.get(taskStepIndex), getSkin());
	taskNodes.put(task, node);
	if (parentNode == null) {
		displayTree.add(node);
	} else {
		parentNode.add(node);
	}
	taskStepIndex++;
	for (int i = 0; i < task.getChildCount(); i++) {
		Task<E> child = task.getChild(i);
		taskStepIndex = addToTree(displayTree, node, child, taskSteps, taskStepIndex);
	}
	return taskStepIndex;
}