@SuppressWarnings("unchecked")
public JgraphTest()
{
super("Hello World!");
//create jgrapht graph and add some nodes
SimpleDirectedGraph g = new SimpleDirectedGraph(new TestEdgeFactory());
Node v1 = new Node("v1");
Node v2 = new Node("v2");
Node v3 = new Node("v3");
Node v4 = new Node("v4");
g.addVertex(v1);
g.addVertex(v2);
g.addVertex(v3);
g.addVertex(v4);
g.addEdge(v1, v2);
g.addEdge(v2, v3);
g.addEdge(v3, v4);
g.addEdge(v4, v3);
//graphx
final mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
HashMap<String, Object> jgraphVertices = new HashMap<String, Object>();
try
{
for(Object o : g.vertexSet())
{
Object o1 = graph.insertVertex(parent,((Node)o).m_name, ((Node)o).m_name, 20, 20, 80, 30);
jgraphVertices.put(((Node)o).m_name, o1);
}
for(Object o : g.edgeSet())
{
Node src = ((TEdge)o).m_src;
Node sink = ((TEdge)o).m_sink;
graph.insertEdge(parent, null, "edge", jgraphVertices.get(src.m_name), jgraphVertices.get(sink.m_name));
}