Our modeling tools allow displaying symbols that are related to a given symbol via relationships. The com.nomagic.magicdraw.uml.symbols.DisplayRelatedSymbols class provides API methods for this. Using this class you can control any of the following behaviors for displaying the related symbols logic:

  • What relationship types should be included.
  • The depth of a relationship tree.
  • Whether or not existing symbols should be reused.


Example: Displaying related generalizations and interface realizations

    SessionManager sessionManager = SessionManager.getInstance();
    sessionManager.createSession(project, "Display related");
 
    Set linkTypes = new HashSet();
    linkTypes.add(new LinkType(Generalization.class));
    linkTypes.add(new LinkType(InterfaceRealization.class));
    
    DisplayRelatedSymbolsInfo info = new DisplayRelatedSymbolsInfo(linkTypes);
    info.setDepthLimited(true);
    info.setDepthLimit(3);
 
    PresentationElement view = ...; // A symbol for which you need to invoke the displaying related symbols action.
    DisplayRelatedSymbols.displayRelatedSymbols(view, info);
    sessionManager.closeSession(project);

 You can find the code examples in

  • <installation_directory>\openapi\examples\displayrelated
Related pages