Roassal2 - Label width

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

Roassal2 - Label width

Leonel Merino
Hi all,

In the example below. How can I print the size of the label instead of the circle’s size?

v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| e width asString]).
v



Best regards

Leonel Merino




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

Re: Roassal2 - Label width

Peter Uhnak
What do you mean by "the size of the label"? It's width?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|v el lbl|
v := RTView new.
el := RTEllipse new size: 5; elementOn: 'number'.
v add: el.
(lbl := RTLabelled new) fontSize: 30.
el @ lbl.
el @ (RTPopup new text: [:e | lbl lbl width asString]).
v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Or you can be exlicit and add RTLabel as a new shape, but then you would have to manually setup the interaction.

Peter

On Thu, Sep 3, 2015 at 2:57 PM, Leonel Merino <[hidden email]> wrote:
Hi all,

In the example below. How can I print the size of the label instead of the circle’s size?

v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| e width asString]).
v



Best regards

Leonel Merino




_______________________________________________
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: Roassal2 - Label width

Leonel Merino
Hi Peter,

Thanks for your prompt answer.
Yes, I meant width :)

How can I retrieve the label (RTLabelled) from an element object (RTElement)?
I don’t have a reference to the label (as in the example) but only to the element.

Leonel Merino


On 03 Sep 2015, at 15:43, Peter Uhnák <[hidden email]> wrote:

What do you mean by "the size of the label"? It's width?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|v el lbl|
v := RTView new.
el := RTEllipse new size: 5; elementOn: 'number'.
v add: el.
(lbl := RTLabelled new) fontSize: 30.
el @ lbl.
el @ (RTPopup new text: [:e | lbl lbl width asString]).
v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Or you can be exlicit and add RTLabel as a new shape, but then you would have to manually setup the interaction.

Peter

On Thu, Sep 3, 2015 at 2:57 PM, Leonel Merino <[hidden email]> wrote:
Hi all,

In the example below. How can I print the size of the label instead of the circle’s size?

v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| e width asString]).
v


<PastedGraphic-5.png>

Best regards

Leonel Merino




_______________________________________________
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: Roassal2 - Label width

Peter Uhnak
Well...

if you are doing this for a one-off visualization (i.e. you will throw the code away within next few months),
you could do this
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|v el|
v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| (e attributeAt: #RTLabelledLabel) width asString]).
v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

the problem is that it is fragile because it relies on internal implementation. On the bright side this is unlikely to change anytime soon.

More robust solution would be to create the label manually, but that is a bit more work.

Is this enough? Do you need more robust solution?

Peter

On Thu, Sep 3, 2015 at 4:05 PM, Leonel Merino <[hidden email]> wrote:
Hi Peter,

Thanks for your prompt answer.
Yes, I meant width :)

How can I retrieve the label (RTLabelled) from an element object (RTElement)?
I don’t have a reference to the label (as in the example) but only to the element.

Leonel Merino


On 03 Sep 2015, at 15:43, Peter Uhnák <[hidden email]> wrote:

What do you mean by "the size of the label"? It's width?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|v el lbl|
v := RTView new.
el := RTEllipse new size: 5; elementOn: 'number'.
v add: el.
(lbl := RTLabelled new) fontSize: 30.
el @ lbl.
el @ (RTPopup new text: [:e | lbl lbl width asString]).
v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Or you can be exlicit and add RTLabel as a new shape, but then you would have to manually setup the interaction.

Peter

On Thu, Sep 3, 2015 at 2:57 PM, Leonel Merino <[hidden email]> wrote:
Hi all,

In the example below. How can I print the size of the label instead of the circle’s size?

v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| e width asString]).
v


<PastedGraphic-5.png>

Best regards

Leonel Merino




_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Roassal2 - Label width

Leonel Merino
That’s perfect. 

I don’t need a robust solution. 
I am playing with a new layout and wanted to properly handle elements that have labels.

Thanks again!.

Leonel Merino



On 03 Sep 2015, at 16:15, Peter Uhnák <[hidden email]> wrote:

Well...

if you are doing this for a one-off visualization (i.e. you will throw the code away within next few months),
you could do this
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|v el|
v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| (e attributeAt: #RTLabelledLabel) width asString]).
v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

the problem is that it is fragile because it relies on internal implementation. On the bright side this is unlikely to change anytime soon.

More robust solution would be to create the label manually, but that is a bit more work.

Is this enough? Do you need more robust solution?

Peter

On Thu, Sep 3, 2015 at 4:05 PM, Leonel Merino <[hidden email]> wrote:
Hi Peter,

Thanks for your prompt answer.
Yes, I meant width :)

How can I retrieve the label (RTLabelled) from an element object (RTElement)?
I don’t have a reference to the label (as in the example) but only to the element.

Leonel Merino


On 03 Sep 2015, at 15:43, Peter Uhnák <[hidden email]> wrote:

What do you mean by "the size of the label"? It's width?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|v el lbl|
v := RTView new.
el := RTEllipse new size: 5; elementOn: 'number'.
v add: el.
(lbl := RTLabelled new) fontSize: 30.
el @ lbl.
el @ (RTPopup new text: [:e | lbl lbl width asString]).
v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Or you can be exlicit and add RTLabel as a new shape, but then you would have to manually setup the interaction.

Peter

On Thu, Sep 3, 2015 at 2:57 PM, Leonel Merino <[hidden email]> wrote:
Hi all,

In the example below. How can I print the size of the label instead of the circle’s size?

v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| e width asString]).
v


<PastedGraphic-5.png>

Best regards

Leonel Merino




_______________________________________________
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


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

Re: Roassal2 - Label width

abergel
In reply to this post by Peter Uhnak
Thanks Peter!
I would not have said better :-)

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



On Sep 3, 2015, at 11:15 AM, Peter Uhnák <[hidden email]> wrote:

Well...

if you are doing this for a one-off visualization (i.e. you will throw the code away within next few months),
you could do this
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|v el|
v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| (e attributeAt: #RTLabelledLabel) width asString]).
v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

the problem is that it is fragile because it relies on internal implementation. On the bright side this is unlikely to change anytime soon.

More robust solution would be to create the label manually, but that is a bit more work.

Is this enough? Do you need more robust solution?

Peter

On Thu, Sep 3, 2015 at 4:05 PM, Leonel Merino <[hidden email]> wrote:
Hi Peter,

Thanks for your prompt answer.
Yes, I meant width :)

How can I retrieve the label (RTLabelled) from an element object (RTElement)?
I don’t have a reference to the label (as in the example) but only to the element.

Leonel Merino


On 03 Sep 2015, at 15:43, Peter Uhnák <[hidden email]> wrote:

What do you mean by "the size of the label"? It's width?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|v el lbl|
v := RTView new.
el := RTEllipse new size: 5; elementOn: 'number'.
v add: el.
(lbl := RTLabelled new) fontSize: 30.
el @ lbl.
el @ (RTPopup new text: [:e | lbl lbl width asString]).
v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Or you can be exlicit and add RTLabel as a new shape, but then you would have to manually setup the interaction.

Peter

On Thu, Sep 3, 2015 at 2:57 PM, Leonel Merino <[hidden email]> wrote:
Hi all,

In the example below. How can I print the size of the label instead of the circle’s size?

v := RTView new.
el := RTEllipse new size: 5; elementOn:'number'.
v add: el.
el @ (RTLabelled new fontSize:30).
el @ (RTPopup new textElement:[:e| e width asString]).
v


<PastedGraphic-5.png>

Best regards

Leonel Merino




_______________________________________________
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


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