Thank you for the feedback!

>> Can someone point me to a detailed explanation of how to extend Region to 
>> create my own layout?
>> In particular, how can I get a region to relayout it's children when it's 
>> being resized?
> Some quick pointers. First, layout is done asynchronously to the changes that 
> cause the layout to have to occur. This is done so that we limit the number 
> of times we layout a container. For example, if a container’s width changes, 
> we mark that container (and on up the hierarchy) as needing a new layout, but 
> we don’t perform the layout yet. If you were to then change the height for a 
> container, we see that it has already been marked dirty and don’t have to go 
> any further. Without this, we ended up with “layout storms”.
> Layouts happen once “per pulse”. A “pulse” happens once per rendering. So we 
> get notification that we need to prepare the scene graph in order to render 
> the next frame. So we do CSS, layout, etc and then synchronize those changes 
> down to the graphics layer to draw. You don’t have to worry about the pulse. 
> Just know that when the width / height / etc of a layout container changes, 
> we mark it as dirty, and then perform layout *sometime before the next render 
> happens*.
> In order to manually tell a region that it has a dirty layout, call 
> requestLayout() on the region.
>> When does a the region's parent call layoutChildren()?
> During the pulse. You can force a layout (which maybe is what you’re bumping 
> up against), but normally if you can, you want to let the “once per pulse” 
> mechanism cause layout to occur for you.

Hmm. I haven’t been forcing the layout. I’ve just overridden layoutChildren() 
to do the graph layout whenever it is called. (Trying to write as little code 
as necessary)

> During the layout pass, the layoutChildren() method on the region will be 
> called. Inside this method you are responsible for taking into account any 
> insets on the region (by calling getInsets()).

So the content area width for rendering the children, for example, is the size 
provided by the parent less the left and right insets. How do you access the 
width and height the parent is requesting the region to be?

For example, let’s say I have:

    protected void layoutChildren() {
        //  What methods do I call to get the desired width and height values 
from the parent to pass into the layout?

        doGraphLayout(?, ?); // layout takes a width and height and layouts out 
the network inside in those dimensions - creates Shapes adds them as children 
to the region

>> If the height and width of the region are set to Double.MAX_VALUE indicating 
>> the area can grow infinitely, how does the region know what size to set 
>> itself to?
> I assume you mean, when the prefWidth and prefHeight? The parent of the 
> region will ask the region for its min/pref/max width and height, and will 
> then decide what size to give your region. So in other words, the region 
> doesn’t figure out its own width/height, it is told its width and height, 
> *prior* to be being asked to layout its children.

Yes, sorry. prefWidth and prefHeight. And the parent calls resize(width, 

So if I understand this correctly, rendering starts at the scene graphs root 
and layouts are computed down the tree. The scene size tells the root node what 
size it should be and then it calls layoutChildren(). If the region has 
children it manages, they are provide with a size they should be. They in turn 
layout their children. The process continues down the tree. So layouts are top 
down? And properties like hgrow, vgrow, etc control the layout behaviour?

If I want to make my graph layout resizable, what do I need to do? Just 
implement resize(width, height)?


Reply via email to