问题
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):
[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:
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:
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);
}
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?
回答1:
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.
回答2:
My eventual solution (with thanks to @Uffe) is this:
decoration database {
orientation = "NE";
image("database", -60, 60, 40, 160);
}
来源:https://stackoverflow.com/questions/37611486/how-to-use-a-custom-icon-for-a-stereotype-in-enterprise-architect