Event when CSS is applied

Tom Eugelink tbee at tbee.org
Tue Feb 17 22:05:27 UTC 2015


On 17-2-2015 20:01, David Grieve wrote:
> On 2/17/15 1:30 PM, Tom Eugelink wrote:
>> The control is a codewise polish up one of Gerrit's gauges (with permission!) and pulled into JFXtras (with tests and all). For an idea on what we are talking about:
>> https://www.youtube.com/watch?v=RH5X1uBu1d8
>>
>> The process of centering the Text in that circle is a bit more complex.
>> 1. The value may vary between a min and max value.
>> 2. I want the Text to automatically utilize the maximum available space, but not change size when a longer or shorter text is shown.
>>
>> To do this I have two additional Text nodes that have the same styling as the Text node (so these are on the scene, but not visible, otherwise CSS is not applied). These two text nodes get the maximum and minimum possible value set. Then on these two some pythagoras is applied and in that way one can determine the scale factor so that the value will never be rendered outside of the circle. Then the actual to-be-rendered value can be placed into the Text node and positioned in the centre of the circle.
>>
>> The problem is that a lot of these calculations depend on the CSS styling. What font is set? Bold or not? So I can only do these calculcation after the CSS has been applied. This unfortunately is not yet the case when the skin is instantiated. This means that if I do not used the layoutChildren, the initial presentation is totally off, untill the first min/max/value is set.
> Have you looked at the javadoc for Node#applyCss()?

I did just now and tried calling that and layout when the skin is being instantiated, but apparently things are not setup right yet.

Maybe layoutChildren with bound checking is the way to go.


More information about the openjfx-dev mailing list