nidi3 / graphviz-java

Use graphviz with pure java
Apache License 2.0
937 stars 107 forks source link

Question: Possibility to visualize the graph directly with java? With tooltips? #191

Open reuschling opened 3 years ago

reuschling commented 3 years ago

The documentation shows how to create (.png)files of the final graph - is there also the possibility to show the graph directly with Java (Swing/AWT)? Of course I can show the png, but I make excessive use of tooltips inside my dot files - it would be great If they will appear!

nidi3 commented 3 years ago

You can do Graphviz.fromGraph(g).render(Format.PNG).toImage(); to get a BufferedImage directly. Tooltips are not supported, what exactly would you expect? (Which DOT attribute should result in what thing in the output?)

reuschling commented 3 years ago

I use the dot tooltip attribute:

digraph{
    A[tooltip="Tooltip for node A"]
    B[tooltip="Tooltip for node B"]
    A->B
}

See the rendered graph with tooltip at http://magjac.com/graphviz-visual-editor

nidi3 commented 3 years ago

I see, and you would expect a (J)Panel or similar with the graph and tooltips

reuschling commented 3 years ago

Yes, exactly :) I make graph traversal recommendations on top of rdf graphs and visualize the results (i.e. the result explanations) in a generic way as dot representations. There exists so much metadata on a node or an edge that the graph is not readable anymore if I show all this information as labels. Thus, I use the tooltips to show the metadata on demand on top of nicely rendered graphs. Currently I give the dot representation as file and someone can look at it on its own, e.g. with magjac.com/graphviz-visual-editor. But it would be much nicer if I could just show the graph directly inside my application.