Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.text.source
Class AnnotationPainter


java.lang.Object
  extended by 
org.eclipse.jface.text.source.AnnotationPainter
All Implemented Interfaces:
EventListener, IPainter, ITextPresentationListener, IAnnotationModelListener, IAnnotationModelListenerExtension, PaintListener, org.eclipse.swt.internal.SWTEventListener

public class AnnotationPainter
extends Object
implements IPainter, PaintListener, IAnnotationModelListener, IAnnotationModelListenerExtension, ITextPresentationListener

Paints decorations for annotations provided by an annotation model and/or highlights them in the associated source viewer.

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 Summary
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.
 
Field Summary
 
Fields inherited from interface org.eclipse.jface.text. IPainter
CONFIGURATION, INTERNAL, KEY_STROKE, MOUSE_BUTTON, SELECTION, TEXT_CHANGE
 
Constructor Summary
AnnotationPainter ( ISourceViewer sourceViewer, IAnnotationAccess access)
          Creates a new annotation painter for the given source viewer and with the given annotation access.
 
Method Summary
 void addAnnotationType ( Object annotationType)
          Adds the given annotation type to the list of annotation types whose annotations should be painted by this painter using squiggly drawing.
 void addAnnotationType ( Object annotationType, Object drawingStrategyID)
          Adds the given annotation type to the list of annotation types whose annotations should be painted by this painter using the given drawing 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?
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationPainter

public AnnotationPainter(
ISourceViewer sourceViewer,
                         
IAnnotationAccess access)
Creates 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 Detail

applyTextPresentation

public void applyTextPresentation(
TextPresentation tp)
Description copied from interface: ITextPresentationListener
This 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:
applyTextPresentation in interface ITextPresentationListener
Parameters:
tp - the current text presentation

modelChanged

public void modelChanged(
IAnnotationModel model)
Description copied from interface: IAnnotationModelListener
Called if a model change occurred on the given model.

Replaced by IAnnotationModelListenerExtension.modelChanged(AnnotationModelEvent).

Specified by:
modelChanged in interface IAnnotationModelListener
Parameters:
model - the changed annotation model

modelChanged

public void modelChanged(
AnnotationModelEvent event)
Description copied from interface: IAnnotationModelListenerExtension
Called if a model change occurred on the given model.

Specified by:
modelChanged in interface IAnnotationModelListenerExtension
Parameters:
event - the event to be sent out

setAnnotationTypeColor

public void setAnnotationTypeColor(
Object annotationType,
                                   
Color color)
Sets the color in which the squiggly for the given annotation type should be drawn.

Parameters:
annotationType - the annotation type
color - the color

addAnnotationType

public void addAnnotationType(
Object annotationType)
Adds 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

addAnnotationType

public void addAnnotationType(
Object annotationType,
                              
Object drawingStrategyID)
Adds the given annotation type to the list of annotation types whose annotations should be painted by this painter using the given drawing strategy. If the annotation type is already in this list, the old drawing strategy gets replaced.

Parameters:
annotationType - the annotation type
drawingStrategyID - the id of the drawing strategy that should be used for this annotation type
Since:
3.0

addDrawingStrategy

public void addDrawingStrategy(
Object id,
                               
AnnotationPainter.IDrawingStrategy strategy)
Registers a new drawing strategy under the given ID. If there is already a strategy registered under id, 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

addTextStyleStrategy

public void addTextStyleStrategy(
Object id,
                                 
AnnotationPainter.ITextStyleStrategy strategy)
Registers a new drawing strategy under the given ID. If there is already a strategy registered under id, 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.4

addHighlightAnnotationType

public void addHighlightAnnotationType(
Object annotationType)
Adds 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.

Parameters:
annotationType - the annotation type
Since:
3.0

removeAnnotationType

public void removeAnnotationType(
Object annotationType)
Removes 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

removeHighlightAnnotationType

public void removeHighlightAnnotationType(
Object annotationType)
Removes 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

removeAllAnnotationTypes

public void removeAllAnnotationTypes()
Clears the list of annotation types whose annotations are painted by this painter.


isPaintingAnnotations

public boolean isPaintingAnnotations()
Returns whether the list of annotation types whose annotations are painted by this painter contains at least on element.

Returns:
true if there is an annotation type whose annotations are painted

dispose

public void dispose()
Description copied from interface: IPainter
Disposes this painter. Prior to disposing, a painter should be deactivated. A disposed painter can not be reactivated.

Specified by:
dispose in interface IPainter
See Also:
IPainter.deactivate(boolean)

paintControl

public void paintControl(
PaintEvent event)
Description copied from interface: PaintListener
Sent when a paint event occurs for the control.

Specified by:
paintControl in interface PaintListener
Parameters:
event - an event containing information about the paint

skip

protected boolean skip(
Annotation annotation)
Should the given annotation be skipped when handling draw requests?

Parameters:
annotation - the annotation
Returns:
true iff the given annotation should be skipped when handling draw requests
Since:
3.0

deactivate

public void deactivate(boolean redraw)
Description copied from interface: IPainter
Deactivates this painter. If the painter is inactive, this call does not have any effect. redraw indicates whether the painter should remove any decoration it previously applied. A deactivated painter can be reactivated by calling paint.

Specified by:
deactivate in interface IPainter
Parameters:
redraw - true if any previously applied decoration should be removed
See Also:
IPainter.paint(int)

isRepaintReason

protected boolean isRepaintReason(int reason)
Returns whether the given reason causes a repaint.

Parameters:
reason - the reason
Returns:
true if repaint reason, false otherwise
Since:
3.0

findAnnotationModel

protected 
IAnnotationModel findAnnotationModel(
ISourceViewer sourceViewer)
Retrieves the annotation model from the given source viewer.

Parameters:
sourceViewer - the source viewer
Returns:
the source viewer's annotation model or null if none can be found
Since:
3.0

paint

public void paint(int reason)
Description copied from interface: IPainter
Requests 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.

Specified by:
paint in interface IPainter
Parameters:
reason - the repaint reason, value is one of the constants defined in this interface

setPositionManager

public void setPositionManager(
IPaintPositionManager manager)
Description copied from interface: IPainter
Sets the paint position manager that can be used by this painter or removes any previously set paint position manager.

Specified by:
setPositionManager in interface IPainter
Parameters:
manager - the paint position manager or null

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire