Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing a matching algorithm #56

Closed
joegas opened this issue May 21, 2014 · 2 comments
Closed

Testing a matching algorithm #56

joegas opened this issue May 21, 2014 · 2 comments

Comments

@joegas
Copy link

joegas commented May 21, 2014

Hi Tomas,

i'm using RichTextFX to highlight search matches from a search algorithm i'm testing, somehow the way Chrome shows you the matches when you use the Find function.
For that im using:

styleClassedTextArea.setStyle(...);

I'm getting perfect results for a few amount of matches but it scales badly with larger texts. I was wondering if there's a more efficient way to set the Styles in the given ranges or maybe i'm using the wrong method for my purposes. Taking a look at the source I already started using setStyle instead of setStyleClass because of the second one creating a new ArrayList on every call.

Anyway, still great features and perhaps you have a tip for me.

@TomasMikula
Copy link
Member

Hello,

thanks for choosing RichTextFX.

A more efficient way of setting multiple style ranges at once is setStyleSpans. Note, however, that this way you also have to specify style for all the intermediate (non-highlighted) ranges.

To obtain a StyleSpans instance, you can use StyleSpansBuilder. You can see an example in the JavaKeywords demo.

@joegas
Copy link
Author

joegas commented May 22, 2014

Wow Tomas, thanks for the quick answer: the process of highlighting went from over 10 mins to under a sec. I'm impressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants