Blog
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: Video 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.