Package com.nomagic.magicdraw.annotation
Class Annotation
java.lang.Object
com.nomagic.magicdraw.annotation.Annotation
Annotation is additional information about particular model element or symbol (target) or any other object.
In contrast with annotation target, annotations are not stored in the project. They are
rather computed in runtime.
This additional information is paint text only: description (text) and short name (kind).
Annotations can come from various sources, e.g. from OCL or some custom validation. Therefore,
many annotations can be bound to the same target. Importance of each annotation
is denoted by severity level. See
AnnotationPriorityComparator
for details.
Annotations provide ready to use action which user can make e.g. in order to fix some
problem in the model.
Annotation are identified by kind, target, severity and actions - see equals() method for details.-
Field Summary
-
Constructor Summary
ConstructorDescriptionAnnotation
(BaseElement target, Constraint constraint) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(BaseElement target, Constraint constraint, String text) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(BaseElement target, Constraint constraint, String text, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(BaseElement target, Constraint constraint, String text, List<? extends NMAction> actions, String kind) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(BaseElement target, Constraint constraint, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(Constraint constraint) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(Constraint constraint, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(EnumerationLiteral severity, String kind, String text, BaseElement target) Creates annotation object without actions.Annotation
(EnumerationLiteral severity, String kind, String text, BaseElement target, List<? extends NMAction> actions) Creates annotation object with actions.Annotation
(EnumerationLiteral severity, String kind, String text, Object target) Creates annotation object without actions.Annotation
(EnumerationLiteral severity, String kind, String text, Object target, List<? extends NMAction> actions) Creates annotation object with actions.Annotation
(Object target, Constraint constraint) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(Object target, Constraint constraint, String text, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters.Annotation
(Object target, Constraint constraint, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPainter
(AnnotationPainter painter) Add painterprotected String
constructText
(BaseElement target, Constraint constraint) void
dispose()
boolean
Returns annotation actions.Returns constraint that represents validation rule.static Icon
getIcon
(Annotation annotation) Returns icon of this annotationgetKind()
Returns annotation kind (short annotation name)Returns parent object.int
Gets project that annotation belongs to.Returns annotation severity level - one of the SeverityKind enumeration.Calculates severity level color.Annotation icon by severity.static EnumerationLiteral
getSeverityLevel
(Project project, String name) Searches for a severity level with a given name in a project.static List<EnumerationLiteral>
getSeverityLevels
(Project project) A utility method for accessing available in the project severity levels (they are mapped to Enumeration Literals).Returns annotation target - the project entity to which the annotation is bound to.Returns an object to which the annotation is bound.getText()
Returns annotation message.Returns annotation tool tip text.int
hashCode()
protected void
initInternal
(List<? extends NMAction> actions) initializes actions, severity color/icon and scopesvoid
removePainter
(AnnotationPainter painter) Remove painterprotected EnumerationLiteral
resolveSeverity
(Constraint constraint) protected void
setActions
(List<? extends NMAction> actions) void
setParentObject
(Object parentObject) Sets parent object.protected final void
setPriority
(int priority) void
setSeverityColor
(Color severityColor) Set severity color, The color may be used to draw decorations around the shape.void
setSeverityIcon
(Image severityIcon) Set annotation icon by severityvoid
Sets annotation text.void
setToolTipText
(String toolTipText) Sets annotation tool tip text.
-
Field Details
-
ERROR
- See Also:
-
INFO
- See Also:
-
WARNING
- See Also:
-
FATAL
- See Also:
-
DEBUG
- See Also:
-
-
Constructor Details
-
Annotation
Creates and initializes a newAnnotation
object from specified parameters. Actions list will be empty.- Parameters:
target
- model element or presentation element that annotation is assigned to.constraint
- constraint that is violated.
-
Annotation
public Annotation(@CheckForNull BaseElement target, Constraint constraint, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters.- Parameters:
target
- model element or presentation element that annotation is assigned to.constraint
- constraint that is violated.actions
- annotation actions, can be an empty list.
-
Annotation
Creates and initializes a newAnnotation
object from specified parameters.- Parameters:
target
- model element or presentation element that annotation is assigned to.constraint
- constraint that is violated.text
- annotation text
-
Annotation
public Annotation(@CheckForNull BaseElement target, Constraint constraint, String text, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters.- Parameters:
target
- model element or presentation element that annotation is assigned to.constraint
- constraint that is violated.text
- annotation textactions
- annotation actions, can be an empty list.
-
Annotation
public Annotation(@CheckForNull BaseElement target, Constraint constraint, String text, List<? extends NMAction> actions, @CheckForNull String kind) Creates and initializes a newAnnotation
object from specified parameters.- Parameters:
target
- model element or presentation element that annotation is assigned to.constraint
- constraint that is violated.text
- annotation textactions
- annotation actions, can be an empty list.kind
- annotation kind (short annotation name)
-
Annotation
public Annotation(EnumerationLiteral severity, String kind, String text, @CheckForNull BaseElement target) Creates annotation object without actions. None of the can be null.- Parameters:
severity
- - defines how important the annotation is, e.g. it may influence the display order of annotation if there are many for the same elementkind
- short unique nametext
- message, detailed description of the problem. It may be displayed in tooltips, tables etc..target
- model element or presentation element that annotation is assigned to.- See Also:
-
Annotation
public Annotation(EnumerationLiteral severity, String kind, String text, @CheckForNull BaseElement target, List<? extends NMAction> actions) Creates annotation object with actions. None of them can be null.- Parameters:
severity
- - defines how important the annotation is, e.g. it may influence the display order of annotation if there are many for the same elementkind
- short unique nametext
- message, detailed description of the problem. It may be displayed in tooltips, tables etc..target
- model element or presentation element that annotation is assigned to.actions
- annotation actions, can be an empty list.- See Also:
-
Annotation
Creates and initializes a newAnnotation
object from specified parameters. Actions list will be empty.- Parameters:
target
- model element or presentation element that annotation is assigned to.constraint
- constraint that is violated.
-
Annotation
Creates and initializes a newAnnotation
object from specified parameters. Target is unspecified (null).- Parameters:
constraint
- constraint that is violated.
-
Annotation
Creates and initializes a newAnnotation
object from specified parameters. Target is unspecified (null).- Parameters:
constraint
- constraint that is violated.actions
- annotation actions, can be an empty list.
-
Annotation
public Annotation(@CheckForNull Object target, Constraint constraint, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters.- Parameters:
target
- model object that annotation is assigned to.constraint
- constraint that is violated.actions
- annotation actions, can be an empty list.
-
Annotation
public Annotation(@CheckForNull Object target, Constraint constraint, String text, List<? extends NMAction> actions) Creates and initializes a newAnnotation
object from specified parameters.- Parameters:
target
- object that annotation is assigned to.constraint
- constraint that is violated.text
- annotation textactions
- annotation actions, can be an empty list.
-
Annotation
Creates annotation object without actions. None of the can be null.- Parameters:
severity
- - defines how important the annotation is, e.g. it may influence the display order of annotation if there are many for the same elementkind
- short unique nametext
- message, detailed description of the problem. It may be displayed in tooltips, tables etc..target
- object that annotation is assigned to.- See Also:
-
Annotation
public Annotation(EnumerationLiteral severity, String kind, String text, @CheckForNull Object target, List<? extends NMAction> actions) Creates annotation object with actions. None of them can be null.- Parameters:
severity
- - defines how important the annotation is, e.g. it may influence the display order of annotation if there are many for the same elementkind
- short unique nametext
- message, detailed description of the problem. It may be displayed in tooltips, tables etc..target
- object that annotation is assigned to.actions
- annotation actions, can be an empty list.- See Also:
-
-
Method Details
-
dispose
public void dispose() -
resolveSeverity
-
constructText
-
setText
Sets annotation text.- Parameters:
text
- text to set.
-
initInternal
initializes actions, severity color/icon and scopes -
getKind
Returns annotation kind (short annotation name)- Returns:
- annotation kind
-
getTarget
Returns annotation target - the project entity to which the annotation is bound to. The method can return null if the annotation is bound to any other project but to a project entity.- Returns:
- annotation target
-
getTargetObject
Returns an object to which the annotation is bound.- Returns:
- target object.
-
getProject
Gets project that annotation belongs to.- Returns:
- Project or null if the project was already disposed.
-
getText
Returns annotation message.- Returns:
- annotation message
-
getToolTipText
Returns annotation tool tip text.- Returns:
- annotation tool tip text.
-
setToolTipText
Sets annotation tool tip text.- Parameters:
toolTipText
- text to set.
-
getActions
Returns annotation actions.- Returns:
- annotation actions
-
setActions
-
getSeverity
Returns annotation severity level - one of the SeverityKind enumeration. Usually it's either an error, warning, info or debug level.- Returns:
- annotation severity
- See Also:
-
getPriority
public int getPriority()- Returns:
- Priority of this annotation. Higher severity annotations have higher priority
-
setPriority
protected final void setPriority(int priority) -
getSeverityColor
Calculates severity level color. The color may be used to draw decorations around the shape.- Returns:
- calculated severity level color
-
setSeverityColor
Set severity color, The color may be used to draw decorations around the shape.- Parameters:
severityColor
- color
-
getSeverityImageIcon
Annotation icon by severity.- Returns:
- Image element of stereotype applied to the severity level.
-
getConstraint
Returns constraint that represents validation rule.- Returns:
- constraint.
-
setSeverityIcon
Set annotation icon by severity- Parameters:
severityIcon
- icon
-
hashCode
public int hashCode() -
equals
-
getParentObject
Returns parent object.- Returns:
- parent object.
-
setParentObject
Sets parent object.- Parameters:
parentObject
- new parent object.
-
getIcon
Returns icon of this annotation- Parameters:
annotation
- annotation- Returns:
- icon
-
getSeverityLevels
A utility method for accessing available in the project severity levels (they are mapped to Enumeration Literals).- Parameters:
project
- an owner of Enumeration- Returns:
- a list of EnumerationLiterals corresponding to severity levels. Literals are sorted by priority (first is highest)
-
getSeverityLevel
Searches for a severity level with a given name in a project. -
getPainters
- Returns:
- painters
-
addPainter
Add painter- Parameters:
painter
- painter
-
removePainter
Remove painter- Parameters:
painter
- painter
-