Main Content

Stateflow.Annotation

Annotation in chart, state, box, or function

    Description

    Use Stateflow.Annotation objects to include descriptive comments in your chart. Annotations can contain any combination of:

    • Text

    • Images

    • Equations using TeX commands

    • Hyperlinks that open a website or perform MATLAB® functions

    For more information, see Add Descriptive Comments in a Chart.

    Creation

    Description

    example

    annotation = Stateflow.Annotation(parent) creates a Stateflow.Annotation object in a parent chart, state, box, or graphical function.

    Input Arguments

    expand all

    Parent for the new annotation, specified as a Stateflow® API object of one of these types:

    Properties

    expand all

    Stateflow API objects have properties that correspond to the values you set in the Stateflow Editor. To access or modify a property, use dot notation. To access or modify multiple properties for multiple API objects, use the get and set functions, respectively. For more information, see Modify Properties and Call Functions of Stateflow Objects.

    Content

    Text for the annotation, specified as a character vector.

    Alignment of the annotation text, specified as 'LEFT', 'CENTER', or 'RIGHT'.

    Format of the annotation text, specified as 'OFF', 'RICH', or 'TEX'.

    This property is read-only.

    Annotation text without formatting, specified as a character vector.

    This property is read-only.

    Whether the annotation contains an image, specified as a numeric or logical 1 (true) or 0 (false).

    Graphical Appearance

    Position and size of annotation box, specified as a four-element numeric vector of the form [left top width height].

    Space between the text and the border of the annotation box, specified as a four-element numeric vector of the form [left top right bottom].

    Whether to display a drop shadow around the annotation box, specified as a numeric or logical 1 (true) or 0 (false).

    Whether to fix height of the annotation box, specified as a numeric or logical 1 (true) or 0 (false).

    • true — Fixes the height of the annotation box and hides content that is longer than the box.

    • false — Resizes the annotation box vertically as you add content.

    Whether to fix height of the annotation box, specified as a numeric or logical 1 (true) or 0 (false).

    • true — Fixes the width of the annotation box and wraps text that is longer than the box.

    • false — Resizes the annotation box horizontally as you add content.

    Background color for the annotation, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1. This property applies only when the AutoBackgroundColor property is false.

    Foreground color for the annotation, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1. This property applies only when the AutoForegroundColor property is false.

    Whether to use the default background color, specified as a numeric or logical 1 (true) or 0 (false).

    • true — Use the default color specified by the ChartColor property of the chart that contains the annotation.

    • false — Use the color specified by the BackgroundColor property of the annotation.

    Whether to use the default foreground color, specified as a numeric or logical 1 (true) or 0 (false).

    • true — Use the default color specified by the StateLabelColor property of the chart that contains the annotation.

    • false — Use the color specified by the ForegroundColor property of the annotation.

    Font for the annotation text, specified as a Stateflow.NoteFont object with these properties:

    • Name — Font name, specified as a character vector. This property is read-only. The StateFont.Name property of the chart that contains the annotation sets the value of this property.

    • Angle — Font angle, specified as 'NORMAL' or 'ITALIC'.

    • Weight — Font weight, specified as 'NORMAL' or 'BOLD'.

    • Size — Font size, specified as a scalar.

    Example: annotation.Font.Angle = 'ITALIC';

    Example: annotation.Font.Weight = 'BOLD';

    Example: annotation.Font.Size = 8;

    Callbacks

    Callback on click, specified as a character vector. This callback contains MATLAB code to execute when to execute when you click the annotation.

    Callback at model load, specified as a character vector. This callback contains MATLAB code to execute when you load the model that contains the annotation.

    Callback at delete, specified as a character vector. This callback contains MATLAB code to execute before you delete the annotation.

    Whether to use the annotation text as a callback, specified as a numeric or logical 1 (true) or 0 (false). When this property is enabled, the contents of the Text property is used as the callback when you click the annotation.

    Hierarchy

    This property is read-only.

    Chart that contains the annotation, specified as a Stateflow.Chart object.

    This property is read-only.

    Subviewer for the annotation, specified as a Stateflow.Chart, Stateflow.State, Stateflow.Box, or Stateflow.Function object. The subviewer is the chart or subchart where you can graphically view the annotation.

    This property is read-only.

    Machine that contains the annotation, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the parent of the annotation in the model hierarchy, specified as a character vector.

    Identification

    Description for the annotation, specified as a character vector.

    Document link for the annotation, specified as a character vector.

    User-defined tag for the annotation, specified as data of any type.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Use this property to distinguish the annotation from other objects in the model. The value of this property is reassigned every time you start a new MATLAB session and may be recycled after an object is deleted.

    Object Functions

    getParentIdentify parent of object
    dialogOpen properties dialog box
    viewDisplay object in editing environment
    fitToViewZoom in on graphical object
    setImageInsert image into annotation

    Examples

    collapse all

    Add an annotation in the chart ch. Set its content to 'This is an annotation.'

    annotation = Stateflow.Annotation(ch);
    annotation.Text = 'This is an annotation';

    Add an annotation in the chart ch. Use the file myImageFile.png, which is located in the folder myfolder/annotation_images, as the image for the annotation.

    annotation = Stateflow.Annotation(ch);
    setImage(annotation, ...
        fullfile('myfolder','annotation_images','myImageFile.png');
    Introduced in R2017b