我不确定 Roassal 是否实现了这种优势。我在 Roassal2 中尝试了相同的方法,虽然创建了边缘,但没有显示。似乎它创建了一条线,其中起点和终点是同一点。
作为一种解决方法,您可以通过为这种情况指定不同的行为来重用贝塞尔线:
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 ]
然后您可以在工作区中运行:
| 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
你应该看到这个:
http://cdn.imghack.se/images/1aaea2de365d0a16818ec8bcf991348a.png