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.

5 thoughts on “Speeding up TextFlow for JavaFX8 (by a factor of ~100)

  1. Daniel Zimmermann February 19, 2013 / 6:42 pm

    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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s