Hello.
I’m trying to use Force based layout to position some elements. I expected to get the image like this. Using this code http://ws.stfx.eu/LACEUL5X6K1S I got something different and I don’t know why. It looks like all elements attract instead of repel each other. Does somebody know why it is like that? Best regards, Natalia _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
2014-11-10 12:17 GMT+01:00 Natalia Tymchuk <[hidden email]>:
edge dirven layouts ignore the supplied edges, if the "userDefinedEdges" are set. (maybe it should use " self userDefinedEdges isEmptyNil " instead of " self userDefinedEdges isNil " ) you can force the layout to use your edges with: #useInLayout | builder | builder := RTGraphBuilder new. builder nodes shape: (RTEllipse new ). builder edges connectTo: [ :c | c subclasses ]; useInLayout; "<<-----" shape: (RTLine new color: Color gray). builder addAll: Boolean allSuperclasses, Boolean withAllSubclasses. builder layout force. builder build. builder view _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
In reply to this post by Natalia Tymchuk
As Nicolai said, you need to explicitly say that you want the edges to be considered in the layout using #useInLayout.
Additionally, you may want to play with the charge and length in the layout. Consider the following example: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= builder := RTGraphBuilder new. builder nodes shape: (RTEllipse new size: 20). builder edges connectTo: [ :c | c subclasses ]; useInLayout; shape: (RTLine new color: Color gray). builder layout force charge: -300; length: 20. builder addAll: Boolean allSuperclasses, Boolean withAllSubclasses. builder build. builder view -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= We give a repulsion of -300 to each node (which is what you want since nodes have to repulse each other), and you give a length of 20 pixel to each edge. You end up with something like: Cheers, Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
_______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Thank you. Best regards, Natalia
_______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
I played a bit with this code and I I understand that:
when I decrease the charge - elements move apart; when I increase the strength - elements move closer to each other; but I don’t understand why when I increase the length - the graph begins to curl. Can you explain this to me please? Best regards, Natalia
_______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
I guess this is because nodes are far for each other. They are like magnets, and edges are like springs. I hope this helps. Alexandre
_______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Free forum by Nabble | Edit this page |