GraphStream Users

Archives de la liste Aide

graphstream embedded in JavaFX

Chronologique Discussions 
  • From: <georgevio AT>
  • To: graphstream-users AT
  • Subject: graphstream embedded in JavaFX
  • Date: Thu, 19 Dec 2019 07:07:06 +0100 (CET)

I created a minimal JavaFX project with both empty Controller and fxml file.
The Application file is below. The first group of lines is a normal
graph which shows ok on a SEPARATE window. The next two groups are trying to
show it inside the javafx window.

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.ui.swingViewer.GraphRenderer;

public class Main extends Application {

public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));;

Graph graph = new SingleGraph("Graph");
graph.addNode("1"); graph.addNode("2"); graph.addNode("3");
graph.addEdge("1-->2","1","2", true);
graph.addEdge("1-->3","1","3", true);

/* These 3 lines show correctly a graph, ON A SEPARATE WINDOW */
Viewer viewer = new Viewer(graph,
viewer = graph.display(true);

// Those below both do not work. I tried many vestions of gs-ui-javafx
but ...

FxViewer fxviewer = new FxViewer(graph,
FxGraphRenderer renderer = new FxGraphRenderer();
FxDefaultView view = (FxDefaultView)
fxviewer.addView(FxViewer.DEFAULT_VIEW_ID, renderer);

FxViewer v = new FxViewer(graph,
FxViewPanel panel = (FxViewPanel)v.addDefaultView(false, new
Scene scene2 = new Scene(panel, 800, 600);

public static void main(String[] args) {

  • graphstream embedded in JavaFX, georgevio, 19/12/2019

Archives gérées par MHonArc 2.6.16.

Top of page