Book a Demo

Author Topic: Changing the look of the package shape  (Read 8879 times)

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
Changing the look of the package shape
« on: June 04, 2021, 01:05:30 am »
Unfortunately the package shape does not have a rectangular notation. As a result I would like to change its shape in such a way that the native shape is surrounded by a rectangle but retains all the "visual functionality" of the native shape. Is this possible using Shape Scripts?


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Changing the look of the package shape
« Reply #1 on: June 04, 2021, 01:20:36 am »
Somehow. You can use DrawNativeShape and add some extending rectangle going over the 100x100 square. Something like
Code: [Select]
shape main {
  DrawNativeShape();
  Rectangle(-1, -1, 101, 101);
}

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Changing the look of the package shape
« Reply #2 on: June 04, 2021, 08:29:21 am »
Hi Modesto,

You can set rectangular notation shapes in the normal way.
Code: [Select]
if(hasproperty("rectanglenotation","0"))
{ //Icon Form
// drawing commands for non-rectangular form
}
else
{
drawnativeshape();
}
However, you have o set the mode by some other means...  Via Script, AddIn, or SQL injection. This is because the Package metaclass won't provide to the [ ] Use Rectangle Notation context menu item.

You could also create a User Specified Diagram Property  (USDP), I suspect.  But haven't tried it since we have an AddIn that allows us to set multiple items to (non/)Rectangular Notation.

We have a small number of stereotyped packages that utilise alternate shapes (selectable via USDPs).

HTH,
Paolo

[Edit: I can't remember if I put in a defect for packages not responding to hasproperty("rectanglenotation","0") and proving the menu item.  Worth a try (by you)]
« Last Edit: June 04, 2021, 08:33:54 am by Paolo F Cantoni »
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: Changing the look of the package shape
« Reply #3 on: June 04, 2021, 09:12:54 pm »
Thank you qwerty, this what I ended up with
Code: [Select]
shape main{

SetFillColor(153, 153, 153);
Rectangle(-1, -1, 101, 101);
SetFillColor(255, 255, 255);
SetFontColor(0, 0, 0) ;
DrawNativeShape();

}
The native shape needs to be drawn after the rectangle. If it is drawn before the rectangle sits on top of the native shape and, since Sparx EA doesn't seem to have the concept of No Fill, it hides the native shape from view.

This has reminded me it is not the 1st time I asked this question.

Paolo - Adding ActRect=1; to the style of a diagram object -i.e., [t_diagramobjects].[ObjectStyle] - does absolutely nothing. Sparx EA simply ignores it.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Changing the look of the package shape
« Reply #4 on: June 04, 2021, 10:19:36 pm »
To speak for Paolo: EA will (often but not always) automatically recognize whether you query the property rectanglenotation. If so it adds the Rectangular Notation check mark to the context menu. So not sure if Packages will react on it (I'd guess that no).

q.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
Re: Changing the look of the package shape
« Reply #5 on: June 04, 2021, 11:43:24 pm »
When I wrote:
Quote
Adding ActRect=1; to the style of a diagram object -i.e., [t_diagramobjects].[ObjectStyle] - does absolutely nothing. Sparx EA simply ignores it.

I should have clarified that "injected" ActRect=1; to the relevant row in  [t_diagramobjects].[ObjectStyle] and Sparx EA simple ignore it, it did not "react on it".

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Changing the look of the package shape
« Reply #6 on: June 05, 2021, 06:11:54 am »
Where from did you get the info about ActRect? The help does not tell anything (and my Inside book neiter).

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Changing the look of the package shape
« Reply #7 on: June 05, 2021, 03:46:50 pm »
Where from did you get the info about ActRect? The help does not tell anything (and my Inside book neither).

q.
There are two "Rect" parameters, UCREct and ActRect.  UCRect is for non-activities and ActRect is for activities (IIRC).

Paolo

[EDIT: as noted later in the thread, ActRect appears to be for Actors.]
« Last Edit: June 07, 2021, 09:02:26 pm by Paolo F Cantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Changing the look of the package shape
« Reply #8 on: June 05, 2021, 04:10:38 pm »
Ah, I see. UCRect=1 in t_diagramobjects.objectstyle makes an Acion show rectangular. I have to test for which elements that works else.

q.

P.S. UCRect=1 works for Actor, UseCase, Action and Activity only (as far as I could see). These also seem to be the only ones to offer Use Rect in the context.
ActRect does not seem to have any effect anywhere.

P.P.S. I have updated my Inside book so you find that info on p. 61.
« Last Edit: June 05, 2021, 05:38:12 pm by qwerty »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Changing the look of the package shape
« Reply #9 on: June 07, 2021, 09:44:43 am »
Thank you qwerty, this what I ended up with
Code: [Select]
shape main{

SetFillColor(153, 153, 153);
Rectangle(-1, -1, 101, 101);
SetFillColor(255, 255, 255);
SetFontColor(0, 0, 0) ;
DrawNativeShape();

}
The native shape needs to be drawn after the rectangle. If it is drawn before the rectangle sits on top of the native shape and, since Sparx EA doesn't seem to have the concept of No Fill, it hides the native shape from view.


For no fill you can do something like this:
Code: [Select]
startpath();
rectangle(-1,-1,101,101);
endpath();
strokepath();
The Sparx Team
[email protected]

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
Re: Changing the look of the package shape
« Reply #10 on: June 07, 2021, 05:50:02 pm »
Where from did you get the info about ActRect? The help does not tell anything (and my Inside book neiter).

q.
I run a query on the t_diagramobjects table for the relevant object and diagram.


Ah, I see. UCRect=1 in t_diagramobjects.objectstyle makes an Acion show rectangular. I have to test for which elements that works else.

q.

P.S. UCRect=1 works for Actor, UseCase, Action and Activity only (as far as I could see). These also seem to be the only ones to offer Use Rect in the context.
ActRect does not seem to have any effect anywhere.

P.P.S. I have updated my Inside book so you find that info on p. 61.
I had to double check this, I have ActRect=1 on an Actor on a diagram where the Actor is set to use rectangular notation in the diagram. I am getting a bit confused.

For no fill you can do something like this:
Code: [Select]
startpath();
rectangle(-1,-1,101,101);
endpath();
strokepath();

Thank you KP, I'll give it a try.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Changing the look of the package shape
« Reply #11 on: June 07, 2021, 08:35:00 pm »
Oh! You are right! Actors are flagged with ActRect=1, the other ones with UCRect=1. I was deceived by an actor OBJECT I had created via automation (I created some 50 different element types). Will make a fix to my book immediately.

q.

P.S. Update is published.
« Last Edit: June 07, 2021, 08:43:13 pm by qwerty »