New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple labels on node #124
Comments
I also have a strong interest to display text in multiple rows. In my case the second row shall display an additional description, with a smaller character set. If this could be implemented, this would be really great and would improve the layout significantly. |
Actually this is possible, I did this with a additional Sprite on the Node. Add a sprite to the node: |
Hello everybody. Is there any new solution to this problem? I'm trying to display a control flow graph like IDA, the disassembler, and i need to print many lines inside a node, making it as big as the text. The code is:
A way to do this without sprites would be great. Thanks the css is:
|
If you really want to do that without sprite (which is still a good option), you can still calculate yourself the optimal size of your nodes, and change the css property of these nodes. Here a simple example based on your sample with graphstream 2 : public void run( String[] args ) throws InterruptedException {
graph = new MultiGraph( "g1" );
graph.addNode("A");
graph.addNode("B");
graph.addNode("C");
graph.addEdge("AB","A","B");
graph.addEdge("AC","A","C");
graph.addEdge("BC","B","C");
graph.getNode("B").setAttribute("ui.label", "B");
graph.getNode("C").setAttribute("ui.label", "C");
Node current = graph.getNode("A");
String label = "This is a test";
current.setAttribute("ui.label", label);
current.setAttribute("ui.class", "basicBlock");
graph.setAttribute( "ui.default.title", "Layout Test Fx" );
graph.setAttribute( "ui.stylesheet", styleSheet );
graph.display();
for (int i = 0 ; i < 8 ; i++) {
label += "\nThis is a test";
current.setAttribute("ui.label", label);
int size = lineToLength((String)current.getAttribute("ui.label"), "\n") ;
if (size != 0) {
String sizeCss = "size: 90px, "+size+"px;";
current.setAttribute("ui.style", sizeCss);
}
Thread.sleep(1000);
}
}
public static int lineToLength(String str, String target) {
int nbLine = ((str.length() - str.replace(target, "").length()) / target.length())+1;
return 10+(nbLine*11);
}
private String styleSheet ="node {"
+ "shape: box;"
+ "stroke-mode: plain;"
+ "stroke-color: #000000;"
+ "fill-color: green;"
+ "text-alignment: above;"
+ "padding: 0, -10px;"
+ "size: 20px, 20px;"
+ "}"; |
We would like to visualize a node with text:
Label 1
Label 2
To me it seems to be a very simple feature, but GraphStream currently does not support this.
As a work around the usage of images is suggested, which requires the need of generating images storing them on a disk somewhere, then let GraphStream access these images by means of a file url. This introduces a lot of disk access and the need to execute maintenance on those images on disk, they can stay there forever but are only accessed when actually visualized. This makes it impossible to use temporary files. All in all very cumbersome :-(.
Is it too much to ask, for support of multiple labels on a node? In other words is it an easy thing for the development team to implement, but failed to get enough priority to do so yet?
The text was updated successfully, but these errors were encountered: