2014-09-02 13 views
5

C'è un modo per far sì che Roassal disegna un bordo da un nodo a se stesso?Bordo da un nodo a se stesso in Roassal

Ho esaminato un gruppo di esempi e non riesco a trovare nessuno che lo faccia, e semplicemente aggiungendo un bordo nel codice sorgente non produce nulla.

cioè

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. 

produce spigoli affatto.

+2

+1 vorrebbe anche questo – Hendekagon

risposta

3

Non sono sicuro che Roassal implementa questo tipo di edge. Ho provato lo stesso in Roassal2 e sebbene il bordo sia stato creato non viene mostrato. Sembra che crei una linea in cui l'origine e la fine sono lo stesso punto.

Per aggirare il problema si potrebbe riutilizzare le linee Bezier specificando un comportamento diverso per quel caso:


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 ] 

allora è possibile eseguire in uno spazio di lavoro:


| 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 

Dovreste vedere questo:

http://cdn.imghack.se/images/1aaea2de365d0a16818ec8bcf991348a.png

Problemi correlati