Speeding up TextFlow for JavaFX8 (by a factor of ~100)


So at the end of last week I blogged about my experiments to get a styled text viewer for (java) source using the new TextFlow-Support in JavaFX8, I did a short screencast and there you noticed that for larger source files the rendering speed was not acceptable anymore.

I’ve worked a bit on it last night and take a look at this result:

The really cool thing is that the API of my StyledTextArea is fairly the same than the one from SWT-StyledText (in fact also many of the inner workings are a shameless copy from SWT!) this will make it super easy to use and adjust the current text parsing infrastructure used by the Eclipse IDE.

public class StyledTextArea extends Control {
  public void setContent(StyledTextContent content) {
    // ...
  }

  public StyledTextContent getContent() {
    // ...
  }

  public ObjectProperty<StyledTextContent> contentProperty() {
    // ...
  }

  public void setStyleRange(StyleRange range) {
    // ...
  }

  public void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles) {
    // ...
  }

  public void setStyleRanges(int[] ranges, StyleRange[] styles) {
    // ...
  }

  public void setStyleRanges(StyleRange[] ranges) {
    // ...
  }

  public void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
    // ...
  }

  public StyleRange[] getStyleRanges(int start, int length, boolean includeRanges) {
    // ...
  }
}

Ok. This was the easy part, next is to somehow add editing functionality, I have no freaking idea on how to do it.

This entry was posted in e(fx)clipse. Bookmark the permalink.

5 Responses to Speeding up TextFlow for JavaFX8 (by a factor of ~100)

  1. Daniel Zimmermann says:

    I don’t know: Often, when you say, you have no idea how to solve a problem, you miraculously come up with a solution only a short time later! 😉

    Whatever: This is really nice to see and my hopes, that the Eclipse UI *might* one day be ported to JavaFX, are rising by the day…

    Keep up the great work!

  2. Pingback: Interview with Tom Schindl // JavaFX News, Demos and Insight // FX Experience

  3. Pingback: Java desktop links of the week, February 24 | Jonathan Giles

  4. Pingback: JavaFX links of the week, February 24 // JavaFX News, Demos and Insight // FX Experience

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.