Package nodebox.node

Examples of nodebox.node.Node


    private class NodeRenderer extends JLabel implements ListCellRenderer {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            assert (value instanceof Node);
            Node node = (Node) value;
            String html = "<html><b>" + StringUtils.humanizeName(node.getName()) + "</b> - " + node.getDescription() + "</html>";
            setText(html);
            if (isSelected) {
                setBackground(Theme.NODE_SELECTION_ACTIVE_BACKGROUND_COLOR);
            } else {
                setBackground(Theme.NODE_SELECTION_BACKGROUND_COLOR);
            }
            setEnabled(list.isEnabled());
            setFont(list.getFont());
            int iconSize = NetworkView.NODE_ICON_SIZE;
            int nodePadding = NetworkView.NODE_PADDING;
            BufferedImage bi = new BufferedImage(iconSize + nodePadding * 2, iconSize + nodePadding * 2, BufferedImage.TYPE_INT_ARGB);
            Graphics g = bi.createGraphics();
            g.setColor(NetworkView.portTypeColor(node.getOutputType()));
            g.fillRect(0, 0, iconSize + nodePadding * 2, iconSize + nodePadding * 2);
            g.drawImage(NetworkView.getImageForNode(node, repository), nodePadding, nodePadding, iconSize, iconSize, null, null);
            setIcon(new ImageIcon(bi));
            setBorder(Theme.BOTTOM_BORDER);
            setOpaque(true);
View Full Code Here


                , context.renderNode(oscReceiveNode));
    }

    @Test
    public void testCallReceiveSpecific() {
        Node oscReceiveNode1 = oscReceiveNode.withInputValue("prefix", "/2/multifader/8");
        List<Map<String, Object>> expectedResult = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multifader/8", "Column", 0.9));
        assertEquals(expectedResult, context.renderNode(oscReceiveNode1));
        Node oscReceiveNode2 = oscReceiveNode.withInputValue("prefix", "/2/multifader/8*");
        assertEquals(expectedResult, context.renderNode(oscReceiveNode2));
    }
View Full Code Here

        assertEquals(expectedResult, context.renderNode(oscReceiveNode2));
    }

    @Test
    public void testCallReceivePrefix() {
        Node oscReceiveNode1 = oscReceiveNode.withInputValue("prefix", "/2/multifader");
        List<Map<String, Object>> expectedResult = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multifader/11", "Column", 0.5),
                ImmutableMap.<String, Object>of("address", "/2/multifader/8", "Column", 0.9));
        assertEquals(expectedResult, context.renderNode(oscReceiveNode1));
        Node oscReceiveNode2 = oscReceiveNode.withInputValue("prefix", "/2/multifader*");
        assertEquals(expectedResult, context.renderNode(oscReceiveNode2));
    }
View Full Code Here

        assertEquals(expectedResult, context.renderNode(oscReceiveNode2));
    }

    @Test
    public void testCallReceiveWildcard() {
        Node oscReceiveNode1 = oscReceiveNode.withInputValue("prefix", "/2/multi*");
        List<Map<String, Object>> expectedResult = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multifader/11", "Column1", 0.5, "Column2", 0),
                ImmutableMap.<String, Object>of("address", "/2/multifader/8", "Column1", 0.9, "Column2", 0),
                ImmutableMap.<String, Object>of("address", "/2/multitoggle/2/15", "Column1", 0.1, "Column2", 0.2),
                ImmutableMap.<String, Object>of("address", "/2/multitoggle/4/10", "Column1", 0.3, "Column2", 0.6));
        assertEquals(expectedResult, context.renderNode(oscReceiveNode1));
        Node oscReceiveNode2 = oscReceiveNode.withInputValue("prefix", "/2/*lti*");
        assertEquals(expectedResult, context.renderNode(oscReceiveNode2));
        Node oscReceiveNode3 = oscReceiveNode.withInputValue("prefix", "*multi");
        assertEquals(expectedResult, context.renderNode(oscReceiveNode3));
        Node oscReceiveNode4 = oscReceiveNode.withInputValue("prefix", "multi*");
        assertEquals(ImmutableList.of(), context.renderNode(oscReceiveNode4));
    }
View Full Code Here

        assertEquals(ImmutableList.of(), context.renderNode(oscReceiveNode4));
    }

    @Test
    public void testCallReceiveMessagePattern() {
        Node oscReceiveNode1 = oscReceiveNode.withInputValue("prefix", "/2/multitoggle/<x>/<y>");
        List<Map<String, Object>> expectedResult = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multitoggle/2/15", "x", "2", "y", "15", "Column1", 0.1, "Column2", 0.2),
                ImmutableMap.<String, Object>of("address", "/2/multitoggle/4/10", "x", "4", "y", "10", "Column1", 0.3, "Column2", 0.6));
        assertEquals(expectedResult, context.renderNode(oscReceiveNode1));
    }
View Full Code Here

        assertEquals(expectedResult, context.renderNode(oscReceiveNode1));
    }

    @Test
    public void testCallReceiveMessageTypedPattern() {
        Node oscReceiveNode1 = oscReceiveNode.withInputValue("prefix", "/<pageid>/multifader/<faderid>");
        List<Map<String, Object>> expectedResult1 = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multifader/11", "pageid", "2", "faderid", "11", "Column", 0.5),
                ImmutableMap.<String, Object>of("address", "/2/multifader/8", "pageid", "2", "faderid", "8", "Column", 0.9));
        assertEquals(expectedResult1, context.renderNode(oscReceiveNode1));
        Node oscReceiveNode2 = oscReceiveNode.withInputValue("prefix", "/<pageid:string>/multifader/<faderid:s>");
        assertEquals(expectedResult1, context.renderNode(oscReceiveNode2));
        Node oscReceiveNode3 = oscReceiveNode.withInputValue("prefix", "/<pageid:int>/multifader/<faderid:i>");
        List<Map<String, Object>> expectedResult3 = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multifader/11", "pageid", 2, "faderid", 11, "Column", 0.5),
                ImmutableMap.<String, Object>of("address", "/2/multifader/8", "pageid", 2, "faderid", 8, "Column", 0.9));
        assertEquals(expectedResult3, context.renderNode(oscReceiveNode3));
        Node oscReceiveNode4 = oscReceiveNode.withInputValue("prefix", "/<pageid:f>/multifader/<faderid:float>");
        List<Map<String, Object>> expectedResult4 = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multifader/11", "pageid", 2.0, "faderid", 11.0, "Column", 0.5),
                ImmutableMap.<String, Object>of("address", "/2/multifader/8", "pageid", 2.0, "faderid", 8.0, "Column", 0.9));
        assertEquals(expectedResult4, context.renderNode(oscReceiveNode4));
        Node oscReceiveNode5 = oscReceiveNode.withInputValue("prefix", "/<pageid:l>/multifader/<faderid>");
        assertEquals(ImmutableList.of(), context.renderNode(oscReceiveNode5));
    }
View Full Code Here

        assertEquals(ImmutableList.of(), context.renderNode(oscReceiveNode5));
    }

    @Test
    public void testCallReceiveAndSortData() {
        Node oscReceiveNode1 = oscReceiveNode
                .withName("osc_receive1")
                .withInputValue("prefix", "/*/*/<itemid>");
        Node sortNode = Node.ROOT
                .withOutputRange(Port.Range.LIST)
                .withFunction("list/sort")
                .withInputAdded(Port.customPort("list", "list").withRange(Port.Range.LIST))
                .withInputAdded(Port.stringPort("key", ""));
        Node sortNode1 = sortNode
                .withName("sort1")
                .withInputValue("key", "itemid");
        Node net1 = Node.NETWORK
                .withChildAdded(oscReceiveNode1)
                .withChildAdded(sortNode1)
                .withRenderedChildName("sort1")
                .connect("osc_receive1", "sort1", "list");
        List<Map<String, Object>> expectedResult1 = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multifader/11", "itemid", "11", "Column1", 0.5, "Column2", 0, "Column3", 0),
                ImmutableMap.<String, Object>of("address", "/2/multitoggle/2/15", "itemid", "2", "Column1", 0.1, "Column2", 0.2, "Column3", 0),
                ImmutableMap.<String, Object>of("address", "/2/multitoggle/4/10", "itemid", "4", "Column1", 0.3, "Column2", 0.6, "Column3", 0),
                ImmutableMap.<String, Object>of("address", "/2/multifader/8", "itemid", "8", "Column1", 0.9, "Column2", 0, "Column3", 0),
                ImmutableMap.<String, Object>of("address", "/r/g/b/20", "itemid", "b", "Column1", 0.15, "Column2", 0.35, "Column3", 0.77));
        assertEquals(expectedResult1, context.renderNode(net1));
        Node oscReceiveNode2 = oscReceiveNode
                .withName("osc_receive2")
                .withInputValue("prefix", "/*/*/<itemid:i>");
        Node net2 = Node.NETWORK
                .withChildAdded(oscReceiveNode2)
                .withChildAdded(sortNode1)
                .withRenderedChildName("sort1")
                .connect("osc_receive2", "sort1", "list");
        List<Map<String, Object>> expectedResult2 = ImmutableList.<Map<String, Object>>of(
View Full Code Here

        assertEquals(expectedResult2, context.renderNode(net2));
    }

    @Test
    public void testCallReceiveArguments() {
        Node oscReceiveNode1 = oscReceiveNode
                .withInputValue("prefix", "/2/multifader*")
                .withInputValue("args", "v");
        List<Map<String, Object>> expectedResult1 = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multifader/11", "v", 0.5),
                ImmutableMap.<String, Object>of("address", "/2/multifader/8", "v", 0.9));
        assertEquals(expectedResult1, context.renderNode(oscReceiveNode1));
        Node oscReceiveNode2 = oscReceiveNode
                .withInputValue("prefix", "/2/multitoggle*")
                .withInputValue("args", "x,y");
        List<Map<String, Object>> expectedResult2 = ImmutableList.<Map<String, Object>>of(
                ImmutableMap.<String, Object>of("address", "/2/multitoggle/2/15", "x", 0.1, "y", 0.2),
                ImmutableMap.<String, Object>of("address", "/2/multitoggle/4/10", "x", 0.3, "y", 0.6));
        assertEquals(expectedResult2, context.renderNode(oscReceiveNode2));
        assertEquals(expectedResult2, context.renderNode(oscReceiveNode2.withInputValue("args", "x ,y")));
        assertEquals(expectedResult2, context.renderNode(oscReceiveNode2.withInputValue("args", "x,  y")));
    }
View Full Code Here

    private final NodeLibrary testLibrary = NodeLibrary.create("test", Node.ROOT, functions);
    private final NodeContext context = new NodeContext(testLibrary);

    @Test
    public void testAdd() {
        Node addNode = Node.ROOT
                .withName("add")
                .withOutputType("int")
                .withFunction("clojure-math/add");
        Iterable<?> results = context.renderNode(addNode);
        assertResultsEqual(results, 0L);
View Full Code Here

        assertResultsEqual(results, 0L);
    }

    @Test
    public void testAddWithArguments() {
        Node addNode = Node.ROOT
                .withName("add")
                .withFunction("clojure-math/add")
                .withOutputType("int")
                .withInputAdded(Port.intPort("v1", 1))
                .withInputAdded(Port.intPort("v2", 2))
View Full Code Here

TOP

Related Classes of nodebox.node.Node

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.