// The z offsets should be drawn, the X offsets should not be overdrawn. That is solved
// by drawing for every z offset area one background rectangle.
List<Span> dontOverDrawSpans = new ArrayList<Span>();
Span annotationSpan = new Span(offset, length);
// add all style ranges to the list in the range of the annotation
for (StyleRange styleRange : textWidget.getStyleRanges(offset, length)) {
Span styleRangeSpan = new Span(styleRange.start, styleRange.length);
if (styleRangeSpan.getLength() > 0)
dontOverDrawSpans.add(styleRangeSpan);
}
// add text selection to the list if intersects with annotation
Point selection = textWidget.getSelection();
Span selectionSpan = new Span(selection.x, selection.y - selection.x);
if (annotationSpan.isIntersecting(selectionSpan) && selectionSpan.getLength() > 0) {
dontOverDrawSpans.add(selectionSpan);
}
Collections.sort(dontOverDrawSpans);
// TODO: Asks on mailing list for help ...