Bor*_*riS 5 pharo moose-technology roassal
有没有办法让Roassal从一个节点到它自己的边缘?
我查看了一些示例,我找不到任何这样做,只是在源代码中添加一个边缘不会产生任何结果.
即
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.
Run Code Online (Sandbox Code Playgroud)
根本不产生任何边缘.
我不确定 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 ]
Run Code Online (Sandbox Code Playgroud)
然后你可以在工作区中运行:
| 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
Run Code Online (Sandbox Code Playgroud)
你应该看到这个:
http://cdn.imghack.se/images/1aaea2de365d0a16818ec8bcf991348a.png
| 归档时间: |
|
| 查看次数: |
135 次 |
| 最近记录: |