Package diva.graph.basic

Examples of diva.graph.basic.BasicGraphController


            }
        });
    }

    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()
                .getGraphController());
        _layout = new LevelLayout(_target);
View Full Code Here

     * meaning that the nodes are layed out in a 0x0 frame,
     * and are all clustered in the upper-left corner.  This
     * is remedied in the other techniques given below.
     */
    public void bogusLayout(MutableGraphModel model, AppContext context) {
        BasicGraphController gc = new BasicGraphController();
        context.getContentPane().add(new JGraph(new GraphPane(gc, model)));

        RandomLayout random = new RandomLayout(new BasicLayoutTarget(gc));
        random.layout(model.getRoot());
    }
View Full Code Here

     * post display" version is preferable, but this might
     * be useful in some cases.
     */
    public void layoutPostDisplay(final MutableGraphModel model,
            AppContext context) {
        final BasicGraphController bgc = new BasicGraphController();
        context.getContentPane().add(new JGraph(new GraphPane(bgc, model)));
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                RandomLayout random = new RandomLayout(new BasicLayoutTarget(
                        bgc));
View Full Code Here

     * In this version you construct the graph widget with
     * the default constructor (giving it an empty graph),
     * and then set the model once the window is showing.
     */
    public void setModelPostDisplay(MutableGraphModel model, AppContext context) {
        BasicGraphController gc = new BasicGraphController();
        gc.addGraphViewListener(new IncrementalLayoutListener(
                new IncrLayoutAdapter(
                        new LevelLayout(new BasicLayoutTarget(gc))), null));
        context.getContentPane().add(new JGraph(new GraphPane(gc, model)));
    }
View Full Code Here

     * think the "set model post display" version is preferable, but
     * this might be useful in some cases.
     */
    public void layoutPostDisplay(final MutableGraphModel model,
            AppContext context) {
        final BasicGraphController bgc = new BasicGraphController();
        context.getContentPane().add(new JGraph(new GraphPane(bgc, model)));
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                RandomLayout random = new RandomLayout(new BasicLayoutTarget(
                        bgc));
View Full Code Here

            }
        });
    }

    private NodeRendererTutorial(AppContext context) {
        final BasicGraphController bgc = new BasicGraphController();

        // Build the renderers
        NodeRenderer defaultRenderer = new BasicNodeRenderer(bgc,
                new Ellipse2D.Double(0.0, 0.0, 40.0, 40.0),
                new Ellipse2D.Double(0.0, 0.0, 600.0, 600.0), Color.gray,
                Color.gray, .3);
        NodeRenderer stringRenderer = new BasicNodeRenderer(bgc,
                new Ellipse2D.Double(0.0, 0.0, 40.0, 40.0),
                new Ellipse2D.Double(0.0, 0.0, 600.0, 600.0), Color.blue,
                Color.blue, .3);
        NodeRenderer integerRenderer = new BasicNodeRenderer(bgc,
                new Rectangle2D.Double(0.0, 0.0, 40.0, 40.0),
                new Rectangle2D.Double(0.0, 0.0, 600.0, 600.0), Color.orange,
                Color.orange, .3);
        NodeRenderer setRenderer = new BasicNodeRenderer(bgc,
                new Ellipse2D.Double(0.0, 0.0, 40.0, 40.0),
                new Ellipse2D.Double(0.0, 0.0, 600.0, 600.0), Color.red,
                Color.red, .3);
        TypedNodeRenderer typedRenderer = new TypedNodeRenderer(bgc,
                defaultRenderer);
        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
        context.getContentPane().add("Center", g);

        // Build the model
        final MutableGraphModel model = makeTypedModel();
        bgc.setGraphModel(model);

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                LevelLayout random = new LevelLayout(new BasicLayoutTarget(bgc));
                random.layout(model.getRoot());
View Full Code Here

TOP

Related Classes of diva.graph.basic.BasicGraphController

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.