use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class TextDynColor method main.
public static void main(String[] args) {
System.setProperty("org.graphstream.ui", "org.graphstream.ui.javafx.util.Display");
MultiGraph g = new MultiGraph("foo");
g.setAttribute("ui.stylesheet", "node { fill-mode: dyn-plain; stroke-mode: plain; stroke-width: 1px; } edge { fill-mode: dyn-plain; }");
g.addNode("A");
g.addNode("B");
g.addNode("C");
g.addEdge("AB", "A", "B");
g.addEdge("BC", "B", "C");
g.addEdge("CA", "C", "A");
g.display();
g.getNode("A").setAttribute("ui.color", Color.RED);
g.getNode("B").setAttribute("ui.color", Color.GREEN);
g.getNode("C").setAttribute("ui.color", Color.BLUE);
g.getEdge("AB").setAttribute("ui.color", Color.YELLOW);
g.getEdge("BC").setAttribute("ui.color", Color.MAGENTA);
g.getEdge("CA").setAttribute("ui.color", Color.CYAN);
}
use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class DemoAllInFx method start.
@Override
public void start(Stage primaryStage) throws Exception {
Graph graph = new MultiGraph("mg");
FxViewer viewer = new FxViewer(graph, FxViewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
graph.addNode("A");
graph.addNode("B");
graph.addNode("C");
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");
graph.setAttribute("ui.antialias");
graph.setAttribute("ui.quality");
graph.setAttribute("ui.stylesheet", styleSheet);
graph.getNode("A").setAttribute("xyz", -1, 0, 0);
graph.getNode("B").setAttribute("xyz", 1, 0, 0);
graph.getNode("C").setAttribute("xyz", 0, 1, 0);
// On ins�re la vue principale du viewer dans la JFrame.
FxViewPanel v = (FxViewPanel) viewer.addDefaultView(false);
Scene scene = new Scene(v, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class BTest method run.
public void run() {
try {
MultiGraph graph = new MultiGraph("TestSize");
Viewer 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 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");
Edge AB = graph.addEdge("AB", "A", "B", true);
Edge BC = graph.addEdge("BC", "B", "C", true);
Edge CD = graph.addEdge("CD", "C", "D", true);
Edge DA = graph.addEdge("DA", "D", "A", true);
Edge BB = graph.addEdge("BB", "B", "B", true);
Edge DE = graph.addEdge("DE", "D", "E", true);
Edge DF = graph.addEdge("DF", "D", "F", true);
Edge CF = graph.addEdge("CF", "C", "F", true);
A.setAttribute("xyz", new double[] { 0, 1, 0 });
B.setAttribute("xyz", new double[] { 1, 0.8, 0 });
C.setAttribute("xyz", new double[] { 0.8, 0, 0 });
D.setAttribute("xyz", new double[] { 0, 0, 0 });
E.setAttribute("xyz", new double[] { 0.5, 0.5, 0 });
F.setAttribute("xyz", new double[] { 0.5, 0.25, 0 });
A.setAttribute("label", "A");
B.setAttribute("label", "Long label ...");
C.setAttribute("label", "C");
D.setAttribute("label", "A long label ...");
E.setAttribute("label", "Another very long label");
F.setAttribute("label", "F");
double size = 20f;
double sizeInc = 1f;
while (loop) {
pipeIn.pump();
sleep(40);
A.setAttribute("ui.size", size);
size += sizeInc;
if (size > 50) {
sizeInc = -1f;
size = 50f;
} else if (size < 20) {
sizeInc = 1f;
size = 20f;
}
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("bye bye");
System.exit(0);
}
use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class DemoTwoGraphsInOneViewerFx method start.
@Override
public void start(Stage primaryStage) throws Exception {
Graph graph1 = new MultiGraph("g1");
Graph graph2 = new MultiGraph("g2");
FxViewer viewer1 = new FxViewer(new ThreadProxyPipe(graph1));
FxViewer viewer2 = new FxViewer(new ThreadProxyPipe(graph2));
graph1.setAttribute("ui.stylesheet", styleSheet1);
graph2.setAttribute("ui.stylesheet", styleSheet2);
// View view1 =
FxViewPanel view1 = (FxViewPanel) viewer1.addDefaultView(true);
FxViewPanel view2 = (FxViewPanel) viewer2.addDefaultView(true);
viewer1.enableAutoLayout();
viewer2.enableAutoLayout();
// view1.setBackLayerRenderer(view2);
FileSourceDGS dgs = new FileSourceDGS();
dgs.addSink(graph1);
try {
dgs.begin(getClass().getResourceAsStream(GRAPH));
for (int i = 0; i < 100 && dgs.nextEvents(); i++) ;
dgs.end();
} catch (IOException e1) {
e1.printStackTrace();
System.exit(1);
}
dgs.removeSink(graph1);
dgs.addSink(graph2);
try {
dgs.begin(getClass().getResourceAsStream(GRAPH));
for (int i = 0; i < 100 && dgs.nextEvents(); i++) ;
dgs.end();
} catch (IOException e1) {
e1.printStackTrace();
System.exit(1);
}
dgs.removeSink(graph2);
primaryStage.setScene(new Scene(view1));
primaryStage.show();
Stage secondStage = new Stage();
secondStage.setScene(new Scene(view2));
secondStage.show();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
System.exit(0);
}
});
secondStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
System.exit(0);
}
});
}
use of org.graphstream.graph.implementations.MultiGraph in project gs-ui-javafx by graphstream.
the class DemoViewerFxEdgeSelection method main.
public static void main(String[] args) {
System.setProperty("org.graphstream.ui", "org.graphstream.ui.javafx.util.Display");
Graph graph = new MultiGraph("main graph");
viewPanel = (FxViewPanel) graph.display(true).getDefaultView();
FxViewer view = (FxViewer) viewPanel.getViewer();
view.getDefaultView().setMouseManager(new FxMouseManager(EnumSet.of(InteractiveElement.EDGE, InteractiveElement.NODE, InteractiveElement.SPRITE)));
ViewerPipe pipe = view.newViewerPipe();
// graph.setAttribute( "ui.quality" );
graph.setAttribute("ui.antialias");
pipe.addViewerListener(new DemoViewerFxEdgeSelection());
for (String nodeId : new String[] { "A", "B", "C" }) {
Node node = graph.addNode(nodeId);
node.setAttribute("ui.label", nodeId);
}
graph.addEdge("AB", "A", "B", true);
graph.addEdge("BC", "B", "C", true);
graph.addEdge("CA", "C", "A", true);
graph.setAttribute("ui.stylesheet", styleSheet);
float color = 0;
float dir = 0.01f;
while (loop) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
pipe.pump();
color += dir;
if (color > 1) {
color = 1;
dir = -dir;
} else if (color < 0) {
color = 0;
dir = -dir;
}
showSelection(graph);
}
}
Aggregations