get size after CSS

Phil Race philip.race at oracle.com
Mon Dec 24 12:14:42 PST 2012


Ah. I understood you to mean some code was calling setStyle(String 
cssStyleStr).
I've never seen a problem before in the CSS applied from a file being 
too late for
layout but I suppose you need this before layout ..

-phil

On 12/24/2012 11:52 AM, Tom Eugelink wrote:
> The style node is not changed when the font is set in a CSS file (just 
> tested it). It does not matter if the node actually is part of the 
> scene or not.
>
> Tom
>
>
>
> On 2012-12-24 20:46, Phil Race wrote:
>> That doesn't sound like what I suggested which is to
>> 1)  listen to the "style" property on the node you care about
>> 2) by hand parse that string and extract the pending font change
>> 3) Construct a Font with that size and face
>> 4) by hand call "setFont(..) using this font you constructed.
>>
>> -phil.
>>
>> On 12/24/2012 11:40 AM, Tom Eugelink wrote:
>>> The trick with listening to the boundInParent works, but only if I 
>>> actually add the dummy node to the scene, otherwise the CSS is never 
>>> applied (which makes sense of course). The problem is to know when 
>>> to remove it again.
>>>
>>> Tom
>>>
>>>
>>>
>>> On 2012-12-24 19:58, Phil Race wrote:
>>>> I'm not the authority on CSS, far from it, but so far as I know that's
>>>> just how the CSS works. So the node has no idea of the pending change.
>>>> I recall Richard saying a couple of months ago that SceneBuilder
>>>> has the same issue/need. I don't know if a solution was applied there.
>>>>
>>>> Perhaps you could listen in on the style string property on the node
>>>> and when you detect its changed parse it yourself, looking for font 
>>>> and
>>>> size and directly apply the new font/size to a dummy Text object and
>>>> extract the needed info from that ?
>>>>
>>>> -phil.
>>>>
>>>>
>>>> On 12/22/2012 11:15 AM, Tom Eugelink wrote:
>>>>> I've got a javafx.scene.txt.Text node with a content that can be a 
>>>>> longer multi line (because of the wrapping width) text. But the 
>>>>> node serves as the title of a special type of appointment in the 
>>>>> agenda control, and I want it to only show the text that fits on 
>>>>> the first single line. For this I'm trying to use Text's clipping 
>>>>> feature with a rectangle of height "M". My problem is that the 
>>>>> font being used is set in CSS.
>>>>>
>>>>> How can I find out the Text's font height?
>>>>>
>>>>> I tried using a 'new Text("M")' and then use boundsInParent, but 
>>>>> the CSS is applied after the next pulse, so the value of 
>>>>> "getBoundsInParent().getHeight()" initially is that of the default 
>>>>> font. I also tried listening to boundsInParentProperty and update 
>>>>> the height when it gets invalidated, but that does not seem to be 
>>>>> triggered.
>>>>>
>>>>> Tom
>>>>
>>>
>>
>



More information about the openjfx-dev mailing list