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.

About these ads

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

  1. 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!

Trackbacks/Pingbacks

  1. Interview with Tom Schindl // JavaFX News, Demos and Insight // FX Experience - February 22, 2013

    […] the last week I’ve been working on a StyledTextArea (Blog 1, Blog 2, Blog 3). Developers interact with such a control day by day when using their favorite IDE – in […]

  2. Java desktop links of the week, February 24 | Jonathan Giles - February 24, 2013

    […] Schindl continues his work on styled text rendering in JavaFX, going so far as to improve performance by 100x, and then developing a styled text editor using a combination of the new rich text support in […]

  3. JavaFX links of the week, February 24 // JavaFX News, Demos and Insight // FX Experience - February 24, 2013

    […] Schindl continues his work on styled text rendering in JavaFX, going so far as to improve performance by 100x, and then developing a styled text editor using a combination of the new rich text support in […]

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

Follow

Get every new post delivered to your Inbox.

Join 740 other followers

%d bloggers like this: