Package diva.graph.layout

Examples of diva.graph.layout.LayoutTarget


            final GraphController gc = gp.getGraphController();
            final GraphPane pane = gp;
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    // Layout is a bit stupid
                    LayoutTarget target = new BasicLayoutTarget(gc);
                    LevelLayout staticLayout = new LevelLayout(target);
                    staticLayout.setOrientation(LevelLayout.HORIZONTAL);
                    staticLayout.layout(layoutGraph.getRoot());
                    pane.repaint();
                }
View Full Code Here


    /** Layout the graph view.
     */
    public void layoutGraph() {
        GraphController controller = _getGraphController();
        AbstractBasicGraphModel model = _getGraphModel();
        LayoutTarget target = new PtolemyLayoutTarget(controller);
        PtolemyLayout layout = new PtolemyLayout(target);
        layout.setOrientation(LevelLayout.HORIZONTAL);
        layout.setRandomizedPlacement(false);

        // Before doing the layout, need to take a copy of all the current
View Full Code Here

        /** Copy the given graph and make the nodes/edges in the copied
         *  graph point to the nodes/edges in the original.
         */
        protected Object copyComposite(Object origComposite) {
            LayoutTarget target = getLayoutTarget();
            GraphModel model = target.getGraphModel();
            diva.graph.basic.BasicGraphModel local = getLocalGraphModel();
            Object copyComposite = local.createComposite(null);
            HashMap map = new HashMap();

            // Copy all the nodes for the graph.
            for (Iterator i = model.nodes(origComposite); i.hasNext();) {
                Object origNode = i.next();

                if (target.isNodeVisible(origNode)) {
                    Rectangle2D r = target.getBounds(origNode);
                    LevelInfo inf = new LevelInfo();
                    inf.origNode = origNode;
                    inf.x = r.getX();
                    inf.y = r.getY();
                    inf.width = r.getWidth();
                    inf.height = r.getHeight();

                    Object copyNode = local.createNode(inf);
                    local.addNode(this, copyNode, copyComposite);
                    map.put(origNode, copyNode);
                }
            }

            // Add all the edges.
            Iterator i = GraphUtilities.partiallyContainedEdges(origComposite,
                    model);

            while (i.hasNext()) {
                Object origEdge = i.next();
                Object origTail = model.getTail(origEdge);
                Object origHead = model.getHead(origEdge);

                if ((origHead != null) && (origTail != null)) {
                    Figure tailFigure = (Figure) target
                            .getVisualObject(origTail);
                    Figure headFigure = (Figure) target
                            .getVisualObject(origHead);

                    // Swap the head and the tail if it will improve the
                    // layout, since LevelLayout only uses directed edges.
                    if (tailFigure instanceof Terminal) {
View Full Code Here

            final GraphController gc = gp.getGraphController();
            final GraphPane pane = gp;
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    // Layout is a bit stupid
                    LayoutTarget target = new BasicLayoutTarget(gc);
                    LevelLayout staticLayout = new LevelLayout(target);
                    staticLayout.setOrientation(LevelLayout.HORIZONTAL);
                    staticLayout.layout(layoutGraph.getRoot());
                    pane.repaint();
                }
View Full Code Here

TOP

Related Classes of diva.graph.layout.LayoutTarget

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.