Book a Demo

Author Topic: ShapeScript Decoration for Application Role  (Read 4970 times)

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
ShapeScript Decoration for Application Role
« on: February 15, 2022, 03:41:53 am »
I am trying to write a ShapeScript decoration for an Application Role combining both a component and role decoration. I am frustratingly close to achieving the right result but somehow not there. I am using the following code:
Code: [Select]
/*Component part*/
moveto(10,10);
lineto(10,0);
lineto(90,0);
lineto(90,100);
lineto(10,100);
lineto(10,70);
moveto(10,50);
lineto(10,30);
startpath();
rectangle(0,10,40,30);
rectangle(0,50,40,70);
endpath();
strokepath();
 
/*Role part*/
moveto(90,10);
lineto(15,10);
arcto(0,10,30,70,15,25,15,75);
lineto(90,70);
startpath();
ellipse(80,10,100,70);
endpath();
strokepath();
I want to role part to be rendered starting at the same y position but half way into the component part and extend to the right of the component decoration about 1/3  of the width of the component.

Somehow I can not find the right values to achieve. Nothing I have tried renders the right shape.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: ShapeScript Decoration for Application Role
« Reply #1 on: February 15, 2022, 03:57:02 am »
Then you'll have to move the role part to the right using the x values.

Something like this:

Code: [Select]
/*Role part*/
moveto(90,10);
lineto(50,10);
arcto(40,10,70,70,50,25,50,75);
lineto(90,70);
startpath();
ellipse(80,10,100,70);
endpath();
strokepath();

Geert

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
Re: ShapeScript Decoration for Application Role
« Reply #2 on: February 15, 2022, 05:18:02 am »
Thanks Geert, the code below more or less does the job. Ideally I would like role path filled (instead of stroked) with the lines drawn but I do not seem to get this to work.

Code: [Select]
setpencolor(1,1,1);
setpenwidth(2);
setfillcolor(255,255,255);

/*Component part*/
startpath();
moveto(10,10);
lineto(10,0);
lineto(90,0);
lineto(90,100);
lineto(10,100);
lineto(10,70);
moveto(10,50);
lineto(10,30);
endpath();
strokepath();
/*fillpath();*/

startpath();
rectangle(0,10,30,30);
rectangle(0,50,30,70);
endpath();
strokepath();
/*fillpath();*/
 
/*Role part*/
startpath();
moveto(95,10);
lineto(50,10);
arcto(40,10,60,60,50,25,50,75);
lineto(95,60);
endpath();
/*strokepath();*/
fillpath();


startpath();
ellipse(90,10,100,60);
endpath();
fillpath();
/*strokepath();*/

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: ShapeScript Decoration for Application Role
« Reply #3 on: February 15, 2022, 05:37:13 am »
You mean something like this?

Code: [Select]
shape main
{
noShadow = true;
/*Component part*/
moveto(10,10);
lineto(10,0);
lineto(90,0);
lineto(90,100);
lineto(10,100);
lineto(10,70);
moveto(10,50);
lineto(10,30);
startpath();
rectangle(0,10,40,30);
rectangle(0,50,40,70);
endpath();
strokepath();

/*Role part*/
startpath();
moveto(90,10);
lineto(50,10);
arcto(40,10,70,70,50,25,50,75);
lineto(90,70);
endpath();
FillAndStrokePath();
startpath();
ellipse(80,10,100,70);
endpath();
FillAndStrokePath();
}

Writing shapescripts is a lot of trial and error, even if you have done lots of them.

I always write them on a test stereotype in the Configure | UML Types | Stereotypes so I get an immediate result.
Only if I'm happy with the shapescript I copy it into my MDG.

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: ShapeScript Decoration for Application Role
« Reply #4 on: February 15, 2022, 09:17:56 am »

Writing shapescripts is a lot of trial and error, even if you have done lots of them.

I always write them on a test stereotype in the Configure | UML Types | Stereotypes so I get an immediate result.
Only if I'm happy with the shapescript I copy it into my MDG.

Geert
Wot 'e said!

If I'm going to change a shapescript, I use essentially the same process and allow an extra hour for the "glitches" that come up.
Another check is once I'm happy with the result, I zoom the test element and move it slightly to see how EA "mangles" the decoration.  Sometimes you have to make it intentionally wrong to get it to look right.
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
Re: ShapeScript Decoration for Application Role
« Reply #5 on: February 15, 2022, 09:22:58 pm »
[SNIP]
Writing shapescripts is a lot of trial and error, even if you have done lots of them.
This is an understatement  ;)
Thanks to both the tips, I think we now have something acceptable.

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: ShapeScript Decoration for Application Role
« Reply #6 on: February 16, 2022, 05:32:03 pm »
Writing shapescripts is a lot of trial and error, even if you have done lots of them.

I always write them on a test stereotype in the Configure | UML Types | Stereotypes so I get an immediate result.
Only if I'm happy with the shapescript I copy it into my MDG.

Same here as its the quickest way to debug them and yeah very much trial and error. Spent over half a day doing a sunray roadmap shape script which should only have taken an 30 min in theory.
But I guess that's where the phrase comes into play.
Quote
In theory, theory and practice are the same but in practice they are different.
Happy to help
:)