Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Guillaume on February 06, 2020, 09:33:48 pm

Title: MDG - alternate image support in a stereotype
Post by: Guillaume on February 06, 2020, 09:33:48 pm
Hi,
I found a number of threads on this topic.
I have stereotyped Archimate elements defined within an MDG - for the stereotyped "communication network object", I want show in a diagram the default Archimate view, and within another diagram an Image (e.g. network switch).
All my images are in the Image Library and they're exported in the MDG.

I applied the following shapescript (based on previous threads):

Code: [Select]
shape main{
Image("NetSwitch",0,0,100,100);
}

Result: the image is shown but I cannot access any longer the Archimate default view.
I looked at the help section https://www.sparxsystems.com/enterprise_architect_user_guide/15.1/model_domains/stereotypeswithalternateima.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.1/model_domains/stereotypeswithalternateima.html) but it doesn't say much.

Is there a way to define 2 views on a stereotyped element e.g. Archimate or Image?
Note: if I create an element in EA, I can set an alternate image for that element in a diagram, however it keeps its original view on other diagrams.

Title: Re: MDG - alternate image support in a stereotype
Post by: qwerty on February 06, 2020, 10:24:37 pm
You can, when you use
Code: [Select]
if(HasProperty('rectanglenotation','0')) the menu will show the "Use Rectangle Notation". The default would be rectangular notation and you could turn it off. From 15.1 on (not tested, only heard of) it should be the other (logical) way around.

A better way is to use a tagged value to allow showing the image or the native notation. So you can choose from the TV window what to display.

q.
Title: Re: MDG - alternate image support in a stereotype
Post by: Guillaume on February 07, 2020, 03:15:17 am
Thanks for the advice, I managed to get it to work for all the elements that don't have a predefined rectangle notation with the following:

Code: [Select]
shape main{
if(HasProperty('rectanglenotation','0'))
{
Image("Switch",0,0,100,100);
return;
}
else
{
DrawNativeShape();
return;
}
}

However I'm having issues with Archimate elements that have an existing rectangle notation behaviour such as Archimate Application components.
The Image displays well with the rectangle notation activated, but by default I get the following:

(http://umlchannel.com/images/archimate_app_component.png)

2 components icons in the top right corner are displayed.

Note: in some cases the Archimate icon remains displayed with image:
(http://umlchannel.com/images/archimate_net.png)

Is there a way to remove it?

Any idea?


Title: Re: MDG - alternate image support in a stereotype
Post by: qwerty on February 07, 2020, 03:54:33 am
So I guess you're on V15. In that case I'd advise to contact Sparx' support.

q.
Title: Re: MDG - alternate image support in a stereotype
Post by: Sunshine on February 08, 2020, 07:53:16 am
You need to put the condition in the decoration code too to prevent the decoration showing but because your using the DrawNativeShape() method you just get whats already there. Another approach is to put a stereotype on the diagram and write the whole script and not use DrawNativeShape().
Here is an example of an application component script for ArchiMate that changes the shape to circle if the stereotype of the diagram is "BubbleChart".
As you can see I don't use DrawNativeShape() method as I need to put the condition in both main and decoration code fragments.

Code: [Select]
shape main
{
layouttype="border";
if(hasproperty("diagram.stereotype","BubbleChart"))
{
defsize(100,100);
ellipse(0,0,100,100);
addsubshape("padding","n");
addsubshape("bubblename","center");
}
else
{
defsize(90,70); //
rectangle(0,0,100,100);
addsubshape("padding","n");
if(hasproperty("rectanglenotation","0"))
{
addsubshape("port","w");
}
addsubshape("name","center");
}

shape bubblename
{
h_align="center";
println("#name#");
}

shape port
{
preferredwidth=20;
scalable=false;
rectangle(-10,-10,10,0);
rectangle(-10,10,10,20);
}

shape padding
{
preferredheight=15;
}

shape name
{
h_align="center";
print("#name#");
}

}

decoration component
{
orientation="ne";
if(hasproperty("diagram.stereotype", "BubbleChart"))
{
return;
}

if(hasproperty("rectanglenotation","0"))
{
return;
}
else
{
rectangle(0,0,60,100);
rectangle(-10,10,10,30);
rectangle(-10,50,10,70);
}
}

decoration composite
{
orientation="SE";
if(hasproperty("diagram.stereotype", "BubbleChart"))
{
return;
}

if(hasproperty("iscomposite","true"))
{
ellipse(0,40,40,60);
ellipse(60,40,100,60);
moveto(30,50);
lineto(70,50);
}
}
Title: Re: MDG - alternate image support in a stereotype
Post by: Guillaume on February 12, 2020, 12:17:11 am
Thank you for the advice. It's helped me!