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);
}
}
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);
}
Aggregations