Rich Text Support
John-Val Rose
johnvalrose at gmail.com
Mon Oct 8 20:05:15 UTC 2018
Thanks for sharing that - it’s really helpful.
And we all make mistakes. It’s what makes us “human” (As I’m sure Commander Data would agree).
> On 9 Oct 2018, at 03:28, Pedro Duque Vieira <pedro.duquevieira at gmail.com> wrote:
>
> I'm not sure, but I think Robert might have only replied to me (probably by
> mistake) and not the whole openjfx list as well. It has happened to me
> before :)
> He makes some points that are probably of interest to this discussion. If
> his email didn't get to the openjfx mailing list, it is below.
>
> I'd like to make some comments to the points he raised:
>
> When I mentioned TextFlow I was mentioning it for the rich text display
> part only. As I mentioned, for the editing, I think it would be good to
> have more API in the JavaFX SDK to facilitate developing a Rich text
> editor. Like I said, FontMetrics would be a nice addition, not just for
> rich text editing but for anything that involves laying out text and other
> things. So this would be very good to have. Right now you have to resort to
> hacks when laying out text, and for some things you simply don't have the
> API.
> Other good additions to the API, which are also relevant to this
> discussion, would be to be able to know which character has been clicked on
> in a text node, either via mouse or touch. FontMetrics could also help with
> this.
>
> When creating a Rich Text editor with a scene graph approach and retained
> mode (vs using an approach like using Canvas), we'd have to use a technic
> that doesn't use a Node for every character or word. Otherwise we will
> eventually have thousands of nodes in the scene which will kill performance
> and memory. One of those techniques is to use virtualization, via the use
> of a ListView for example. Each cell can be a TextFlow representing a line
> that would automatically be re-used by the ListView. So I don't think we
> must resort to using Canvas. Personally I prefer using a scene graph based
> approach.
>
> Like I said, I've never actually implemented or tried to implement a rich
> text editor, so there might be people with better knowledge and experience
> in this list to talk about this.
> My 2 cents.
>
>
>
>
>
>
>
>
> On Mon, Oct 8, 2018 at 3:05 PM Robert Lichtenberger <
> r.lichtenberger at gmail.com> wrote:
>
>>> Am 03.10.2018 um 14:21 schrieb Pedro Duque Vieira:
>>> Hi,
>>>
>>> Have you guys tried JavaFX TextFlow class and such for just the display
>>> part of rich text?
>>
>> I have some (albeit very old now) background in writing an editor for an
>> IDE.
>>
>> The the best of my knowledge, TextFlow is not even usable to display
>> large amounts of (colored/highlighted) text let alone make it editable.
>>
>> I've tried and rigged together a little piece of code that would display
>> an XML file in a colorful way (i.e. three to five Texts per line plus an
>> additional Text-Object per line).
>>
>> Displaying a file with 5 MB will consume a whopping 800 MB of
>> Text-objects in that way. The application has never been able to render
>> anything beyond tiny files.
>>
>> Displaying text files in a graph of nodes is just plain wrong. You have
>> to invert the situation so that only the part of the file that is
>> currently visible gets rendered.
>> That is where things get complicated (in my opinion), because JavaFX
>> dictates (AFAIK) that rendering has to be the other way round. While
>> painting callbacks may seem like an artifact of the past they are
>> superior when it comes to rendering texts. (Model-View-Controller ...
>> anyone still remembering ?)
>>
>> Maybe something can be done with a Canvas in a ScrollPane (will have to
>> try that), but TextFlow seems to rather mislead people into the wrong
>> direction.
>>
>> BTW, TextArea is also very bad performance-wise: Loading the 5 MB file
>> into a textarea makes the application unresponsive (on both Linux and
>> Windows)
>>
>> Robert Lichtenberger
>>
>>
>
> --
> Pedro Duque Vieira - https://www.pixelduke.com
More information about the openjfx-discuss
mailing list