Author Topic: Shape script woes !  (Read 5521 times)

jguerra

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Shape script woes !
« on: July 01, 2008, 03:23:51 am »
Hi,

I try to create a new stereotype for the "Feature" metaclass but with a different color. The first problem I got is that there is no attribute (“_color” or something like that) to change the actual default color for the new stereotype. So, I created a Shape script (see snipped below) in order to intercept an embedded tag to draw the new stereotype with a different color to the default one as long as apparently, there is no “_color” attribute available on the supported stereotype attributes. Ok, the attempt failed  >:(.

So, I was wondering whether this sort of customization is available on EA, changing the color in a native shape when you invoke drawnativeshape() function in a Shape Script.


{
    if (HasTag("color","red"))
    {
        drawnativeshape();
        setfillcolor(255,0,0); // New color for the feature shape
        return;
   }
}

I'd appreciate any feedback, comments, workarounds, etc!
Thanks,

Jose

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Shape script woes !
« Reply #1 on: July 01, 2008, 08:25:46 am »
There is no _color supported attribute.  You don't need it either.  You can set the color of the stereotype itself and that will set the color used for that stereotype.

I don't know if a shape script can change the colors used when drawing the native shape.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape script woes !
« Reply #2 on: July 01, 2008, 08:31:07 am »
Hi folks,

Simon, I tried this back about the time that 7.1 was in beta - you probably remember some of the flurry of discussions about profiles and such about that time - and at the time I was unsuccessful in changing the color of native shapes.

What I did not try was setting the color on the stereotype dialog and using a shape script. Perhaps that would work.

Even if it did this would involve an extra step in the case of a profile. Installation of the profile would not be enough; there would have to be a reference data import (or something) to set up the color.

If anyone tries either or both steps above please post back here and let us know what happens.

David
No, you can't have it!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Shape script woes !
« Reply #3 on: July 01, 2008, 08:41:31 am »
Quote
The first problem I got is that there is no attribute (“_color” or something like that) to change the actual default color for the new stereotype.
When creating a profile, select a stereotype class, press F4 and choose your colours. If your stereotype extends a connector then change the border colour to set the line colour. When you save the profile, tick the option "Color and Appearance".


Quote
So, I was wondering whether this sort of customization is available on EA, changing the color in a native shape when you invoke drawnativeshape() function in a Shape Script.


{
    if (HasTag("color","red"))
    {
        drawnativeshape();
        setfillcolor(255,0,0); // New color for the feature shape
        return;
   }
}
The setfillcolor() needs to be before the drawnativeshape() command.

EDIT: My two answers above give two different solutions to your problem - it's either/or, you don't need to do both.
« Last Edit: July 01, 2008, 08:43:07 am by KP »
The Sparx Team
[email protected]

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Shape script woes !
« Reply #4 on: July 01, 2008, 09:08:07 am »
We have recently added a short topic to the Create Profiles section of the SDK. It describes how to define the default colours and border thickness for stereotyped elements and connectors. It basically focuses you on the UML Types dialog and the F4 key, as Simon and Neil have mentioned.

See the Help when the next release comes out.
Best Regards, Roy

jguerra

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: Shape script woes !
« Reply #5 on: July 01, 2008, 11:32:25 pm »
Hi,

Thanks in advance for your suggestions!, I appreciate them.
So, back to the business.  A simple Shape script like this (see below), it didn't take the effect that I expected. The profile was saved with the box "Color and Appearence" ticked. When I dragged the new stereotype from the toolbox into the diagram, the element is drawn in its native color. BTW, in our UML profile, the stereotype is extending a Feature metaclass.

shape main
{
    SetFillColor(255,0,0);
    drawnativeshape();      
  
}

Changing the color property on the UML Types, is not a runner. We develop a custom toolbox and we need everything in the technology file. We don’t want to enforce modelers to change that property every time they start a new project. That approach will overkill our process, so we need to bring everything along with the technology file.

Thank to you lads for the help, comments, suggestions etc.!!

Cheers

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Shape script woes !
« Reply #6 on: July 03, 2008, 09:26:49 am »
Quote
shape main
{
    SetFillColor(255,0,0);
    drawnativeshape();      
  
}
Hmmm... for reasons unknown, this shape script works when applied to a stereotype in the stereotypes table ("Settings > UML" from the main menu) but doesn't work when applied in a profile. Can you send in a bug report please because this will need investigating. Thanks.
The Sparx Team
[email protected]

jguerra

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: Shape script woes !
« Reply #7 on: July 07, 2008, 10:06:22 pm »
Hi,

How can I do that?
Cheers

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape script woes !
« Reply #8 on: July 07, 2008, 11:43:21 pm »
Click the Report a Bug link below the Support link near the bottom of any forum page. If you are a registered user click the appropriate link above the form; this takes you to a similar form that also let's you attach any sample files you want to send along.
No, you can't have it!

jguerra

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: Shape script woes !
« Reply #9 on: July 08, 2008, 12:06:08 am »
Ok, fair enough !