aligning and positioning edge labels

18 views
Skip to first unread message

Srirama Bhamidipati

unread,
Dec 17, 2014, 11:01:11 AM12/17/14
to gama-p...@googlegroups.com
Hi,

I would like to label edges of my graph. And I would like to align these labels to the edge's direction/ heading. I tried "rotate" with a heading, but it did not work for me. Is there something I am missing? How do I know what is the heading of my edge? To make it more precise, I am not making this graph as an agent *yet" and displaying it from the "graphics" section. 

Would the approach differ if I have my graph as a species ?

Please guide,

thanks
srirama

Patrick Taillandier

unread,
Dec 17, 2014, 11:22:28 AM12/17/14
to gama-p...@googlegroups.com
Hi,

Here a solution that is far from perfect (a bit ugly sometimes) but that is better than nothing :p :

display cool_graph {
       graphics "graph" {
               int i <- 0; //just use to give a different name to each edge
               loop e over: gr.edges {
                geometry eg <- geometry(e); // to avoid to write many times "geometry(e)"
                draw eg end_arrow: 2 color: #blue; //just add an end arrow to know the direction of the edge
                draw ("edge " + i) size: 3 at: eg.location color: #black rotate: (angle_between(first(eg.points), {first(eg.points).x,0}, last(eg.points)) - 90); //a bit ugly... but well..... there is maybe a better solution....
                i<- i + 1;
                }
        }
               
}  

Cheers,

Patrick

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.

Srirama Bhamidipati

unread,
Dec 17, 2014, 11:46:14 AM12/17/14
to gama-p...@googlegroups.com
It indeed is a Cool_display, it works !!!!

regards,
Sriram

Patrick Taillandier

unread,
Dec 19, 2014, 9:30:43 AM12/19/14
to gama-p...@googlegroups.com
Note than rather using "angle_between", you can use here "direction_to" (simpler here):
draw ("edge " + i) size: 3 at: eg.location color: #black rotate: first(eg.points) direction_to last(eg.points);

Cheers,

Patricj

--
Reply all
Reply to author
Forward
0 new messages