![](/img/trans.png)
[英]Make edges not clickable in Roassal visualization from within a Glamour browser
[英]Edge from a node to itself in 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.
根本不产生任何边缘。
我不确定Roassal是否实现了这种优势。 我在Roassal2中试过了同样的东西,尽管创建了边缘,但是没有显示出来。 它似乎创建了一条线,其中原点和结尾是同一点。
作为一种解决方法,您可以通过为该案例指定不同的行为来重用Bezier行:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.