How can I display a graph generated by a graphics thread inside a JavaFX GUI component?

I am trying to display a Graph generated using a GraphStream in a GUI that is generated using JavaFX. That's what I have far

Graph graphInit = new Graph(); //class that handles graph population
SingleGraph graph = new SingleGraph("Graph"); //GraphStream Class
SwingNode graphViewer = new SwingNode(); //JavaFX Component to display Swing elements
graph = graphInit.genGraph(graph);
Viewer viewer = new Viewer(graph,    Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
View view = viewer.addDefaultView(false);   // false indicates "no JFrame".
graphViewer.setContent((JComponent) view);
graphHook.getChildren().add(graphViewer);

      

GraphViewer is a SwingNode component.

I think GraphStream doesn't support JavaFX yet, but I'm not sure. Also, I found gs-fx which I don't know how to use.

Any help would be greatly appreciated. If there is some other library like GraphStream to generate the graph and display it in the GUI, that will work too.

+3


source to share





All Articles