It is possible to create Java implementation describing what model element or presentation element should a Legend Item adorn in a diagram.  

  1. The Java class should be implemented following the very same rules as when creating implementation for a validation rule. Each com.nomagic.magicdraw.annotation.Annotation object returned by the rule will cause the targeted model or presentation element to be adorned in the diagram (but only if the Legend is used in that diagram).
  2. Specify the full class name as the value of "Implementation" property for the Legend Item in the modeling application. 
  3. Compile Java code, resulting in .class files possibly contained by a .jar file.
  4. Ensure that your modeling tool can find and load these classes. You can place them in the program classpath or use the modeling tool plugins mechanism.

Example

See AdornComponentsOfInterestInDiagramValidator.java example implementation in the <program installation directory>\openapi\examples\legendItem directory.


Also see: Legends