Force based layout

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Force based layout

Natalia Tymchuk
Hello.
I’m trying to use Force based layout to position some elements. I expected to get the image like this.
Using this code http://ws.stfx.eu/LACEUL5X6K1S  I got something different and I don’t know why. 
 
It looks like all elements attract instead of repel each other. Does somebody know why it is like that?

Best regards,
Natalia


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Force based layout

Nicolai Hess
2014-11-10 12:17 GMT+01:00 Natalia Tymchuk <[hidden email]>:
Hello.
I’m trying to use Force based layout to position some elements. I expected to get the image like this.
Using this code http://ws.stfx.eu/LACEUL5X6K1S  I got something different and I don’t know why. 
 
It looks like all elements attract instead of repel each other. Does somebody know why it is like that?

Best regards,
Natalia


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev


edge dirven layouts ignore the supplied edges, if the "userDefinedEdges" are set.
(maybe it should use
"    self userDefinedEdges isEmptyNil "
instead of
"    self userDefinedEdges isNil "
)
you can force the layout to use your edges with:
#useInLayout



| builder |

builder := RTGraphBuilder new.

builder nodes shape: (RTEllipse new ).
builder edges
        connectTo: [ :c | c subclasses ];
        useInLayout;                                             "<<-----"
        shape: (RTLine new color: Color gray).
builder addAll: Boolean allSuperclasses, Boolean withAllSubclasses.

builder layout force.

builder build.
builder view






_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Force based layout

abergel
In reply to this post by Natalia Tymchuk
As Nicolai said, you need to explicitly say that you want the edges to be considered in the layout using #useInLayout.

Additionally, you may want to play with the charge and length in the layout. Consider the following example:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
builder := RTGraphBuilder new.

builder nodes shape: (RTEllipse new size: 20).
builder edges
connectTo: [ :c | c subclasses ];
useInLayout;
shape: (RTLine new color: Color gray).

builder layout force
charge: -300;
length: 20.

builder addAll: Boolean allSuperclasses, Boolean withAllSubclasses.

builder build.
builder view
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

We give a repulsion of -300 to each node (which is what you want since nodes have to repulse each other), and you give a length of 20 pixel to each edge.
You end up with something like:

Cheers,
Alexandre


-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On Nov 10, 2014, at 8:17 AM, Natalia Tymchuk <[hidden email]> wrote:

Hello.
I’m trying to use Force based layout to position some elements. I expected to get the image like this.
<Screen Shot 2014-11-10 at 11.16.54.png>
Using this code http://ws.stfx.eu/LACEUL5X6K1S  I got something different and I don’t know why. 
 <Screen Shot 2014-11-10 at 12.01.11 PM.png>
It looks like all elements attract instead of repel each other. Does somebody know why it is like that?

Best regards,
Natalia

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Force based layout

Natalia Tymchuk
Thank you. 

Best regards,
Natalia


On Nov 11, 2014, at 3:02 PM, Alexandre Bergel <[hidden email]> wrote:

As Nicolai said, you need to explicitly say that you want the edges to be considered in the layout using #useInLayout.

Additionally, you may want to play with the charge and length in the layout. Consider the following example:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
builder := RTGraphBuilder new.

builder nodes shape: (RTEllipse new size: 20).
builder edges
connectTo: [ :c | c subclasses ];
useInLayout;
shape: (RTLine new color: Color gray).

builder layout force
charge: -300;
length: 20.

builder addAll: Boolean allSuperclasses, Boolean withAllSubclasses.

builder build.
builder view
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

We give a repulsion of -300 to each node (which is what you want since nodes have to repulse each other), and you give a length of 20 pixel to each edge.
You end up with something like:
<Screen Shot 2014-11-11 at 11.01.43 AM.png>

Cheers,
Alexandre


-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On Nov 10, 2014, at 8:17 AM, Natalia Tymchuk <[hidden email]> wrote:

Hello.
I’m trying to use Force based layout to position some elements. I expected to get the image like this.
<Screen Shot 2014-11-10 at 11.16.54.png>
Using this code http://ws.stfx.eu/LACEUL5X6K1S  I got something different and I don’t know why. 
 <Screen Shot 2014-11-10 at 12.01.11 PM.png>
It looks like all elements attract instead of repel each other. Does somebody know why it is like that?

Best regards,
Natalia

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Force based layout

Natalia Tymchuk
I played a bit with this code and I I understand that:
when I decrease the charge - elements move apart;
when I increase the strength - elements move closer to each other;
 but I don’t understand why when I increase the length - the graph begins to curl.
Can you explain this to me please?

Best regards,
Natalia

On Nov 11, 2014, at 4:27 PM, Natalia Tymchuk <[hidden email]> wrote:

Thank you. 

Best regards,
Natalia


On Nov 11, 2014, at 3:02 PM, Alexandre Bergel <[hidden email]> wrote:

As Nicolai said, you need to explicitly say that you want the edges to be considered in the layout using #useInLayout.

Additionally, you may want to play with the charge and length in the layout. Consider the following example:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
builder := RTGraphBuilder new.

builder nodes shape: (RTEllipse new size: 20).
builder edges
connectTo: [ :c | c subclasses ];
useInLayout;
shape: (RTLine new color: Color gray).

builder layout force
charge: -300;
length: 20.

builder addAll: Boolean allSuperclasses, Boolean withAllSubclasses.

builder build.
builder view
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

We give a repulsion of -300 to each node (which is what you want since nodes have to repulse each other), and you give a length of 20 pixel to each edge.
You end up with something like:
<Screen Shot 2014-11-11 at 11.01.43 AM.png>

Cheers,
Alexandre


-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On Nov 10, 2014, at 8:17 AM, Natalia Tymchuk <[hidden email]> wrote:

Hello.
I’m trying to use Force based layout to position some elements. I expected to get the image like this.
<Screen Shot 2014-11-10 at 11.16.54.png>
Using this code http://ws.stfx.eu/LACEUL5X6K1S  I got something different and I don’t know why. 
 <Screen Shot 2014-11-10 at 12.01.11 PM.png>
It looks like all elements attract instead of repel each other. Does somebody know why it is like that?

Best regards,
Natalia

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Force based layout

abergel
I guess this is because nodes are far for each other. They are like magnets, and edges are like springs. 
I hope this helps. 

Alexandre



Le 11-11-2014 à 18:07, Natalia Tymchuk <[hidden email]> a écrit :

I played a bit with this code and I I understand that:
when I decrease the charge - elements move apart;
when I increase the strength - elements move closer to each other;
 but I don’t understand why when I increase the length - the graph begins to curl.
Can you explain this to me please?

Best regards,
Natalia

On Nov 11, 2014, at 4:27 PM, Natalia Tymchuk <[hidden email]> wrote:

Thank you. 

Best regards,
Natalia


On Nov 11, 2014, at 3:02 PM, Alexandre Bergel <[hidden email]> wrote:

As Nicolai said, you need to explicitly say that you want the edges to be considered in the layout using #useInLayout.

Additionally, you may want to play with the charge and length in the layout. Consider the following example:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
builder := RTGraphBuilder new.

builder nodes shape: (RTEllipse new size: 20).
builder edges
connectTo: [ :c | c subclasses ];
useInLayout;
shape: (RTLine new color: Color gray).

builder layout force
charge: -300;
length: 20.

builder addAll: Boolean allSuperclasses, Boolean withAllSubclasses.

builder build.
builder view
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

We give a repulsion of -300 to each node (which is what you want since nodes have to repulse each other), and you give a length of 20 pixel to each edge.
You end up with something like:
<Screen Shot 2014-11-11 at 11.01.43 AM.png>

Cheers,
Alexandre


-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On Nov 10, 2014, at 8:17 AM, Natalia Tymchuk <[hidden email]> wrote:

Hello.
I’m trying to use Force based layout to position some elements. I expected to get the image like this.
<Screen Shot 2014-11-10 at 11.16.54.png>
Using this code http://ws.stfx.eu/LACEUL5X6K1S  I got something different and I don’t know why. 
 <Screen Shot 2014-11-10 at 12.01.11 PM.png>
It looks like all elements attract instead of repel each other. Does somebody know why it is like that?

Best regards,
Natalia

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev