Package diva.graph.basic

Examples of diva.graph.basic.BasicGraphModel


    /**
     * Construct a new levelizing layout with a vertical orientation.
     */
    public LevelLayout(LayoutTarget target) {
        super(target);
        _local = new BasicGraphModel();
    }
View Full Code Here


        });
    }

    public SimpleTutorial(AppContext context) {
        JGraph jg = new JGraph(new GraphPane(new BasicGraphController(),
                new BasicGraphModel()));
        context.getContentPane().add("Center", jg);
    }
View Full Code Here

            }
        });
    }

    public EditorTutorial(AppContext context) {
        _model = new BasicGraphModel();

        GraphPane pane = new GraphPane(new BasicGraphController(), _model);
        _editor = new JGraph(pane);
        context.getContentPane().add("Center", _editor);
        _target = new BasicLayoutTarget(_editor.getGraphPane()
View Full Code Here

    public static class BasicGraphModelFactory implements GraphFactory {
        /** Create a BasicGraphModel.
         *  @return a BasicGraphModel.
         */
        public BasicGraphModel createGraph() {
            return new BasicGraphModel();
        }
View Full Code Here

        //
        //        A
        //       / \
        //      B   C
        //
        BasicGraphModel model = new BasicGraphModel();
        CompositeNode root = (CompositeNode) model.getRoot();
        Node a = model.createNode("a");
        Node b = model.createNode("b");
        Node c = model.createNode("c");
        model.addNode(this, a, root);
        model.addNode(this, b, root);
        model.addNode(this, c, root);

        Edge x = model.createEdge("x");
        Edge y = model.createEdge("y");
        model.connectEdge(this, x, a, b);
        model.connectEdge(this, y, a, c);

        // Display the model in three
        // different panes, using three
        // different techniques.
        try {
View Full Code Here

        //
        //        A
        //       / \
        //      B   C
        //
        BasicGraphModel model = new BasicGraphModel();
        Node a = model.createNode("a");
        Node b = model.createNode("b");
        CompositeNode c = model.createComposite("c");
        CompositeNode c2 = model.createComposite("c2");
        Node d = model.createNode("d");
        Node d2 = model.createNode("d2");
        model.addNode(this, a, model.getRoot());
        model.addNode(this, c, model.getRoot());
        model.addNode(this, b, model.getRoot());
        model.addNode(this, c2, model.getRoot());
        model.addNode(this, d, c);
        model.addNode(this, d2, c);

        Edge e = model.createEdge("edge");
        model.connectEdge(this, e, a, b);
        e = model.createEdge("edge");
        model.connectEdge(this, e, a, d);
        e = model.createEdge("edge");
        model.connectEdge(this, e, d2, d);
        e = model.createEdge("edge");
        model.connectEdge(this, e, a, c);
        e = model.createEdge("edge");
        model.connectEdge(this, e, c2, c);

        try {
            layoutPostDisplay(model, context);
        } catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

        typedRenderer.addTypedRenderer(Integer.class, integerRenderer);
        typedRenderer.addTypedRenderer(ArrayList.class, setRenderer);
        typedRenderer.addTypedRenderer(String.class, stringRenderer);

        // Use the renderer in the JGraph
        GraphPane gp = new GraphPane(bgc, new BasicGraphModel());
        bgc.getNodeController().setNodeRenderer(typedRenderer); // <=== HERE!

        JGraph g = new JGraph(gp);

        // Display it all
View Full Code Here

    /**
     * Construct an interesting graph model with nodes that
     * have user objects of type {String, Set, Integer}
     */
    public MutableGraphModel makeTypedModel() {
        BasicGraphModel model = new BasicGraphModel();
        ArrayList set0 = new ArrayList();
        Object o1 = Integer.valueOf(5);
        Object o2 = Integer.valueOf(6);
        Object o3 = Integer.valueOf(10);
        Object o4 = "foo";
        Object o5 = "bar";
        set0.add(o1);
        set0.add(o2);
        set0.add(o3);
        set0.add(o4);
        set0.add(o5);

        Graph root = (Graph) model.getRoot();
        Node s0 = model.createNode(set0);
        Node n1 = model.createNode(o1);
        Node n2 = model.createNode(o2);
        Node n3 = model.createNode(o3);
        Node n4 = model.createNode(o4);
        Node n5 = model.createNode(o5);
        model.addNode(this, s0, root);
        model.addNode(this, n1, root);
        model.addNode(this, n2, root);
        model.addNode(this, n3, root);
        model.addNode(this, n4, root);
        model.addNode(this, n5, root);

        Edge e1 = model.createEdge("e1");
        Edge e2 = model.createEdge("e2");
        Edge e3 = model.createEdge("e3");
        Edge e4 = model.createEdge("e4");
        Edge e5 = model.createEdge("e5");
        model.connectEdge(this, e1, s0, n1);
        model.connectEdge(this, e2, s0, n2);
        model.connectEdge(this, e3, s0, n3);
        model.connectEdge(this, e4, s0, n4);
        model.connectEdge(this, e5, s0, n5);

        // another cluster
        ArrayList set1 = new ArrayList();
        Object o11 = Integer.valueOf(15);
        Object o12 = Integer.valueOf(15);
        Node s1 = model.createNode(set1);
        Node n11 = model.createNode(o11);
        Node n12 = model.createNode(o12);
        model.addNode(this, s1, root);
        model.addNode(this, n11, root);
        model.addNode(this, n12, root);

        Edge e6 = model.createEdge("e6");
        Edge e7 = model.createEdge("e7");
        model.connectEdge(this, e6, s1, n11);
        model.connectEdge(this, e7, s1, n12);

        // an empty cluster
        ArrayList set2 = new ArrayList();
        Node s2 = model.createNode(set2);
        model.addNode(this, s2, root);

        return model;
    }
View Full Code Here

    /** Construct the graph representing the topology.
     *  This is sort of bogus because it's totally hard-wired,
     *  but it will do for now...
     */
    protected MutableGraphModel _constructDivaGraph() {
        BasicGraphModel model = new BasicGraphModel();
        Object root = model.getRoot();

        // Objects, with user object set to the actor
        Object n1 = model.createNode(_clock);

        Object n2 = model.createNode(_join1);
        Object n3 = model.createNode(_fork1);
        Object n4 = model.createNode(_fBack1);
        Object n5 = model.createNode(_rcvr1);

        Object n6 = model.createNode(_join2);
        Object n7 = model.createNode(_fork2);
        Object n8 = model.createNode(_fBack2);
        Object n9 = model.createNode(_rcvr2);

        model.addNode(this, n1, root);
        model.addNode(this, n2, root);
        model.addNode(this, n3, root);
        model.addNode(this, n4, root);
        model.addNode(this, n5, root);
        model.addNode(this, n6, root);
        model.addNode(this, n7, root);
        model.addNode(this, n8, root);
        model.addNode(this, n9, root);

        _nodeMap.put(_clock, n1);

        _nodeMap.put(_join1, n2);
        _nodeMap.put(_fork1, n3);
        _nodeMap.put(_fBack1, n4);
        _nodeMap.put(_rcvr1, n5);

        _nodeMap.put(_join2, n6);
        _nodeMap.put(_fork2, n7);
        _nodeMap.put(_fBack2, n8);
        _nodeMap.put(_rcvr2, n9);

        // Edges
        Object e;

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n1);
        model.setEdgeHead(this, e, n2);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n2);
        model.setEdgeHead(this, e, n3);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n4);
        model.setEdgeHead(this, e, n2);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n3);
        model.setEdgeHead(this, e, n4);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n3);
        model.setEdgeHead(this, e, n5);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n1);
        model.setEdgeHead(this, e, n6);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n7);
        model.setEdgeHead(this, e, n8);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n6);
        model.setEdgeHead(this, e, n7);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n7);
        model.setEdgeHead(this, e, n9);

        e = model.createEdge(null);
        model.setEdgeTail(this, e, n8);
        model.setEdgeHead(this, e, n6);

        return model;
    }
View Full Code Here

    /** Construct the graph representing the topology.
     *  This is sort of bogus because it's totally hard-wired,
     *  but it will do for now...
     */
    private BasicGraphModel _constructGraph() {
        BasicGraphModel model = new BasicGraphModel();
        Object root = model.getRoot();

        // Nodes, with user object set to the actor
        Object n1 = model.createNode(_contentionActor);
        Object n2 = model.createNode(_alarmActor);
        Object n3 = model.createNode(_memoryActor);
        Object n4 = model.createNode(_processActor1);
        Object n5 = model.createNode(_processActor2);
        Object n6 = model.createNode(_processActor3);

        model.addNode(this, n1, root);
        model.addNode(this, n2, root);
        model.addNode(this, n3, root);
        model.addNode(this, n4, root);
        model.addNode(this, n5, root);
        model.addNode(this, n6, root);

        _nodeMap.put(_contentionActor, n1);
        _nodeMap.put(_alarmActor, n2);
        _nodeMap.put(_memoryActor, n3);
        _nodeMap.put(_processActor1, n4);
        _nodeMap.put(_processActor2, n5);
        _nodeMap.put(_processActor3, n6);

        // Edges
        Object e;

        e = model.createEdge(null);
        model.setEdgeHead(this, e, n1);
        model.setEdgeTail(this, e, n2);

        e = model.createEdge(null);
        model.setEdgeHead(this, e, n1);
        model.setEdgeTail(this, e, n4);

        e = model.createEdge(null);
        model.setEdgeHead(this, e, n1);
        model.setEdgeTail(this, e, n5);

        e = model.createEdge(null);
        model.setEdgeHead(this, e, n1);
        model.setEdgeTail(this, e, n6);

        e = model.createEdge(null);
        model.setEdgeHead(this, e, n3);
        model.setEdgeTail(this, e, n4);

        e = model.createEdge(null);
        model.setEdgeHead(this, e, n3);
        model.setEdgeTail(this, e, n5);

        e = model.createEdge(null);
        model.setEdgeHead(this, e, n3);
        model.setEdgeTail(this, e, n6);

        return model;
    }
View Full Code Here

TOP

Related Classes of diva.graph.basic.BasicGraphModel

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.