Extending Builders: Layout Builders

Richard Bair richard.bair at oracle.com
Tue Dec 18 08:26:43 PST 2012

> On 21.11.2012 11:03, Eva Krejcirova wrote:
>> On 20.11.2012 15:41, Richard Bair wrote:
>>>> *GridPaneBuilder*
>>>> addColumn(int columnIndex, Node... children)
>>>> addRow(int rowIndex, Node... children)
>>>> add(Node child, int columnIndex, int rowIndex)
>>>> add(Node child, int columnIndex, int rowIndex, int colspan, int rowspan)
>>> Do we  use columnIndex, rowIndex elsewhere? Usually I've seen "row, col", but "x, y", so it could go either way, but we should be consistent with elsewhere in the platform.
>> I took the names and order of the arguments from the corresponding methods in GridPane, so that its builder is consistent with it. Having the order different in GrindPane and GridPaneBuilder would be extremely confusing, I think.

This is the right thing to do (following the order of the methods in the GridPane).

>>>> *RegionBuilder*
>>>> maxSize(double width, double height)
>>>> minSize(double width, double height)
>>>> prefSize(double width, double height)
>>>> These will be inherited by all layout builders.
>>>> A also propose to add following convenience methods which don't have direct counterpart in layout classes (the constraints can be specified only by static methods there)
>>>> Adding these would enable us to add child with constraint to  layout without having to hold a reference to it. e.g
>>>> Hbox h = HBoxBuilder.create().add(CircleBuilder.create...build(), margin).build();
>>>> instead of
>>>> Circle circle = CircleBuilder.create...build();
>>>> Hbox h = HBoxBuilder.create().children(circle).build();
>>>> Hbox.setMargin (circle, margin);
>>>> The proposed methods are:
>>>> *AnchorPaneBuilder*
>>>> add(Node child, Double topAnchor, Double rightAnchor, Double bottomAnchor, Double leftAnchor)
>>> Can these be primitive doubles instead?
>> AnchorPane uses Doubles,  so I used them in Builder too, but I can surely change them to primitives.

Using the same types as the class is the right thing to do (not sure why AnchorPane uses Double instead of double, but we need to be consistent I think).


More information about the openjfx-dev mailing list