How to draw Annotation in SourceViewer [message #1717685] |
Tue, 15 December 2015 20:22 |
|
Hi,
I want to decorate some text in my SourceViewer with an added visual presentation (f. e. like squiggles). I tried to use Annotations.
I added the AnnotationModel
viewer.setDocument(new Document(), new AnnotationModel());
and added the AnnotationPainter:
AnnotationPainter painter = new AnnotationPainter(viewer, annotationAccess);
painter.addDrawingStrategy(Constants.ANNOTATION_VARIABLE_TYPE, new MySquigglesStrategy());
painter.addAnnotationType(Constants.ANNOTATION_VARIABLE_TYPE, Constants.ANNOTATION_VARIABLE_TYPE);
painter.setAnnotationTypeColor(Constants.ANNOTATION_VARIABLE_TYPE, viewer.getTextWidget().getForeground());
And on some action I am adding the Annotation to the AnnotationModel:
Annotation annotation = new Annotation(Constants.ANNOTATION_VARIABLE_TYPE, false, variable.getName());
sourceViewer.getAnnotationModel().addAnnotation(annotation, position);
But nothing is painted. The draw method of my drawing strategy is not called at all. How/When does the AnnotationPainter gets the info that it has something to paint. I cannot see the connection between the AnnotationModel and the AnnotationPainter.
Any idea?
Thanx in advance
Mihael
EDIT: by calling AnnotationPainter.paint(reason) it will set the annotation model internally. But I can't believe that this is the way to go. Any help is very much appreciated.
[Updated on: Sun, 20 December 2015 06:16] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01853 seconds