use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class AllFxTest method start.
public void start(Stage primaryStage) throws Exception {
MultiGraph g = new MultiGraph("mg");
FxViewer v = new FxViewer(g, FxViewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
g.setAttribute("ui.antialias");
g.setAttribute("ui.quality");
g.setAttribute("ui.stylesheet", styleSheet);
v.enableAutoLayout();
FxViewPanel panel = (FxViewPanel) v.addDefaultView(false, new FxGraphRenderer());
gen.addSink(g);
gen.begin();
for (int i = 0; i < 100; i++) gen.nextEvents();
gen.end();
gen.removeSink(g);
Scene scene = new Scene(panel, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class ATest method run.
public void run(String[] args) {
Graph graph = new MultiGraph("g1");
Viewer viewer = graph.display(true);
ViewerPipe pipeIn = viewer.newViewerPipe();
DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
pipeIn.addAttributeSink(graph);
pipeIn.addViewerListener(this);
pipeIn.pump();
graph.setAttribute("ui.default.title", "Layout Test Fx");
graph.setAttribute("ui.antialias");
graph.setAttribute("ui.stylesheet", styleSheet);
gen.addSink(graph);
gen.setDirectedEdges(true, true);
gen.begin();
int i = 0;
while (i < 100) {
gen.nextEvents();
i += 1;
}
gen.end();
graph.forEach(n -> n.setAttribute("ui.label", "truc"));
while (loop) {
pipeIn.pump();
sleep(10);
}
System.out.println("bye bye");
System.exit(0);
}
use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class TestFreePlane method run.
private void run(String[] args) {
MultiGraph graph = new MultiGraph("g1");
FxViewer viewer = new FxViewer(graph, FxViewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
ViewerPipe pipeIn = viewer.newViewerPipe();
FxDefaultView view = (FxDefaultView) viewer.addView("view1", new FxGraphRenderer());
DefaultApplication.init(view, graph);
new Thread(() -> Application.launch(DefaultApplication.class)).start();
pipeIn.addAttributeSink(graph);
pipeIn.addViewerListener(this);
pipeIn.pump();
graph.setAttribute("ui.stylesheet", styleSheet);
graph.setAttribute("ui.antialias");
graph.setAttribute("ui.quality");
Node root = graph.addNode("root");
Node A = graph.addNode("A");
Node B = graph.addNode("B");
Node C = graph.addNode("C");
Node D = graph.addNode("D");
Node E = graph.addNode("E");
Node F = graph.addNode("F");
Node G = graph.addNode("G");
Node H = graph.addNode("H");
graph.addEdge("rA", "root", "A");
graph.addEdge("rB", "root", "B");
graph.addEdge("rC", "root", "C");
graph.addEdge("rD", "root", "D");
graph.addEdge("rE", "root", "E");
graph.addEdge("AF", "A", "F");
graph.addEdge("CG", "C", "G");
graph.addEdge("DH", "D", "H");
root.setAttribute("xyz", new double[] { 0, 0, 0 });
A.setAttribute("xyz", new double[] { 1, 1, 0 });
B.setAttribute("xyz", new double[] { 1, 0, 0 });
C.setAttribute("xyz", new double[] { -1, 1, 0 });
D.setAttribute("xyz", new double[] { -1, 0, 0 });
E.setAttribute("xyz", new double[] { -1, -1, 0 });
F.setAttribute("xyz", new double[] { 2, 1.2, 0 });
G.setAttribute("xyz", new double[] { -2, 1.2, 0 });
H.setAttribute("xyz", new double[] { -2, -.5, 0 });
root.setAttribute("label", "Idea");
A.setAttribute("label", "Topic1");
B.setAttribute("label", "Topic2");
C.setAttribute("label", "Topic3");
D.setAttribute("label", "Topic4");
E.setAttribute("label", "Topic5");
F.setAttribute("label", "SubTopic1");
G.setAttribute("label", "SubTopic2");
H.setAttribute("label", "Very Long Sub Topic ...");
while (loop) {
pipeIn.pump();
sleep(10);
}
System.out.println("bye bye");
System.exit(0);
}
use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class TestTwoViewersInOneFrame method start.
public void start(Stage primaryStage) throws Exception {
MultiGraph graph1 = new MultiGraph("g1");
MultiGraph graph2 = new MultiGraph("g2");
ThreadProxyPipe pipe1 = new ThreadProxyPipe();
pipe1.init(graph1);
ThreadProxyPipe pipe2 = new ThreadProxyPipe();
pipe2.init(graph2);
Viewer viewer1 = new FxViewer(pipe1);
Viewer viewer2 = new FxViewer(pipe2);
graph1.setAttribute("ui.quality");
graph2.setAttribute("ui.quality");
graph1.setAttribute("ui.antialias");
graph2.setAttribute("ui.antialias");
graph1.setAttribute("ui.stylesheet", styleSheet1);
graph2.setAttribute("ui.stylesheet", styleSheet2);
FxDefaultView view1 = new FxDefaultView(viewer1, "view1", new FxGraphRenderer());
FxDefaultView view2 = new FxDefaultView(viewer2, "view2", new FxGraphRenderer());
viewer1.addView(view1);
viewer2.addView(view2);
viewer1.enableAutoLayout();
viewer2.enableAutoLayout();
DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
gen.addSink(graph1);
gen.addSink(graph2);
gen.begin();
for (int i = 0; i < 100; i++) gen.nextEvents();
gen.end();
gen.removeSink(graph1);
gen.removeSink(graph2);
StackPane paneView1 = new StackPane();
// prevent UI shift issues
paneView1.getChildren().addAll(view1);
StackPane paneView2 = new StackPane();
// prevent UI shift issues
paneView2.getChildren().addAll(view2);
GridPane gridpane = new GridPane();
gridpane.add(paneView1, 1, 0);
gridpane.add(paneView2, 2, 0);
Scene scene = new Scene(gridpane, 800, 600, true, SceneAntialiasing.BALANCED);
primaryStage.setScene(scene);
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
System.exit(0);
}
});
primaryStage.show();
}
use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class TutorialDiagrams method diagram1b.
public Scene diagram1b(String title, String styleSheet) {
MultiGraph graph = new MultiGraph(title);
Scene s = diagram(graph, styleSheet, title, 500, 370);
Node G = graph.addNode("Graph");
Node V = graph.addNode("Viewer");
Node B1 = graph.addNode("bidon1");
Node B2 = graph.addNode("bidon2");
graph.addEdge("G->bidon1", "Graph", "bidon1", true);
graph.addEdge("bidon1->V", "bidon1", "Viewer", true);
graph.addEdge("V->bidon2", "Viewer", "bidon2", true);
graph.addEdge("bidon2->G", "bidon2", "Graph", true);
G.setAttribute("xyz", new double[] { 0, 0, 0 });
B1.setAttribute("xyz", new double[] { 0, 0.5, 0 });
V.setAttribute("xyz", new double[] { 1, 0.5, 0 });
B2.setAttribute("xyz", new double[] { 1, 0, 0 });
G.setAttribute("ui.label", "Graph");
V.setAttribute("ui.label", "Viewer");
B1.setAttribute("ui.class", "invisible");
B2.setAttribute("ui.class", "invisible");
return s;
}
Aggregations