RFR: 8341670: [Text, TextFlow] Public API for Text Layout Info [v5]

Jurgen duke at openjdk.org
Fri Oct 11 13:59:16 UTC 2024


On Thu, 10 Oct 2024 19:23:47 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   convert to wrapper
>
> One additional thought/question:
> 
> There is a need to extract a few more data points from the text layout in addition to the text lines, specifically:
> - bounds of the (selection) range, as rectangles
> - strikethrough range shape (as `PathElement[]` and/or rectangles)
> - underline range shape (as `PathElement[]` and/or rectangles)
> 
> We currently have `Text/TextFlow.underlineShape(int,int)`, `.rangeShape(int,int)` which return `PathElement[]` in an undocumented way.
> 
> There is no corresponding `.strikeThroughShape()` method, or a way to retrieve the geometric bounds as lines/rectangles.
> 
> Granted, one can attempt to analyze the `PathElement[]` and convert it to geometry, but it seems we should avoid asking the clients to do that.
> 
> So the question are:
> - should we add these data points to LayoutInfo
> - if so, in what form?  i.e. as individual methods or as an array of Line/Rectangle objects,
> - should we add the `.strikeThroughShape()` to Text/TextFlow, or simply adding it here should be sufficient?

@andy-goryachev-oracle First off thanks for all your work on the richtext control you're working on.

> @Jugen do you think this PR addresses the issue https://bugs.openjdk.org/browse/JDK-8091012 ?

Unfortunately I don't think this helps for the hit problem Tomas was having, see `hit(x,y)` in RichTextFX's [TextFlowExt](https://github.com/FXMisc/RichTextFX/blob/9405b4f03a4a7865741a8216671f4bbbd3fe27bc/richtextfx/src/main/java/org/fxmisc/richtext/TextFlowExt.java#L142) for the relevant code.

However I was able to use **all** the methods in the `LayoutInfo` interface of this PR in RichTextFX to replace the custom layout info code, which is great.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1596#issuecomment-2407473228


More information about the openjfx-dev mailing list