Login  Register

Re: Named edges and nodes in a Roassal graph

Posted by Peter Uhnak on Nov 23, 2014; 12:55am
URL: https://forum.world.st/Named-edges-and-nodes-in-a-Roassal-graph-tp4791772p4791787.html

Hmm, maybe that's the reason why there is separate class for ArrowedLine.

Essentially both RTElement and RTEdge has method 'model:' (RTShapedObject>>model:) where you can put a string which is then used by RTLabelled. (You can actually pass any object, but then you will have to modify it to send it the proper message).

anyway, I modified your example:
====
| vista e1 e2 e3 e4 line edge1 edge2 |

"Se crea un objeto tipo vista"
vista := RTView new.

"Definimo los elementos, que denominamos simplemente e1, e2, etc, con
su color y su tamaño"
e1 := (RTEllipse new color: (Color blue alpha: 0.4); size: 20) elementOn: 'first'.
e2 := (RTEllipse new color: (Color red alpha: 0.4); size: 20) elementOn: 'second'.
e3 := (RTEllipse new color: (Color yellow alpha: 0.4); size: 20) elementOn: 'third'.
e4 := (RTEllipse new color: (Color green alpha: 0.4); size: 20) elementOn: 'fourth'.

"Decimos que los elementos antes definidos se podrán arrastrar"
vista add: e1; add: e2; add: e3; add: e4.

vista elements do: [ :each | each @ RTDraggable @ RTLabelled ].


"Adicionamos los elementos a la vista"

"Decimos qué propiedades va a tener la línea que los conecta los elementos"
line := RTArrowedLine  new color: Color red.
line withOffsetIfMultiple.

"Decimos de dónde a dónde van las líneas que unen los elementos en la vista"

edge1 := (line edgeFrom: e1 to: e2). 
edge2 := (line edgeFrom: e3 to: e4) model: 'second label'.

vista add: edge1.
vista add: (line edgeFrom: e2 to: e1).
vista add: (line edgeFrom: e1 to: e2).
vista  add: (line edgeFrom: e2 to: e2).
vista  add: edge2.

edge1 @ (RTLabelled new text: 'edge label').
edge2 @ RTLabelled. "this uses the model of edge2"


"Decimos que dispocisión van a tener los elementos en la vista. 
En este caso se van a disponer de manera circular"
RTCircleLayout on: { e1 . e2 . e3 . e4 }.

"Abrimos la vista"
vista open
====

On Sun, Nov 23, 2014 at 1:43 AM, Peter Uhnák <[hidden email]> wrote:
It seems there is an issue with the arrow head, I'll try to investigate it

for now try running it without it

===========================
v := RTView new.

e1 := (RTEllipse new size: 20) elementOn: 'hello'.
e2 := (RTEllipse new size: 20) elementOn: 'world'.

e1 @ RTDraggable.
e2 @ RTDraggable.

l := RTEdge from: e1 to: e2.
l + (RTLine new color: Color red).
"l + (RTSimpleArrowHead new color: Color red)."

e2 translateBy: 60 @ 80.
v addAll: (Array with: e1 with: e2 with: l ).

e1 @ RTLabelled.
e2 @ RTLabelled.

"Note that the RTLabelled interaction has to be set after having added the element in the view"
l @ (RTLabelled new text: 'lining up!').

v open
=========================

As far as documentation goes, it is still heavily work in progress, so right now Agile Visualization is probably the best source (and of course mailing list).