Roassal3 icon indicating copy to clipboard operation
Roassal3 copied to clipboard

How to make large nodes away from small

Open bergel opened this issue 4 years ago • 1 comments

Is there a way to make a arge node more "repulsive" than a smaller node?

r := Random seed: 42.
values := Dictionary new.
1 to: 4 do: [ :i | values at: i put: (r nextInt: 50) + 10 ].
assoc := { 1 -> 2 . 1 -> 3 . 3 -> 4 }.

c := RSCanvas new.
nodes := RSCircle models: (1 to: 4) forEach: [ :s :o | s size: (values at: o); color: Color gray translucent ].
c addAll: nodes.

nodes @ RSDraggable @ RSPopup.

lb := RSLineBuilder line.
lb canvas: c.
lb useAssociations: assoc.

RSForceBasedLayout on: nodes.
c @ RSCanvasController

This script gives: image

The big nodes is above the small nodes.... It would be great to have large nodes away from the small nodes.

bergel avatar Aug 09 '21 09:08 bergel

I have added a boolean accessor to automatically set the charge and the length of each node and line

r := Random seed: 42.
values := Dictionary new.
1 to: 4 do: [ :i | values at: i put: (r nextInt: 50) + 10 ].
assoc := { 1 -> 2 . 1 -> 3 . 3 -> 4 }.

c := RSCanvas new.
nodes := RSCircle models: (1 to: 4) forEach: [ :s :o | s size: (values at: o); color: Color gray translucent ].
c addAll: nodes.

nodes @ RSDraggable @ RSPopup.

lb := RSLineBuilder line.
lb canvas: c.
lb useAssociations: assoc.
i:= RSForceLayoutSteppingInteraction new.
i layout
	autoRepulse: true.
c @ RSCanvasController; @ i.
c

image

akevalion avatar Sep 10 '21 14:09 akevalion

We have RSSimpleForceBasedLayout

akevalion avatar May 30 '23 11:05 akevalion