Edge from node to itself in Roassal

Is there a way to make Roassal draw an edge from one node for myself?

I looked at a bunch of examples, and I can't find anything like that, and just adding an edge in the source code does 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. 

doesn't create any edges.

+5
source share
1 answer

I am not sure that Roassal implements such an edge. I tried the same in Roassal2, and although the edge is created, it does not display. It seems that he is creating a line where the beginning and the end are the same point.

As a workaround, you can reuse Bezier strings by specifying a different behavior for this 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 the 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

+3
source

Source: https://habr.com/ru/post/1201649/


All Articles