# Class LineContentAnnotation

java.lang.Object
org.eclipse.jface.text.source.Annotation
org.eclipse.jface.text.source.inlined.AbstractInlinedAnnotation
org.eclipse.jface.text.source.inlined.LineContentAnnotation

public class LineContentAnnotation extends AbstractInlinedAnnotation
Inlined annotation which is drawn in the line content and which takes some place with a given width.

Since:
  3.13

## Field Summary

### Fields inherited from class AbstractInlinedAnnotation

`TYPE`

### Fields inherited from class Annotation

`TYPE_UNKNOWN`

## Constructor Summary

Constructors
Constructor
Description
`LineContentAnnotation(Position position, ISourceViewer viewer)`
Line content annotation constructor.
`LineContentAnnotation(Position position, ISourceViewer viewer, Consumer<MouseEvent> onMouseHover, Consumer<MouseEvent> onMouseOut, Consumer<MouseEvent> onMouseMove)`
Line content annotation constructor.

## Method Summary

Modifier and Type
Method
Description
`final void`
`draw(GC gc, StyledText textWidget, int offset, int length, Color color, int x, int y)`
Draw the inlined annotation.
`protected int`
`drawAndComputeWidth(GC gc, StyledText textWidget, int offset, int length, Color color, int x, int y)`
Draw the inlined annotation.
`final int`
`getWidth()`
Returns the annotation width.

### Methods inherited from class AbstractInlinedAnnotation

`getAction, getMinings, getPosition, getTextWidget, getViewer, isInVisibleLines, isInVisibleLines, onMouseHover, onMouseMove, onMouseOut, redraw`

### Methods inherited from class Annotation

`getText, getType, isMarkedDeleted, isPersistent, markDeleted, setText, setType`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### LineContentAnnotation

public LineContentAnnotation(Position position, ISourceViewer viewer)
Line content annotation constructor.

Parameters:
  `position` - the position where the annotation must be drawn.
  `viewer` - the `ISourceViewer` where the annotation must be drawn.

### LineContentAnnotation

public LineContentAnnotation(Position position, ISourceViewer viewer, Consumer<MouseEvent> onMouseHover, Consumer<MouseEvent> onMouseOut, Consumer<MouseEvent> onMouseMove)
Line content annotation constructor.

Parameters:
  `position` - the position where the annotation must be drawn.
  `viewer` - the `ISourceViewer` where the annotation must be drawn.
  `onMouseHover` - the consumer to be called on mouse hover. If set, the implementor needs to take care of setting the cursor if wanted.
  `onMouseOut` - the consumer to be called on mouse out. If set, the implementor needs to take care of resetting the cursor.
  `onMouseMove` - the consumer to be called on mouse move
Since:
  3.27

## Method Details

### getWidth

public final int getWidth()
Returns the annotation width. By default it computes the well width for the text annotation.

Returns:
  the annotation width.

### draw

public final void draw(GC gc, StyledText textWidget, int offset, int length, Color color, int x, int y)
Draw the inlined annotation. By default it draw the text of the annotation with gray color. User can override this method to draw anything.

After drawn, compute the text width and update it.

Overrides:
  `draw` in class `AbstractInlinedAnnotation`
Parameters:
  `gc` - the graphics context
  `textWidget` - the text widget to draw on
  `offset` - the offset
  `length` - the length of the line
  `color` - the color of the line
  `x` - the x position of the annotation
  `y` - the y position of the annotation

### drawAndComputeWidth

protected int drawAndComputeWidth(GC gc, StyledText textWidget, int offset, int length, Color color, int x, int y)
Draw the inlined annotation. By default it draws the text of the annotation with gray color. User can override this method to draw anything.

Parameters:
  `gc` - the graphics context
  `textWidget` - the text widget to draw on
  `offset` - the offset of the line
  `length` - the length of the line
  `color` - the color of the line
  `x` - the x position of the annotation
  `y` - the y position of the annotation
Returns:
  the text width.