Class AnnotationPainter
- All Implemented Interfaces:
- EventListener,- IPainter,- ITextPresentationListener,- IAnnotationModelListener,- IAnnotationModelListenerExtension,- PaintListener
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.
- Since:
- 2.1
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classBox text style strategy.static final classstatic interfaceA drawing strategy draws the decoration for an annotation onto the text widget.static interfaceA text style painting strategy draws the decoration for an annotation onto the text widget by applying aTextStyleon a givenStyleRange.static final classDrawing strategy that does nothing.static classDeprecated.static final classUnderline text style strategy.
- 
Field SummaryFields inherited from interface org.eclipse.jface.text.IPainterCONFIGURATION, INTERNAL, KEY_STROKE, MOUSE_BUTTON, SELECTION, TEXT_CHANGE
- 
Constructor SummaryConstructorsConstructorDescriptionAnnotationPainter(ISourceViewer sourceViewer, IAnnotationAccess access) Creates a new annotation painter for the given source viewer and with the given annotation access.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddAnnotationType(Object annotationType) Deprecated.As of 3.4 replaced byaddTextStyleStrategy(Object, AnnotationPainter.ITextStyleStrategy)andAnnotationPainter.UnderlineStrategyvoidaddAnnotationType(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.voidaddDrawingStrategy(Object id, AnnotationPainter.IDrawingStrategy strategy) Registers a new drawing strategy under the given ID.voidaddHighlightAnnotationType(Object annotationType) Adds the given annotation type to the list of annotation types whose annotations should be highlighted this painter.voidaddTextStyleStrategy(Object id, AnnotationPainter.ITextStyleStrategy strategy) Registers a new drawing strategy under the given ID.voidThis method is called when a text presentation is about to be applied to the text viewer.voiddeactivate(boolean redraw) Deactivates this painter.voiddispose()Disposes this painter.protected IAnnotationModelfindAnnotationModel(ISourceViewer sourceViewer) Retrieves the annotation model from the given source viewer.booleanReturns whether the list of annotation types whose annotations are painted by this painter contains at least on element.protected booleanisRepaintReason(int reason) Returns whether the given reason causes a repaint.voidmodelChanged(AnnotationModelEvent event) Called if a model change occurred on the given model.voidmodelChanged(IAnnotationModel model) Called if a model change occurred on the given model.voidpaint(int reason) Requests this painter to repaint because of the given reason.voidpaintControl(PaintEvent event) Sent when a paint event occurs for the control.voidClears the list of annotation types whose annotations are painted by this painter.voidremoveAnnotationType(Object annotationType) Removes the given annotation type from the list of annotation types whose annotations are painted by this painter.voidremoveHighlightAnnotationType(Object annotationType) Removes the given annotation type from the list of annotation types whose annotations are highlighted by this painter.voidsetAnnotationTypeColor(Object annotationType, Color color) Sets the color in which the squiggly for the given annotation type should be drawn.voidsetInlineAnnotationColor(Color color) voidsetPositionManager(IPaintPositionManager manager) Sets the paint position manager that can be used by this painter or removes any previously set paint position manager.protected booleanskip(Annotation annotation) Should the given annotation be skipped when handling draw requests?
- 
Constructor Details- 
AnnotationPainterCreates a new annotation painter for the given source viewer and with the given annotation access. The painter is not initialized, i.e. no annotation types are configured to be painted.- Parameters:
- sourceViewer- the source viewer for this painter
- access- the annotation access for this painter
 
 
- 
- 
Method Details- 
applyTextPresentationDescription copied from interface:ITextPresentationListenerThis method is called when a text presentation is about to be applied to the text viewer. The receiver is allowed to change the text presentation during that call.- Specified by:
- applyTextPresentationin interface- ITextPresentationListener
- Parameters:
- tp- the current text presentation
 
- 
modelChangedDescription copied from interface:IAnnotationModelListenerCalled if a model change occurred on the given model.Replaced by IAnnotationModelListenerExtension.modelChanged(AnnotationModelEvent).- Specified by:
- modelChangedin interface- IAnnotationModelListener
- Parameters:
- model- the changed annotation model
 
- 
modelChangedDescription copied from interface:IAnnotationModelListenerExtensionCalled if a model change occurred on the given model.- Specified by:
- modelChangedin interface- IAnnotationModelListenerExtension
- Parameters:
- event- the event to be sent out
 
- 
setAnnotationTypeColorSets the color in which the squiggly for the given annotation type should be drawn.- Parameters:
- annotationType- the annotation type
- color- the color
 
- 
addAnnotationTypeDeprecated.As of 3.4 replaced byaddTextStyleStrategy(Object, AnnotationPainter.ITextStyleStrategy)andAnnotationPainter.UnderlineStrategyAdds the given annotation type to the list of annotation types whose annotations should be painted by this painter using squiggly drawing. If the annotation type is already in this list, this method is without effect.- Parameters:
- annotationType- the annotation type
 
- 
addAnnotationTypeAdds the given annotation type to the list of annotation types whose annotations should be painted by this painter using the given strategy. If the annotation type is already in this list, the old strategy gets replaced.- Parameters:
- annotationType- the annotation type
- strategyID- the id of the drawing or text style strategy that should be used for this annotation type
- Since:
- 3.0
 
- 
addDrawingStrategyRegisters a new drawing strategy under the given ID. If there is already a strategy registered underid, the old strategy gets replaced.The given id can be referenced when adding annotation types, see addAnnotationType(Object, Object).- Parameters:
- id- the identifier under which the strategy can be referenced, not- null
- strategy- the new strategy
- Since:
- 3.0
 
- 
addTextStyleStrategyRegisters a new drawing strategy under the given ID. If there is already a strategy registered underid, 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. - Parameters:
- id- the identifier under which the strategy can be referenced, not- null
- strategy- the new strategy
- Since:
- 3.4
- See Also:
 
- 
addHighlightAnnotationTypeAdds the given annotation type to the list of annotation types whose annotations should be highlighted this painter. If the annotation type is already in this list, this method is without effect.Note: The annotations will only be painted if this painter has been registered as text presentation listener on the viewer. - Parameters:
- annotationType- the annotation type
- Since:
- 3.0
- See Also:
 
- 
removeAnnotationTypeRemoves the given annotation type from the list of annotation types whose annotations are painted by this painter. If the annotation type is not in this list, this method is without effect.- Parameters:
- annotationType- the annotation type
 
- 
removeHighlightAnnotationTypeRemoves the given annotation type from the list of annotation types whose annotations are highlighted by this painter. If the annotation type is not in this list, this method is without effect.- Parameters:
- annotationType- the annotation type
- Since:
- 3.0
 
- 
removeAllAnnotationTypespublic void removeAllAnnotationTypes()Clears the list of annotation types whose annotations are painted by this painter.
- 
isPaintingAnnotationspublic boolean isPaintingAnnotations()Returns whether the list of annotation types whose annotations are painted by this painter contains at least on element.- Returns:
- trueif there is an annotation type whose annotations are painted
 
- 
disposepublic void dispose()Description copied from interface:IPainterDisposes this painter. Prior to disposing, a painter should be deactivated. A disposed painter can not be reactivated.
- 
paintControlDescription copied from interface:PaintListenerSent when a paint event occurs for the control.- Specified by:
- paintControlin interface- PaintListener
- Parameters:
- event- an event containing information about the paint
 
- 
skipShould the given annotation be skipped when handling draw requests?- Parameters:
- annotation- the annotation
- Returns:
- trueiff the given annotation should be skipped when handling draw requests
- Since:
- 3.0
 
- 
deactivatepublic void deactivate(boolean redraw) Description copied from interface:IPainterDeactivates this painter. If the painter is inactive, this call does not have any effect.redrawindicates whether the painter should remove any decoration it previously applied. A deactivated painter can be reactivated by callingpaint.- Specified by:
- deactivatein interface- IPainter
- Parameters:
- redraw-- trueif any previously applied decoration should be removed
- See Also:
 
- 
isRepaintReasonprotected boolean isRepaintReason(int reason) Returns whether the given reason causes a repaint.- Parameters:
- reason- the reason
- Returns:
- trueif repaint reason,- falseotherwise
- Since:
- 3.0
 
- 
findAnnotationModelRetrieves the annotation model from the given source viewer.- Parameters:
- sourceViewer- the source viewer
- Returns:
- the source viewer's annotation model or nullif none can be found
- Since:
- 3.0
 
- 
paintpublic void paint(int reason) Description copied from interface:IPainterRequests this painter to repaint because of the given reason. Based on the given reason the painter can decide whether it will repaint or not. If it repaints and is inactive, it will activate itself.
- 
setPositionManagerDescription copied from interface:IPainterSets the paint position manager that can be used by this painter or removes any previously set paint position manager.- Specified by:
- setPositionManagerin interface- IPainter
- Parameters:
- manager- the paint position manager or- null
 
- 
setInlineAnnotationColor- Since:
- 3.26
 
- 
getInlineAnnotationColor- Since:
- 3.26
 
 
- 
AnnotationPainter.UnderlineStrategy