Search code examples
javagraphvizdotimage-graphviz

Graphviz (Java) label of rectangle-node writes over the ends of the node


My problem is that long node labels do reach on both sides over the end of the node

see here

This only occurs with node-shapes like rectangle, square, tab or similar but never with oval,circle or diamond. I am using the Java Graphviz-Engine (guru-nidi:graphviz-java:0.14.1) and my corresponding code (simplified) is the following:

String graphString =

digraph g { 
extralargesubject [shape=diamond]; 
extralargeobject [shape=rectangle] ; 
extralargesubject -> extralargeobject; 
}

and

import guru.nidi.graphviz.engine.Format;
import guru.nidi.graphviz.engine.Graphviz;
import guru.nidi.graphviz.model.MutableGraph;
import guru.nidi.graphviz.parse.Parser;

MutableGraph g = new Parser().read(graphString);
BufferedImage image = Graphviz.fromGraph(g).render(Format.SVG).toImage();

Maybe someone can help me with this problem?


Solution

  • Ok, I found the solution. I only worked with the .jar. But that's only the Engine. Of course I had to install Graphviz also on my machine. Now I did and everything works now fine!