RFR: 8371070: RichParagraph enhancements [v2]

Andy Goryachev angorya at openjdk.org
Mon Nov 10 20:55:52 UTC 2025


On Fri, 7 Nov 2025 22:25:26 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/model/RichParagraph.java line 133:
>> 
>>> 131:      * @since 26
>>> 132:      */
>>> 133:     public abstract StyledSegment getSegment(int index);
>> 
>> A `List<StyledSegment> getSegments()` method would be more convenient to use. You could either return an unmodifiable view of the list or make a shallow copy.
>> 
>> What is the reason for separate `getSegmentCount` and `getSegment(index)` methods?
>
> Did explain it in the description.  Avoid extra allocation + most of the clients have special logic for paragraphs that contain 0 segments.

In theory, `List<StyledSegment> getSegments()` can be added as a convenience method which returns an unmodifiable copy.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1966#discussion_r2511938569


More information about the openjfx-dev mailing list