Package org.terasology.logic.behavior.nui

Examples of org.terasology.logic.behavior.nui.RenderableNode$Visitor


        Assert.assertEquals(two, parent.getChild(1));
    }

    @Test
    public void testConnectToConnectedComposite() {
        RenderableNode parent = new RenderableNode();
        parent.setNode(composite());
        RenderableNode one = new RenderableNode();
        one.setNode(node());
        RenderableNode two = new RenderableNode();
        two.setNode(node());

        ((Port.OutputPort) parent.getPortList().ports().get(0)).setTarget(one.getInputPort());
        ((Port.OutputPort) parent.getPortList().ports().get(2)).setTarget(two.getInputPort());

        RenderableNode three = new RenderableNode();
        three.setNode(node());
        ((Port.OutputPort) parent.getPortList().ports().get(3)).setTarget(three.getInputPort());

        Assert.assertEquals(parent, one.getInputPort().getTargetPort().getSourceNode());
        Assert.assertEquals(parent, three.getInputPort().getTargetPort().getSourceNode());
        Assert.assertEquals(parent.getPortList().ports().get(1), one.getInputPort().getTargetPort());
        Assert.assertEquals(parent.getPortList().ports().get(3), three.getInputPort().getTargetPort());

        Assert.assertEquals(2, parent.getChildrenCount());

        Assert.assertEquals(one, parent.getChild(0));
        Assert.assertEquals(three, parent.getChild(1));
View Full Code Here


        Assert.assertEquals(null, two.getInputPort().getTargetPort());
    }

    @Test
    public void testDisconnectComposite() {
        RenderableNode parent = new RenderableNode();
        parent.setNode(composite());
        RenderableNode one = new RenderableNode();
        one.setNode(node());
        RenderableNode two = new RenderableNode();
        two.setNode(node());

        ((Port.OutputPort) parent.getPortList().ports().get(0)).setTarget(one.getInputPort());
        ((Port.OutputPort) parent.getPortList().ports().get(2)).setTarget(two.getInputPort());

        ((Port.OutputPort) parent.getPortList().ports().get(1)).setTarget(null);
        Assert.assertEquals(1, parent.getChildrenCount());
        Assert.assertEquals(two, parent.getChild(0));
        Assert.assertEquals(null, one.getInputPort().getTargetPort());

        ((Port.OutputPort) parent.getPortList().ports().get(1)).setTarget(null);
        Assert.assertEquals(0, parent.getChildrenCount());
        Assert.assertEquals(null, two.getInputPort().getTargetPort());
    }
View Full Code Here

        Assert.assertEquals(null, two.getInputPort().getTargetPort());
    }

    @Test
    public void testLeaf() {
        RenderableNode node = new RenderableNode();
        node.setNode(node());
        PortList portList = node.getPortList();
        Assert.assertEquals(0, portList.ports().size());

    }
View Full Code Here

    }

    @Test
    public void testDecorator() {
        RenderableNode node = new RenderableNode();
        node.setNode(decorator(node()));
        PortList portList = node.getPortList();
        Assert.assertEquals(1, portList.ports().size());
    }
View Full Code Here

        };
    }

    @Test
    public void testComposite() {
        RenderableNode node = new RenderableNode();
        node.setNode(new CompositeNode() {
            @Override
            public Task createTask() {
                return null;
            }
        });
        PortList portList = node.getPortList();
        Assert.assertEquals(1, portList.ports().size());
    }
View Full Code Here

        this.renderableRoot = renderableRoot;
    }

    public RenderableNode createNode(Node node) {
        BehaviorNodeComponent nodeComponent = CoreRegistry.get(BehaviorNodeFactory.class).getNodeComponent(node);
        RenderableNode self = new RenderableNode(nodeComponent);
        self.setNode(node);
        renderableNodes.put(node, self);
        return self;
    }
View Full Code Here

    public RenderableNode createRenderable(Node node) {
        return node.visit(null, new Node.Visitor<RenderableNode>() {
            @Override
            public RenderableNode visit(RenderableNode parent, Node node) {
                RenderableNode self = createNode(node);
                if (parent != null) {
                    parent.withoutModel().insertChild(-1, self);
                }
                return self;
            }
View Full Code Here

            layoutTree = new LayoutTree(start);
        }
        TreeLayout<RenderableNode> layout = new TreeLayout<>(layoutTree, new FixedNodeExtentProvider<RenderableNode>(10, 5), new DefaultConfiguration<RenderableNode>(4, 2));
        Map<RenderableNode, Rectangle2D.Double> bounds = layout.getNodeBounds();
        for (Map.Entry<RenderableNode, Rectangle2D.Double> entry : bounds.entrySet()) {
            RenderableNode node = entry.getKey();
            Rectangle2D.Double rect = entry.getValue();
            node.setPosition((float) rect.getX(), (float) rect.getY());
        }
    }
View Full Code Here

    protected void onDispose() {
        this.data = null;
    }

    public RenderableNode createNode(Node node) {
        RenderableNode renderable = data.createRenderable(node);
        data.layout(renderable);
        return renderable;
    }
View Full Code Here

        CoreRegistry.put(AssetManager.class, assetManager);
    }

    @Test
    public void testConnectDecorator() {
        RenderableNode one = new RenderableNode();
        one.setNode(decorator(null));
        RenderableNode two = new RenderableNode();
        two.setNode(node());
        ((Port.OutputPort) one.getPortList().ports().get(0)).setTarget(two.getInputPort());

        Assert.assertEquals(one, two.getInputPort().getTargetPort().getSourceNode());
        Assert.assertEquals(one.getPortList().ports().get(0), two.getInputPort().getTargetPort());

        Assert.assertEquals(1, one.getChildrenCount());
        Assert.assertEquals(two, one.getChild(0));
    }
View Full Code Here

TOP

Related Classes of org.terasology.logic.behavior.nui.RenderableNode$Visitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.