Using the Open API you can add an annotation to any base element (a model element or a symbol on the diagram pane). Annotations are used to highlight and adorn elements in the Containment tree and on the diagram pane. For example validation engine is using annotations for showing invalid elements.

Annotation has the following properties:

  • severity - like an error, warning, info, debug, fatal
  • kind - a string representing the annotation short name
  • text - a string representing the annotation text
  • target - a target base element
  • actions - an optional list of actions. They are shown in a diagram on a symbol’s smart manipulator.

To add or remove annotations, use com.nomagic.magicdraw.annotation.AnnotationManager.

 

Do not forget to call AnnotationManager.update(), when you are done with adding or removing in order to refresh UI.

More information is available in javadoc.

 You can find the code examples in

  • <installation_directory>\openapi\examples\annotations