enterprise-architectstereotypeshapescript

How to use a custom icon for a stereotype in Enterprise Architect?


I want to use my own icons for elements (nodes) in Enterprise Architect.

For certain stereotypes, there is a build in behavior in Enterprise Architect, that adds an icon in the upper-right corner of an element, like this (in this case the stereotype "server" is used):

enter image description here

[see this page for a list of the default stereotypes].

Note that the position (offset from top and right) and absolute size of the icon are preserved, even when the shape is resized:

enter image description here

I want to display my own custom icons for my stereotypes, just like Enterprise Architect does. So i tried to use a shapescript to display the icon, but all drawing in shapescript seems to be relative to the shape's size. For example:

shape main {
    drawnativeshape();
    image("database", 87, 10, 92, 25);
}

Results in this:

enter image description here

The first one is stretched wrong, and while the second is better, that is just luck.

While using a "decoration" seems to preserve the size of the picture, it is always placed in the top left corner:

decoration icon {
    image("firewall", 0, 0, 100, 100);
}

enter image description here

So how do i add a custom icon, based on the object's stereotype, that is drawn correctly (always same size, always in top-right corner), like Enterprise Architect does?


Solution

  • You're almost there. It is a decoration you want. To place it in the upper right corner use

    orientation = "NE";
    

    in the decoration shape.