Proposal: Avoiding nested views with a merge tag

Yennick Trevels yennick.trevels at gmail.com
Mon Dec 17 13:15:53 PST 2012


I don't have timings for JavaFx, but in most application frameworks (like
Flex and Android) it's encouraged to keep the nesting as low as possible
because it will have to measure, layout and draw every container you use.
And while this might seem insignificant for a small tree, these timings can
add up when nesting too much.

Here's an example of some timings on Android:
http://developer.android.com/training/improving-layouts/optimizing-layout.html
While JavaFx has different code behind it, it will probably have to do the
same.


On Mon, Dec 17, 2012 at 9:24 PM, Daniel Zwolenski <zonski at gmail.com> wrote:

> Just curious, is there really any significant performance hit to the extra
> Node, even on a limited device?
>
> I was under the impression that we had heaps of Nodes within Nodes all
> over the place (e.g. Controls/Skins) and this wasn't seen as something to
> be avoided. An extra VBox would seem quite light to me and this merging
> idea seems a little complex by comparison (e.g. what happens to CSS styles
> applied at the root level)?
>
> I'm not overly fussed though, just interested in knowing more about the
> performance costs.
>
>
>
> On Tue, Dec 18, 2012 at 7:01 AM, Yennick Trevels <
> yennick.trevels at gmail.com> wrote:
>
>> @Werner An XML document can have only one root node, so that's indeed the
>> problem :)
>> @Knut,Tom Why not implement it "the android way" (see article I linked in
>> my first post). Then the fxml processor can just skip the "merge" tag and
>> add its children to the parent; and you can still use the view multiple
>> times just like any other custom view.
>>
>>
>>
>> On Mon, Dec 17, 2012 at 8:03 PM, Tom Schindl <tom.schindl at bestsolution.at
>> >wrote:
>>
>> > Yes that would be an idea, the problem is however is that this syntax
>> only
>> > allows to "merge" in 1 subfxml, unless we'd allow to reference multiple
>> > fxmls there separated through e.g. ",".
>> >
>> > Tom
>> >
>> > Von meinem iPhone gesendet
>> >
>> > Am 17.12.2012 um 19:57 schrieb Knut Arne Vedaa <
>> > knut.arne.vedaa at broadpark.no>:
>> >
>> > > Wild suggestion:
>> > >
>> > > host.fxml:
>> > >
>> > > <VBox fx:include="morecontrols.fxml">
>> > > <TextField/>
>> > > <ComboBox/>
>> > > </VBox>
>> > >
>> > > morecontrols.fxml:
>> > >
>> > > <fx:root type="VBox">
>> > >  <Label/>
>> > > </fx:root>
>> > >
>> > > I.e. a kind of "mixin" or "partial nodes" syntax. Parser should ensure
>> > that the root type (or "self type") of morecontrols.fxml is (in this
>> case)
>> > VBox.
>> > >
>> > > So what you end up with is:
>> > >
>> > > <VBox>
>> > > <TextField/>
>> > > <ComboBox/>
>> > > <Label/>
>> > > </VBox>
>> > >
>> > >
>> > > Knut Arne Vedaa
>> >
>>
>
>


More information about the openjfx-dev mailing list