Is there a way to make Roassal draw an edge from one node to itself?
I looked at a bunch of the examples and I cannot find any that does that, and simply adding an edge in the source code produces nothing.
i.e.
view shape rectangle size: 1.
view nodes: (1 to: 5).
view shape arrowedLine.
view
edges: ((OrderedCollection new) add: (1->1); add: (2->2); add: (3->3); add: (4->4); add: (5->5); yourself)
from: #key
to: #value.
view circleLayout.
produces no edges at all.
I'm not sure if Roassal implements that kind of edge. I tried the same in Roassal2 and although the edge is created it is not showed. It seems that it creates a line where the origin and the end is the same point.
As a workaround you could reuse Bezier lines by specifying a different behaviour for that case:
RTDirectedLine>>pointsFrom: from To: to
| point mid |
from = to
ifTrue: [
mid := to * (1 - offset) + (from * offset).
point := from + (50 @ 50).
^ Array with: from - (10 @ 0) with: point with: to - (0 @ 10) ]
ifFalse: [
mid := to * (1 - offset) + (from * offset).
point := from + (mid - from) rightRotated.
^ Array with: from with: point with: to ]
Then you can run in a workspace:
| b |
b := RTGraphBuilder new.
b nodes
size: 20;
color: Color gray.
b edges
directed;
connectTo: #yourself.
b layout circle.
b addAll: (1 to:5).
b open.
b view canvas
You should see this:
http://cdn.imghack.se/images/1aaea2de365d0a16818ec8bcf991348a.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With