How to set icon to stereotype via plugin

Visual Paradigm allows user to using custom graphic to present stereotypes. Besides using GUI, this can also being configured using Plugin API. In this article you will learn how to configure stereotype icon using Plugin.

To set icon to stereotype:

  1. Create File object point to your image file.
    File f = new File(%PATH_TO_YOUR_IMAGE%);
  2. Use ProjectManager to obtain the icon path for particular stereotype.
    IStereotype st = //your stereotype, either create from IModelElementFactory or load from your project
    ProjectManager pm = ApplicationManager.instance().getProjectManager();
    String path = pm.getStereotypeIconPath(st);
  3. Call ProjectManger to import the stereotype icon.
    try {
        pm.importStereotypeIcon(path, f, proj);
    } catch (Exception e) {
        e.printStackTrace();
    }
  4. Set the icon path obtained from step#2 to stereotype.
    st.setIconPath(path);

 

Related Know-how

Related Links

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply