Hi Scott,
I don't know why it was decided that non-textual Nodes have baseline == height, but I suppose it was because HTML does the same.

E.g.
<table border="1">
  <tr>
   <td valign="baseline">abcde</td>
<td valign="baseline"><div style="width:100px;height:100px;border:1px solid;"/></td>
   <td  valign="baseline" style="font-size:200%">fgh</td>
  </tr>
</table>

Will align the text baseline to the height of the "div" rectangle.
Maybe it's possible to find some explanation for HTML.

Note that the descenders are not cut off, as it's just the height of the Node, not the full height of the HBox/Gridpane row/etc... The full height will be the Node's height + descent.

-Martin

On 09/09/2013 06:00 PM, Scott Palmer wrote:
I don't get it. When is the height ever the correct position for the baseline? The height value can't actually be used as the baseline as that would mean descenders are cut off. How can the layout container compute the baseline for a node if it isn't what is painting the text?

Scott


On Mon, Sep 9, 2013 at 10:19 AM, Richard Bair <richard.b...@oracle.com <mailto:richard.b...@oracle.com>> wrote:

    Sorry we flew off the list accidentally. I like
    BASELINE_OFFSET_SAME_AS_HEIGHT. This change in behavior will
    potentially break other layout managers which are handling the
    baseline case. Specifically, we should test with MigLayout.
    Otherwise this seems like a significant improvement in that we can
    avoid multiple passes and also correct layout the first time
    around instead of having things in the wrong place the first time,
    only to be moved around the next pass.

    Richard

    On Sep 3, 2013, at 9:50 PM, Martin Sladecek
    <martin.slade...@oracle.com <mailto:martin.slade...@oracle.com>>
    wrote:

    > Maybe the USE_COMPUTED_BASELINE_OFFSET should be rather
    BASELINE_OFFSET_SAME_AS_HEIGHT.
    > It's up to the layout container to compute the baseline of such
    Node, as the layout container must compute the height as well.
    > Currently, the layoutBounds height is returned, but this is
    incorrect, as the layoutBounds contain the old width&height and
    will be updated during the layout.
    >
    > So it actually means, for the baseline of this Node, use it's
    newly computed height.
    >
    > -Martin
    >
    > On 09/03/2013 09:45 PM, Richard Bair wrote:
    >> I must be missing something. I thought the getBaselineOffset
    method was the means by which that was done? Meaning, if I'm a
    layout container, then I would call getBaselineOffset to get this
    value. Now, I call it and it tells me
    USE_COMPUTED_BASELINE_OFFSET, so how do I compute it? Or do you
    mean, if somebody gets USE_COMPUTED_BASELINE_OFFSET, then it
    really means, use the layoutBounds height?
    >>
    >> Richard
    >>
    >> On Sep 3, 2013, at 12:37 PM, Martin Sladecek
    <martin.slade...@oracle.com <mailto:martin.slade...@oracle.com>>
    wrote:
    >>
    >>> The layout container will need to compute the baseline for
    Nodes with USE_COMPUTED_BASELINE_OFFSET, because it's the layout
    container who needs to compute the child's height (which is equal
    to it's baseline). I've prepared the code of all the layout Panes
    so that the baseline is computed after the heights and the heights
    are computed with respect to the baseline. There are many
    package-private helper methods in Region that I've updated and
    used in our layout Panes, so it's a matter of a few calls for us,
    but 3rd party layouts will have to compute this by themselves (as
    they aways had).
    >>>
    >>> -Martin
    >>>
    >>> On 09/03/2013 05:56 PM, Richard Bair wrote:
    >>>> So how does the layout container ask for the computed
    baseline offset? It used to be, by calling this method.
    >>>>
    >>>> Richard
    >>>>
    >>>> On Sep 3, 2013, at 6:11 AM, Martin Sladecek
    <martin.slade...@oracle.com <mailto:martin.slade...@oracle.com>>
    wrote:
    >>>>
    >>>>> Hi,
    >>>>> related JIRA issue:
    https://javafx-jira.kenai.com/browse/RT-31006
    >>>>>
    >>>>> I propose to add constant "public static final double
    USE_COMPUTED_BASELINE_OFFSET" to Node class.
    >>>>>
    >>>>> This would be returned by the default Node implementation of
    getBaselineOffset. Currently, the layout bounds are returned, but
    they are not computed at the time getBaselineOffset is called,
    which leads to incorrect layout and other problems (see more in
    description of the issue).
    >>>>>
    >>>>> Thanks,
    >>>>> -Martin
    >



Reply via email to