Search code examples
positionlabelcenteringnetlogo

Netlogo - Setting the position of the patches label to center


I have labels on my patches but they are alligned in the bottom right of the patch.

Can I aligne them in the center of the patch, and how?


Solution

  • Not possible. A possible loophole is:

    Currently there is no easy way to align text to the left in the view using labels. Whenever i needed to do that i used to change the xcor and ycor of the "label turtle" so that i would get the desired result. There is light at the end of the tunnel though. By knowing the horizontal size of letters, numbers and symbols used in netlogo in pixels, patch-size, font size of labels, world-width and world-height, the position of the "label turtle" can be calculated so that it would align its label exaclty like the user desires.

    My question: is there a easy way to find out the exact horizontal length of a symbol/letter/number at font size y? It seems like the horizontal length of a symbol is the only thing that wont let me to just write a procedure for label text alignment purpose.

    By easy i mean easier then measuring all common letters, symbols and numbers. Measuring is doable, but takes some time and will not be perfect.

    Another important and odd point that should be mentioned is that some font sizes have a equal horizontal size and some can be described with a formula which contains current font size. For example font sizes [1 2], [3 4], [6 7], [9 10 11], [12 13 14] have an equal horizontal size.... (and now for the odd part) ...in case of letter "A". In case of letter "B" font sizes of [12 13] have an equal horizontal length, but 14 has a bigger horizontal length. At some point the horizontal size starts following a formula. So if the horizontal length of letter "A" would be x at font size 100, then at font size 27 its horizontal size will be x / (100 / 27).

    It seems that the font used in labels is Tahoma. Im not 100% sure about that though. It really looks like Tahoma in bigger font sizes, but the oddness with lower font sizes raises suspicion about that.


    http://netlogo-users.18673.x6.nabble.com/Label-alignment-td4871179.html