Setting label font size in Roassal2

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

Setting label font size in Roassal2

hernanmd
Hi guys,

I was able to create a world map rendering circles in the country centroids.
However, labelling such circles is problematic, specially in the case of Europe where many countries are small and close enough each other.

See the attachment picture,

Is there a way to set up the label size?

This is what I am doing:

    self filteredTerritories: (self itemsByFeature: 'country') asBag sortedElements.
    gbViewBuilder := RTCountryMapBuilder newWithCentroids: self filteredTerritories.
    gbViewBuilder countries: RTMapBuilder countries.
    gbViewBuilder centroids: self filteredTerritories  named: [ : assoc | assoc key  ].
    gbViewBuilder centroids shape
        size: [ : countryAssoc | countryAssoc value  ];
        if: [ :c | c value < 10 ] fillColor: (Color green alpha: 0.5);
        if: [ :c | c value >= 10 and: c value < 50 ] fillColor: (Color yellow alpha: 0.5);
        if: [ :c | c value >= 50 ] fillColor: (Color red alpha: 0.5);       
        labelledAs: [ : c | self centroidLabel: c  ].

    gbViewBuilder color: Color veryVeryLightGray.
    gbViewBuilder scale: 1.5.
    gbViewBuilder withPopup.
    gbViewBuilder build.
    gbViewBuilder view.


Cheers,

Hernán


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

Untitled window.jpeg (148K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Setting label font size in Roassal2

abergel
Hi Hernan,

Yes, label size can be easily set up. Check this:

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

shape := RTLabel new height: #yourself.
labels := shape elementsOn: (5 to: 30 by: 5).
v addAll: labels.

RTFlowLayout on: labels.

v
-=-=-=-=-=-=-=-=-=-=-=-=

I suspect that in your case, you need to keep the size of the label when you zoom in. Is that correct?
If this is the case, then you may need to fix the elements:
-=-=-=
v := RTView new.

shape := RTLabel new height: #yourself.
labels := shape elementsOn: (5 to: 30 by: 5).
labels do: #setAsFixed.
v addAll: labels.

RTFlowLayout on: labels.

v
-=-=-=-=

But you cannot scroll them. Let me know what you exactly need.

Alexandre



> On Sep 23, 2016, at 1:29 AM, Hernán Morales Durand <[hidden email]> wrote:
>
> Hi guys,
>
> I was able to create a world map rendering circles in the country centroids.
> However, labelling such circles is problematic, specially in the case of Europe where many countries are small and close enough each other.
>
> See the attachment picture,
>
> Is there a way to set up the label size?
>
> This is what I am doing:
>
>     self filteredTerritories: (self itemsByFeature: 'country') asBag sortedElements.
>     gbViewBuilder := RTCountryMapBuilder newWithCentroids: self filteredTerritories.
>     gbViewBuilder countries: RTMapBuilder countries.
>     gbViewBuilder centroids: self filteredTerritories  named: [ : assoc | assoc key  ].
>     gbViewBuilder centroids shape
>         size: [ : countryAssoc | countryAssoc value  ];
>         if: [ :c | c value < 10 ] fillColor: (Color green alpha: 0.5);
>         if: [ :c | c value >= 10 and: c value < 50 ] fillColor: (Color yellow alpha: 0.5);
>         if: [ :c | c value >= 50 ] fillColor: (Color red alpha: 0.5);        
>         labelledAs: [ : c | self centroidLabel: c  ].
>
>     gbViewBuilder color: Color veryVeryLightGray.
>     gbViewBuilder scale: 1.5.
>     gbViewBuilder withPopup.
>     gbViewBuilder build.
>     gbViewBuilder view.
>
>
> Cheers,
>
> Hernán
>
> <Untitled window.jpeg>_______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

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

Re: Setting label font size in Roassal2

hernanmd
Hi Alex,

I just added a method to set font size and color:

RTShapeBuilder>>labelledAs: aBlock size: aValue color: aColor

    | label oldShape |
    label := RTLabel new text: aBlock.
    label height: aValue.
    label color: aColor.
    oldShape := shape.
    shape := RTCompositeShape new.
    shape add: oldShape.
    shape add: label.
   
    shape vertical.
    shapeInitializer rtValue: shape.
   
    ^ label


I will take a look to the examples you wrote.

Hernán


2016-09-23 13:25 GMT-03:00 Alexandre Bergel <[hidden email]>:
Hi Hernan,

Yes, label size can be easily set up. Check this:

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

shape := RTLabel new height: #yourself.
labels := shape elementsOn: (5 to: 30 by: 5).
v addAll: labels.

RTFlowLayout on: labels.

v
-=-=-=-=-=-=-=-=-=-=-=-=

I suspect that in your case, you need to keep the size of the label when you zoom in. Is that correct?
If this is the case, then you may need to fix the elements:
-=-=-=
v := RTView new.

shape := RTLabel new height: #yourself.
labels := shape elementsOn: (5 to: 30 by: 5).
labels do: #setAsFixed.
v addAll: labels.

RTFlowLayout on: labels.

v
-=-=-=-=

But you cannot scroll them. Let me know what you exactly need.

Alexandre



> On Sep 23, 2016, at 1:29 AM, Hernán Morales Durand <[hidden email]> wrote:
>
> Hi guys,
>
> I was able to create a world map rendering circles in the country centroids.
> However, labelling such circles is problematic, specially in the case of Europe where many countries are small and close enough each other.
>
> See the attachment picture,
>
> Is there a way to set up the label size?
>
> This is what I am doing:
>
>     self filteredTerritories: (self itemsByFeature: 'country') asBag sortedElements.
>     gbViewBuilder := RTCountryMapBuilder newWithCentroids: self filteredTerritories.
>     gbViewBuilder countries: RTMapBuilder countries.
>     gbViewBuilder centroids: self filteredTerritories  named: [ : assoc | assoc key  ].
>     gbViewBuilder centroids shape
>         size: [ : countryAssoc | countryAssoc value  ];
>         if: [ :c | c value < 10 ] fillColor: (Color green alpha: 0.5);
>         if: [ :c | c value >= 10 and: c value < 50 ] fillColor: (Color yellow alpha: 0.5);
>         if: [ :c | c value >= 50 ] fillColor: (Color red alpha: 0.5);
>         labelledAs: [ : c | self centroidLabel: c  ].
>
>     gbViewBuilder color: Color veryVeryLightGray.
>     gbViewBuilder scale: 1.5.
>     gbViewBuilder withPopup.
>     gbViewBuilder build.
>     gbViewBuilder view.
>
>
> Cheers,
>
> Hernán
>
> <Untitled window.jpeg>_______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

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


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

Re: Setting label font size in Roassal2

abergel
It looks like to be redundant with RTShapeBuilder>>fontSize:

For example:
-=-=-=-=-=-=-=-=
b := RTMondrian new.
b shape label
fontSize: #yourself;
color: [ :v | Color random ].
b nodes: (1 to: 40).
b layout grid.
b
-=-=-=-=-=-=-=-=

Cheers,
Alexandre



On Sep 23, 2016, at 4:59 PM, Hernán Morales Durand <[hidden email]> wrote:

Hi Alex,

I just added a method to set font size and color:

RTShapeBuilder>>labelledAs: aBlock size: aValue color: aColor

    | label oldShape |
    label := RTLabel new text: aBlock.
    label height: aValue.
    label color: aColor.
    oldShape := shape.
    shape := RTCompositeShape new.
    shape add: oldShape.
    shape add: label.
   
    shape vertical.
    shapeInitializer rtValue: shape.
   
    ^ label


I will take a look to the examples you wrote.

Hernán


2016-09-23 13:25 GMT-03:00 Alexandre Bergel <[hidden email]>:
Hi Hernan,

Yes, label size can be easily set up. Check this:

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

shape := RTLabel new height: #yourself.
labels := shape elementsOn: (5 to: 30 by: 5).
v addAll: labels.

RTFlowLayout on: labels.

v
-=-=-=-=-=-=-=-=-=-=-=-=

I suspect that in your case, you need to keep the size of the label when you zoom in. Is that correct?
If this is the case, then you may need to fix the elements:
-=-=-=
v := RTView new.

shape := RTLabel new height: #yourself.
labels := shape elementsOn: (5 to: 30 by: 5).
labels do: #setAsFixed.
v addAll: labels.

RTFlowLayout on: labels.

v
-=-=-=-=

But you cannot scroll them. Let me know what you exactly need.

Alexandre



> On Sep 23, 2016, at 1:29 AM, Hernán Morales Durand <[hidden email]> wrote:
>
> Hi guys,
>
> I was able to create a world map rendering circles in the country centroids.
> However, labelling such circles is problematic, specially in the case of Europe where many countries are small and close enough each other.
>
> See the attachment picture,
>
> Is there a way to set up the label size?
>
> This is what I am doing:
>
>     self filteredTerritories: (self itemsByFeature: 'country') asBag sortedElements.
>     gbViewBuilder := RTCountryMapBuilder newWithCentroids: self filteredTerritories.
>     gbViewBuilder countries: RTMapBuilder countries.
>     gbViewBuilder centroids: self filteredTerritories  named: [ : assoc | assoc key  ].
>     gbViewBuilder centroids shape
>         size: [ : countryAssoc | countryAssoc value  ];
>         if: [ :c | c value < 10 ] fillColor: (Color green alpha: 0.5);
>         if: [ :c | c value >= 10 and: c value < 50 ] fillColor: (Color yellow alpha: 0.5);
>         if: [ :c | c value >= 50 ] fillColor: (Color red alpha: 0.5);
>         labelledAs: [ : c | self centroidLabel: c  ].
>
>     gbViewBuilder color: Color veryVeryLightGray.
>     gbViewBuilder scale: 1.5.
>     gbViewBuilder withPopup.
>     gbViewBuilder build.
>     gbViewBuilder view.
>
>
> Cheers,
>
> Hernán
>
> <Untitled window.jpeg>_______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

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

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


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