Java 类com.badlogic.gdx.scenes.scene2d.ui.Tree.Node 实例源码

项目:gaiasky    文件:ObjectsComponent.java   
private Array<Node> createTree(Array<SceneGraphNode> nodes) {
    Array<Node> treeNodes = new Array<Node>(nodes.size);
    for (SceneGraphNode node : nodes) {
        Label l = new Label(node.name, skin, "ui-10");
        l.setColor(Color.BLACK);
        Node treeNode = new Node(l);

        if (node.children != null && node.children.size != 0) {
            treeNode.addAll(createTree(node.children));
        }

        treeNodes.add(treeNode);
        treeToModel.add(node, treeNode);
    }

    return treeNodes;
}
项目:vis-editor    文件:TestTree.java   
private void addVisWidgets () {
    VisTree tree = new VisTree();
    Node item1 = new Node(new VisLabel("item 1"));
    Node item2 = new Node(new VisLabel("item 2"));
    Node item3 = new Node(new VisLabel("item 3"));

    item1.add(new Node(new VisLabel("item 1.1")));
    item1.add(new Node(new VisLabel("item 1.2")));
    item1.add(new Node(new VisLabel("item 1.3")));

    item2.add(new Node(new VisLabel("item 2.1")));
    item2.add(new Node(new VisLabel("item 2.2")));
    item2.add(new Node(new VisLabel("item 2.3")));

    item3.add(new Node(new VisLabel("item 3.1")));
    item3.add(new Node(new VisLabel("item 3.2")));
    item3.add(new Node(new VisLabel("item 3.3")));

    item1.setExpanded(true);

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

    add(tree).expand().fill();
}
项目:vis-editor    文件:AssetsUIModule.java   
private boolean highlightDir (FileHandle dir, Array<Node> nodes) {
    for (Node node : nodes) {
        if (((FolderItem) node.getActor()).getFile().equals(dir)) {
            contentTree.getSelection().set(node);
            return true;
        }

        if (node.getChildren().size > 0) {
            boolean prevNodeState = node.isExpanded();
            node.setExpanded(true);
            if (highlightDir(dir, node.getChildren())) return true;
            node.setExpanded(prevNodeState);
        }
    }

    return false;
}
项目:vis-editor    文件:AssetsUIModule.java   
private void createContentTree () {
    contentTree = new VisTree();
    contentTree.getSelection().setMultiple(false);
    contentTree.getSelection().setRequired(true);
    contentTree.getSelection().setProgrammaticChangeEvents(false);
    treeTable.add(createScrollPane(contentTree, false)).expand().fill();

    contentTree.addListener(new ChangeListener() {
        @Override
        public void changed (ChangeEvent event, Actor actor) {
            Node node = contentTree.getSelection().first();

            if (node != null) {
                searchField.clearSearch();

                FolderItem item = (FolderItem) node.getActor();
                changeCurrentDirectory(item.getFile(), HistoryPolicy.ADD);
            }
        }
    });
}
项目:vis-editor    文件:SceneOutline.java   
private void buildGroupNodeState (Array<Node> nodes) {
    for (Node n : nodes) {

        if (n.getChildren().size > 0) {

            if (n instanceof GroupNode) {
                GroupNode groupNode = (GroupNode) n;

                if (groupNode.isExpanded()) {
                    expandedNodes.add(groupNode.groupId);
                }

                buildGroupNodeState(groupNode.getChildren());
            }
        }
    }
}
项目:libgdxcn    文件:TreeTest.java   
public void create () {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

    Table table = new Table();
    table.setFillParent(true);
    stage.addActor(table);

    final Tree tree = new Tree(skin);

    final Node moo1 = new Node(new TextButton("moo1", skin));
    final Node moo2 = new Node(new TextButton("moo2", skin));
    final Node moo3 = new Node(new TextButton("moo3", skin));
    final Node moo4 = new Node(new TextButton("moo4", skin));
    final Node moo5 = new Node(new TextButton("moo5", skin));
    tree.add(moo1);
    tree.add(moo2);
    moo2.add(moo3);
    moo3.add(moo4);
    tree.add(moo5);

    moo5.getActor().addListener(new ClickListener() {
        public void clicked (InputEvent event, float x, float y) {
            tree.remove(moo4);
        }
    });

    table.add(tree).fill().expand();
}
项目:bladecoder-adventure-engine    文件:EditTree.java   
public Array<Node> getSiblings() {
    Selection<Node> selection = tree.getSelection();
    Node nodeSel = selection.first();

    int level = nodeSel.getLevel();
    Array<Node> siblings = (level == 1) ? tree.getRootNodes(): nodeSel.getParent().getChildren(); 

    return siblings;
}
项目:vis-editor    文件:TestTree.java   
private void addNormalWidgets () {
    Skin skin = VisUI.getSkin();

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

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

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

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

    item1.setExpanded(true);

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

    add(tree).expand().fill();
}
项目:vis-editor    文件:AssetsUIModule.java   
@Override
public void init () {
    initModule();
    initUI();

    rebuildFolderTree();
    Node node = contentTree.getNodes().get(0);
    contentTree.getSelection().set(node); // select first item in tree
    changeCurrentDirectory(((FolderItem) node.getActor()).getFile(), HistoryPolicy.IGNORE);

    Array<AssetsUIContextGeneratorProvider> providers = extensionStorage.getAssetsContextGeneratorsProviders();
    for (AssetsUIContextGeneratorProvider provider : providers) {
        contextGenerators.add(provider.provide());
    }

    for (AssetsUIContextGenerator generator : contextGenerators) {
        projectContainer.injectModules(generator);
        generator.init();
    }

    tabsModule.addListener(this);
    assetsWatcher.addListener(this);

    json = new Json();
    metadataFile = fileAccess.getModuleFolder(".metadata").child("assetsUIMetadata");

    if (metadataFile.exists())
        metadata = json.fromJson(AssetsUIModuleMetadata.class, metadataFile);
    else
        metadata = new AssetsUIModuleMetadata();
}
项目:vis-editor    文件:AssetsUIModule.java   
private void rebuildFolderTree () {
    contentTree.clearChildren();

    contentTree.add(new Node(new FolderItem(assetsFolder, true)));

    for (FileHandle contentRoot : assetsFolder.list(DirectoriesOnlyFileFilter.FILTER)) {

        //hide empty dirs except 'gfx' and 'scene'
        if (contentRoot.list().length != 0 || contentRoot.name().equals("gfx") || contentRoot.name().equals("scene")) {
            Node node = new Node(new FolderItem(contentRoot));
            processFolder(node, contentRoot);
            contentTree.add(node);
        }
    }
}
项目:vis-editor    文件:AssetsUIModule.java   
private void processFolder (Node node, FileHandle dir) {
    FileHandle[] files = dir.list(DirectoriesOnlyFileFilter.FILTER);

    for (FileHandle file : files) {
        if (file.name().startsWith(".")) continue; //hide folders starting with dot

        Node currentNode = new Node(new FolderItem(file));
        node.add(currentNode);

        processFolder(currentNode, file);
    }
}
项目:vis-editor    文件:SettingsDialog.java   
public void add (final SettableModule module) {
    Node node = new Node(new SettingsCategoryLabel(module.getSettingsName(), module.getListPriority()));

    modulesMap.put(module, node);
    tree.add(node);
    tree.getNodes().sort(nodeComparator);
}
项目:vis-editor    文件:SettingsDialog.java   
@Override
public int compare (Node n1, Node n2) {
    SettingsCategoryLabel l1 = (SettingsCategoryLabel) n1.getActor();
    SettingsCategoryLabel l2 = (SettingsCategoryLabel) n2.getActor();
    String t1 = l1.getText().toString();
    String t2 = l2.getText().toString();

    int priorityResult = (int) Math.signum(l1.getPriority() - l2.getPriority()) * -1;

    if (priorityResult != 0)
        return priorityResult;
    else
        return t1.compareToIgnoreCase(t2);
}
项目:vis-editor    文件:SceneOutline.java   
private void buildTreeRecursively (Array<EntityProxy> groupProxies, int gid, Node parent) {
    GroupNode groupRoot = new GroupNode(groupProxies.first().getLayerID(), gid);
    if (parent == null)
        tree.add(groupRoot);
    else
        parent.add(groupRoot);

    if (expandedNodes.contains(gid)) {
        groupRoot.setExpanded(true);
    }

    Array<EntityProxy> ignoreProxies = new Array<>();

    for (EntityProxy proxy : groupProxies) {
        if (ignoreProxies.contains(proxy, true)) {
            continue;
        }

        int gidBefore = proxy.getGroupIdBefore(gid);
        if (gidBefore != -1) {
            Array<EntityProxy> result = entitiesCollector.collect(proxy.getLayerID(), gidBefore);
            ignoreProxies.addAll(result);
            buildTreeRecursively(result, gidBefore, groupRoot);
            continue;
        }

        groupRoot.add(new ProxyNode(proxy));
    }
}
项目:vis-editor    文件:AssetsUsagesTab.java   
public AssetsUsagesTab (ModuleInjector injector, AssetsUsages usages, boolean showDeleteButton) {
    super(false, true);
    injector.injectModules(this);
    this.usages = usages;

    createButtonTable(showDeleteButton);

    mainTable = new VisTable();
    mainTable.setBackground("window-bg");
    mainTable.defaults().left();
    tree = new VisTree();

    usagesTable = new VisTable();

    VisScrollPane scrollPane = new VisScrollPane(usagesTable);
    scrollPane.setFadeScrollBars(false);

    mainTable.row();
    mainTable.add(scrollPane).expand().fill().row();
    mainTable.addSeparator();
    mainTable.add(buttonTable).pad(3);

    rebuildUsagesTable();

    tree.addListener(new ClickListener() {
        @Override
        public void clicked (InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            if (getTapCount() == 2) {
                Node node = tree.getNodeAt(y);
                if (node != null) {
                    Actor actor = node.getActor();
                    if (actor instanceof UsageLabel) selectEntityInScene((UsageLabel) actor);
                }
            }
        }
    });
}
项目:vis-editor    文件:AssetsUsagesTab.java   
private void processUsages () {
    for (SceneUsages sceneUsages : usages.list) {
        Node node = new Node(new VisLabel(sceneUsages.scene.path, "small"));
        node.setExpanded(true);
        tree.add(node);

        for (int i = 0; i < sceneUsages.ids.size; i++) {
            int id = sceneUsages.ids.get(i);
            node.add(new Node(new UsageLabel(sceneUsages.scene, id)));
        }

    }
}
项目:vis-editor    文件:SceneOutline.java   
public SceneOutline (SceneModuleContainer sceneMC) {
    super(true);
    sceneMC.injectModules(this);
    scene = sceneMC.getScene();

    proxyCache.addListener(this);

    tree = new VisTree();
    tree.getSelection().setMultiple(true);
    tree.getSelection().setRequired(false);
    tree.getSelection().setProgrammaticChangeEvents(false);

    tree.addListener(new ClickListener() {
        Node selection;

        @Override
        public void clicked (InputEvent event, float x, float y) {
            //tree will deselect item after double click so we on first click store selection
            if (getTapCount() == 1 && tree.getSelection().size() == 1) {
                selection = tree.getSelection().getLastSelected();
            }

            if (getTapCount() == 2 && selection != null) {
                if (selection instanceof ProxyNode) {
                    sceneMC.getSceneTab().centerAround(((ProxyNode) selection).proxy);
                }

                if (selection instanceof GroupNode) {
                    GroupNode groupNode = (GroupNode) selection;
                    sceneMC.getSceneTab().centerAroundGroup(groupNode.layerId, groupNode.groupId);
                }

                selection = null;
            }
        }
    });

    setBackground(VisUI.getSkin().getDrawable("window-bg"));
    setTouchable(Touchable.enabled);

    add(new VisLabel("Outline", Align.center)).expandX().fillX().top().spaceBottom(0).row();

    VisScrollPane scrollPane = new VisScrollPane(tree);
    scrollPane.setFadeScrollBars(false);

    add(scrollPane).expand().fill();
    pack();

    rebuildOutline(); //do first update
}
项目:gdx-ai    文件:BehaviorTreeViewer.java   
private void fill (IntArray taskSteps, TaskNode taskNode) {
    taskSteps.add(taskNode.step);
    for (Node child : taskNode.getChildren()) {
        fill(taskSteps, (TaskNode)child);
    }
}