graphstream / gs-ui-swing

GraphStream Swing user interface
http://graphstream-project.org/
Other
25 stars 12 forks source link

Fill Nodes with images #13

Closed Julian-Z98 closed 3 years ago

Julian-Z98 commented 3 years ago

I would like to use GraphStream to display a tree where the nodes are images. None of the commands I found in the tutorials work for me. Colouring the nodes with the same commands is no problem. The Url works without any problems in another context. Unfortunately, I don't see the error even after trying around for a while.

Graph graph = new SingleGraph("Tutorial 1");
Node tmpNode = graph.addNode("A" );
graph.addNode("B" );
graph.addNode("C" );
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");
System.setProperty("org.graphstream.ui", "swing");

tmpNode.addAttribute("ui.style", "fill-color: rgb(0,100,255);"); //works fine
graph.addAttribute("ui.stylesheet", "node { fill-color: rgb(0,100,255); }"); //works fine

tmpNode.addAttribute("ui.style", "fill-image: url('D:/Studium/Scaffold/scaffoldTest/scaffoldTestOutput/Test11/Tree/TreeTest0Level0.png');"); //does not work
graph.addAttribute("ui.stylesheet", "node { fill-mode: image-scaled; fill-image: url('D:/Studium/Scaffold/scaffoldTest/scaffoldTestOutput/Test11/Tree/TreeTest0Level0.png'); }"); //does not work

graph.display();

Greetings Julian

pigne commented 3 years ago

Could you try with a propper url (with schema) :url('file:///D:/Studium/Scaffold/s[...].png'

Julian-Z98 commented 3 years ago

Thanks for the quick answer. Unfortunately it does not work with this addition either.

tmpNode.addAttribute("ui.style", "fill-image: url('file:///D:/Studium/Scaffold/scaffoldTest/scaffoldTestOutput/Test11/Tree/TreeTest0Level0.png');"); //does not work
graph.addAttribute("ui.stylesheet", "node { fill-mode: image-scaled; fill-image: url('file:///D:/Studium/Scaffold/scaffoldTest/scaffoldTestOutput/Test11/Tree/TreeTest0Level0.png'); }"); //does not work
Julian-Z98 commented 3 years ago

I just tried it again with version 2.0 and setAttribute instead of addAttribute. Now it works with the new Url. Thanks a lot for the help.