Auto-Layout and size?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Auto-Layout and size?

Sven Abels
Hi,

I would like to use JGraphT for a representation of our network and I would
like to visualize the graph. However: I don't know in advance the number of
vertex entries. Is it possible to use a "autosize" function to automatically
set the size and the possition of the nodes in the graph visualization?

Best greetings,

Sven



Reply | Threaded
Open this post in threaded view
|

Re: Auto-Layout and size?

John Sichi
Administrator
Yes, JGraph has these capabilities (in the addons package), so if you
use the JGraphModelAdapter to make JGraph and JGraphT work together, you
can auto-layout your visualization.  Here's some example code (assuming
you already have the model, view, and adapter tied together):

void layout(
     ListenableDirectedGraph graphModel,
     JGraphModelAdapter graphAdapter,
     JGraph graph)
{
     List roots = new ArrayList();
     Iterator vertexIter = graphModel.vertexSet().iterator();
     while (vertexIter.hasNext()) {
         Object vertex = vertexIter.next();
         if (graphModel.inDegreeOf(vertex) == 0) {
             roots.add(graphAdapter.getVertexCell(vertex));
         }
     }

     JGraphLayoutAlgorithm layout = new SugiyamaLayoutAlgorithm();
     layout.applyLayout(graph, layout, roots.toArray(), null);
}

JVS

Sven Abels wrote:

> Hi,
>
> I would like to use JGraphT for a representation of our network and I would
> like to visualize the graph. However: I don't know in advance the number of
> vertex entries. Is it possible to use a "autosize" function to automatically
> set the size and the possition of the nodes in the graph visualization?
>
> Best greetings,
>
> Sven
>
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> jgrapht-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jgrapht-users
>