Search in sources :

Example 1 with StretchToBoundaryLayouter

use of org.vcell.util.graphlayout.StretchToBoundaryLayouter in project vcell by virtualcell.

the class GraphLayoutManager method layoutContainedGraph.

public void layoutContainedGraph(Client client) {
    ContainedGraphLayouter layouter = null;
    String layoutName = client.getLayoutName();
    if (RandomLayouter.LAYOUT_NAME.equals(layoutName)) {
        layouter = new RandomLayouter();
    } else if (EdgeTugLayouter.LAYOUT_NAME.equals(layoutName)) {
        layouter = new EdgeTugLayouter();
    } else if (ShootAndCutLayouter.LAYOUT_NAME.equals(layoutName)) {
        layouter = new ShootAndCutLayouter();
    } else if (StretchToBoundaryLayouter.LAYOUT_NAME.equals(layoutName)) {
        layouter = new StretchToBoundaryLayouter();
    } else if (SimpleElipticalLayouter.LAYOUT_NAME.equals(layoutName)) {
        layouter = new SimpleElipticalLayouter();
    } else if (ShrinkCanvasLayouter.LAYOUT_NAME.equals(layoutName)) {
        layouter = new ShrinkCanvasLayouter();
    } else if (ExpandCanvasLayouter.LAYOUT_NAME.equals(layoutName)) {
        layouter = new ExpandCanvasLayouter();
    } else if (GenericLogicGraphLayouter.LAYOUT_NAME.equals(layoutName)) {
        layouter = new GenericLogicGraphLayouter();
    }
    if (layouter != null) {
        layouter.layout(client);
    }
}
Also used : ContainedGraphLayouter(org.vcell.util.graphlayout.ContainedGraphLayouter) RandomLayouter(org.vcell.util.graphlayout.RandomLayouter) ShrinkCanvasLayouter(org.vcell.util.graphlayout.ShrinkCanvasLayouter) GenericLogicGraphLayouter(org.vcell.util.graphlayout.GenericLogicGraphLayouter) ShootAndCutLayouter(org.vcell.util.graphlayout.energybased.ShootAndCutLayouter) SimpleElipticalLayouter(org.vcell.util.graphlayout.SimpleElipticalLayouter) EdgeTugLayouter(org.vcell.util.graphlayout.EdgeTugLayouter) StretchToBoundaryLayouter(org.vcell.util.graphlayout.StretchToBoundaryLayouter) ExpandCanvasLayouter(org.vcell.util.graphlayout.ExpandCanvasLayouter)

Example 2 with StretchToBoundaryLayouter

use of org.vcell.util.graphlayout.StretchToBoundaryLayouter in project vcell by virtualcell.

the class GraphLayoutManager method layoutRPI.

public void layoutRPI(Client client) throws Exception {
    Blackboard bb = new Blackboard();
    HashMap<String, Shape> nodeShapeMap = new HashMap<String, Shape>();
    for (Shape shape : client.getGraphModel().getShapes()) {
        Node newNode = null;
        if (ShapeUtil.isMovable(shape)) {
            newNode = bb.addNode(shape.getLabel());
        }
        // initialize node location to current absolute position
        if (newNode != null) {
            newNode.XY(shape.getSpaceManager().getAbsLoc().x, shape.getSpaceManager().getAbsLoc().y);
            nodeShapeMap.put(newNode.label(), shape);
        }
    }
    for (Shape shape : client.getGraphModel().getShapes()) {
        if (shape instanceof EdgeShape) {
            EdgeShape edgeShape = (EdgeShape) shape;
            Shape startShape = edgeShape.getStartShape();
            Shape endShape = edgeShape.getEndShape();
            if (edgeShape.isDirectedForward()) {
                bb.addEdge(startShape.getLabel(), endShape.getLabel());
            } else {
                bb.addEdge(endShape.getLabel(), startShape.getLabel());
            }
        }
    }
    bb.setArea(0, 0, client.getWidth(), client.getHeight());
    bb.globals.D(20);
    bb.addEmbedder(GraphLayoutManager.OldLayouts.ANNEALER, new Annealer(bb));
    bb.addEmbedder(GraphLayoutManager.OldLayouts.CIRCULARIZER, new Circularizer(bb));
    bb.addEmbedder(GraphLayoutManager.OldLayouts.CYCLEIZER, new Cycleizer(bb));
    bb.addEmbedder(GraphLayoutManager.OldLayouts.FORCEDIRECT, new ForceDirect(bb));
    bb.addEmbedder(GraphLayoutManager.OldLayouts.LEVELLER, new Leveller(bb));
    bb.addEmbedder(GraphLayoutManager.OldLayouts.RANDOMIZER, new Randomizer(bb));
    bb.addEmbedder(GraphLayoutManager.OldLayouts.RELAXER, new Relaxer(bb));
    bb.addEmbedder(GraphLayoutManager.OldLayouts.STABILIZER, new Stabilizer(bb));
    bb.setEmbedding(client.getLayoutName());
    @SuppressWarnings("unchecked") List<Node> nodeList = bb.nodes();
    bb.PreprocessNodes();
    Embedder embedder = bb.embedder();
    embedder.Init();
    for (int i = 0; i < 1000; i++) {
        embedder.Embed();
    }
    bb.removeDummies();
    @SuppressWarnings("unchecked") List<Node> nodesRaw = bb.nodes();
    nodeList = nodesRaw;
    for (int i = 0; i < nodeList.size(); i++) {
        Node node = nodeList.get(i);
        Shape shape = nodeShapeMap.get(node.label());
        if (shape != null) {
            shape.setAbsPos((int) node.x(), (int) node.y());
        }
    }
    new StretchToBoundaryLayouter().layout(client);
}
Also used : Randomizer(edu.rpi.graphdrawing.Randomizer) Circularizer(edu.rpi.graphdrawing.Circularizer) HashMap(java.util.HashMap) Relaxer(edu.rpi.graphdrawing.Relaxer) Node(edu.rpi.graphdrawing.Node) Cycleizer(edu.rpi.graphdrawing.Cycleizer) Embedder(edu.rpi.graphdrawing.Embedder) Stabilizer(edu.rpi.graphdrawing.Stabilizer) Annealer(edu.rpi.graphdrawing.Annealer) Leveller(edu.rpi.graphdrawing.Leveller) StretchToBoundaryLayouter(org.vcell.util.graphlayout.StretchToBoundaryLayouter) ForceDirect(edu.rpi.graphdrawing.ForceDirect) Blackboard(edu.rpi.graphdrawing.Blackboard)

Aggregations

StretchToBoundaryLayouter (org.vcell.util.graphlayout.StretchToBoundaryLayouter)2 Annealer (edu.rpi.graphdrawing.Annealer)1 Blackboard (edu.rpi.graphdrawing.Blackboard)1 Circularizer (edu.rpi.graphdrawing.Circularizer)1 Cycleizer (edu.rpi.graphdrawing.Cycleizer)1 Embedder (edu.rpi.graphdrawing.Embedder)1 ForceDirect (edu.rpi.graphdrawing.ForceDirect)1 Leveller (edu.rpi.graphdrawing.Leveller)1 Node (edu.rpi.graphdrawing.Node)1 Randomizer (edu.rpi.graphdrawing.Randomizer)1 Relaxer (edu.rpi.graphdrawing.Relaxer)1 Stabilizer (edu.rpi.graphdrawing.Stabilizer)1 HashMap (java.util.HashMap)1 ContainedGraphLayouter (org.vcell.util.graphlayout.ContainedGraphLayouter)1 EdgeTugLayouter (org.vcell.util.graphlayout.EdgeTugLayouter)1 ExpandCanvasLayouter (org.vcell.util.graphlayout.ExpandCanvasLayouter)1 GenericLogicGraphLayouter (org.vcell.util.graphlayout.GenericLogicGraphLayouter)1 RandomLayouter (org.vcell.util.graphlayout.RandomLayouter)1 ShrinkCanvasLayouter (org.vcell.util.graphlayout.ShrinkCanvasLayouter)1 SimpleElipticalLayouter (org.vcell.util.graphlayout.SimpleElipticalLayouter)1