IAnnotationAccessExtension annotationAccessExtension= null;
if (fAnnotationAccess instanceof IAnnotationAccessExtension)
annotationAccessExtension= (IAnnotationAccessExtension) fAnnotationAccess;
ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
StyledText textWidget= fTextViewer.getTextWidget();
fScrollPos= textWidget.getTopPixel();
Point dimension= fCanvas.getSize();
// draw Annotations
Rectangle r= new Rectangle(0, 0, 0, 0);
int maxLayer= 1; // loop at least once through layers.
for (int layer= 0; layer < maxLayer; layer++) {
Iterator iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
IAnnotationPresentation annotationPresentation= null;
Annotation annotation= (Annotation) iter.next();
int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
if (annotationAccessExtension != null)
lay= annotationAccessExtension.getLayer(annotation);
else if (annotation instanceof IAnnotationPresentation) {
annotationPresentation= (IAnnotationPresentation)annotation;
lay= annotationPresentation.getLayer();
}
maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
if (lay != layer) // wrong layer: skip annotation
continue;
Position position= fModel.getPosition(annotation);
if (position == null)
continue;
IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(position.getOffset(), position.getLength()));
if (widgetRegion == null)
continue;
int startLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset());
if (startLine == -1)
continue;
int endLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset() + Math.max(widgetRegion.getLength() -1, 0));
if (endLine == -1)
continue;
r.x= 0;
r.y= JFaceTextUtil.computeLineHeight(textWidget, 0, startLine, startLine) - fScrollPos;