We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I am programming a network visualizing applet. I render each of the nodes of the network using a texture with glgraphics (following the swarming sprites example). I need, however to draw also the links between the nodes. How should I do this? When I use the standard line method link don't appear at the "right" coordinates. I am using processing 1.5.
Thanks for your help!
Answers
Well, i can draw a line using:
and then lines.render().
However, i have to render a graph, so not all vertices will be linked. Some may have several links. There will also be non-conected components, which means that i would have sets of isolated nodes. I cant figure out how i should build my model in this case.I guess it doesn't make any sense to have a model with only one line... or does it?
I tried with an array of models (one for each link) but fps go very low.
what do you have in your
model = new GLModel(this, numPoints, GLModel.POINT_SPRITES, GLModel.DYNAMIC);
line?
i think you need LINES rather than POINT_SPRITES. and this will then take pairs of coords and draw a line between each pair (allowing for gaps). if it's LINE (or maybe LINE_STRIP, i can't remember) then it'll draw from one coord to the next, one continuous line.
I have lines, like this:
So, 1. How should I allow the gaps? 2. A continous line sounds problematic, since I need to draw a graph, which is a complex set of nodes and vertices. What is the best solution?
can't really tell based on the 4 lines of your code we can see...
it will draw separate lines if you use LINES. your array will have to hold pairs of coordinates, start and end for each line.
oh, i have an example. it's a STATIC example but hopefully it'll help:
Thank you very much koogs. I had assumed that lines were connected one after another (is this the case with LINE_STRIP?) so I was a bit puzzled when it came to drawing a graph. I followed your suggestion and used LINE, which worked perfectly. I have an arraylist of links and an arraylist of people (i'm drawing a social graph). The links hold the indices of the people they have to link to.
...
Here is the link class
Now the question is: lets say i want to filter some links, using some kind of criteria. For example, only draw link between a male node and a female node. I should therefore bypass the rendering of a line, or delete it. Is this possible?
i think you can draw subsets of the data. yes, according to the javadoc:
public void render(int first, int last)
but you'd need to call this for all the (groups of) links you want to draw. might be easier and faster to redo the lines array so it contains only the lines you want and then call render() with no arguments.