Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Arnoud_B on February 10, 2022, 07:51:02 pm
-
I have asked this question in a different treat before but all suggestions given did not help me resolve the issue.
As SparxEA is not very verbose (it does not give you any feedback why things do not work ;-/ ) it is hard to say it I do it wrong or if SparxEA just works differently. So I will try to document my case a bit better and I hope somebody will spot the error.
So what do I do?
I am building a ArchiMate MDG with some specific extensions of standard ArchiMate element that will contain extra attributes and which I can validate with scripts (as different rules apply to different sub types)
In my POC I create an extension of ArchiMate_Device --> ArchiStib_StandardHardware
It 'generalizes' the ArchiMate element and it 'Extends' the UML metaclass. I think I now do that correctly.
https://imgur.com/a/t6MHO3P
I add a shape script (code below) to overwrite the image;
- it makes it a simple rectangle
- it adds a SBB decorator on top in the middle
- it overwrites the decorators device and composite
Well at least I try! overwriting the image with a rectangle works, the extra decorator is there however I have the device and composite decorators twice. Once from this class once from its parent.
(a sniplet of the result is in above image URL)
On the metaclass there is an attribute _HideMetaclassIcon however I do not think there is such an attribute for a stereotype object.
I tried all kinds of things but it is trail and error and it gets me nowhere ...
Any help is highly appreciated.
The typescript code I use:
shape main
{
layouttype="border";
noshadow=true;
defsize(90,70);
//if(hasproperty("rectanglenotation","1")) only rectangle notation is supported
rectangle(0,0,100,100);
addsubshape("rect_padding","n");
addsubshape("name","center");
shape rect_padding
{
preferredheight=20;
}
shape name
{
bold=true;
v_align="top";
h_align="center";
print("#name#");
}
}
decoration device // same icon but on a different place
{
orientation="ne";
moveto(15,75);
lineto(0,100);
lineto(100,100);
lineto(85,75);
startpath();
roundrect(0,0,100,75,30,30);
endpath();
strokepath();
}
decoration SBB // new 'icon'
{
orientation="n";
print("SBB");
}
decoration composite // same icon but on a different place
{
orientation="se";
if(hasproperty("iscomposite","true"))
{
ellipse(0,40,40,60);
ellipse(60,40,100,60);
moveto(30,50);
lineto(70,50);
}
}
-
I guess the inheritance will already take the shape script from the general class. So you don't need to draw it yourself a 2nd time.
Inheritance of shape scripts is a bit of black magic, though. Nobody knows in which way inhertance is done on shape scripts (and other properties).
q.
-
I think you'll need to "paint over" the existing decorations, and then add your own decorations like you did now.
There is a topic from Paolo on this forum where he shares his experiments with these kind of things.
Geert
-
I guess the inheritance will already take the shape script from the general class. So you don't need to draw it yourself a 2nd time.
I change the shape to be a simple box instead of the 3d box shape so I need to override it.
-
Hmm. Both of the decorators look very similar. Anyhow, you could go the way Geert (and originally Paolo) suggestedl. But due to the gradient the "correction fluid" will be recognizable. Just looks ugly.
q.
-
Hmm. Both of the decorators look very similar. Anyhow, you could go the way Geert (and originally Paolo) suggested. But due to the gradient the "correction fluid" will be recognizable. Just looks ugly.
q.
Yes, we had to turn off gradient fill. As q said, UGLY.
Paolo
-
Paolo,
Hopefully the last question; where do you turn the gradient fill off. I cannot find it in the default appearance (F4) you can only set the color there I think.
So here my code hack for anybody who wants to do the same:
@Paolo, did you do it in a similar fashion or did you find a better way to do this?
decoration device // same icon but on a different place
{
orientation="ne";
// 'remove' the original image by drawing over it in green
setpencolor(getUserFillColor());
setorigin("ne",-26,10);
moveto(15,75);
lineto(0,100);
lineto(100,100);
lineto(85,75);
startpath();
roundrect(0,0,100,75,30,30);
endpath();
strokepath();
// now draw the new one in the same color as the border
setpencolor(GetUserBorderColor());
setorigin("ne",-15,0);
moveto(15,75);
lineto(0,100);
lineto(100,100);
lineto(85,75);
startpath();
roundrect(0,0,100,75,30,30);
endpath();
strokepath();
}
-
It's in the general settings. Also (IIRC, not sitting in front of my Windoze) there is a style setting per diagram which might include no/shading.
q.
-
Arnoud,
If you turn off gradient fill, you don't need to draw over the old icon, just cover it with a simple rectangle with the correct background colour. Then draw your new icon.
HTH,
Paolo
-
Thanks Paolo,
That fixed it (well nearly) I still have a vague outline of the rectangle drawn although I "remove" two decorators the device one and the composite one and the top one still have a bit of a shadow left but the other one hasn't ?? if I zoom with SparxEA the shadow goes away or becomes bit worse, it seems a rendering glitch it is not really a problem.
I tried the noshadow command but I think it only effects the complete shape
noShadow=true;
// 'remove' the original image by drawing over it in the background color
setorigin("ne",-26,10);
setpencolor(getUserFillColor());
rectangle(0,0,100,100);
A more generic question on this; is shapescript case sensitive? the documentation says noShadow and in the shapescript I copied (ArchiMate3) it uses noshadow. As tiny typo's lead to non-working stuff without any errors I get a bit paranoia, however I tried both and I have a tiny shadow anyway ...
-
A more generic question on this; is shapescript case sensitive? the documentation says noShadow and in the shapescript I copied (ArchiMate3) it uses noshadow. As tiny typo's lead to non-working stuff without any errors I get a bit paranoia, however I tried both and I have a tiny shadow anyway ...
Most of it isn't case sensitive. But honestly I don't remeber which is (probably some property comparison, but not sure). I'm always prepared to step in one of EA's pitfalls.
q.
-
Arnoud,
We make out "covering" rectangle oversize if required. if Gradient Fill is disabled, you should see no evidence of the rectangle.
Paolo