I'm using the JGraphX library and am trying to perform an automatic layout using the mxFastOrganicLayout:
import javax.swing.JFrame;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
public class FastOrganic extends JFrame {
public static void main(String[] args) {
mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try {
Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80,
30);
Object v2 = graph.insertVertex(parent, null, "World!", 240, 150,
80, 30);
graph.insertEdge(parent, null, "Edge", v1, v2);
} finally {
graph.getModel().endUpdate();
}
mxGraphComponent graphComponent = new mxGraphComponent(graph);
FastOrganic frame = new FastOrganic();
frame.add(graphComponent);
frame.pack();
frame.setVisible(true);
}
}
I want to find out how to apply a fast organic layout, the documentation defines it as mxFastOrganicLayout
. The problem is that I cannot turn it into a component like this :
mxGraphComponent graphComponent = new mxGraphComponent(graph);
as mxGraphComponent
does not take mxFastOrganicLayout
as a constructor, but mxFastOrganicLayout
takes mxGraph
, which seems to be the right step? I would be grateful for any help, regards.