SciChart Android 2D Charts API > Annotations API > Common Annotations Features
Common Annotations Features

All the Annotation classes provided by SciChart implement the IAnnotation interface and derive from the AnnotationBase class. These provide an API which allows to put Android Views onto a chart and interact with them.

Please refer to the What is an Annotation article for the complete list of all the Annotation types available out of the box in SciChart.

Common Features of Annotations

The table below lists all the methods declared by the IAnnotation interface:

Feature Description
getX1()setX1() X1, X2, Y1, Y2 specify the position of an annotation on a SciChartSurface. These are chart coordinates, not device (screen or pixel) coordinates. To find out about coordinate transformation in SciChart, please refer to the Convert Pixels to Data Coordinates article.
getX2()setX2() X1, X2, Y1, Y2 specify the position of an annotation on a SciChartSurface. These are chart coordinates, not device (screen or pixel) coordinates. To find out about coordinate transformation in SciChart, please refer to the Convert Pixels to Data Coordinates article.
getY1()setY1() X1, X2, Y1, Y2 specify the position of an annotation on a SciChartSurface. These are chart coordinates, not device (screen or pixel) coordinates. To find out about coordinate transformation in SciChart, please refer to the Convert Pixels to Data Coordinates article.
getY2()setY2() X1, X2, Y1, Y2 specify the position of an annotation on a SciChartSurface. These are chart coordinates, not device (screen or pixel) coordinates. To find out about coordinate transformation in SciChart, please refer to the Convert Pixels to Data Coordinates article.
getXAxisId()setXAxisId() Specifies the ID of X Axis that this annotation is measured against.
getYAxisId()setYAxisId() Specifies the ID of Y Axis that this annotation is measured against.
isSelected()setSelected() Makes an annotation Selected. When Selected, round resizing markers appears at the ends or corners of the annotation which can be used to resize it. Resizing markers can be changed via the setResizingGrip() method (see the following table).
isEditable()setIsEditable() Specifies whether an annotation is available for interaction. When Editable, the annotation can be Selected, Moved and Resized by a user with a finger.
isHidden()setIsHidden() Hides or shows an annotation.
getDragDirections()setDragDirections() Allows to constrain drag directions for an annotation. Accepts a member of the Direction2D enumeration.
getResizeDirections()setResizeDirections() Allows to constrain resize directions for an annotation. Accepts a member of the Direction2D enumeration.
setOnAnnotationDragListener() Allows to appoint OnAnnotationDragListener to receive notifications about user interactions with an annotation.
setOnAnnotationSelectionChangeListener() Allows to appoint OnAnnotationSelectionChangeListener to receive notifications about user interactions with an annotation.
setOnAnnotationIsHiddenChangeListener() Allows to appoint OnAnnotationIsHiddenChangeListener to receive notifications when an annotation gets hidden or visible.
moveAnnotation() Moves an annotation by the specified amount in horizontal and vertical directions.
refresh() Redraws an annotation without invalidating the ParentSurface. Calls update() internally.
update() Redraws an annotation without invalidating the ParentSurface.

Methods, inherited from the AnnotationBase:

Feature Description
getResizingGrip()setResizingGrip() Determines what resizing markers look like. Custom ones have to implement IResizingGrip.
getCoordinateMode()setCoordinateMode()

Determines whether X1, X2, Y1, Y2 coordinates are in chart coordinates or in relative screen coordinates. Relative coordinates range from 0 to 1, where 1 refers to the full Width or Height of the canvas.

Accepts a member of the AnnotationCoordinateMode enumeration.

getAnnotationsSurface()setAnnotationsSurface()

Specifies a surface to place an annotation on. All possible options are declared by the AnnotationSurfaceEnum enumeration.

Note: This feature doesn't work for all the annotation types. For now, it has an effect on AxisMarkerAnnotations only. Other annotation types will ignore it.

For more information about specifics of any annotation type, please refer to the corresponding article on that annotation type. The full list of annotation classes provided by SciChart can be found in the What is an Annotation article.

Annotation Alignment (Anchor Points)

There is the subset of classes among all the annotation types that allows their instances to be aligned relative to the X1,Y1 control point. The base class responsible for this behavior is called AnchorPointAnnotation. It adds two methods, setHorizontalAnchorPoint() and setVerticalAnchorPoint(), that accept HorizontalAnchorPoint and VerticalAnchorPoint enumeration members correspondingly. The image below illustrates how it works:

The annotation types that derive from AnchorPointAnnotation are TextAnnotationCustomAnnotation and AxisMarkerAnnotation. As the information above implies, annotations of these types are controlled by the X1,Y1 coordinates only. The X2,Y2 coordinates have no impact on placement and are simply ignored.

See Also