Question

I'm using JUNG2 to draw some graphs.

This is the image I get: http://img841.imageshack.us/img841/205/graphvizkk3312164f020b4.png

I'd like to:

1) change the rendering order (labels should be the last objects to be drawn);

2) add a semi-transparent background to the labels.

3) change background color of the whole image.

Any idea on how to do this? The JUNG2 documentation is not very extensive on these issues.

Mulone

Was it helpful?

Solution

(1) To do this you'd have to hack the rendering code; I don't believe that we support this at the moment.

UPDATE: I took a closer look. Actually JUNG does support this without hacking the existing libraries; the easiest way is perhaps to subclass BasicRenderer and then override the render() method so that things happen in the order that you want. (I recommend that you render vertices after edges.) Once you do that, you create an instance of your custom Renderer, and call VisualizationViewer.setRenderer(customRenderer).

(2) The labels respect HTML code (i.e., surround your label with <html></html> and then put whatever tags you like in it).

(3) BasicVisualizationServer (and its subclasses, e.g. VisualizationViewer) inherit from JComponent, which defines setBackground(Color).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top