public class AnnotationPainter extends Object implements IPainter, PaintListener, IAnnotationModelListener, IAnnotationModelListenerExtension, ITextPresentationListener
The annotation painter can be configured with drawing strategies. A drawing strategy defines the visual presentation of a particular type of annotation decoration.
Clients usually instantiate and configure objects of this class.
Modifier and Type | Class and Description |
---|---|
static class |
AnnotationPainter.BoxStrategy
Box text style strategy.
|
static class |
AnnotationPainter.HighlightingStrategy |
static interface |
AnnotationPainter.IDrawingStrategy
A drawing strategy draws the decoration for an annotation onto the text widget.
|
static interface |
AnnotationPainter.ITextStyleStrategy
A text style painting strategy draws the decoration for an annotation
onto the text widget by applying a
TextStyle on a given
StyleRange . |
static class |
AnnotationPainter.NullStrategy
Drawing strategy that does nothing.
|
static class |
AnnotationPainter.SquigglesStrategy
Deprecated.
As of 3.4, replaced by
AnnotationPainter.UnderlineStrategy |
static class |
AnnotationPainter.UnderlineStrategy
Underline text style strategy.
|
CONFIGURATION, INTERNAL, KEY_STROKE, MOUSE_BUTTON, SELECTION, TEXT_CHANGE
Constructor and Description |
---|
AnnotationPainter(ISourceViewer sourceViewer,
IAnnotationAccess access)
Creates a new annotation painter for the given source viewer and with the
given annotation access.
|
Modifier and Type | Method and Description |
---|---|
void |
addAnnotationType(Object annotationType)
Deprecated.
As of 3.4 replaced by
addTextStyleStrategy(Object, AnnotationPainter.ITextStyleStrategy) and
AnnotationPainter.UnderlineStrategy |
void |
addAnnotationType(Object annotationType,
Object strategyID)
Adds the given annotation type to the list of annotation types whose annotations should be
painted by this painter using the given strategy.
|
void |
addDrawingStrategy(Object id,
AnnotationPainter.IDrawingStrategy strategy)
Registers a new drawing strategy under the given ID.
|
void |
addHighlightAnnotationType(Object annotationType)
Adds the given annotation type to the list of annotation types whose
annotations should be highlighted this painter.
|
void |
addTextStyleStrategy(Object id,
AnnotationPainter.ITextStyleStrategy strategy)
Registers a new drawing strategy under the given ID.
|
void |
applyTextPresentation(TextPresentation tp)
This method is called when a text presentation is about to be applied to
the text viewer.
|
void |
deactivate(boolean redraw)
Deactivates this painter.
|
void |
dispose()
Disposes this painter.
|
protected IAnnotationModel |
findAnnotationModel(ISourceViewer sourceViewer)
Retrieves the annotation model from the given source viewer.
|
boolean |
isPaintingAnnotations()
Returns whether the list of annotation types whose annotations are painted
by this painter contains at least on element.
|
protected boolean |
isRepaintReason(int reason)
Returns whether the given reason causes a repaint.
|
void |
modelChanged(AnnotationModelEvent event)
Called if a model change occurred on the given model.
|
void |
modelChanged(IAnnotationModel model)
Called if a model change occurred on the given model.
|
void |
paint(int reason)
Requests this painter to repaint because of the given reason.
|
void |
paintControl(PaintEvent event)
Sent when a paint event occurs for the control.
|
void |
removeAllAnnotationTypes()
Clears the list of annotation types whose annotations are
painted by this painter.
|
void |
removeAnnotationType(Object annotationType)
Removes the given annotation type from the list of annotation types whose
annotations are painted by this painter.
|
void |
removeHighlightAnnotationType(Object annotationType)
Removes the given annotation type from the list of annotation types whose
annotations are highlighted by this painter.
|
void |
setAnnotationTypeColor(Object annotationType,
Color color)
Sets the color in which the squiggly for the given annotation type should be drawn.
|
void |
setPositionManager(IPaintPositionManager manager)
Sets the paint position manager that can be used by this painter or removes any previously
set paint position manager.
|
protected boolean |
skip(Annotation annotation)
Should the given annotation be skipped when handling draw requests?
|
public AnnotationPainter(ISourceViewer sourceViewer, IAnnotationAccess access)
sourceViewer
- the source viewer for this painteraccess
- the annotation access for this painterpublic void applyTextPresentation(TextPresentation tp)
ITextPresentationListener
applyTextPresentation
in interface ITextPresentationListener
tp
- the current text presentationpublic void modelChanged(IAnnotationModel model)
IAnnotationModelListener
Replaced by IAnnotationModelListenerExtension.modelChanged(AnnotationModelEvent)
.
modelChanged
in interface IAnnotationModelListener
model
- the changed annotation modelpublic void modelChanged(AnnotationModelEvent event)
IAnnotationModelListenerExtension
modelChanged
in interface IAnnotationModelListenerExtension
event
- the event to be sent outpublic void setAnnotationTypeColor(Object annotationType, Color color)
annotationType
- the annotation typecolor
- the colorpublic void addAnnotationType(Object annotationType)
addTextStyleStrategy(Object, AnnotationPainter.ITextStyleStrategy)
and
AnnotationPainter.UnderlineStrategy
annotationType
- the annotation typepublic void addAnnotationType(Object annotationType, Object strategyID)
annotationType
- the annotation typestrategyID
- the id of the drawing or text style strategy that should be used for this
annotation typepublic void addDrawingStrategy(Object id, AnnotationPainter.IDrawingStrategy strategy)
id
, the old strategy gets replaced.
The given id can be referenced when adding annotation types, see
addAnnotationType(Object, Object)
.
id
- the identifier under which the strategy can be referenced, not null
strategy
- the new strategypublic void addTextStyleStrategy(Object id, AnnotationPainter.ITextStyleStrategy strategy)
id
, the old strategy gets
replaced.
The given id can be referenced when adding annotation types, see
addAnnotationType(Object, Object)
.
Note: The annotations will only be painted if this painter has been registered as text presentation listener on the viewer.
id
- the identifier under which the strategy can be referenced, not null
strategy
- the new strategyITextViewerExtension4.addTextPresentationListener(ITextPresentationListener)
public void addHighlightAnnotationType(Object annotationType)
Note: The annotations will only be painted if this painter has been registered as text presentation listener on the viewer.
annotationType
- the annotation typeITextViewerExtension4.addTextPresentationListener(ITextPresentationListener)
public void removeAnnotationType(Object annotationType)
annotationType
- the annotation typepublic void removeHighlightAnnotationType(Object annotationType)
annotationType
- the annotation typepublic void removeAllAnnotationTypes()
public boolean isPaintingAnnotations()
true
if there is an annotation type whose annotations are paintedpublic void dispose()
IPainter
dispose
in interface IPainter
IPainter.deactivate(boolean)
public void paintControl(PaintEvent event)
PaintListener
paintControl
in interface PaintListener
event
- an event containing information about the paintprotected boolean skip(Annotation annotation)
annotation
- the annotationtrue
iff the given annotation should be
skipped when handling draw requestspublic void deactivate(boolean redraw)
IPainter
redraw
indicates whether the painter
should remove any decoration it previously applied. A deactivated painter
can be reactivated by calling paint
.deactivate
in interface IPainter
redraw
- true
if any previously applied decoration
should be removedIPainter.paint(int)
protected boolean isRepaintReason(int reason)
reason
- the reasontrue
if repaint reason, false
otherwiseprotected IAnnotationModel findAnnotationModel(ISourceViewer sourceViewer)
sourceViewer
- the source viewernull
if none can be foundpublic void paint(int reason)
IPainter
public void setPositionManager(IPaintPositionManager manager)
IPainter
setPositionManager
in interface IPainter
manager
- the paint position manager or null
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.