Author Topic: Hiding the decorators of the parent class  (Read 4068 times)

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Hiding the decorators of the parent class
« 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);
   }
}


« Last Edit: February 10, 2022, 09:01:27 pm by Arnoud_B »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #1 on: February 10, 2022, 09:18:22 pm »
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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Hiding the decorators of the parent class
« Reply #2 on: February 10, 2022, 09:24:49 pm »
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

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #3 on: February 11, 2022, 05:20:24 am »
Quote
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.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #4 on: February 11, 2022, 08:26:50 am »
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.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8599
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #5 on: February 11, 2022, 09:18:21 am »
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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #6 on: February 11, 2022, 07:03:02 pm »
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();
}

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #7 on: February 11, 2022, 07:28:56 pm »
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.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8599
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #8 on: February 11, 2022, 07:54:49 pm »
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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #9 on: February 12, 2022, 12:30:32 am »
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 ...

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #10 on: February 12, 2022, 12:51:46 am »
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.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8599
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Hiding the decorators of the parent class
« Reply #11 on: February 12, 2022, 12:07:37 pm »
Arnoud,
We make out "covering" rectangle oversize if required.  if Gradient Fill is disabled, you should see no evidence of the rectangle.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!