On Fri, 7 Nov 2025 21:59:37 GMT, Kevin Rushforth <[email protected]> wrote:
>> Addressing the user feedback: >> >> In RichParagraph you have a note to make getSegments() public. It would be >> helpful if it was. >> >> >> Adding two methods to the `RichParagraph` class: >> >> - getSegmentCount() >> - getSegment(int index) >> >> Decided against exposing a List since it would require additional >> allocation. Some of the callers seems to implement special logic when the >> number of segments is 0 anyway. > > 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. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1966#discussion_r2505744934
